DirectWrite to use PostScript name for PDF.

The PDF backend expects info->fFontName to be the PostScript name.
Prior to this change the '<family> <sytle>' name was used instead.

R=vandebo@chromium.org, halcanary@google.com, reed@google.com, thestig@chromium.org

Author: bungeman@google.com

Review URL: https://codereview.chromium.org/324403010
This commit is contained in:
bungeman 2014-06-17 10:48:04 -07:00 committed by Commit bot
parent 057ef35280
commit 6d867d494a

View File

@ -365,23 +365,18 @@ SkAdvancedTypefaceMetrics* DWriteFontTypeface::onGetAdvancedTypefaceMetrics(
info->fLastGlyphID = SkToU16(glyphCount - 1); info->fLastGlyphID = SkToU16(glyphCount - 1);
info->fStyle = 0; info->fStyle = 0;
// SkAdvancedTypefaceMetrics::fFontName is in theory supposed to be
// the PostScript name of the font. However, due to the way it is currently
// used, it must actually be a family name.
SkTScopedComPtr<IDWriteLocalizedStrings> familyNames; SkTScopedComPtr<IDWriteLocalizedStrings> familyNames;
SkTScopedComPtr<IDWriteLocalizedStrings> faceNames;
hr = fDWriteFontFamily->GetFamilyNames(&familyNames); hr = fDWriteFontFamily->GetFamilyNames(&familyNames);
hr = fDWriteFont->GetFaceNames(&faceNames);
UINT32 familyNameLength; UINT32 familyNameLength;
hr = familyNames->GetStringLength(0, &familyNameLength); hr = familyNames->GetStringLength(0, &familyNameLength);
UINT32 faceNameLength; UINT32 size = familyNameLength+1;
hr = faceNames->GetStringLength(0, &faceNameLength);
UINT32 size = familyNameLength+1+faceNameLength+1;
SkSMallocWCHAR wFamilyName(size); SkSMallocWCHAR wFamilyName(size);
hr = familyNames->GetString(0, wFamilyName.get(), size); hr = familyNames->GetString(0, wFamilyName.get(), size);
wFamilyName[familyNameLength] = L' ';
hr = faceNames->GetString(0, &wFamilyName[familyNameLength+1], size - faceNameLength + 1);
hr = sk_wchar_to_skstring(wFamilyName.get(), &info->fFontName); hr = sk_wchar_to_skstring(wFamilyName.get(), &info->fFontName);