summaryrefslogtreecommitdiff
path: root/vcl/quartz
diff options
context:
space:
mode:
authorKhaled Hosny <khaled@aliftype.com>2022-10-29 20:17:35 +0200
committerخالد حسني <khaled@aliftype.com>2022-11-02 23:06:46 +0100
commit643fec7cf7a81bf8c89a8efd47c0310b38f9076c (patch)
tree95add7bdb619d55d5ca35ca3258d79bcb9af187a /vcl/quartz
parent29f318f90d2ed72a807d803094734d5ee7322a2d (diff)
vcl: add PhysicalFontFace::GetVariations()
Use it to set the variations on hb_font_t, and we will use it for other things in later commits. Change-Id: Iae1861f74b38af4921ac97c1facecf0d4815c201 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142024 Tested-by: Jenkins Reviewed-by: خالد حسني <khaled@aliftype.com>
Diffstat (limited to 'vcl/quartz')
-rw-r--r--vcl/quartz/ctfonts.cxx68
1 files changed, 34 insertions, 34 deletions
diff --git a/vcl/quartz/ctfonts.cxx b/vcl/quartz/ctfonts.cxx
index 9a2e2ab4ee69..0adc0bbfef39 100644
--- a/vcl/quartz/ctfonts.cxx
+++ b/vcl/quartz/ctfonts.cxx
@@ -269,49 +269,49 @@ hb_blob_t* CoreTextFontFace::GetHbTable(hb_tag_t nTag) const
return pBlob;
}
-void CoreTextFont::SetFontVariationsOnHBFont(hb_font_t* pHbFont) const
+std::vector<hb_variation_t> CoreTextFontFace::GetVariations() const
{
+ CTFontRef pFont = CTFontCreateWithFontDescriptor(mxFontDescriptor, 0.0, nullptr);
- CFArrayRef pAxes = CTFontCopyVariationAxes(mpCTFont);
- if (!pAxes)
- return;
-
- CFDictionaryRef pVariations = CTFontCopyVariation(mpCTFont);
- std::vector<hb_variation_t> aHBVariations;
- if (pVariations)
+ if (m_aVariations.empty())
{
- CFIndex nAxes = CFArrayGetCount(pAxes);
- for (CFIndex i = 0; i < nAxes; ++i)
+ CFArrayRef pAxes = CTFontCopyVariationAxes(pFont);
+ if (pAxes)
{
- auto pAxis = static_cast<CFDictionaryRef>(CFArrayGetValueAtIndex(pAxes, i));
- if (pAxis)
+ CFDictionaryRef pVariations = CTFontCopyVariation(pFont);
+ std::vector<hb_variation_t> aHBVariations;
+ if (pVariations)
{
- hb_tag_t nTag;
- auto pTag = static_cast<CFNumberRef>(CFDictionaryGetValue(pAxis, kCTFontVariationAxisIdentifierKey));
- if (!pTag)
- continue;
- CFNumberGetValue(pTag, kCFNumberIntType, &nTag);
-
- float fValue;
- auto pValue = static_cast<CFNumberRef>(CFDictionaryGetValue(pVariations, pTag));
- if (!pValue)
- continue;
- CFNumberGetValue(pValue, kCFNumberFloatType, &fValue);
-
- aHBVariations.push_back({ nTag, fValue });
+ CFIndex nAxes = CFArrayGetCount(pAxes);
+ for (CFIndex i = 0; i < nAxes; ++i)
+ {
+ auto pAxis = static_cast<CFDictionaryRef>(CFArrayGetValueAtIndex(pAxes, i));
+ if (pAxis)
+ {
+ hb_tag_t nTag;
+ auto pTag = static_cast<CFNumberRef>(
+ CFDictionaryGetValue(pAxis, kCTFontVariationAxisIdentifierKey));
+ if (!pTag)
+ continue;
+ CFNumberGetValue(pTag, kCFNumberIntType, &nTag);
+
+ float fValue;
+ auto pValue
+ = static_cast<CFNumberRef>(CFDictionaryGetValue(pVariations, pTag));
+ if (!pValue)
+ continue;
+ CFNumberGetValue(pValue, kCFNumberFloatType, &fValue);
+
+ m_aVariations.push_back({ nTag, fValue });
+ }
+ }
+ CFRelease(pVariations);
}
+ CFRelease(pAxes);
}
- CFRelease(pVariations);
}
- CFRelease(pAxes);
-
- if (!aHBVariations.empty())
- hb_font_set_variations(pHbFont, aHBVariations.data(), aHBVariations.size());
-}
-void CoreTextFont::ImplInitHbFont(hb_font_t* pHbFont)
-{
- SetFontVariationsOnHBFont(pHbFont);
+ return m_aVariations;
}
rtl::Reference<LogicalFontInstance> CoreTextFontFace::CreateFontInstance(const vcl::font::FontSelectPattern& rFSD) const