Rebased ref, commits from common ancestor:
commit ee86dd814895eab17ab8e928603d62518a161079
Author:     Khaled Hosny <[email protected]>
AuthorDate: Mon Mar 2 01:21:07 2026 +0200
Commit:     Khaled Hosny <[email protected]>
CommitDate: Mon Mar 2 01:21:07 2026 +0200

    CT
    
    Change-Id: I20645c4c5087e78957b3af3ea6e50eb9d34d55b5

diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx
index af5a620484c8..4ea145303218 100644
--- a/vcl/quartz/salgdi.cxx
+++ b/vcl/quartz/salgdi.cxx
@@ -382,6 +382,37 @@ void AquaGraphicsBackend::drawTextLayout(const 
GenericSalLayout& rLayout)
     }
 
     CTFontRef pCTFont = rFont.GetCTFont();
+    CTFontRef pVarFont = nullptr;
+    const auto& variations = rFont.GetVariations();
+    if (!variations.empty())
+    {
+        CFMutableDictionaryRef pVarDict = 
CFDictionaryCreateMutable(kCFAllocatorDefault, variations.size(),
+                                                                     
&kCFTypeDictionaryKeyCallBacks,
+                                                                     
&kCFTypeDictionaryValueCallBacks);
+        for (const auto& var : variations)
+        {
+            hb_tag_t nTag = var.tag;
+            CFNumberRef pTag = CFNumberCreate(kCFAllocatorDefault, 
kCFNumberSInt32Type, &nTag);
+            double fValue = var.value;
+            CFNumberRef pValue = CFNumberCreate(kCFAllocatorDefault, 
kCFNumberDoubleType, &fValue);
+            CFDictionaryAddValue(pVarDict, pTag, pValue);
+            CFRelease(pTag);
+            CFRelease(pValue);
+        }
+        CFDictionaryRef pAttrDict = CFDictionaryCreate(kCFAllocatorDefault,
+                                                       (const 
void**)&kCTFontVariationAttribute,
+                                                       (const 
void**)&pVarDict, 1,
+                                                       
&kCFTypeDictionaryKeyCallBacks,
+                                                       
&kCFTypeDictionaryValueCallBacks);
+        CTFontDescriptorRef pVarDesc = 
CTFontDescriptorCreateWithAttributes(pAttrDict);
+        pVarFont = CTFontCreateCopyWithAttributes(pCTFont, 0.0, nullptr, 
pVarDesc);
+        pCTFont = pVarFont;
+
+        CFRelease(pVarDesc);
+        CFRelease(pAttrDict);
+        CFRelease(pVarDict);
+    }
+
     CGAffineTransform aRotMatrix = 
CGAffineTransformMakeRotation(-rFont.mfFontRotation);
 
     basegfx::B2DPoint aPos;
@@ -412,7 +443,11 @@ void AquaGraphicsBackend::drawTextLayout(const 
GenericSalLayout& rLayout)
     }
 
     if (aGlyphIds.empty())
+    {
+        if (pVarFont)
+            CFRelease(pVarFont);
         return;
+    }
 
     assert(aGlyphIds.size() == aGlyphPos.size());
 #if 0
@@ -481,6 +516,9 @@ void AquaGraphicsBackend::drawTextLayout(const 
GenericSalLayout& rLayout)
     }
 
     mrShared.maContextHolder.restoreState();
+
+    if (pVarFont)
+        CFRelease(pVarFont);
 }
 
 void AquaSalGraphics::SetFont(LogicalFontInstance* pReqFont, int 
nFallbackLevel)
commit 98203551b14bfacf5be105a138177275b455a13f
Author:     Khaled Hosny <[email protected]>
AuthorDate: Mon Mar 2 01:20:54 2026 +0200
Commit:     Khaled Hosny <[email protected]>
CommitDate: Mon Mar 2 01:20:54 2026 +0200

    FC
    
    Change-Id: I4631d9d67a52e4421346e67e3ce019eb8d677ff7

diff --git a/vcl/inc/unx/fc_fontoptions.hxx b/vcl/inc/unx/fc_fontoptions.hxx
index 73bcf3421bc5..5e76c381b959 100644
--- a/vcl/inc/unx/fc_fontoptions.hxx
+++ b/vcl/inc/unx/fc_fontoptions.hxx
@@ -21,6 +21,8 @@
 
 #include <rtl/string.hxx>
 #include <vcl/dllapi.h>
