| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 847 weight = FXFONT_FW_NORMAL; | 837 weight = FXFONT_FW_NORMAL; |
| 848 italic_angle = 0; | 838 italic_angle = 0; |
| 849 } | 839 } |
| 850 CFX_ByteString SubstName = name; | 840 CFX_ByteString SubstName = name; |
| 851 SubstName.Remove(0x20); | 841 SubstName.Remove(0x20); |
| 852 if (bTrueType) { | 842 if (bTrueType) { |
| 853 if (name[0] == '@') { | 843 if (name[0] == '@') { |
| 854 SubstName = name.Mid(1); | 844 SubstName = name.Mid(1); |
| 855 } | 845 } |
| 856 } | 846 } |
| 857 _PDF_GetStandardFontName(SubstName); | 847 PDF_GetStandardFontName(&SubstName); |
| 858 if (SubstName == FX_BSTRC("Symbol") && !bTrueType) { | 848 if (SubstName == FX_BSTRC("Symbol") && !bTrueType) { |
| 859 pSubstFont->m_Family = "Chrome Symbol"; | 849 pSubstFont->m_Family = "Chrome Symbol"; |
| 860 pSubstFont->m_Charset = FXFONT_SYMBOL_CHARSET; | 850 pSubstFont->m_Charset = FXFONT_SYMBOL_CHARSET; |
| 861 pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; | 851 pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; |
| 862 if (m_FoxitFaces[12]) { | 852 if (m_FoxitFaces[12]) { |
| 863 return m_FoxitFaces[12]; | 853 return m_FoxitFaces[12]; |
| 864 } | 854 } |
| 865 const uint8_t* pFontData = NULL; | 855 const uint8_t* pFontData = NULL; |
| 866 FX_DWORD size = 0; | 856 FX_DWORD size = 0; |
| 867 m_pFontMgr->GetStandardFont(pFontData, size, 12); | 857 m_pFontMgr->GetStandardFont(pFontData, size, 12); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 881 m_FoxitFaces[13] = m_pFontMgr->GetFixedFace(pFontData, size, 0); | 871 m_FoxitFaces[13] = m_pFontMgr->GetFixedFace(pFontData, size, 0); |
| 882 return m_FoxitFaces[13]; | 872 return m_FoxitFaces[13]; |
| 883 } | 873 } |
| 884 int iBaseFont = 0; | 874 int iBaseFont = 0; |
| 885 CFX_ByteString family, style; | 875 CFX_ByteString family, style; |
| 886 FX_BOOL bHasComma = FALSE; | 876 FX_BOOL bHasComma = FALSE; |
| 887 FX_BOOL bHasHypen = FALSE; | 877 FX_BOOL bHasHypen = FALSE; |
| 888 int find = SubstName.Find(FX_BSTRC(","), 0); | 878 int find = SubstName.Find(FX_BSTRC(","), 0); |
| 889 if (find >= 0) { | 879 if (find >= 0) { |
| 890 family = SubstName.Left(find); | 880 family = SubstName.Left(find); |
| 891 _PDF_GetStandardFontName(family); | 881 PDF_GetStandardFontName(&family); |
| 892 style = SubstName.Mid(find + 1); | 882 style = SubstName.Mid(find + 1); |
| 893 bHasComma = TRUE; | 883 bHasComma = TRUE; |
| 894 } else { | 884 } else { |
| 895 family = SubstName; | 885 family = SubstName; |
| 896 } | 886 } |
| 897 for (; iBaseFont < 12; iBaseFont++) | 887 for (; iBaseFont < 12; iBaseFont++) |
| 898 if (family == CFX_ByteStringC(g_Base14FontNames[iBaseFont])) { | 888 if (family == CFX_ByteStringC(g_Base14FontNames[iBaseFont])) { |
| 899 break; | 889 break; |
| 900 } | 890 } |
| 901 int PitchFamily = 0; | 891 int PitchFamily = 0; |
| (...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1662 if (hFont == NULL) { | 1652 if (hFont == NULL) { |
| 1663 return FALSE; | 1653 return FALSE; |
| 1664 } | 1654 } |
| 1665 CFX_FontFaceInfo* pFont = (CFX_FontFaceInfo*)hFont; | 1655 CFX_FontFaceInfo* pFont = (CFX_FontFaceInfo*)hFont; |
| 1666 name = pFont->m_FaceName; | 1656 name = pFont->m_FaceName; |
| 1667 return TRUE; | 1657 return TRUE; |
| 1668 } | 1658 } |
| 1669 FX_BOOL CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset) { | 1659 FX_BOOL CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset) { |
| 1670 return FALSE; | 1660 return FALSE; |
| 1671 } | 1661 } |
| 1662 |
| 1663 int PDF_GetStandardFontName(CFX_ByteString* name) { |
| 1664 AltFontName* found = static_cast<AltFontName*>( |
| 1665 FXSYS_bsearch(name->c_str(), g_AltFontNames, FX_ArraySize(g_AltFontNames), |
| 1666 sizeof(AltFontName), compareString)); |
| 1667 if (!found) |
| 1668 return -1; |
| 1669 |
| 1670 *name = g_Base14FontNames[found->m_Index]; |
| 1671 return found->m_Index; |
| 1672 } |
| OLD | NEW |