+void wxHtmlWinParser::SetFontPointSize(int pt)
+{
+ if (pt <= m_FontsSizes[0])
+ m_FontSize = 1;
+ else if (pt >= m_FontsSizes[6])
+ m_FontSize = 7;
+ else
+ {
+ // Find the font closest to the given value with a simple linear search
+ // (binary search is not worth it here for so small number of elements)
+ for ( int n = 0; n < 6; n++ )
+ {
+ if ( (pt > m_FontsSizes[n]) && (pt <= m_FontsSizes[n + 1]) )
+ {
+ if ( (pt - m_FontsSizes[n]) >= (m_FontsSizes[n + 1] - pt) )
+ {
+ // The actual size is closer to the next entry than to this
+ // one, so use it.
+ n++;
+ }
+
+ // Notice that m_FontSize starts from 1, hence +1 here.
+ m_FontSize = n + 1;
+
+ break;
+ }
+ }
+ }
+}