summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/font/PhysicalFontFace.cxx19
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx6
2 files changed, 23 insertions, 2 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();
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 83887db1a4dc..a381d9287c4e 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -2500,7 +2500,9 @@ bool PDFWriterImpl::emitType3Font(const vcl::font::PhysicalFontFace* pFace,
for (auto i = 1u; i < nGlyphs; i++)
{
auto nStream = createObject();
- aLine.append("/g" + OString::number(i) + " ");
+ aLine.append("/");
+ aLine.append(pFace->GetGlyphName(pGlyphIds[i], true));
+ aLine.append(" ");
aLine.append(nStream);
aLine.append(" 0 R\n");
pGlyphStreams[i] = nStream;
@@ -2509,7 +2511,7 @@ bool PDFWriterImpl::emitType3Font(const vcl::font::PhysicalFontFace* pFace,
aLine.append("/Encoding<</Type/Encoding/Differences[1");
for (auto i = 1u; i < nGlyphs; i++)
- aLine.append(" /g" + OString::number(i));
+ aLine.append(" /" + pFace->GetGlyphName(pGlyphIds[i], true));
aLine.append("]>>\n");
aLine.append("/FirstChar 0\n"