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

Side by Side Diff: core/src/fxge/ge/fx_ge_fontmap.cpp

Issue 1410043003: Declare PDF_GetStandardFontName() in the header. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 2 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
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "../../../include/fxge/fx_ge.h" 9 #include "../../../include/fxge/fx_ge.h"
10 #include "../../../include/fxge/fx_freetype.h" 10 #include "../../../include/fxge/fx_freetype.h"
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 "Helvetica-Bold", 172 "Helvetica-Bold",
173 "Helvetica-BoldOblique", 173 "Helvetica-BoldOblique",
174 "Helvetica-Oblique", 174 "Helvetica-Oblique",
175 "Times-Roman", 175 "Times-Roman",
176 "Times-Bold", 176 "Times-Bold",
177 "Times-BoldItalic", 177 "Times-BoldItalic",
178 "Times-Italic", 178 "Times-Italic",
179 "Symbol", 179 "Symbol",
180 "ZapfDingbats", 180 "ZapfDingbats",
181 }; 181 };
182 const struct _AltFontName { 182 const struct AltFontName {
183 const FX_CHAR* m_pName; 183 const FX_CHAR* m_pName;
184 int m_Index; 184 int m_Index;
185 } g_AltFontNames[] = { 185 } g_AltFontNames[] = {
186 {"Arial", 4}, 186 {"Arial", 4},
187 {"Arial,Bold", 5}, 187 {"Arial,Bold", 5},
188 {"Arial,BoldItalic", 6}, 188 {"Arial,BoldItalic", 6},
189 {"Arial,Italic", 7}, 189 {"Arial,Italic", 7},
190 {"Arial-Bold", 5}, 190 {"Arial-Bold", 5},
191 {"Arial-BoldItalic", 6}, 191 {"Arial-BoldItalic", 6},
192 {"Arial-BoldItalicMT", 6}, 192 {"Arial-BoldItalicMT", 6},
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 {"TimesNewRomanPS-Italic", 11}, 268 {"TimesNewRomanPS-Italic", 11},
269 {"TimesNewRomanPS-ItalicMT", 11}, 269 {"TimesNewRomanPS-ItalicMT", 11},
270 {"TimesNewRomanPSMT", 8}, 270 {"TimesNewRomanPSMT", 8},
271 {"TimesNewRomanPSMT,Bold", 9}, 271 {"TimesNewRomanPSMT,Bold", 9},
272 {"TimesNewRomanPSMT,BoldItalic", 10}, 272 {"TimesNewRomanPSMT,BoldItalic", 10},
273 {"TimesNewRomanPSMT,Italic", 11}, 273 {"TimesNewRomanPSMT,Italic", 11},
274 {"ZapfDingbats", 13}, 274 {"ZapfDingbats", 13},
275 }; 275 };
276 extern "C" { 276 extern "C" {
277 static int compareString(const void* key, const void* element) { 277 static int compareString(const void* key, const void* element) {
278 return FXSYS_stricmp((const FX_CHAR*)key, ((_AltFontName*)element)->m_pName); 278 return FXSYS_stricmp((const FX_CHAR*)key, ((AltFontName*)element)->m_pName);
279 } 279 }
280 } 280 }
281 int _PDF_GetStandardFontName(CFX_ByteString& name) { 281
282 _AltFontName* found =
283 (_AltFontName*)FXSYS_bsearch(name.c_str(), g_AltFontNames,
284 sizeof g_AltFontNames / sizeof(_AltFontName),
285 sizeof(_AltFontName), compareString);
286 if (found == NULL) {
287 return -1;
288 }
289 name = g_Base14FontNames[found->m_Index];
290 return found->m_Index;
291 }
292 int GetTTCIndex(const uint8_t* pFontData, 282 int GetTTCIndex(const uint8_t* pFontData,
293 FX_DWORD ttc_size, 283 FX_DWORD ttc_size,
294 FX_DWORD font_offset) { 284 FX_DWORD font_offset) {
295 int face_index = 0; 285 int face_index = 0;
296 const uint8_t* p = pFontData + 8; 286 const uint8_t* p = pFontData + 8;
297 FX_DWORD nfont = GET_TT_LONG(p); 287 FX_DWORD nfont = GET_TT_LONG(p);
298 FX_DWORD index; 288 FX_DWORD index;
299 for (index = 0; index < nfont; index++) { 289 for (index = 0; index < nfont; index++) {
300 p = pFontData + 12 + index * 4; 290 p = pFontData + 12 + index * 4;
301 if (GET_TT_LONG(p) == font_offset) { 291 if (GET_TT_LONG(p) == font_offset) {
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 weight = FXFONT_FW_NORMAL; 829 weight = FXFONT_FW_NORMAL;
840 italic_angle = 0; 830 italic_angle = 0;
841 } 831 }
842 CFX_ByteString SubstName = name; 832 CFX_ByteString SubstName = name;
843 SubstName.Remove(0x20); 833 SubstName.Remove(0x20);
844 if (bTrueType) { 834 if (bTrueType) {
845 if (name[0] == '@') { 835 if (name[0] == '@') {
846 SubstName = name.Mid(1); 836 SubstName = name.Mid(1);
847 } 837 }
848 } 838 }
849 _PDF_GetStandardFontName(SubstName); 839 PDF_GetStandardFontName(&SubstName);
850 if (SubstName == FX_BSTRC("Symbol") && !bTrueType) { 840 if (SubstName == FX_BSTRC("Symbol") && !bTrueType) {
851 pSubstFont->m_Family = "Chrome Symbol"; 841 pSubstFont->m_Family = "Chrome Symbol";
852 pSubstFont->m_Charset = FXFONT_SYMBOL_CHARSET; 842 pSubstFont->m_Charset = FXFONT_SYMBOL_CHARSET;
853 pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; 843 pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD;
854 if (m_FoxitFaces[12]) { 844 if (m_FoxitFaces[12]) {
855 return m_FoxitFaces[12]; 845 return m_FoxitFaces[12];
856 } 846 }
857 const uint8_t* pFontData = NULL; 847 const uint8_t* pFontData = NULL;
858 FX_DWORD size = 0; 848 FX_DWORD size = 0;
859 m_pFontMgr->GetStandardFont(pFontData, size, 12); 849 m_pFontMgr->GetStandardFont(pFontData, size, 12);
(...skipping 13 matching lines...) Expand all
873 m_FoxitFaces[13] = m_pFontMgr->GetFixedFace(pFontData, size, 0); 863 m_FoxitFaces[13] = m_pFontMgr->GetFixedFace(pFontData, size, 0);
874 return m_FoxitFaces[13]; 864 return m_FoxitFaces[13];
875 } 865 }
876 int iBaseFont = 0; 866 int iBaseFont = 0;
877 CFX_ByteString family, style; 867 CFX_ByteString family, style;
878 FX_BOOL bHasComma = FALSE; 868 FX_BOOL bHasComma = FALSE;
879 FX_BOOL bHasHypen = FALSE; 869 FX_BOOL bHasHypen = FALSE;
880 int find = SubstName.Find(FX_BSTRC(","), 0); 870 int find = SubstName.Find(FX_BSTRC(","), 0);
881 if (find >= 0) { 871 if (find >= 0) {
882 family = SubstName.Left(find); 872 family = SubstName.Left(find);
883 _PDF_GetStandardFontName(family); 873 PDF_GetStandardFontName(&family);
884 style = SubstName.Mid(find + 1); 874 style = SubstName.Mid(find + 1);
885 bHasComma = TRUE; 875 bHasComma = TRUE;
886 } else { 876 } else {
887 family = SubstName; 877 family = SubstName;
888 } 878 }
889 for (; iBaseFont < 12; iBaseFont++) 879 for (; iBaseFont < 12; iBaseFont++)
890 if (family == CFX_ByteStringC(g_Base14FontNames[iBaseFont])) { 880 if (family == CFX_ByteStringC(g_Base14FontNames[iBaseFont])) {
891 break; 881 break;
892 } 882 }
893 int PitchFamily = 0; 883 int PitchFamily = 0;
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
1563 if (hFont == NULL) { 1553 if (hFont == NULL) {
1564 return FALSE; 1554 return FALSE;
1565 } 1555 }
1566 CFX_FontFaceInfo* pFont = (CFX_FontFaceInfo*)hFont; 1556 CFX_FontFaceInfo* pFont = (CFX_FontFaceInfo*)hFont;
1567 name = pFont->m_FaceName; 1557 name = pFont->m_FaceName;
1568 return TRUE; 1558 return TRUE;
1569 } 1559 }
1570 FX_BOOL CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset) { 1560 FX_BOOL CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset) {
1571 return FALSE; 1561 return FALSE;
1572 } 1562 }
1563
1564 int PDF_GetStandardFontName(CFX_ByteString* name) {
1565 AltFontName* found = static_cast<AltFontName*>(
1566 FXSYS_bsearch(name->c_str(), g_AltFontNames, FX_ArraySize(g_AltFontNames),
1567 sizeof(AltFontName), compareString));
1568 if (!found)
1569 return -1;
1570
1571 *name = g_Base14FontNames[found->m_Index];
1572 return found->m_Index;
1573 }
OLDNEW
« core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp ('K') | « core/src/fpdfapi/fpdf_font/fpdf_font.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698