Index: core/fxge/ge/cfx_fontmapper.cpp |
diff --git a/core/fxge/ge/cfx_fontmapper.cpp b/core/fxge/ge/cfx_fontmapper.cpp |
index 86dc2389d607a8ee77e96cd91478c94c70545c6c..58c10a2950edc12c4dda8957a604656d035610b4 100644 |
--- a/core/fxge/ge/cfx_fontmapper.cpp |
+++ b/core/fxge/ge/cfx_fontmapper.cpp |
@@ -23,9 +23,9 @@ |
namespace { |
-const int kExternalFontIndex = 12; |
+const int kNumStandardFonts = 14; |
-const FX_CHAR* const g_Base14FontNames[14] = { |
+const FX_CHAR* const g_Base14FontNames[kNumStandardFonts] = { |
"Courier", |
"Courier-Bold", |
"Courier-BoldOblique", |
@@ -387,7 +387,7 @@ FXFT_Face CFX_FontMapper::UseInternalSubst(CFX_SubstFont* pSubstFont, |
int italic_angle, |
int weight, |
int picthfamily) { |
- if (iBaseFont < kExternalFontIndex) { |
+ if (iBaseFont < kNumStandardFonts) { |
dsinclair
2016/10/11 14:11:37
Doesn't this change the meaning? Previously it was
npm
2016/10/11 14:19:55
That is precisely what I want because I now use it
|
if (m_FoxitFaces[iBaseFont]) |
return m_FoxitFaces[iBaseFont]; |
const uint8_t* pFontData = nullptr; |
@@ -441,26 +441,12 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, |
if (SubstName == "Symbol" && !bTrueType) { |
pSubstFont->m_Family = "Chrome Symbol"; |
pSubstFont->m_Charset = FXFONT_SYMBOL_CHARSET; |
- pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; |
- if (m_FoxitFaces[12]) |
- return m_FoxitFaces[12]; |
- const uint8_t* pFontData = nullptr; |
- uint32_t size = 0; |
- m_pFontMgr->GetBuiltinFont(12, &pFontData, &size); |
- m_FoxitFaces[12] = m_pFontMgr->GetFixedFace(pFontData, size, 0); |
- return m_FoxitFaces[12]; |
+ return UseInternalSubst(pSubstFont, 12, italic_angle, weight, 0); |
} |
if (SubstName == "ZapfDingbats") { |
pSubstFont->m_Family = "Chrome Dingbats"; |
pSubstFont->m_Charset = FXFONT_SYMBOL_CHARSET; |
- pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; |
- if (m_FoxitFaces[13]) |
- return m_FoxitFaces[13]; |
- const uint8_t* pFontData = nullptr; |
- uint32_t size = 0; |
- m_pFontMgr->GetBuiltinFont(13, &pFontData, &size); |
- m_FoxitFaces[13] = m_pFontMgr->GetFixedFace(pFontData, size, 0); |
- return m_FoxitFaces[13]; |
+ return UseInternalSubst(pSubstFont, 13, italic_angle, weight, 0); |
} |
int iBaseFont = 0; |
CFX_ByteString family; |
@@ -476,7 +462,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, |
} else { |
family = SubstName; |
} |
- for (; iBaseFont < kExternalFontIndex; iBaseFont++) { |
+ for (; iBaseFont < 12; iBaseFont++) { |
if (family == CFX_ByteStringC(g_Base14FontNames[iBaseFont])) |
break; |
} |
@@ -484,7 +470,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, |
bool bItalic = false; |
uint32_t nStyle = 0; |
bool bStyleAvail = false; |
- if (iBaseFont < kExternalFontIndex) { |
+ if (iBaseFont < 12) { |
if ((iBaseFont % 4) == 1 || (iBaseFont % 4) == 2) |
nStyle |= FX_FONT_STYLE_Bold; |
if ((iBaseFont % 4) / 2) |
@@ -494,6 +480,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, |
if (iBaseFont >= 8) |
PitchFamily |= FXFONT_FF_ROMAN; |
} else { |
+ iBaseFont = kNumStandardFonts; |
if (!bHasComma) { |
find = family.ReverseFind('-'); |
if (find >= 0) { |
@@ -528,7 +515,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, |
int32_t nRet = GetStyleType(buf, false); |
if ((i && !bStyleAvail) || (!i && nRet < 0)) { |
family = SubstName; |
- iBaseFont = kExternalFontIndex; |
+ iBaseFont = kNumStandardFonts; |
break; |
} |
if (nRet >= 0) { |
@@ -539,7 +526,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, |
nStyle |= FX_FONT_STYLE_Italic; |
} else { |
family = SubstName; |
- iBaseFont = kExternalFontIndex; |
+ iBaseFont = kNumStandardFonts; |
} |
break; |
} |
@@ -574,14 +561,13 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, |
int Charset = FXFONT_ANSI_CHARSET; |
if (WindowCP) |
Charset = GetCharsetFromCodePage(WindowCP); |
- else if (iBaseFont == kExternalFontIndex && (flags & FXFONT_SYMBOLIC)) |
+ else if (iBaseFont == kNumStandardFonts && (flags & FXFONT_SYMBOLIC)) |
Charset = FXFONT_SYMBOL_CHARSET; |
bool bCJK = |
(Charset == FXFONT_SHIFTJIS_CHARSET || Charset == FXFONT_GB2312_CHARSET || |
Charset == FXFONT_HANGUL_CHARSET || |
Charset == FXFONT_CHINESEBIG5_CHARSET); |
if (!m_pFontInfo) { |
- pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; |
return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight, |
PitchFamily); |
} |
@@ -591,7 +577,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, |
(!bHasComma && (!bHasHyphen || (bHasHyphen && !bStyleAvail)))) { |
match = MatchInstalledFonts(TT_NormalizeName(SubstName.c_str())); |
} |
- if (match.IsEmpty() && iBaseFont >= kExternalFontIndex) { |
+ if (match.IsEmpty() && iBaseFont >= kNumStandardFonts) { |
if (!bCJK) { |
if (!CheckSupportThirdPartFont(family, PitchFamily)) { |
bItalic = italic_angle != 0; |
@@ -611,10 +597,10 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, |
? 900 |
: (nStyle & FX_FONT_STYLE_Bold ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL); |
} |
- if (!match.IsEmpty() || iBaseFont < kExternalFontIndex) { |
+ if (!match.IsEmpty() || iBaseFont < kNumStandardFonts) { |
if (!match.IsEmpty()) |
family = match; |
- if (iBaseFont < kExternalFontIndex) { |
+ if (iBaseFont < kNumStandardFonts) { |
if (nStyle && !(iBaseFont % 4)) { |
if ((nStyle & 0x3) == 1) |
iBaseFont += 1; |
@@ -624,7 +610,6 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, |
iBaseFont += 2; |
} |
family = g_Base14FontNames[iBaseFont]; |
- pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; |
} |
} else { |
if (flags & FXFONT_ITALIC) |
@@ -656,15 +641,9 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, |
_FXM_PLATFORM_ == _FXM_PLATFORM_ANDROID_ |
if (SubstName == "Symbol") { |
pSubstFont->m_Family = "Chrome Symbol"; |
- pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; |
pSubstFont->m_Charset = FXFONT_SYMBOL_CHARSET; |
- if (m_FoxitFaces[12]) |
- return m_FoxitFaces[12]; |
- const uint8_t* pFontData = nullptr; |
- uint32_t size = 0; |
- m_pFontMgr->GetBuiltinFont(12, &pFontData, &size); |
- m_FoxitFaces[12] = m_pFontMgr->GetFixedFace(pFontData, size, 0); |
- return m_FoxitFaces[12]; |
+ return UseInternalSubst(pSubstFont, 12, italic_angle, old_weight, |
+ PitchFamily); |
} |
#endif |
pSubstFont->m_SubstFlags |= FXFONT_SUBST_NONSYMBOL; |
@@ -672,7 +651,6 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, |
weight, italic_angle, 0, pSubstFont); |
} |
if (Charset == FXFONT_ANSI_CHARSET) { |
- pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; |
return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight, |
PitchFamily); |
} |