| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkTypes.h" | 8 #include "SkTypes.h" |
| 9 #undef GetGlyphIndices | 9 #undef GetGlyphIndices |
| 10 | 10 |
| (...skipping 1472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1483 | 1483 |
| 1484 HRESULT hr = S_OK; | 1484 HRESULT hr = S_OK; |
| 1485 | 1485 |
| 1486 const unsigned glyphCount = fDWriteFontFace->GetGlyphCount(); | 1486 const unsigned glyphCount = fDWriteFontFace->GetGlyphCount(); |
| 1487 | 1487 |
| 1488 DWRITE_FONT_METRICS dwfm; | 1488 DWRITE_FONT_METRICS dwfm; |
| 1489 fDWriteFontFace->GetMetrics(&dwfm); | 1489 fDWriteFontFace->GetMetrics(&dwfm); |
| 1490 | 1490 |
| 1491 info = new SkAdvancedTypefaceMetrics; | 1491 info = new SkAdvancedTypefaceMetrics; |
| 1492 info->fEmSize = dwfm.designUnitsPerEm; | 1492 info->fEmSize = dwfm.designUnitsPerEm; |
| 1493 info->fMultiMaster = false; |
| 1493 info->fLastGlyphID = SkToU16(glyphCount - 1); | 1494 info->fLastGlyphID = SkToU16(glyphCount - 1); |
| 1494 info->fStyle = 0; | 1495 info->fStyle = 0; |
| 1495 info->fFlags = SkAdvancedTypefaceMetrics::kEmpty_FontFlag; | 1496 |
| 1496 | 1497 |
| 1497 SkTScopedComPtr<IDWriteLocalizedStrings> familyNames; | 1498 SkTScopedComPtr<IDWriteLocalizedStrings> familyNames; |
| 1498 SkTScopedComPtr<IDWriteLocalizedStrings> faceNames; | 1499 SkTScopedComPtr<IDWriteLocalizedStrings> faceNames; |
| 1499 hr = fDWriteFontFamily->GetFamilyNames(&familyNames); | 1500 hr = fDWriteFontFamily->GetFamilyNames(&familyNames); |
| 1500 hr = fDWriteFont->GetFaceNames(&faceNames); | 1501 hr = fDWriteFont->GetFaceNames(&faceNames); |
| 1501 | 1502 |
| 1502 UINT32 familyNameLength; | 1503 UINT32 familyNameLength; |
| 1503 hr = familyNames->GetStringLength(0, &familyNameLength); | 1504 hr = familyNames->GetStringLength(0, &familyNameLength); |
| 1504 | 1505 |
| 1505 UINT32 faceNameLength; | 1506 UINT32 faceNameLength; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1593 if (GetCharABCWidths(hdc, stem_chars[i], stem_chars[i], &abcWidths)) { | 1594 if (GetCharABCWidths(hdc, stem_chars[i], stem_chars[i], &abcWidths)) { |
| 1594 int16_t width = abcWidths.abcB; | 1595 int16_t width = abcWidths.abcB; |
| 1595 if (width > 0 && width < min_width) { | 1596 if (width > 0 && width < min_width) { |
| 1596 min_width = width; | 1597 min_width = width; |
| 1597 info->fStemV = min_width; | 1598 info->fStemV = min_width; |
| 1598 } | 1599 } |
| 1599 } | 1600 } |
| 1600 } | 1601 } |
| 1601 */ | 1602 */ |
| 1602 | 1603 |
| 1603 if (perGlyphInfo & SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo) { | 1604 // If Restricted, the font may not be embedded in a document. |
| 1605 // If not Restricted, the font can be embedded. |
| 1606 // If PreviewPrint, the embedding is read-only. |
| 1607 if (os2Table->version.v0.fsType.field.Restricted) { |
| 1608 info->fType = SkAdvancedTypefaceMetrics::kNotEmbeddable_Font; |
| 1609 } else if (perGlyphInfo & SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo)
{ |
| 1604 if (fixedWidth) { | 1610 if (fixedWidth) { |
| 1605 appendRange(&info->fGlyphWidths, 0); | 1611 appendRange(&info->fGlyphWidths, 0); |
| 1606 int16_t advance; | 1612 int16_t advance; |
| 1607 getWidthAdvance(fDWriteFontFace.get(), 1, &advance); | 1613 getWidthAdvance(fDWriteFontFace.get(), 1, &advance); |
| 1608 info->fGlyphWidths->fAdvance.append(1, &advance); | 1614 info->fGlyphWidths->fAdvance.append(1, &advance); |
| 1609 finishRange(info->fGlyphWidths.get(), 0, | 1615 finishRange(info->fGlyphWidths.get(), 0, |
| 1610 SkAdvancedTypefaceMetrics::WidthRange::kDefault); | 1616 SkAdvancedTypefaceMetrics::WidthRange::kDefault); |
| 1611 } else { | 1617 } else { |
| 1612 info->fGlyphWidths.reset( | 1618 info->fGlyphWidths.reset( |
| 1613 getAdvanceData(fDWriteFontFace.get(), | 1619 getAdvanceData(fDWriteFontFace.get(), |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1897 SK_TRACEHR(hr, "Could not get GetUserDefaultLocaleName."); | 1903 SK_TRACEHR(hr, "Could not get GetUserDefaultLocaleName."); |
| 1898 } else { | 1904 } else { |
| 1899 localeNameLen = getUserDefaultLocaleNameProc(localeNameStorage, LOCALE_N
AME_MAX_LENGTH); | 1905 localeNameLen = getUserDefaultLocaleNameProc(localeNameStorage, LOCALE_N
AME_MAX_LENGTH); |
| 1900 if (localeNameLen) { | 1906 if (localeNameLen) { |
| 1901 localeName = localeNameStorage; | 1907 localeName = localeNameStorage; |
| 1902 }; | 1908 }; |
| 1903 } | 1909 } |
| 1904 | 1910 |
| 1905 return SkNEW_ARGS(SkFontMgr_DirectWrite, (sysFontCollection.get(), localeNam
e, localeNameLen)); | 1911 return SkNEW_ARGS(SkFontMgr_DirectWrite, (sysFontCollection.get(), localeNam
e, localeNameLen)); |
| 1906 } | 1912 } |
| OLD | NEW |