SkPDF: Always give a default advance for glyphs.
Prior to this we assumed the default default was 0. It is actually 1000, according to the spec. fixes BUG=skia:5321 GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2146403005 Review-Url: https://codereview.chromium.org/2146403005
This commit is contained in:
parent
ec58b86437
commit
39f988eb41
33
gm/skbug_5321.cpp
Normal file
33
gm/skbug_5321.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "gm.h"
|
||||
|
||||
// https://bugs.skia.org/5321
|
||||
// two strings should draw the same. PDF did not.
|
||||
DEF_SIMPLE_GM(skbug_5321, canvas, 128, 128) {
|
||||
SkPaint paint;
|
||||
paint.setStyle(SkPaint::kFill_Style);
|
||||
paint.setTextSize(30);
|
||||
|
||||
paint.setTextEncoding(SkPaint::kUTF8_TextEncoding);
|
||||
const char text[] = "x\314\200y"; // utf8(u"x\u0300y")
|
||||
SkScalar x = 20, y = 45;
|
||||
size_t byteLength = strlen(text);
|
||||
canvas->drawText(text, byteLength, x, y, paint);
|
||||
|
||||
int glyph_count = paint.countText(text, byteLength);
|
||||
SkAutoTMalloc<SkScalar> widths(glyph_count);
|
||||
(void)paint.getTextWidths(text, byteLength, &widths[0]);
|
||||
for (int i = 0; i < glyph_count; ++i) {
|
||||
SkScalar w = widths[i];
|
||||
widths[i] = x;
|
||||
x += w;
|
||||
}
|
||||
y += paint.getFontMetrics(nullptr);
|
||||
canvas->drawPosTextH(text, byteLength, &widths[0], y, paint);
|
||||
}
|
@ -1137,13 +1137,11 @@ bool SkPDFCIDFont::populate(const SkPDFGlyphSet* subset) {
|
||||
sk_sp<SkPDFArray> widths(composeAdvanceData(
|
||||
fontInfo()->fGlyphWidths, fontInfo()->fEmSize, &appendWidth,
|
||||
&defaultWidth));
|
||||
if (widths->size())
|
||||
if (widths->size()) {
|
||||
this->insertObject("W", std::move(widths));
|
||||
if (defaultWidth != 0) {
|
||||
this->insertScalar(
|
||||
"DW",
|
||||
scaleFromFontUnits(defaultWidth, fontInfo()->fEmSize));
|
||||
}
|
||||
this->insertScalar(
|
||||
"DW", scaleFromFontUnits(defaultWidth, fontInfo()->fEmSize));
|
||||
}
|
||||
if (!fontInfo()->fVerticalMetrics.empty()) {
|
||||
struct SkAdvancedTypefaceMetrics::VerticalMetric defaultAdvance;
|
||||
|
Loading…
Reference in New Issue
Block a user