summaryrefslogtreecommitdiff
path: root/vcl/source/font
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/source/font')
-rw-r--r--vcl/source/font/FeatureCollector.cxx28
-rw-r--r--vcl/source/font/LogicalFontInstance.cxx20
-rw-r--r--vcl/source/font/PhysicalFontFace.cxx30
3 files changed, 38 insertions, 40 deletions
diff --git a/vcl/source/font/FeatureCollector.cxx b/vcl/source/font/FeatureCollector.cxx
index 134462e0ed44..a97988ca46ce 100644
--- a/vcl/source/font/FeatureCollector.cxx
+++ b/vcl/source/font/FeatureCollector.cxx
@@ -84,29 +84,6 @@ bool FeatureCollector::collectGraphite()
return true;
}
-static OUString getName(hb_face_t* pHbFace, hb_ot_name_id_t aNameID, OString& rLanguage)
-{
- auto aHbLang = hb_language_from_string(rLanguage.getStr(), rLanguage.getLength());
- auto nName = hb_ot_name_get_utf16(pHbFace, aNameID, aHbLang, nullptr, nullptr);
-
- if (!nName)
- {
- // Fallback to English if localized name is missing.
- aHbLang = hb_language_from_string("en", 2);
- nName = hb_ot_name_get_utf16(pHbFace, aNameID, aHbLang, nullptr, nullptr);
- }
-
- OUString sName;
- if (nName)
- {
- std::vector<uint16_t> aBuf(++nName); // make space for terminating NUL.
- hb_ot_name_get_utf16(pHbFace, aNameID, aHbLang, &nName, aBuf.data());
- sName = OUString(reinterpret_cast<sal_Unicode*>(aBuf.data()), nName);
- }
-
- return sName;
-}
-
void FeatureCollector::collectForTable(hb_tag_t aTableTag)
{
unsigned int nFeatureCount
@@ -144,8 +121,7 @@ void FeatureCollector::collectForTable(hb_tag_t aTableTag)
nullptr, nullptr, &nNamedParameters,
&aFirstParameterID))
{
- OString sLanguage = m_rLanguageTag.getBcp47().toUtf8();
- OUString sLabel = getName(m_pHbFace, aLabelID, sLanguage);
+ OUString sLabel = m_pFace->GetName(NameID(aLabelID), m_rLanguageTag);
if (!sLabel.isEmpty())
aDefinition = vcl::font::FeatureDefinition(aFeatureTag, sLabel);
@@ -154,7 +130,7 @@ void FeatureCollector::collectForTable(hb_tag_t aTableTag)
for (unsigned i = 0; i < nNamedParameters; i++)
{
hb_ot_name_id_t aNameID = aFirstParameterID + i;
- OUString sName = getName(m_pHbFace, aNameID, sLanguage);
+ OUString sName = m_pFace->GetName(NameID(aNameID), m_rLanguageTag);
if (!sName.isEmpty())
aParameters.emplace_back(uint32_t(i + 1), sName);
else
diff --git a/vcl/source/font/LogicalFontInstance.cxx b/vcl/source/font/LogicalFontInstance.cxx
index 6124d41b3dba..b5d36afb2e56 100644
--- a/vcl/source/font/LogicalFontInstance.cxx
+++ b/vcl/source/font/LogicalFontInstance.cxx
@@ -181,22 +181,14 @@ bool LogicalFontInstance::NeedOffsetCorrection(sal_Int32 nYOffset)
{
if (!m_xeFontFamilyEnum)
{
- char familyname[10];
- unsigned int familyname_size = 10;
-
m_xeFontFamilyEnum = FontFamilyEnum::Unclassified;
- if (hb_ot_name_get_utf8(hb_font_get_face(GetHbFont()), HB_OT_NAME_ID_FONT_FAMILY,
- HB_LANGUAGE_INVALID, &familyname_size, familyname)
- == 8)
- {
- // DFKai-SB (ukai.ttf) is a built-in font under traditional Chinese
- // Windows. It has wrong extent values in glyf table. The problem results
- // in wrong positioning of glyphs in vertical writing.
- // Check https://github.com/harfbuzz/harfbuzz/issues/3521 for reference.
- if (!strncmp("DFKai-SB", familyname, 8))
- m_xeFontFamilyEnum = FontFamilyEnum::DFKaiSB;
- }
+ // DFKai-SB (ukai.ttf) is a built-in font under traditional Chinese
+ // Windows. It has wrong extent values in glyf table. The problem results
+ // in wrong positioning of glyphs in vertical writing.
+ // Check https://github.com/harfbuzz/harfbuzz/issues/3521 for reference.
+ if (GetFontFace()->GetName(vcl::font::NAME_ID_FONT_FAMILY) == "DFKai-SB")
+ m_xeFontFamilyEnum = FontFamilyEnum::DFKaiSB;
}
bool bRet = true;
diff --git a/vcl/source/font/PhysicalFontFace.cxx b/vcl/source/font/PhysicalFontFace.cxx
index 4a459ae8cee3..d210304f5b47 100644
--- a/vcl/source/font/PhysicalFontFace.cxx
+++ b/vcl/source/font/PhysicalFontFace.cxx
@@ -360,6 +360,36 @@ std::vector<ColorLayer> PhysicalFontFace::GetGlyphColorLayers(sal_GlyphId nGlyph
return aLayers;
}
+
+OUString PhysicalFontFace::GetName(NameID aNameID, const LanguageTag& rLanguageTag) const
+{
+ auto pHbFace = GetHbFace();
+
+ auto aHbLang = HB_LANGUAGE_INVALID;
+ if (rLanguageTag.getLanguageType() != LANGUAGE_NONE)
+ {
+ auto aLanguage(rLanguageTag.getBcp47().toUtf8());
+ aHbLang = hb_language_from_string(aLanguage.getStr(), aLanguage.getLength());
+ }
+
+ auto nName = hb_ot_name_get_utf16(pHbFace, aNameID, aHbLang, nullptr, nullptr);
+ if (!nName && aHbLang == HB_LANGUAGE_INVALID)
+ {
+ // Fallback to English if localized name is missing.
+ aHbLang = hb_language_from_string("en", 2);
+ nName = hb_ot_name_get_utf16(pHbFace, aNameID, aHbLang, nullptr, nullptr);
+ }
+
+ OUString sName;
+ if (nName)
+ {
+ std::vector<uint16_t> aBuf(++nName); // make space for terminating NUL.
+ hb_ot_name_get_utf16(pHbFace, aNameID, aHbLang, &nName, aBuf.data());
+ sName = OUString(reinterpret_cast<sal_Unicode*>(aBuf.data()), nName);
+ }
+
+ return sName;
+}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */