Create CGFont when a new font is set

CTFont and CGFont are used in parallel so both
need to be stored when a new font is set.

Closes #18610.
This commit is contained in:
Artur Wieczorek
2019-12-04 22:16:19 +01:00
parent 8cb9272458
commit 64ae98e671

View File

@@ -288,6 +288,8 @@ void wxFontRefData::SetFont(CTFontRef font)
dict.SetValue(kCTForegroundColorFromContextAttributeName, kCFBooleanTrue); dict.SetValue(kCTForegroundColorFromContextAttributeName, kCFBooleanTrue);
m_ctFontAttributes = dict; m_ctFontAttributes = dict;
m_cgFont = CTFontCopyGraphicsFont(m_ctFont, NULL);
} }
static const CGAffineTransform kSlantTransform = CGAffineTransformMake(1, 0, tan(wxDegToRad(11)), 1, 0, 0); static const CGAffineTransform kSlantTransform = CGAffineTransformMake(1, 0, tan(wxDegToRad(11)), 1, 0, 0);
@@ -366,7 +368,7 @@ void wxFontRefData::Alloc()
// emulate weigth if necessary // emulate weigth if necessary
int difference = m_info.GetNumericWeight() - CTWeightToWX(wxNativeFontInfo::GetCTWeight(font)); int difference = m_info.GetNumericWeight() - CTWeightToWX(wxNativeFontInfo::GetCTWeight(font));
SetFont(font); SetFont(font); // Sets m_ctFont, m_ctFontAttributes, m_cgFont
if ( difference != 0 ) if ( difference != 0 )
{ {
if ( difference > 0 ) if ( difference > 0 )
@@ -382,7 +384,6 @@ void wxFontRefData::Alloc()
} }
} }
m_cgFont = CTFontCopyGraphicsFont(m_ctFont, NULL);
entryWithSize.font = m_ctFont; entryWithSize.font = m_ctFont;
entryWithSize.cgFont = m_cgFont; entryWithSize.cgFont = m_cgFont;
entryWithSize.fontAttributes = m_ctFontAttributes; entryWithSize.fontAttributes = m_ctFontAttributes;