summaryrefslogtreecommitdiff
path: root/core/fxge
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxge')
-rw-r--r--core/fxge/android/cfpf_skiafontmgr.cpp19
-rw-r--r--core/fxge/cfx_fontmapper.cpp41
2 files changed, 32 insertions, 28 deletions
diff --git a/core/fxge/android/cfpf_skiafontmgr.cpp b/core/fxge/android/cfpf_skiafontmgr.cpp
index f9afdabb93..2288a86e92 100644
--- a/core/fxge/android/cfpf_skiafontmgr.cpp
+++ b/core/fxge/android/cfpf_skiafontmgr.cpp
@@ -252,9 +252,9 @@ CFPF_SkiaFont* CFPF_SkiaFontMgr::CreateFont(const ByteStringView& bsFamilyname,
uint8_t uCharset,
uint32_t dwStyle) {
uint32_t dwHash = FPF_SKIAGetFamilyHash(bsFamilyname, dwStyle, uCharset);
- auto it = m_FamilyFonts.find(dwHash);
- if (it != m_FamilyFonts.end())
- return it->second.get();
+ auto family_iter = m_FamilyFonts.find(dwHash);
+ if (family_iter != m_FamilyFonts.end())
+ return family_iter->second.get();
uint32_t dwFaceName = FPF_SKIANormalizeFontName(bsFamilyname);
uint32_t dwSubst = FPF_SkiaGetSubstFont(dwFaceName, g_SkiaFontmap,
@@ -273,8 +273,9 @@ CFPF_SkiaFont* CFPF_SkiaFontMgr::CreateFont(const ByteStringView& bsFamilyname,
const CFPF_SkiaPathFont* pBestFont = nullptr;
int32_t nMax = -1;
int32_t nGlyphNum = 0;
- for (auto it = m_FontFaces.rbegin(); it != m_FontFaces.rend(); ++it) {
- const CFPF_SkiaPathFont* pFont = it->get();
+ for (auto face_iter = m_FontFaces.rbegin(); face_iter != m_FontFaces.rend();
+ ++face_iter) {
+ const CFPF_SkiaPathFont* pFont = face_iter->get();
if (!(pFont->charsets() & FPF_SkiaGetCharset(uCharset)))
continue;
int32_t nFind = 0;
@@ -301,19 +302,19 @@ CFPF_SkiaFont* CFPF_SkiaFontMgr::CreateFont(const ByteStringView& bsFamilyname,
if (uCharset == FX_CHARSET_Default || bMaybeSymbol) {
if (nFind > nMax && bMatchedName) {
nMax = nFind;
- pBestFont = it->get();
+ pBestFont = face_iter->get();
}
} else if (FPF_SkiaIsCJK(uCharset)) {
if (bMatchedName || pFont->glyph_num() > nGlyphNum) {
- pBestFont = it->get();
+ pBestFont = face_iter->get();
nGlyphNum = pFont->glyph_num();
}
} else if (nFind > nMax) {
nMax = nFind;
- pBestFont = it->get();
+ pBestFont = face_iter->get();
}
if (nExpectVal <= nFind) {
- pBestFont = it->get();
+ pBestFont = face_iter->get();
break;
}
}
diff --git a/core/fxge/cfx_fontmapper.cpp b/core/fxge/cfx_fontmapper.cpp
index c7a7015680..461094d81e 100644
--- a/core/fxge/cfx_fontmapper.cpp
+++ b/core/fxge/cfx_fontmapper.cpp
@@ -149,6 +149,14 @@ const AltFontFamily g_AltFontFamilies[] = {
{"ForteMT", "Forte"},
};
+#if _FX_PLATFORM_ == _FX_PLATFORM_LINUX_
+const char kNarrowFamily[] = "LiberationSansNarrow";
+#elif _FX_PLATFORM_ == _FX_PLATFORM_ANDROID_
+const char kNarrowFamily[] = "RobotoCondensed";
+#else
+const char kNarrowFamily[] = "ArialNarrow";
+#endif // _FX_PLATFORM_ == _FX_PLATFORM_LINUX_
+
ByteString TT_NormalizeName(const char* family) {
ByteString norm(family);
norm.Remove(' ');
@@ -415,14 +423,16 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const ByteString& name,
ByteString style;
bool bHasComma = false;
bool bHasHyphen = false;
- auto pos = SubstName.Find(",", 0);
- if (pos.has_value()) {
- family = SubstName.Left(pos.value());
- PDF_GetStandardFontName(&family);
- style = SubstName.Right(SubstName.GetLength() - (pos.value() + 1));
- bHasComma = true;
- } else {
- family = SubstName;
+ {
+ Optional<size_t> pos = SubstName.Find(",", 0);
+ if (pos.has_value()) {
+ family = SubstName.Left(pos.value());
+ PDF_GetStandardFontName(&family);
+ style = SubstName.Right(SubstName.GetLength() - (pos.value() + 1));
+ bHasComma = true;
+ } else {
+ family = SubstName;
+ }
}
for (; iBaseFont < 12; iBaseFont++) {
if (family == ByteStringView(g_Base14FontNames[iBaseFont]))
@@ -443,7 +453,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const ByteString& name,
} else {
iBaseFont = kNumStandardFonts;
if (!bHasComma) {
- pos = family.ReverseFind('-');
+ Optional<size_t> pos = family.ReverseFind('-');
if (pos.has_value()) {
style = family.Right(family.GetLength() - (pos.value() + 1));
family = family.Left(pos.value());
@@ -540,19 +550,12 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const ByteString& name,
bItalic = italic_angle != 0;
weight = old_weight;
}
-#if _FX_PLATFORM_ == _FX_PLATFORM_LINUX_
- const char* narrow_family = "LiberationSansNarrow";
-#elif _FX_PLATFORM_ == _FX_PLATFORM_ANDROID_
- const char* narrow_family = "RobotoCondensed";
-#else
- const char* narrow_family = "ArialNarrow";
-#endif // _FX_PLATFORM_ == _FX_PLATFORM_LINUX_
- auto pos = SubstName.Find("Narrow");
+ Optional<size_t> pos = SubstName.Find("Narrow");
if (pos.has_value() && pos.value() != 0)
- family = narrow_family;
+ family = kNarrowFamily;
pos = SubstName.Find("Condensed");
if (pos.has_value() && pos.value() != 0)
- family = narrow_family;
+ family = kNarrowFamily;
} else {
pSubstFont->m_bSubstCJK = true;
if (nStyle)