From 0ad685a170112b0c775442280d067af36458153e Mon Sep 17 00:00:00 2001 From: Hal Canary Date: Mon, 2 Apr 2018 15:53:24 -0400 Subject: SkPDF: implement xheight for type3 fonts Change-Id: Ib8e5424e31003798ea141e958a74aa8110ee52c7 Reviewed-on: https://skia-review.googlesource.com/117860 Reviewed-by: Ben Wagner Commit-Queue: Hal Canary --- src/pdf/SkPDFFont.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/pdf') diff --git a/src/pdf/SkPDFFont.cpp b/src/pdf/SkPDFFont.cpp index ff3b84cf75..c9230f017b 100644 --- a/src/pdf/SkPDFFont.cpp +++ b/src/pdf/SkPDFFont.cpp @@ -629,6 +629,7 @@ static void add_type3_font_info(SkPDFCanon* canon, } int unitsPerEm; auto cache = SkPDFFont::MakeVectorCache(typeface, &unitsPerEm); + SkASSERT(cache); SkScalar emSize = (SkScalar)unitsPerEm; font->insertName("Subtype", "Type3"); // Flip about the x-axis and scale by 1/emSize. @@ -727,8 +728,11 @@ static void add_type3_font_info(SkPDFCanon* canon, // Adobe requests CapHeight, XHeight, and StemV be added // to "greatly help our workflow downstream". if (metrics->fCapHeight != 0) { descriptor->insertInt("CapHeight", metrics->fCapHeight); } - if (metrics->fXHeight != 0) { descriptor->insertInt("XHeight", metrics->fXHeight); } if (metrics->fStemV != 0) { descriptor->insertInt("StemV", metrics->fStemV); } + SkScalar xHeight = cache->getFontMetrics().fXHeight; + if (xHeight != 0) { + descriptor->insertScalar("XHeight", xHeight); + } } descriptor->insertInt("Flags", fontDescriptorFlags); font->insertObjRef("FontDescriptor", std::move(descriptor)); -- cgit v1.2.3