diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-05-10 16:44:27 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-05-10 20:33:48 +0200 |
commit | 4b693a0c594fb3b73f4a4c1e03e9916f1a107012 (patch) | |
tree | 70b3c3cc428178923cb43bd2e832607b059ea013 /vcl/quartz/salgdi.cxx | |
parent | ad79900cd62c487bda9d2515892d62b3b08a5dfa (diff) |
tdf#148470 if macOS glyph fallback provided a partial result flag what failed
so another font can be attempted for the remainder
Change-Id: Ie2c67c7c63510d02c99f2377c0c43ed6050ccd86
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134131
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/quartz/salgdi.cxx')
-rw-r--r-- | vcl/quartz/salgdi.cxx | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx index 98b00b305366..1ce488be9c4d 100644 --- a/vcl/quartz/salgdi.cxx +++ b/vcl/quartz/salgdi.cxx @@ -30,6 +30,7 @@ #include <osl/process.h> #include <rtl/bootstrap.h> #include <rtl/strbuf.hxx> +#include <rtl/ustrbuf.hxx> #include <tools/long.hxx> #include <comphelper/lok.hxx> @@ -73,6 +74,12 @@ public: bool FindFontSubstitute(vcl::font::FontSelectPattern&, LogicalFontInstance* pLogicalFont, OUString&) const override; }; +bool FontHasCharacter(CTFontRef pFont, const OUString& rString, sal_Int32 nIndex, sal_Int32 nLen) +{ + CGGlyph glyphs[nLen]; + return CTFontGetGlyphsForCharacters(pFont, reinterpret_cast<const UniChar*>(rString.getStr() + nIndex), glyphs, nLen); +} + } bool CoreTextGlyphFallbackSubstititution::FindFontSubstitute(vcl::font::FontSelectPattern& rPattern, LogicalFontInstance* pLogicalFont, @@ -89,6 +96,19 @@ bool CoreTextGlyphFallbackSubstititution::FindFontSubstitute(vcl::font::FontSele { bFound = true; + // tdf#148470 remove the resolved chars from rMissing to flag which ones are still missing + // for an attempt with another font + OUStringBuffer aStillMissingChars; + for (sal_Int32 nStrIndex = 0; nStrIndex < rMissingChars.getLength();) + { + sal_Int32 nOldStrIndex = nStrIndex; + rMissingChars.iterateCodePoints(&nStrIndex); + sal_Int32 nCharLength = nStrIndex - nOldStrIndex; + if (!FontHasCharacter(pFallback, rMissingChars, nOldStrIndex, nCharLength)) + aStillMissingChars.append(rMissingChars.getStr() + nOldStrIndex, nCharLength); + } + rMissingChars = aStillMissingChars.toString(); + CTFontDescriptorRef pDesc = CTFontCopyFontDescriptor(pFallback); FontAttributes rAttr = DevFontFromCTFontDescriptor(pDesc, nullptr); |