OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "SkAdvancedTypefaceMetrics.h" | 9 #include "SkAdvancedTypefaceMetrics.h" |
10 #include "SkBase64.h" | 10 #include "SkBase64.h" |
(...skipping 1849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1860 lf.lfHeight = -SkToS32(otm.otmEMSquare); | 1860 lf.lfHeight = -SkToS32(otm.otmEMSquare); |
1861 designFont = CreateFontIndirect(&lf); | 1861 designFont = CreateFontIndirect(&lf); |
1862 SelectObject(hdc, designFont); | 1862 SelectObject(hdc, designFont); |
1863 if (!GetOutlineTextMetrics(hdc, sizeof(otm), &otm)) { | 1863 if (!GetOutlineTextMetrics(hdc, sizeof(otm), &otm)) { |
1864 goto Error; | 1864 goto Error; |
1865 } | 1865 } |
1866 glyphCount = calculateGlyphCount(hdc, fLogFont); | 1866 glyphCount = calculateGlyphCount(hdc, fLogFont); |
1867 | 1867 |
1868 info = new SkAdvancedTypefaceMetrics; | 1868 info = new SkAdvancedTypefaceMetrics; |
1869 info->fEmSize = otm.otmEMSquare; | 1869 info->fEmSize = otm.otmEMSquare; |
1870 info->fMultiMaster = false; | |
1871 info->fLastGlyphID = SkToU16(glyphCount - 1); | 1870 info->fLastGlyphID = SkToU16(glyphCount - 1); |
1872 info->fStyle = 0; | 1871 info->fStyle = 0; |
1873 tchar_to_skstring(lf.lfFaceName, &info->fFontName); | 1872 tchar_to_skstring(lf.lfFaceName, &info->fFontName); |
| 1873 info->fFlags = SkAdvancedTypefaceMetrics::kEmpty_FontFlag; |
| 1874 // If bit 1 is set, the font may not be embedded in a document. |
| 1875 // If bit 1 is clear, the font can be embedded. |
| 1876 // If bit 2 is set, the embedding is read-only. |
| 1877 if (otm.otmfsType & 0x1) { |
| 1878 info->fFlags = SkTBitOr<SkAdvancedTypefaceMetrics::FontFlags>( |
| 1879 info->fFlags, |
| 1880 SkAdvancedTypefaceMetrics::kNotEmbeddable_FontFlag); |
| 1881 } |
1874 | 1882 |
1875 if (perGlyphInfo & SkAdvancedTypefaceMetrics::kToUnicode_PerGlyphInfo) { | 1883 if (perGlyphInfo & SkAdvancedTypefaceMetrics::kToUnicode_PerGlyphInfo) { |
1876 populate_glyph_to_unicode(hdc, glyphCount, &(info->fGlyphToUnicode)); | 1884 populate_glyph_to_unicode(hdc, glyphCount, &(info->fGlyphToUnicode)); |
1877 } | 1885 } |
1878 | 1886 |
1879 if (glyphCount > 0 && | 1887 if (glyphCount > 0 && |
1880 (otm.otmTextMetrics.tmPitchAndFamily & TMPF_TRUETYPE)) { | 1888 (otm.otmTextMetrics.tmPitchAndFamily & TMPF_TRUETYPE)) { |
1881 info->fType = SkAdvancedTypefaceMetrics::kTrueType_Font; | 1889 info->fType = SkAdvancedTypefaceMetrics::kTrueType_Font; |
1882 } else { | 1890 } else { |
1883 info->fType = SkAdvancedTypefaceMetrics::kOther_Font; | 1891 info->fType = SkAdvancedTypefaceMetrics::kOther_Font; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1924 ABC abcWidths; | 1932 ABC abcWidths; |
1925 if (GetCharABCWidths(hdc, stem_chars[i], stem_chars[i], &abcWidths)) { | 1933 if (GetCharABCWidths(hdc, stem_chars[i], stem_chars[i], &abcWidths)) { |
1926 int16_t width = abcWidths.abcB; | 1934 int16_t width = abcWidths.abcB; |
1927 if (width > 0 && width < min_width) { | 1935 if (width > 0 && width < min_width) { |
1928 min_width = width; | 1936 min_width = width; |
1929 info->fStemV = min_width; | 1937 info->fStemV = min_width; |
1930 } | 1938 } |
1931 } | 1939 } |
1932 } | 1940 } |
1933 | 1941 |
1934 // If bit 1 is set, the font may not be embedded in a document. | 1942 if (perGlyphInfo & SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo) { |
1935 // If bit 1 is clear, the font can be embedded. | |
1936 // If bit 2 is set, the embedding is read-only. | |
1937 if (otm.otmfsType & 0x1) { | |
1938 info->fType = SkAdvancedTypefaceMetrics::kNotEmbeddable_Font; | |
1939 } else if (perGlyphInfo & | |
1940 SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo) { | |
1941 if (info->fStyle & SkAdvancedTypefaceMetrics::kFixedPitch_Style) { | 1943 if (info->fStyle & SkAdvancedTypefaceMetrics::kFixedPitch_Style) { |
1942 appendRange(&info->fGlyphWidths, 0); | 1944 appendRange(&info->fGlyphWidths, 0); |
1943 info->fGlyphWidths->fAdvance.append(1, &min_width); | 1945 info->fGlyphWidths->fAdvance.append(1, &min_width); |
1944 finishRange(info->fGlyphWidths.get(), 0, | 1946 finishRange(info->fGlyphWidths.get(), 0, |
1945 SkAdvancedTypefaceMetrics::WidthRange::kDefault); | 1947 SkAdvancedTypefaceMetrics::WidthRange::kDefault); |
1946 } else { | 1948 } else { |
1947 info->fGlyphWidths.reset( | 1949 info->fGlyphWidths.reset( |
1948 getAdvanceData(hdc, | 1950 getAdvanceData(hdc, |
1949 glyphCount, | 1951 glyphCount, |
1950 glyphIDs, | 1952 glyphIDs, |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2616 | 2618 |
2617 private: | 2619 private: |
2618 SkTDArray<ENUMLOGFONTEX> fLogFontArray; | 2620 SkTDArray<ENUMLOGFONTEX> fLogFontArray; |
2619 }; | 2621 }; |
2620 | 2622 |
2621 /////////////////////////////////////////////////////////////////////////////// | 2623 /////////////////////////////////////////////////////////////////////////////// |
2622 | 2624 |
2623 SkFontMgr* SkFontMgr_New_GDI() { | 2625 SkFontMgr* SkFontMgr_New_GDI() { |
2624 return SkNEW(SkFontMgrGDI); | 2626 return SkNEW(SkFontMgrGDI); |
2625 } | 2627 } |
OLD | NEW |