summaryrefslogtreecommitdiff
path: root/vcl/source/font/PhysicalFontFace.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/source/font/PhysicalFontFace.cxx')
-rw-r--r--vcl/source/font/PhysicalFontFace.cxx19
1 files changed, 19 insertions, 0 deletions
diff --git a/vcl/source/font/PhysicalFontFace.cxx b/vcl/source/font/PhysicalFontFace.cxx
index 337995964389..70738bbad06b 100644
--- a/vcl/source/font/PhysicalFontFace.cxx
+++ b/vcl/source/font/PhysicalFontFace.cxx
@@ -399,6 +399,25 @@ RawFontData PhysicalFontFace::GetGlyphColorBitmap(sal_GlyphId nGlyphIndex,
return aData;
}
+OString PhysicalFontFace::GetGlyphName(sal_GlyphId nGlyphIndex, bool bValidate) const
+{
+ char aBuffer[256];
+ hb_font_glyph_to_string(GetHbUnscaledFont(), nGlyphIndex, aBuffer, 256);
+ if (bValidate)
+ {
+ // https://learn.microsoft.com/en-us/typography/opentype/spec/post#version-20
+ // Valid characters are limited to A–Z, a–z, 0–9, “.” (FULL STOP), and “_” (LOW LINE).
+ const char* p = aBuffer;
+ while ((*p >= '0' && *p <= '9') || (*p >= 'A' && *p <= 'Z') || (*p >= 'a' && *p <= 'z')
+ || *p == '.' || *p == '_')
+ ++p;
+ if (*p != '\0')
+ return "g" + OString::number(nGlyphIndex);
+ }
+
+ return OString(aBuffer);
+}
+
OUString PhysicalFontFace::GetName(NameID aNameID, const LanguageTag& rLanguageTag) const
{
auto pHbFace = GetHbFace();