+#include <hb.h>
+#include <vector>
 
 typedef struct _FcPattern   FcPattern;
 class VCL_DLLPUBLIC FontConfigFontOptions
@@ -30,7 +32,9 @@ public:
                             mpPattern(pPattern) {}
                         ~FontConfigFontOptions();
 
-    void                SyncPattern(const OString& rFileName, sal_uInt32 
nFontFace, sal_uInt32 nFontVariation, bool bEmbolden);
+    void                SyncPattern(const OString& rFileName, sal_uInt32 
nFontFace,
+                                    sal_uInt32 nFontVariation, bool bEmbolden,
+                                    const std::vector<hb_variation_t>& 
rFontVariations);
     FcPattern*          GetPattern() const;
     static void         cairo_font_options_substitute(FcPattern* pPattern);
 private:
diff --git a/vcl/unx/generic/fontmanager/fontconfig.cxx 
b/vcl/unx/generic/fontmanager/fontconfig.cxx
index b33675cd7b2a..9836670eb29c 100644
--- a/vcl/unx/generic/fontmanager/fontconfig.cxx
+++ b/vcl/unx/generic/fontmanager/fontconfig.cxx
@@ -1295,7 +1295,11 @@ FcPattern *FontConfigFontOptions::GetPattern() const
     return mpPattern;
 }
 
-void FontConfigFontOptions::SyncPattern(const OString& rFileName, sal_uInt32 
nIndex, sal_uInt32 nVariation, bool bEmbolden)
+#ifndef FC_FONT_VARIATIONS
+#define FC_FONT_VARIATIONS "fontvariations"
+#endif
+
+void FontConfigFontOptions::SyncPattern(const OString& rFileName, sal_uInt32 
nIndex, sal_uInt32 nVariation, bool bEmbolden, const 
std::vector<hb_variation_t>& rVariations)
 {
     FcPatternDel(mpPattern, FC_FILE);
     FcPatternAddString(mpPattern, FC_FILE, reinterpret_cast<FcChar8 const 
*>(rFileName.getStr()));
@@ -1304,6 +1308,21 @@ void FontConfigFontOptions::SyncPattern(const OString& 
rFileName, sal_uInt32 nIn
     FcPatternAddInteger(mpPattern, FC_INDEX, nFcIndex);
     FcPatternDel(mpPattern, FC_EMBOLDEN);
     FcPatternAddBool(mpPattern, FC_EMBOLDEN, bEmbolden ? FcTrue : FcFalse);
+
+    FcPatternDel(mpPattern, FC_FONT_VARIATIONS);
+    if (!rVariations.empty())
+    {
+        OStringBuffer aVarStr;
+        for (const auto& var : rVariations)
+        {
+            if (!aVarStr.isEmpty())
+                aVarStr.append(',');
+            char tag[4];
+            hb_tag_to_string(var.tag, tag);
+            aVarStr.append(tag, 
4).append('=').append(OString::number(var.value));
+        }
+        FcPatternAddString(mpPattern, FC_FONT_VARIATIONS, 
reinterpret_cast<const FcChar8*>(aVarStr.getStr()));
+    }
 }
 
 std::unique_ptr<FontConfigFontOptions> PrintFontManager::getFontOptions(const 
FontAttributes& rInfo, int nSize)
diff --git a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx 
b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
index b2d47f717ed3..20836be4750c 100644
--- a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
+++ b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
@@ -476,7 +476,7 @@ const FontConfigFontOptions* FreetypeFont::GetFontOptions() 
const
     if (!mxFontOptions)
     {
         mxFontOptions = GetFCFontOptions(mxFontInfo->GetFontAttributes(), 
mrFontInstance.GetFontSelectPattern().mnHeight);
-        mxFontOptions->SyncPattern(GetFontFileName(), GetFontFaceIndex(), 
GetFontFaceVariation(), mrFontInstance.NeedsArtificialBold());
+        mxFontOptions->SyncPattern(GetFontFileName(), GetFontFaceIndex(), 
GetFontFaceVariation(), mrFontInstance.NeedsArtificialBold(), 
mrFontInstance.GetVariations());
     }
     return mxFontOptions.get();
 }

Reply via email to