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

Side by Side Diff: src/ports/SkTypeface_win_dw.cpp

Issue 324403010: DirectWrite to use PostScript name for PDF. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Use family name instead. Created 6 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkDWriteFontFileStream.h" 8 #include "SkDWriteFontFileStream.h"
9 #include "SkFontDescriptor.h" 9 #include "SkFontDescriptor.h"
10 #include "SkFontStream.h" 10 #include "SkFontStream.h"
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 358
359 DWRITE_FONT_METRICS dwfm; 359 DWRITE_FONT_METRICS dwfm;
360 fDWriteFontFace->GetMetrics(&dwfm); 360 fDWriteFontFace->GetMetrics(&dwfm);
361 361
362 info = new SkAdvancedTypefaceMetrics; 362 info = new SkAdvancedTypefaceMetrics;
363 info->fEmSize = dwfm.designUnitsPerEm; 363 info->fEmSize = dwfm.designUnitsPerEm;
364 info->fMultiMaster = false; 364 info->fMultiMaster = false;
365 info->fLastGlyphID = SkToU16(glyphCount - 1); 365 info->fLastGlyphID = SkToU16(glyphCount - 1);
366 info->fStyle = 0; 366 info->fStyle = 0;
367 367
368 368 // SkAdvancedTypefaceMetrics::fFontName is in theory supposed to be
369 // the PostScript name of the font. However, due to the way it is currently
370 // used, it must actually be a family name.
369 SkTScopedComPtr<IDWriteLocalizedStrings> familyNames; 371 SkTScopedComPtr<IDWriteLocalizedStrings> familyNames;
370 SkTScopedComPtr<IDWriteLocalizedStrings> faceNames;
371 hr = fDWriteFontFamily->GetFamilyNames(&familyNames); 372 hr = fDWriteFontFamily->GetFamilyNames(&familyNames);
372 hr = fDWriteFont->GetFaceNames(&faceNames);
373 373
374 UINT32 familyNameLength; 374 UINT32 familyNameLength;
375 hr = familyNames->GetStringLength(0, &familyNameLength); 375 hr = familyNames->GetStringLength(0, &familyNameLength);
376 376
377 UINT32 faceNameLength; 377 UINT32 size = familyNameLength+1;
378 hr = faceNames->GetStringLength(0, &faceNameLength);
379
380 UINT32 size = familyNameLength+1+faceNameLength+1;
381 SkSMallocWCHAR wFamilyName(size); 378 SkSMallocWCHAR wFamilyName(size);
382 hr = familyNames->GetString(0, wFamilyName.get(), size); 379 hr = familyNames->GetString(0, wFamilyName.get(), size);
383 wFamilyName[familyNameLength] = L' ';
384 hr = faceNames->GetString(0, &wFamilyName[familyNameLength+1], size - faceNa meLength + 1);
385 380
386 hr = sk_wchar_to_skstring(wFamilyName.get(), &info->fFontName); 381 hr = sk_wchar_to_skstring(wFamilyName.get(), &info->fFontName);
387 382
388 if (perGlyphInfo & SkAdvancedTypefaceMetrics::kToUnicode_PerGlyphInfo) { 383 if (perGlyphInfo & SkAdvancedTypefaceMetrics::kToUnicode_PerGlyphInfo) {
389 populate_glyph_to_unicode(fDWriteFontFace.get(), glyphCount, &(info->fGl yphToUnicode)); 384 populate_glyph_to_unicode(fDWriteFontFace.get(), glyphCount, &(info->fGl yphToUnicode));
390 } 385 }
391 386
392 DWRITE_FONT_FACE_TYPE fontType = fDWriteFontFace->GetType(); 387 DWRITE_FONT_FACE_TYPE fontType = fDWriteFontFace->GetType();
393 if (fontType == DWRITE_FONT_FACE_TYPE_TRUETYPE || 388 if (fontType == DWRITE_FONT_FACE_TYPE_TRUETYPE ||
394 fontType == DWRITE_FONT_FACE_TYPE_TRUETYPE_COLLECTION) { 389 fontType == DWRITE_FONT_FACE_TYPE_TRUETYPE_COLLECTION) {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 getAdvanceData(fDWriteFontFace.get(), 485 getAdvanceData(fDWriteFontFace.get(),
491 glyphCount, 486 glyphCount,
492 glyphIDs, 487 glyphIDs,
493 glyphIDsCount, 488 glyphIDsCount,
494 getWidthAdvance)); 489 getWidthAdvance));
495 } 490 }
496 } 491 }
497 492
498 return info; 493 return info;
499 } 494 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698