[PDF] Always set the symbolic Flag for Fonts.

This should fix Chrome bug 124572

Review URL: https://codereview.appspot.com/7631045

git-svn-id: http://skia.googlecode.com/svn/trunk@8136 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
vandebo@chromium.org 2013-03-13 20:01:51 +00:00
parent d34fda187c
commit dcf9c19d38
6 changed files with 6 additions and 13 deletions

View File

@ -52,9 +52,7 @@ public:
enum StyleFlags { enum StyleFlags {
kFixedPitch_Style = 0x00001, kFixedPitch_Style = 0x00001,
kSerif_Style = 0x00002, kSerif_Style = 0x00002,
kSymbolic_Style = 0x00004,
kScript_Style = 0x00008, kScript_Style = 0x00008,
kNonsymbolic_Style = 0x00020,
kItalic_Style = 0x00040, kItalic_Style = 0x00040,
kAllCaps_Style = 0x10000, kAllCaps_Style = 0x10000,
kSmallCaps_Style = 0x20000, kSmallCaps_Style = 0x20000,

View File

@ -31,6 +31,11 @@
#include SK_SFNTLY_SUBSETTER #include SK_SFNTLY_SUBSETTER
#endif #endif
// PDF's notion of symbolic vs non-symbolic is related to the character set, not
// symbols vs. characters. Rarely is a font the right character set to call it
// non-symbolic, so always call it symbolic. (PDF 1.4 spec, section 5.7.1)
static const int kPdfSymbolic = 4;
namespace { namespace {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -945,7 +950,7 @@ bool SkPDFFont::addCommonFontDescriptorEntries(int16_t defaultWidth) {
const uint16_t emSize = fFontInfo->fEmSize; const uint16_t emSize = fFontInfo->fEmSize;
fDescriptor->insertName("FontName", fFontInfo->fFontName); fDescriptor->insertName("FontName", fFontInfo->fFontName);
fDescriptor->insertInt("Flags", fFontInfo->fStyle); fDescriptor->insertInt("Flags", fFontInfo->fStyle | kPdfSymbolic);
fDescriptor->insertScalar("Ascent", fDescriptor->insertScalar("Ascent",
scaleFromFontUnits(fFontInfo->fAscent, emSize)); scaleFromFontUnits(fFontInfo->fAscent, emSize));
fDescriptor->insertScalar("Descent", fDescriptor->insertScalar("Descent",

View File

@ -499,9 +499,6 @@ SkAdvancedTypefaceMetrics* SkFontHost::GetAdvancedTypefaceMetrics(
info->fStyle |= SkAdvancedTypefaceMetrics::kFixedPitch_Style; info->fStyle |= SkAdvancedTypefaceMetrics::kFixedPitch_Style;
if (face->style_flags & FT_STYLE_FLAG_ITALIC) if (face->style_flags & FT_STYLE_FLAG_ITALIC)
info->fStyle |= SkAdvancedTypefaceMetrics::kItalic_Style; info->fStyle |= SkAdvancedTypefaceMetrics::kItalic_Style;
// We should set either Symbolic or Nonsymbolic; Nonsymbolic if the font's
// character set is a subset of 'Adobe standard Latin.'
info->fStyle |= SkAdvancedTypefaceMetrics::kSymbolic_Style;
PS_FontInfoRec ps_info; PS_FontInfoRec ps_info;
TT_Postscript* tt_info; TT_Postscript* tt_info;

View File

@ -1520,9 +1520,6 @@ SkAdvancedTypefaceMetrics* SkFontHost::GetAdvancedTypefaceMetrics(
info->fStyle |= SkAdvancedTypefaceMetrics::kItalic_Style; info->fStyle |= SkAdvancedTypefaceMetrics::kItalic_Style;
} }
CTFontStylisticClass stylisticClass = symbolicTraits & kCTFontClassMaskTrait; CTFontStylisticClass stylisticClass = symbolicTraits & kCTFontClassMaskTrait;
if (stylisticClass & kCTFontSymbolicClass) {
info->fStyle |= SkAdvancedTypefaceMetrics::kSymbolic_Style;
}
if (stylisticClass >= kCTFontOldStyleSerifsClass && stylisticClass <= kCTFontSlabSerifsClass) { if (stylisticClass >= kCTFontOldStyleSerifsClass && stylisticClass <= kCTFontSlabSerifsClass) {
info->fStyle |= SkAdvancedTypefaceMetrics::kSerif_Style; info->fStyle |= SkAdvancedTypefaceMetrics::kSerif_Style;
} else if (stylisticClass & kCTFontScriptsClass) { } else if (stylisticClass & kCTFontScriptsClass) {

View File

@ -1406,8 +1406,6 @@ SkAdvancedTypefaceMetrics* SkFontHost::GetAdvancedTypefaceMetrics(
if (otm.otmTextMetrics.tmItalic) { if (otm.otmTextMetrics.tmItalic) {
info->fStyle |= SkAdvancedTypefaceMetrics::kItalic_Style; info->fStyle |= SkAdvancedTypefaceMetrics::kItalic_Style;
} }
// Setting symbolic style by default for now.
info->fStyle |= SkAdvancedTypefaceMetrics::kSymbolic_Style;
if (otm.otmTextMetrics.tmPitchAndFamily & FF_ROMAN) { if (otm.otmTextMetrics.tmPitchAndFamily & FF_ROMAN) {
info->fStyle |= SkAdvancedTypefaceMetrics::kSerif_Style; info->fStyle |= SkAdvancedTypefaceMetrics::kSerif_Style;
} else if (otm.otmTextMetrics.tmPitchAndFamily & FF_SCRIPT) { } else if (otm.otmTextMetrics.tmPitchAndFamily & FF_SCRIPT) {

View File

@ -1488,8 +1488,6 @@ SkAdvancedTypefaceMetrics* SkFontHost::GetAdvancedTypefaceMetrics(
if (os2Table->version.v0.fsSelection.field.Italic) { if (os2Table->version.v0.fsSelection.field.Italic) {
info->fStyle |= SkAdvancedTypefaceMetrics::kItalic_Style; info->fStyle |= SkAdvancedTypefaceMetrics::kItalic_Style;
} }
//Symbolic (uses more than base latin).
info->fStyle |= SkAdvancedTypefaceMetrics::kSymbolic_Style;
//Script //Script
if (SkPanose::FamilyType::Script == os2Table->version.v0.panose.bFamilyType.value) { if (SkPanose::FamilyType::Script == os2Table->version.v0.panose.bFamilyType.value) {
info->fStyle |= SkAdvancedTypefaceMetrics::kScript_Style; info->fStyle |= SkAdvancedTypefaceMetrics::kScript_Style;