Applied pop menu patch.

Applied font util patch for better font matching under GTK 1.2


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22229 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2003-07-22 09:01:49 +00:00
parent aa3d520a74
commit 3479189669
3 changed files with 47 additions and 28 deletions

View File

@@ -797,27 +797,49 @@ wxNativeFont wxLoadQueryNearestFont(int pointSize,
*xFontName = newFontName;
}
// try to load exactly the font requested first
if( !font )
{
font = wxLoadQueryFont( pointSize, family, style, weight,
underlined, facename,
info.xregistry, info.xencoding,
xFontName );
}
if ( !font )
{
// search up and down by stepsize 10
int max_size = pointSize + 20 * (1 + (pointSize/180));
int min_size = pointSize - 20 * (1 + (pointSize/180));
int i;
int i, round; // counters
// Search for smaller size (approx.)
for ( i = pointSize - 10; !font && i >= 10 && i >= min_size; i -= 10 )
// first round: search for equal, then for smaller and for larger size with the given weight and style
int testweight = weight;
int teststyle = style;
for ( round = 0; round < 3; round++ )
{
font = wxLoadQueryFont(i, family, style, weight, underlined,
// second round: use normal weight
if ( round == 1 )
{
if ( testweight != wxNORMAL )
{
testweight = wxNORMAL;
}
else
{
++round; // fall through to third round
}
}
// third round: ... and use normal style
if ( round == 2 )
{
if ( teststyle != wxNORMAL )
{
teststyle = wxNORMAL;
}
else
{
break;
}
}
// Search for equal or smaller size (approx.)
for ( i = pointSize; !font && i >= 10 && i >= min_size; i -= 10 )
{
font = wxLoadQueryFont(i, family, teststyle, testweight, underlined,
facename, info.xregistry, info.xencoding,
xFontName);
}
@@ -825,9 +847,10 @@ wxNativeFont wxLoadQueryNearestFont(int pointSize,
// Search for larger size (approx.)
for ( i = pointSize + 10; !font && i <= max_size; i += 10 )
{
font = wxLoadQueryFont(i, family, style, weight, underlined,
font = wxLoadQueryFont(i, family, teststyle, testweight, underlined,
facename, info.xregistry, info.xencoding,
xFontName);
}
}
// Try default family