summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorPatrick Luby <guibmacdev@gmail.com>2024-09-30 19:58:56 -0400
committerPatrick Luby <guibomacdev@gmail.com>2024-10-02 16:00:04 +0200
commita6c02c2bdebc196e5e7113aecbfd8d2debf4bb06 (patch)
treee2b99df12b9cfab0fbd4222aa1a9c468c31427e0 /vcl
parentb387a283c08a8efcd91e2386db41467435fb9856 (diff)
tdf#163000 don't add any fonts with an 'hvgl' font table
macOS Sequoia added a new PingFangUI.ttc font file which contains all of the PingFang font families. However, any fonts loaded from this font file result in the following failures: - Skia renders font with wrong glyphs - Export to PDF contain a damaged embedded font Despite the fact that the fonts in this new font file have a TrueType font type, they are missing a 'glyf' font table and, instead, have a new, undefined 'hvgl' font table. See the following link for more details about the new 'hvgl' font table: https://gitlab.freedesktop.org/freetype/freetype/-/issues/1281 Change-Id: I18170b1b226de86f79402ad0e45df8620c693f83 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174305 Reviewed-by: Patrick Luby <guibomacdev@gmail.com> Tested-by: Jenkins Reviewed-by: Jonathan Clark <jonathan@libreoffice.org> Reviewed-by: خالد حسني <khaled@libreoffice.org> (cherry picked from commit a4e9584c554ea018691b2c97d38cce3d83f8ea9a) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174331
Diffstat (limited to 'vcl')
-rw-r--r--vcl/quartz/SystemFontList.cxx56
1 files changed, 56 insertions, 0 deletions
diff --git a/vcl/quartz/SystemFontList.cxx b/vcl/quartz/SystemFontList.cxx
index 3ca09bfcf21e..d39327c4c823 100644
--- a/vcl/quartz/SystemFontList.cxx
+++ b/vcl/quartz/SystemFontList.cxx
@@ -205,6 +205,62 @@ static void fontEnumCallBack( const void* pValue, void* pContext )
{
CTFontDescriptorRef pFD = static_cast<CTFontDescriptorRef>(pValue);
+ // tdf#163000 don't add any fonts with an 'hvgl' font table
+ // macOS Sequoia added a new PingFangUI.ttc font file which
+ // contains all of the PingFang font families. However, any
+ // fonts loaded from this font file result in the following
+ // failures:
+ // - Skia renders font with wrong glyphs
+ // - Export to PDF contain a damaged embedded font
+ // Despite the fact that the fonts in this new font file have
+ // a TrueType font type, they are missing a 'glyf' font table
+ // and, instead, have a new, undefined 'hvgl' font table. See
+ // the following link for more details about the new 'hvgl'
+ // font table:
+ // https://gitlab.freedesktop.org/freetype/freetype/-/issues/1281
+ CFNumberRef pFontFormat = static_cast<CFNumberRef>(CTFontDescriptorCopyAttribute(pFD, kCTFontFormatAttribute));
+ if (pFontFormat)
+ {
+ bool bSkipFont = false;
+ int nFontFormat;
+ // At least for the PingFangUI.ttc font file, the font format is
+ // different on macOS and iOS
+ if (CFNumberGetValue(pFontFormat, kCFNumberIntType, &nFontFormat) && (nFontFormat == kCTFontFormatOpenTypeTrueType || nFontFormat == kCTFontFormatTrueType))
+ {
+ CTFontRef pFont = CTFontCreateWithFontDescriptor(pFD, 0.0, nullptr);
+ if (pFont)
+ {
+ CFArrayRef pFontTableTags = CTFontCopyAvailableTables(pFont, kCTFontTableOptionNoOptions);
+ if (pFontTableTags)
+ {
+ bool bGlyfTableFound = false;
+ bool bHvglTableFound = false;
+ CFIndex nFontTableTagCount = CFArrayGetCount(pFontTableTags);
+ for (CFIndex i = 0; i < nFontTableTagCount; i++)
+ {
+ CTFontTableTag nTag = reinterpret_cast<uintptr_t>(CFArrayGetValueAtIndex(pFontTableTags, i));
+ if (nTag == kCTFontTableGlyf)
+ {
+ bGlyfTableFound = true;
+ break;
+ }
+ else if (nTag == 'hvgl')
+ {
+ bHvglTableFound = true;
+ }
+ }
+ bSkipFont = !bGlyfTableFound && bHvglTableFound;
+ CFRelease(pFontTableTags);
+ }
+ CFRelease(pFont);
+ }
+ }
+ CFRelease(pFontFormat);
+
+ if (bSkipFont)
+ return;
+ }
+
bool bFontEnabled;
FontAttributes rDFA = DevFontFromCTFontDescriptor( pFD, &bFontEnabled );