diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2017-12-26 15:58:21 +0100 |
---|---|---|
committer | Khaled Hosny <khaledhosny@eglug.org> | 2018-05-07 23:03:37 +0200 |
commit | 083b7ca26bbf4b9bad2922520caaf5c0227dac5e (patch) | |
tree | b33576cd90c64cb2ede5ab1a930b11828f110105 /vcl/quartz/salgdi.cxx | |
parent | 1ca1886d46f38a0759ab466e6a4a8c3c0866c523 (diff) |
Move PhysicalFontFace member of FontSelectPattern
A FontSelectPattern describes a general font request. It can be
used to find the best matching LogicalFontInstance. The instance
will be created based on a PhysicalFontFace, which is really a
factory since commit 8b700794b2746070814e9ff416ecd7bbb1c902e7.
Following this workflow, this moves the PhysicalFontFace pointer
to the instance and makes it constant.
Which leaves some special symbol font handling code in the hash
and instance lookup code path. It used to query the font face
directly from the instance.
I'm not sure of the correct handling. The related commits where
made to fix #i89002#, which has an attached test document.
1. commit 849f618270da313f9339dda29a9f35938434c91d
2. commit 8c9823d311fdf8092cc75873e4565325d204a658
The document is as broken as it was before the patch. The symbol
substitution still works, but the 'Q's are missing when displaying
a symbol font.
I also don't understand all the reinterpret_casts for fake font
ids. I guess this was used to prevent the crashes I see, where a
PhysicalFontFace referenced in a valid LogicalFontInstance is
freed and a later FontId check in the GlyphCache crashes. So this
now checks for a valid cache instead.
Change-Id: If8ee5a6288e66cfa4c419289fbdd5b5da128c6ea
Reviewed-on: https://gerrit.libreoffice.org/47279
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Khaled Hosny <khaledhosny@eglug.org>
Diffstat (limited to 'vcl/quartz/salgdi.cxx')
-rw-r--r-- | vcl/quartz/salgdi.cxx | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx index ed0d4b78d9d1..80825e77c84f 100644 --- a/vcl/quartz/salgdi.cxx +++ b/vcl/quartz/salgdi.cxx @@ -67,8 +67,8 @@ bool CoreTextGlyphFallbackSubstititution::FindFontSubstitute(FontSelectPattern& OUString& rMissingChars) const { bool bFound = false; - CoreTextStyle rStyle(rPattern); - CTFontRef pFont = static_cast<CTFontRef>(CFDictionaryGetValue(rStyle.GetStyleDict(), kCTFontAttributeName)); + CoreTextStyle* pStyle = static_cast<CoreTextStyle*>(rPattern.mpFontInstance); + CTFontRef pFont = static_cast<CTFontRef>(CFDictionaryGetValue(pStyle->GetStyleDict(), kCTFontAttributeName)); CFStringRef pStr = CreateCFString(rMissingChars); if (pStr) { @@ -89,7 +89,11 @@ bool CoreTextGlyphFallbackSubstititution::FindFontSubstitute(FontSelectPattern& SalData* pSalData = GetSalData(); if (pSalData->mpFontList) - rPattern.mpFontData = pSalData->mpFontList->GetFontDataFromId(reinterpret_cast<sal_IntPtr>(pDesc)); + { + const CoreTextFontFace *pFontFace = pSalData->mpFontList->GetFontDataFromId(reinterpret_cast<sal_IntPtr>(pDesc)); + if (pFontFace) + rPattern.mpFontInstance = pFontFace->CreateFontInstance(rPattern); + } CFRelease(pFallback); CFRelease(pDesc); @@ -223,10 +227,7 @@ AquaSalGraphics::AquaSalGraphics() SAL_INFO( "vcl.quartz", "AquaSalGraphics::AquaSalGraphics() this=" << this ); for (int i = 0; i < MAX_FALLBACK; ++i) - { mpTextStyle[i] = nullptr; - mpFontData[i] = nullptr; - } } AquaSalGraphics::~AquaSalGraphics() @@ -240,7 +241,11 @@ AquaSalGraphics::~AquaSalGraphics() } for (int i = 0; i < MAX_FALLBACK; ++i) - delete mpTextStyle[i]; + { + if (!mpTextStyle[i]) + break; + mpTextStyle[i]->Release(); + } if( mpXorEmulation ) delete mpXorEmulation; @@ -405,7 +410,7 @@ bool AquaSalGraphics::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangl void AquaSalGraphics::DrawTextLayout(const CommonSalLayout& rLayout) { const CoreTextStyle& rStyle = rLayout.getFontData(); - const FontSelectPattern& rFontSelect = rStyle.maFontSelData; + const FontSelectPattern& rFontSelect = rStyle.GetFontSelectPattern(); if (rFontSelect.mnHeight == 0) return; @@ -482,26 +487,27 @@ void AquaSalGraphics::SetFont(const FontSelectPattern* pReqFont, int nFallbackLe // release the text style for (int i = nFallbackLevel; i < MAX_FALLBACK; ++i) { - delete mpTextStyle[i]; + if (!mpTextStyle[i]) + break; + mpTextStyle[i]->Release(); mpTextStyle[i] = nullptr; } - // handle NULL request meaning: release-font-resources request - if( !pReqFont ) - { - mpFontData[nFallbackLevel] = nullptr; + if (!pReqFont) + return; + assert(pReqFont->mpFontInstance); + if (!pReqFont->mpFontInstance) return; - } // update the text style - mpFontData[nFallbackLevel] = static_cast<const CoreTextFontFace*>(pReqFont->mpFontData); - mpTextStyle[nFallbackLevel] = new CoreTextStyle(*pReqFont); + mpTextStyle[nFallbackLevel] = static_cast<CoreTextStyle*>(pReqFont->mpFontInstance); + mpTextStyle[nFallbackLevel]->Acquire(); SAL_INFO("vcl.ct", "SetFont" - " to " << mpFontData[nFallbackLevel]->GetFamilyName() - << ", " << mpFontData[nFallbackLevel]->GetStyleName() - << " fontid=" << mpFontData[nFallbackLevel]->GetFontId() + " to " << mpTextStyle[nFallbackLevel]->GetFontFace()->GetFamilyName() + << ", " << mpTextStyle[nFallbackLevel]->GetFontFace()->GetStyleName() + << " fontid=" << mpTextStyle[nFallbackLevel]->GetFontFace()->GetFontId() << " for " << pReqFont->GetFamilyName() << ", " << pReqFont->GetStyleName() << " weight=" << pReqFont->GetWeight() @@ -522,21 +528,21 @@ std::unique_ptr<SalLayout> AquaSalGraphics::GetTextLayout(ImplLayoutArgs& /*rArg const FontCharMapRef AquaSalGraphics::GetFontCharMap() const { - if (!mpFontData[0]) + if (!mpTextStyle[0]) { FontCharMapRef xFontCharMap( new FontCharMap() ); return xFontCharMap; } - return mpFontData[0]->GetFontCharMap(); + return static_cast<const CoreTextFontFace*>(mpTextStyle[0]->GetFontFace())->GetFontCharMap(); } bool AquaSalGraphics::GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const { - if (!mpFontData[0]) + if (!mpTextStyle[0]) return false; - return mpFontData[0]->GetFontCapabilities(rFontCapabilities); + return static_cast<const CoreTextFontFace*>(mpTextStyle[0]->GetFontFace())->GetFontCapabilities(rFontCapabilities); } // fake a SFNT font directory entry for a font table |