summaryrefslogtreecommitdiff
path: root/core/fxge
diff options
context:
space:
mode:
authornpm <npm@chromium.org>2016-10-11 08:57:01 -0700
committerCommit bot <commit-bot@chromium.org>2016-10-11 08:57:01 -0700
commit232ce9365df0768846972be34a3a84f915bf7e82 (patch)
treed2100e73102ca4c8be7cd3813d857fed873f9550 /core/fxge
parentd2023170190b4eb278054fd84765412c1a6ccddd (diff)
downloadpdfium-232ce9365df0768846972be34a3a84f915bf7e82.tar.xz
Slightly simplify CFX_FontMapper::FindSubstFont
- Deleted useless flag FXFONT_SUBST_STANDARD - Change kExternalFontIndex to something more meaningful - Fetch symbolic fonts using UseInternalSubst too Review-Url: https://codereview.chromium.org/2400773002
Diffstat (limited to 'core/fxge')
-rw-r--r--core/fxge/cfx_substfont.h1
-rw-r--r--core/fxge/ge/cfx_fontmapper.cpp54
2 files changed, 16 insertions, 39 deletions
diff --git a/core/fxge/cfx_substfont.h b/core/fxge/cfx_substfont.h
index 943f7bf866..8dba1006c0 100644
--- a/core/fxge/cfx_substfont.h
+++ b/core/fxge/cfx_substfont.h
@@ -15,7 +15,6 @@
#define FXFONT_SUBST_TRANSFORM 0x10
#define FXFONT_SUBST_NONSYMBOL 0x20
#define FXFONT_SUBST_EXACT 0x40
-#define FXFONT_SUBST_STANDARD 0x80
class CFX_SubstFont {
public:
diff --git a/core/fxge/ge/cfx_fontmapper.cpp b/core/fxge/ge/cfx_fontmapper.cpp
index b388545751..e59fbe1ba8 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",
@@ -386,7 +386,7 @@ FXFT_Face CFX_FontMapper::UseInternalSubst(CFX_SubstFont* pSubstFont,
int italic_angle,
int weight,
int picthfamily) {
- if (iBaseFont < kExternalFontIndex) {
+ if (iBaseFont < kNumStandardFonts) {
if (m_FoxitFaces[iBaseFont])
return m_FoxitFaces[iBaseFont];
const uint8_t* pFontData = nullptr;
@@ -440,26 +440,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;
@@ -475,7 +461,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;
}
@@ -483,7 +469,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)
@@ -493,6 +479,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) {
@@ -527,7 +514,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) {
@@ -538,7 +525,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name,
nStyle |= FX_FONT_STYLE_Italic;
} else {
family = SubstName;
- iBaseFont = kExternalFontIndex;
+ iBaseFont = kNumStandardFonts;
}
break;
}
@@ -573,14 +560,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);
}
@@ -590,7 +576,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;
@@ -610,10 +596,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;
@@ -623,7 +609,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)
@@ -655,15 +640,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;
@@ -671,7 +650,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);
}