From 64ae98e671fc93cea47338d3068a760c68922ed7 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Wed, 4 Dec 2019 22:16:19 +0100 Subject: [PATCH] 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. --- src/osx/carbon/font.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/osx/carbon/font.cpp b/src/osx/carbon/font.cpp index 95e9f93f9b..2ae9cd7c80 100644 --- a/src/osx/carbon/font.cpp +++ b/src/osx/carbon/font.cpp @@ -288,6 +288,8 @@ void wxFontRefData::SetFont(CTFontRef font) dict.SetValue(kCTForegroundColorFromContextAttributeName, kCFBooleanTrue); m_ctFontAttributes = dict; + + m_cgFont = CTFontCopyGraphicsFont(m_ctFont, NULL); } static const CGAffineTransform kSlantTransform = CGAffineTransformMake(1, 0, tan(wxDegToRad(11)), 1, 0, 0); @@ -366,7 +368,7 @@ void wxFontRefData::Alloc() // emulate weigth if necessary 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 ) @@ -382,7 +384,6 @@ void wxFontRefData::Alloc() } } - m_cgFont = CTFontCopyGraphicsFont(m_ctFont, NULL); entryWithSize.font = m_ctFont; entryWithSize.cgFont = m_cgFont; entryWithSize.fontAttributes = m_ctFontAttributes;