vcl/quartz/salgdi.cxx |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

New commits:
commit 4b693a0c594fb3b73f4a4c1e03e9916f1a107012
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Tue May 10 16:44:27 2022 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Tue May 10 20:33:48 2022 +0200

    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 <caol...@redhat.com>

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);
 

Reply via email to