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

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

Issue 2083943003: Use FXFONT defines in place of integers. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: nits Created 4 years, 6 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
« no previous file with comments | « core/fxge/ge/fx_ge_font.cpp ('k') | core/fxge/ge/fx_ge_text.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 // 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 <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 uint8_t GetCharsetFromCodePage(uint16_t codepage) { 286 uint8_t GetCharsetFromCodePage(uint16_t codepage) {
287 const CODEPAGE_MAP* pEnd = 287 const CODEPAGE_MAP* pEnd =
288 g_Codepage2CharsetTable + FX_ArraySize(g_Codepage2CharsetTable); 288 g_Codepage2CharsetTable + FX_ArraySize(g_Codepage2CharsetTable);
289 const CODEPAGE_MAP* pCharmap = 289 const CODEPAGE_MAP* pCharmap =
290 std::lower_bound(g_Codepage2CharsetTable, pEnd, codepage, 290 std::lower_bound(g_Codepage2CharsetTable, pEnd, codepage,
291 [](const CODEPAGE_MAP& charset, uint16_t page) { 291 [](const CODEPAGE_MAP& charset, uint16_t page) {
292 return charset.codepage < page; 292 return charset.codepage < page;
293 }); 293 });
294 if (pCharmap < pEnd && codepage == pCharmap->codepage) 294 if (pCharmap < pEnd && codepage == pCharmap->codepage)
295 return pCharmap->charset; 295 return pCharmap->charset;
296 return 1; 296 return FXFONT_DEFAULT_CHARSET;
297 } 297 }
298 298
299 CFX_ByteString GetFontFamily(CFX_ByteString fontName, int nStyle) { 299 CFX_ByteString GetFontFamily(CFX_ByteString fontName, int nStyle) {
300 if (fontName.Find("Script") >= 0) { 300 if (fontName.Find("Script") >= 0) {
301 if ((nStyle & FX_FONT_STYLE_Bold) == FX_FONT_STYLE_Bold) { 301 if ((nStyle & FX_FONT_STYLE_Bold) == FX_FONT_STYLE_Bold) {
302 fontName = "ScriptMTBold"; 302 fontName = "ScriptMTBold";
303 } else if (fontName.Find("Palace") >= 0) { 303 } else if (fontName.Find("Palace") >= 0) {
304 fontName = "PalaceScriptMT"; 304 fontName = "PalaceScriptMT";
305 } else if (fontName.Find("French") >= 0) { 305 } else if (fontName.Find("French") >= 0) {
306 fontName = "FrenchScriptMT"; 306 fontName = "FrenchScriptMT";
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 !!(pitch_family & FXFONT_FF_FIXEDPITCH)) { 405 !!(pitch_family & FXFONT_FF_FIXEDPITCH)) {
406 iSimilarValue += 8; 406 iSimilarValue += 8;
407 } 407 }
408 return iSimilarValue; 408 return iSimilarValue;
409 } 409 }
410 410
411 } // namespace 411 } // namespace
412 412
413 CFX_SubstFont::CFX_SubstFont() { 413 CFX_SubstFont::CFX_SubstFont() {
414 m_ExtHandle = nullptr; 414 m_ExtHandle = nullptr;
415 m_Charset = 0; 415 m_Charset = FXFONT_ANSI_CHARSET;
416 m_SubstFlags = 0; 416 m_SubstFlags = 0;
417 m_Weight = 0; 417 m_Weight = 0;
418 m_ItalicAngle = 0; 418 m_ItalicAngle = 0;
419 m_bSubstOfCJK = FALSE; 419 m_bSubstCJK = false;
420 m_WeightCJK = 0; 420 m_WeightCJK = 0;
421 m_bItlicCJK = FALSE; 421 m_bItalicCJK = false;
422 } 422 }
423
423 CTTFontDesc::~CTTFontDesc() { 424 CTTFontDesc::~CTTFontDesc() {
424 if (m_Type == 1) { 425 if (m_Type == 1) {
425 if (m_SingleFace.m_pFace) { 426 if (m_SingleFace.m_pFace) {
426 FXFT_Done_Face(m_SingleFace.m_pFace); 427 FXFT_Done_Face(m_SingleFace.m_pFace);
427 } 428 }
428 } else if (m_Type == 2) { 429 } else if (m_Type == 2) {
429 for (int i = 0; i < 16; i++) 430 for (int i = 0; i < 16; i++)
430 if (m_TTCFace.m_pFaces[i]) { 431 if (m_TTCFace.m_pFaces[i]) {
431 FXFT_Done_Face(m_TTCFace.m_pFaces[i]); 432 FXFT_Done_Face(m_TTCFace.m_pFaces[i]);
432 } 433 }
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 if (!bCJK) { 1051 if (!bCJK) {
1051 if (!CheckSupportThirdPartFont(family, PitchFamily)) { 1052 if (!CheckSupportThirdPartFont(family, PitchFamily)) {
1052 if (italic_angle != 0) { 1053 if (italic_angle != 0) {
1053 bItalic = TRUE; 1054 bItalic = TRUE;
1054 } else { 1055 } else {
1055 bItalic = FALSE; 1056 bItalic = FALSE;
1056 } 1057 }
1057 weight = old_weight; 1058 weight = old_weight;
1058 } 1059 }
1059 } else { 1060 } else {
1060 pSubstFont->m_bSubstOfCJK = TRUE; 1061 pSubstFont->m_bSubstCJK = true;
1061 if (nStyle) { 1062 if (nStyle) {
1062 pSubstFont->m_WeightCJK = weight; 1063 pSubstFont->m_WeightCJK = weight;
1063 } else { 1064 } else {
1064 pSubstFont->m_WeightCJK = FXFONT_FW_NORMAL; 1065 pSubstFont->m_WeightCJK = FXFONT_FW_NORMAL;
1065 } 1066 }
1066 if (nStyle & FX_FONT_STYLE_Italic) { 1067 if (nStyle & FX_FONT_STYLE_Italic) {
1067 pSubstFont->m_bItlicCJK = TRUE; 1068 pSubstFont->m_bItalicCJK = true;
1068 } 1069 }
1069 } 1070 }
1070 } else { 1071 } else {
1071 italic_angle = 0; 1072 italic_angle = 0;
1072 weight = 1073 weight =
1073 nStyle & FX_FONT_STYLE_BoldBold 1074 nStyle & FX_FONT_STYLE_BoldBold
1074 ? 900 1075 ? 900
1075 : (nStyle & FX_FONT_STYLE_Bold ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL); 1076 : (nStyle & FX_FONT_STYLE_Bold ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL);
1076 } 1077 }
1077 if (!match.IsEmpty() || iBaseFont < 12) { 1078 if (!match.IsEmpty() || iBaseFont < 12) {
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
1654 int PDF_GetStandardFontName(CFX_ByteString* name) { 1655 int PDF_GetStandardFontName(CFX_ByteString* name) {
1655 AltFontName* found = static_cast<AltFontName*>( 1656 AltFontName* found = static_cast<AltFontName*>(
1656 FXSYS_bsearch(name->c_str(), g_AltFontNames, FX_ArraySize(g_AltFontNames), 1657 FXSYS_bsearch(name->c_str(), g_AltFontNames, FX_ArraySize(g_AltFontNames),
1657 sizeof(AltFontName), CompareString)); 1658 sizeof(AltFontName), CompareString));
1658 if (!found) 1659 if (!found)
1659 return -1; 1660 return -1;
1660 1661
1661 *name = g_Base14FontNames[found->m_Index]; 1662 *name = g_Base14FontNames[found->m_Index];
1662 return found->m_Index; 1663 return found->m_Index;
1663 } 1664 }
OLDNEW
« no previous file with comments | « core/fxge/ge/fx_ge_font.cpp ('k') | core/fxge/ge/fx_ge_text.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698