Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(399)

Unified Diff: src/ports/SkFontHost_mac.cpp

Issue 2162023002: Correct advances for 'monospace' fonts in PDF. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: CG and GDI as well. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/ports/SkFontHost_mac.cpp
diff --git a/src/ports/SkFontHost_mac.cpp b/src/ports/SkFontHost_mac.cpp
index 55eec335027a9262e580081d98f7b09716f86114..68668c248e8ab5a084e511df8ed108b82c06ea19 100644
--- a/src/ports/SkFontHost_mac.cpp
+++ b/src/ports/SkFontHost_mac.cpp
@@ -1610,29 +1610,21 @@ SkAdvancedTypefaceMetrics* SkTypeface_Mac::onGetAdvancedTypefaceMetrics(
}
if (perGlyphInfo & kHAdvance_PerGlyphInfo) {
- if (info->fStyle & SkAdvancedTypefaceMetrics::kFixedPitch_Style) {
- SkAdvancedTypefaceMetrics::WidthRange range(0);
- range.fAdvance.append(1, &min_width);
- SkAdvancedTypefaceMetrics::FinishRange(
- &range, 0, SkAdvancedTypefaceMetrics::WidthRange::kDefault);
- info->fGlyphWidths.emplace_back(std::move(range));
- } else {
- CTFontRef borrowedCTFont = ctFont.get();
- info->setGlyphWidths(
- SkToInt(glyphCount),
- glyphIDs,
- glyphIDsCount,
- SkAdvancedTypefaceMetrics::GetAdvance([borrowedCTFont](int gId, int16_t* data) {
- CGSize advance;
- advance.width = 0;
- CGGlyph glyph = gId;
- CTFontGetAdvancesForGlyphs(borrowedCTFont, kCTFontHorizontalOrientation,
- &glyph, &advance, 1);
- *data = sk_float_round2int(advance.width);
- return true;
- })
- );
- }
+ CTFontRef borrowedCTFont = ctFont.get();
+ info->setGlyphWidths(
+ SkToInt(glyphCount),
+ glyphIDs,
+ glyphIDsCount,
+ SkAdvancedTypefaceMetrics::GetAdvance([borrowedCTFont](int gId, int16_t* data) {
+ CGSize advance;
+ advance.width = 0;
+ CGGlyph glyph = gId;
+ CTFontGetAdvancesForGlyphs(borrowedCTFont, kCTFontHorizontalOrientation,
+ &glyph, &advance, 1);
+ *data = sk_float_round2int(advance.width);
+ return true;
+ })
+ );
}
return info;
}

Powered by Google App Engine
This is Rietveld 408576698