Port change r2040 to mac
authorctguil@chromium.org <ctguil@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 8 Aug 2011 23:23:20 +0000 (23:23 +0000)
committerctguil@chromium.org <ctguil@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 8 Aug 2011 23:23:20 +0000 (23:23 +0000)
This is to honor fixed width font during PDF generation.  Change r2040 fixed only Windows port.  Linux does not have the problem.

Review URL: http://codereview.appspot.com/4855046

git-svn-id: http://skia.googlecode.com/svn/trunk@2076 2bbb7eff-a529-9590-31e7-b0007b416f81

src/ports/SkFontHost_mac_coretext.cpp

index 5b04f0208a2bf2ae91d3ff5035995fea6afb8642..3bb90f7a6ea6c0907e0b9698381665c9606c9961 100644 (file)
@@ -820,8 +820,15 @@ SkAdvancedTypefaceMetrics* SkFontHost::GetAdvancedTypefaceMetrics(
         info->fType = SkAdvancedTypefaceMetrics::kNotEmbeddable_Font;
     } else if (perGlyphInfo &
                SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo) {
-        info->fGlyphWidths.reset(
-            getAdvanceData(ctFont, glyphCount, &getWidthAdvance));
+        if (info->fStyle & SkAdvancedTypefaceMetrics::kFixedPitch_Style) {
+            appendRange(&info->fGlyphWidths, 0);
+            info->fGlyphWidths->fAdvance.append(1, &min_width);
+            finishRange(info->fGlyphWidths.get(), 0,
+                        SkAdvancedTypefaceMetrics::WidthRange::kDefault);
+        } else {
+            info->fGlyphWidths.reset(
+                getAdvanceData(ctFont, glyphCount, &getWidthAdvance));
+        }
     }
 
     CFSafeRelease(ctFont);