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

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

Issue 107863002: [PDF] Fix font embedding restrictions. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix Mac Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « src/ports/SkFontHost_mac.cpp ('k') | src/ports/SkFontHost_win_dw.cpp » ('j') | 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 /* 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 1833 matching lines...) Expand 10 before | Expand all | Expand 10 after
1844 lf.lfHeight = -SkToS32(otm.otmEMSquare); 1844 lf.lfHeight = -SkToS32(otm.otmEMSquare);
1845 designFont = CreateFontIndirect(&lf); 1845 designFont = CreateFontIndirect(&lf);
1846 SelectObject(hdc, designFont); 1846 SelectObject(hdc, designFont);
1847 if (!GetOutlineTextMetrics(hdc, sizeof(otm), &otm)) { 1847 if (!GetOutlineTextMetrics(hdc, sizeof(otm), &otm)) {
1848 goto Error; 1848 goto Error;
1849 } 1849 }
1850 glyphCount = calculateGlyphCount(hdc, fLogFont); 1850 glyphCount = calculateGlyphCount(hdc, fLogFont);
1851 1851
1852 info = new SkAdvancedTypefaceMetrics; 1852 info = new SkAdvancedTypefaceMetrics;
1853 info->fEmSize = otm.otmEMSquare; 1853 info->fEmSize = otm.otmEMSquare;
1854 info->fMultiMaster = false;
1855 info->fLastGlyphID = SkToU16(glyphCount - 1); 1854 info->fLastGlyphID = SkToU16(glyphCount - 1);
1856 info->fStyle = 0; 1855 info->fStyle = 0;
1857 tchar_to_skstring(lf.lfFaceName, &info->fFontName); 1856 tchar_to_skstring(lf.lfFaceName, &info->fFontName);
1857 info->fFlags = SkAdvancedTypefaceMetrics::kEmpty_FontFlag;
1858 // If bit 1 is set, the font may not be embedded in a document.
1859 // If bit 1 is clear, the font can be embedded.
1860 // If bit 2 is set, the embedding is read-only.
1861 if (otm.otmfsType & 0x1) {
1862 info->fFlags = SkTBitOr<SkAdvancedTypefaceMetrics::FontFlags>(
1863 info->fFlags,
1864 SkAdvancedTypefaceMetrics::kNotEmbeddable_FontFlag)
bungeman-skia 2013/12/10 16:43:50 Looks like there's a missing ';' here.
1865 }
1858 1866
1859 if (perGlyphInfo & SkAdvancedTypefaceMetrics::kToUnicode_PerGlyphInfo) { 1867 if (perGlyphInfo & SkAdvancedTypefaceMetrics::kToUnicode_PerGlyphInfo) {
1860 populate_glyph_to_unicode(hdc, glyphCount, &(info->fGlyphToUnicode)); 1868 populate_glyph_to_unicode(hdc, glyphCount, &(info->fGlyphToUnicode));
1861 } 1869 }
1862 1870
1863 if (glyphCount > 0 && 1871 if (glyphCount > 0 &&
1864 (otm.otmTextMetrics.tmPitchAndFamily & TMPF_TRUETYPE)) { 1872 (otm.otmTextMetrics.tmPitchAndFamily & TMPF_TRUETYPE)) {
1865 info->fType = SkAdvancedTypefaceMetrics::kTrueType_Font; 1873 info->fType = SkAdvancedTypefaceMetrics::kTrueType_Font;
1866 } else { 1874 } else {
1867 info->fType = SkAdvancedTypefaceMetrics::kOther_Font; 1875 info->fType = SkAdvancedTypefaceMetrics::kOther_Font;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1908 ABC abcWidths; 1916 ABC abcWidths;
1909 if (GetCharABCWidths(hdc, stem_chars[i], stem_chars[i], &abcWidths)) { 1917 if (GetCharABCWidths(hdc, stem_chars[i], stem_chars[i], &abcWidths)) {
1910 int16_t width = abcWidths.abcB; 1918 int16_t width = abcWidths.abcB;
1911 if (width > 0 && width < min_width) { 1919 if (width > 0 && width < min_width) {
1912 min_width = width; 1920 min_width = width;
1913 info->fStemV = min_width; 1921 info->fStemV = min_width;
1914 } 1922 }
1915 } 1923 }
1916 } 1924 }
1917 1925
1918 // If bit 1 is set, the font may not be embedded in a document. 1926 if (perGlyphInfo & SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo) {
1919 // If bit 1 is clear, the font can be embedded.
1920 // If bit 2 is set, the embedding is read-only.
1921 if (otm.otmfsType & 0x1) {
1922 info->fType = SkAdvancedTypefaceMetrics::kNotEmbeddable_Font;
1923 } else if (perGlyphInfo &
1924 SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo) {
1925 if (info->fStyle & SkAdvancedTypefaceMetrics::kFixedPitch_Style) { 1927 if (info->fStyle & SkAdvancedTypefaceMetrics::kFixedPitch_Style) {
1926 appendRange(&info->fGlyphWidths, 0); 1928 appendRange(&info->fGlyphWidths, 0);
1927 info->fGlyphWidths->fAdvance.append(1, &min_width); 1929 info->fGlyphWidths->fAdvance.append(1, &min_width);
1928 finishRange(info->fGlyphWidths.get(), 0, 1930 finishRange(info->fGlyphWidths.get(), 0,
1929 SkAdvancedTypefaceMetrics::WidthRange::kDefault); 1931 SkAdvancedTypefaceMetrics::WidthRange::kDefault);
1930 } else { 1932 } else {
1931 info->fGlyphWidths.reset( 1933 info->fGlyphWidths.reset(
1932 getAdvanceData(hdc, 1934 getAdvanceData(hdc,
1933 glyphCount, 1935 glyphCount,
1934 glyphIDs, 1936 glyphIDs,
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
2600 2602
2601 private: 2603 private:
2602 SkTDArray<ENUMLOGFONTEX> fLogFontArray; 2604 SkTDArray<ENUMLOGFONTEX> fLogFontArray;
2603 }; 2605 };
2604 2606
2605 /////////////////////////////////////////////////////////////////////////////// 2607 ///////////////////////////////////////////////////////////////////////////////
2606 2608
2607 SkFontMgr* SkFontMgr_New_GDI() { 2609 SkFontMgr* SkFontMgr_New_GDI() {
2608 return SkNEW(SkFontMgrGDI); 2610 return SkNEW(SkFontMgrGDI);
2609 } 2611 }
OLDNEW
« no previous file with comments | « src/ports/SkFontHost_mac.cpp ('k') | src/ports/SkFontHost_win_dw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698