| OLD | NEW |
| 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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 | 354 |
| 355 HRESULT hr = S_OK; | 355 HRESULT hr = S_OK; |
| 356 | 356 |
| 357 const unsigned glyphCount = fDWriteFontFace->GetGlyphCount(); | 357 const unsigned glyphCount = fDWriteFontFace->GetGlyphCount(); |
| 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; | |
| 365 info->fLastGlyphID = SkToU16(glyphCount - 1); | 364 info->fLastGlyphID = SkToU16(glyphCount - 1); |
| 366 info->fStyle = 0; | 365 info->fStyle = 0; |
| 366 info->fFlags = SkAdvancedTypefaceMetrics::kEmpty_FontFlag; |
| 367 | 367 |
| 368 // SkAdvancedTypefaceMetrics::fFontName is in theory supposed to be | 368 // SkAdvancedTypefaceMetrics::fFontName is in theory supposed to be |
| 369 // the PostScript name of the font. However, due to the way it is currently | 369 // the PostScript name of the font. However, due to the way it is currently |
| 370 // used, it must actually be a family name. | 370 // used, it must actually be a family name. |
| 371 SkTScopedComPtr<IDWriteLocalizedStrings> familyNames; | 371 SkTScopedComPtr<IDWriteLocalizedStrings> familyNames; |
| 372 hr = fDWriteFontFamily->GetFamilyNames(&familyNames); | 372 hr = fDWriteFontFamily->GetFamilyNames(&familyNames); |
| 373 | 373 |
| 374 UINT32 familyNameLength; | 374 UINT32 familyNameLength; |
| 375 hr = familyNames->GetStringLength(0, &familyNameLength); | 375 hr = familyNames->GetStringLength(0, &familyNameLength); |
| 376 | 376 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 if (GetCharABCWidths(hdc, stem_chars[i], stem_chars[i], &abcWidths)) { | 460 if (GetCharABCWidths(hdc, stem_chars[i], stem_chars[i], &abcWidths)) { |
| 461 int16_t width = abcWidths.abcB; | 461 int16_t width = abcWidths.abcB; |
| 462 if (width > 0 && width < min_width) { | 462 if (width > 0 && width < min_width) { |
| 463 min_width = width; | 463 min_width = width; |
| 464 info->fStemV = min_width; | 464 info->fStemV = min_width; |
| 465 } | 465 } |
| 466 } | 466 } |
| 467 } | 467 } |
| 468 */ | 468 */ |
| 469 | 469 |
| 470 // If Restricted, the font may not be embedded in a document. | 470 if (perGlyphInfo & SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo) { |
| 471 // If not Restricted, the font can be embedded. | |
| 472 // If PreviewPrint, the embedding is read-only. | |
| 473 if (os2Table->version.v0.fsType.field.Restricted) { | |
| 474 info->fType = SkAdvancedTypefaceMetrics::kNotEmbeddable_Font; | |
| 475 } else if (perGlyphInfo & SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo)
{ | |
| 476 if (fixedWidth) { | 471 if (fixedWidth) { |
| 477 appendRange(&info->fGlyphWidths, 0); | 472 appendRange(&info->fGlyphWidths, 0); |
| 478 int16_t advance; | 473 int16_t advance; |
| 479 getWidthAdvance(fDWriteFontFace.get(), 1, &advance); | 474 getWidthAdvance(fDWriteFontFace.get(), 1, &advance); |
| 480 info->fGlyphWidths->fAdvance.append(1, &advance); | 475 info->fGlyphWidths->fAdvance.append(1, &advance); |
| 481 finishRange(info->fGlyphWidths.get(), 0, | 476 finishRange(info->fGlyphWidths.get(), 0, |
| 482 SkAdvancedTypefaceMetrics::WidthRange::kDefault); | 477 SkAdvancedTypefaceMetrics::WidthRange::kDefault); |
| 483 } else { | 478 } else { |
| 484 info->fGlyphWidths.reset( | 479 info->fGlyphWidths.reset( |
| 485 getAdvanceData(fDWriteFontFace.get(), | 480 getAdvanceData(fDWriteFontFace.get(), |
| 486 glyphCount, | 481 glyphCount, |
| 487 glyphIDs, | 482 glyphIDs, |
| 488 glyphIDsCount, | 483 glyphIDsCount, |
| 489 getWidthAdvance)); | 484 getWidthAdvance)); |
| 490 } | 485 } |
| 491 } | 486 } |
| 492 | 487 |
| 493 return info; | 488 return info; |
| 494 } | 489 } |
| OLD | NEW |