Add numeric weights support for ports using XLFD-based fonts
Translate numeric weight to the symbolic name too instead of only doing it in the other direction in GetNumericWeight().
This commit is contained in:
@@ -823,28 +823,58 @@ void wxNativeFontInfo::SetStyle(wxFontStyle style)
|
|||||||
SetXFontComponent(wxXLFD_SLANT, s);
|
SetXFontComponent(wxXLFD_SLANT, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxNativeFontInfo::SetWeight(wxFontWeight weight)
|
void wxNativeFontInfo::SetNumericWeight(int weight)
|
||||||
{
|
{
|
||||||
wxString s;
|
wxString s;
|
||||||
switch ( weight )
|
switch ( wxFont::GetWeightClosestToNumericValue(weight) )
|
||||||
{
|
{
|
||||||
case wxFONTWEIGHT_BOLD:
|
case wxFONTWEIGHT_THIN:
|
||||||
s = wxT("bold");
|
s = "thin";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxFONTWEIGHT_EXTRALIGHT:
|
||||||
|
s = "extralight";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxFONTWEIGHT_LIGHT:
|
case wxFONTWEIGHT_LIGHT:
|
||||||
s = wxT("light");
|
s = "light";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxFONTWEIGHT_NORMAL:
|
case wxFONTWEIGHT_NORMAL:
|
||||||
s = wxT("medium");
|
s = "normal";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
case wxFONTWEIGHT_MEDIUM:
|
||||||
wxFAIL_MSG( wxT("unknown wxFontWeight in wxNativeFontInfo::SetWeight") );
|
s = "medium";
|
||||||
return;
|
break;
|
||||||
|
|
||||||
|
case wxFONTWEIGHT_SEMIBOLD:
|
||||||
|
s = "semibold";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxFONTWEIGHT_BOLD:
|
||||||
|
s = "bold";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxFONTWEIGHT_EXTRABOLD:
|
||||||
|
s = "extrabold";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxFONTWEIGHT_HEAVY:
|
||||||
|
s = "heavy";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxFONTWEIGHT_EXTRAHEAVY:
|
||||||
|
s = "extraheavy";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxFONTWEIGHT_INVALID:
|
||||||
|
wxFAIL_MSG( "Invalid font weight" );
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxCHECK_RET( !s.empty(), "unknown weight value" );
|
||||||
|
|
||||||
SetXFontComponent(wxXLFD_WEIGHT, s);
|
SetXFontComponent(wxXLFD_WEIGHT, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user