From f51a02a29e10fcc490ba28f44d43f50104f940ed Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Wed, 19 Apr 2017 12:46:53 -0400 Subject: Cleanup codepage and charset definitions. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This Cl cleans up the unused defines in fx_codepage.h. The FXFONT_CHARSET_ defines are replaced with fx_codepage defines, this moves fx_codepage into core instead of xfa only. Static asserts are added to verify the public/ charsets match the fx_codepage charsets. Change-Id: Ie2f749e093de60a9a6743128a1fb087912e4cc96 Reviewed-on: https://pdfium-review.googlesource.com/4316 Commit-Queue: dsinclair Commit-Queue: Nicolás Peña Reviewed-by: Nicolás Peña --- core/fxge/android/cfpf_skiafontmgr.cpp | 49 +++++++++++++++++----------------- core/fxge/apple/fx_mac_imp.cpp | 13 ++++----- core/fxge/fx_font.h | 19 ------------- core/fxge/ge/cfx_facecache.cpp | 3 ++- core/fxge/ge/cfx_folderfontinfo.cpp | 32 +++++++++++----------- core/fxge/ge/cfx_font.cpp | 3 ++- core/fxge/ge/cfx_fontmapper.cpp | 31 ++++++++++----------- core/fxge/ge/cfx_substfont.cpp | 3 ++- core/fxge/ge/cfx_unicodeencoding.cpp | 3 ++- core/fxge/ge/fx_ge_linux.cpp | 9 ++++--- core/fxge/win32/fx_win32_device.cpp | 35 ++++++++++++------------ 11 files changed, 95 insertions(+), 105 deletions(-) (limited to 'core/fxge') diff --git a/core/fxge/android/cfpf_skiafontmgr.cpp b/core/fxge/android/cfpf_skiafontmgr.cpp index 534f41a548..46aa76e822 100644 --- a/core/fxge/android/cfpf_skiafontmgr.cpp +++ b/core/fxge/android/cfpf_skiafontmgr.cpp @@ -13,6 +13,7 @@ #include +#include "core/fxcrt/fx_codepage.h" #include "core/fxcrt/fx_ext.h" #include "core/fxcrt/fx_memory.h" #include "core/fxcrt/fx_system.h" @@ -123,35 +124,35 @@ enum FPF_SKIACHARSET { uint32_t FPF_SkiaGetCharset(uint8_t uCharset) { switch (uCharset) { - case FXFONT_ANSI_CHARSET: + case FX_CHARSET_ANSI: return FPF_SKIACHARSET_Ansi; - case FXFONT_DEFAULT_CHARSET: + case FX_CHARSET_Default: return FPF_SKIACHARSET_Default; - case FXFONT_SYMBOL_CHARSET: + case FX_CHARSET_Symbol: return FPF_SKIACHARSET_Symbol; - case FXFONT_SHIFTJIS_CHARSET: + case FX_CHARSET_ShiftJIS: return FPF_SKIACHARSET_ShiftJIS; - case FXFONT_HANGUL_CHARSET: + case FX_CHARSET_Hangul: return FPF_SKIACHARSET_Korean; - case FXFONT_GB2312_CHARSET: + case FX_CHARSET_ChineseSimplified: return FPF_SKIACHARSET_GB2312; - case FXFONT_CHINESEBIG5_CHARSET: + case FX_CHARSET_ChineseTraditional: return FPF_SKIACHARSET_BIG5; - case FXFONT_GREEK_CHARSET: + case FX_CHARSET_MSWin_Greek: return FPF_SKIACHARSET_Greek; - case FXFONT_TURKISH_CHARSET: + case FX_CHARSET_MSWin_Turkish: return FPF_SKIACHARSET_Turkish; - case FXFONT_HEBREW_CHARSET: + case FX_CHARSET_MSWin_Hebrew: return FPF_SKIACHARSET_Hebrew; - case FXFONT_ARABIC_CHARSET: + case FX_CHARSET_MSWin_Arabic: return FPF_SKIACHARSET_Arabic; - case FXFONT_BALTIC_CHARSET: + case FX_CHARSET_MSWin_Baltic: return FPF_SKIACHARSET_Baltic; - case FXFONT_RUSSIAN_CHARSET: + case FX_CHARSET_MSWin_Cyrillic: return FPF_SKIACHARSET_Cyrillic; - case FXFONT_THAI_CHARSET: + case FX_CHARSET_Thai: return FPF_SKIACHARSET_Thai; - case FXFONT_EASTEUROPE_CHARSET: + case FX_CHARSET_MSWin_EasternEuropean: return FPF_SKIACHARSET_EeasternEuropean; } return FPF_SKIACHARSET_Default; @@ -185,10 +186,9 @@ uint32_t FPF_SKIAGetFamilyHash(const CFX_ByteStringC& bsFamily, } bool FPF_SkiaIsCJK(uint8_t uCharset) { - return (uCharset == FXFONT_GB2312_CHARSET) || - (uCharset == FXFONT_CHINESEBIG5_CHARSET) || - (uCharset == FXFONT_HANGUL_CHARSET) || - (uCharset == FXFONT_SHIFTJIS_CHARSET); + return (uCharset == FX_CHARSET_ChineseSimplified) || + (uCharset == FX_CHARSET_ChineseTraditional) || + (uCharset == FX_CHARSET_Hangul) || (uCharset == FX_CHARSET_ShiftJIS); } bool FPF_SkiaMaybeSymbol(const CFX_ByteStringC& bsFacename) { @@ -295,11 +295,12 @@ CFPF_SkiaFont* CFPF_SkiaFontMgr::CreateFont(const CFX_ByteStringC& bsFamilyname, uint32_t dwSubstSans = FPF_SkiaGetSubstFont(dwFaceName, g_SkiaSansFontMap, FX_ArraySize(g_SkiaSansFontMap)); bool bMaybeSymbol = FPF_SkiaMaybeSymbol(bsFamilyname); - if (uCharset != FXFONT_ARABIC_CHARSET && FPF_SkiaMaybeArabic(bsFamilyname)) { - uCharset = FXFONT_ARABIC_CHARSET; - } else if (uCharset == FXFONT_ANSI_CHARSET && + if (uCharset != FX_CHARSET_MSWin_Arabic && + FPF_SkiaMaybeArabic(bsFamilyname)) { + uCharset = FX_CHARSET_MSWin_Arabic; + } else if (uCharset == FX_CHARSET_ANSI && (dwMatch & FPF_MATCHFONT_REPLACEANSI)) { - uCharset = FXFONT_DEFAULT_CHARSET; + uCharset = FX_CHARSET_Default; } int32_t nExpectVal = FPF_SKIAMATCHWEIGHT_NAME1 + FPF_SKIAMATCHWEIGHT_1 * 3 + FPF_SKIAMATCHWEIGHT_2 * 2; @@ -331,7 +332,7 @@ CFPF_SkiaFont* CFPF_SkiaFontMgr::CreateFont(const CFX_ByteStringC& bsFamilyname, nFind += FPF_SKIAMATCHWEIGHT_NAME2; bMatchedName = true; } - if (uCharset == FXFONT_DEFAULT_CHARSET || bMaybeSymbol) { + if (uCharset == FX_CHARSET_Default || bMaybeSymbol) { if (nFind > nMax && bMatchedName) { nMax = nFind; pBestFontDes = *it; diff --git a/core/fxge/apple/fx_mac_imp.cpp b/core/fxge/apple/fx_mac_imp.cpp index 2df6e754a0..cb1adf701f 100644 --- a/core/fxge/apple/fx_mac_imp.cpp +++ b/core/fxge/apple/fx_mac_imp.cpp @@ -6,6 +6,7 @@ #include +#include "core/fxcrt/fx_codepage.h" #include "core/fxge/apple/apple_int.h" #include "core/fxge/cfx_gemodule.h" #include "core/fxge/ge/cfx_folderfontinfo.h" @@ -94,23 +95,23 @@ void* CFX_MacFontInfo::MapFont(int weight, if (it != m_FontList.end()) return it->second; - if (charset == FXFONT_ANSI_CHARSET && (pitch_family & FXFONT_FF_FIXEDPITCH)) + if (charset == FX_CHARSET_ANSI && (pitch_family & FXFONT_FF_FIXEDPITCH)) return GetFont("Courier New"); - if (charset == FXFONT_ANSI_CHARSET || charset == FXFONT_SYMBOL_CHARSET) + if (charset == FX_CHARSET_ANSI || charset == FX_CHARSET_Symbol) return nullptr; switch (charset) { - case FXFONT_SHIFTJIS_CHARSET: + case FX_CHARSET_ShiftJIS: GetJapanesePreference(&face, weight, pitch_family); break; - case FXFONT_GB2312_CHARSET: + case FX_CHARSET_ChineseSimplified: face = "STSong"; break; - case FXFONT_HANGUL_CHARSET: + case FX_CHARSET_Hangul: face = "AppleMyungjo"; break; - case FXFONT_CHINESEBIG5_CHARSET: + case FX_CHARSET_ChineseTraditional: face = "LiSong Pro Light"; } it = m_FontList.find(face); diff --git a/core/fxge/fx_font.h b/core/fxge/fx_font.h index 87f36060b7..ce91e27c42 100644 --- a/core/fxge/fx_font.h +++ b/core/fxge/fx_font.h @@ -31,25 +31,6 @@ class SkTypeface; using CFX_TypeFace = SkTypeface; #endif -/* Character sets for the font */ -#define FXFONT_ANSI_CHARSET 0 -#define FXFONT_DEFAULT_CHARSET 1 -#define FXFONT_SYMBOL_CHARSET 2 -#define FXFONT_SHIFTJIS_CHARSET 128 -#define FXFONT_HANGUL_CHARSET 129 -#define FXFONT_GB2312_CHARSET 134 -#define FXFONT_CHINESEBIG5_CHARSET 136 -#define FXFONT_THAI_CHARSET 222 -#define FXFONT_EASTEUROPE_CHARSET 238 -#define FXFONT_RUSSIAN_CHARSET 204 -#define FXFONT_GREEK_CHARSET 161 -#define FXFONT_TURKISH_CHARSET 162 -#define FXFONT_HEBREW_CHARSET 177 -#define FXFONT_ARABIC_CHARSET 178 -#define FXFONT_BALTIC_CHARSET 186 -#define FXFONT_JOHAB_CHARSET 130 -#define FXFONT_VIETNAMESE_CHARSET 163 - /* Font pitch and family flags */ #define FXFONT_FF_FIXEDPITCH 1 #define FXFONT_FF_ROMAN (1 << 4) diff --git a/core/fxge/ge/cfx_facecache.cpp b/core/fxge/ge/cfx_facecache.cpp index 2a8e71acf5..0e1dea4bb3 100644 --- a/core/fxge/ge/cfx_facecache.cpp +++ b/core/fxge/ge/cfx_facecache.cpp @@ -10,6 +10,7 @@ #include #include +#include "core/fxcrt/fx_codepage.h" #include "core/fxge/cfx_fontmgr.h" #include "core/fxge/cfx_gemodule.h" #include "core/fxge/cfx_pathdata.h" @@ -165,7 +166,7 @@ CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph(const CFX_Font* pFont, if (index >= CFX_Font::kWeightPowArraySize) return nullptr; pdfium::base::CheckedNumeric level = 0; - if (pSubstFont->m_Charset == FXFONT_SHIFTJIS_CHARSET) + if (pSubstFont->m_Charset == FX_CHARSET_ShiftJIS) level = CFX_Font::s_WeightPow_SHIFTJIS[index] * 2; else level = CFX_Font::s_WeightPow_11[index]; diff --git a/core/fxge/ge/cfx_folderfontinfo.cpp b/core/fxge/ge/cfx_folderfontinfo.cpp index ff8cc4c29f..d46c7b5fef 100644 --- a/core/fxge/ge/cfx_folderfontinfo.cpp +++ b/core/fxge/ge/cfx_folderfontinfo.cpp @@ -8,6 +8,7 @@ #include +#include "core/fxcrt/fx_codepage.h" #include "core/fxge/cfx_fontmapper.h" #include "core/fxge/fx_font.h" @@ -59,17 +60,17 @@ CFX_ByteString FPDF_LoadTableFromTT(FILE* pFile, uint32_t GetCharset(int charset) { switch (charset) { - case FXFONT_SHIFTJIS_CHARSET: + case FX_CHARSET_ShiftJIS: return CHARSET_FLAG_SHIFTJIS; - case FXFONT_GB2312_CHARSET: + case FX_CHARSET_ChineseSimplified: return CHARSET_FLAG_GB; - case FXFONT_CHINESEBIG5_CHARSET: + case FX_CHARSET_ChineseTraditional: return CHARSET_FLAG_BIG5; - case FXFONT_HANGUL_CHARSET: + case FX_CHARSET_Hangul: return CHARSET_FLAG_KOREAN; - case FXFONT_SYMBOL_CHARSET: + case FX_CHARSET_Symbol: return CHARSET_FLAG_SYMBOL; - case FXFONT_ANSI_CHARSET: + case FX_CHARSET_ANSI: return CHARSET_FLAG_ANSI; default: break; @@ -229,27 +230,27 @@ void CFX_FolderFontInfo::ReportFace(const CFX_ByteString& path, const uint8_t* p = os2.raw_str() + 78; uint32_t codepages = GET_TT_LONG(p); if (codepages & (1 << 17)) { - m_pMapper->AddInstalledFont(facename, FXFONT_SHIFTJIS_CHARSET); + m_pMapper->AddInstalledFont(facename, FX_CHARSET_ShiftJIS); pInfo->m_Charsets |= CHARSET_FLAG_SHIFTJIS; } if (codepages & (1 << 18)) { - m_pMapper->AddInstalledFont(facename, FXFONT_GB2312_CHARSET); + m_pMapper->AddInstalledFont(facename, FX_CHARSET_ChineseSimplified); pInfo->m_Charsets |= CHARSET_FLAG_GB; } if (codepages & (1 << 20)) { - m_pMapper->AddInstalledFont(facename, FXFONT_CHINESEBIG5_CHARSET); + m_pMapper->AddInstalledFont(facename, FX_CHARSET_ChineseTraditional); pInfo->m_Charsets |= CHARSET_FLAG_BIG5; } if ((codepages & (1 << 19)) || (codepages & (1 << 21))) { - m_pMapper->AddInstalledFont(facename, FXFONT_HANGUL_CHARSET); + m_pMapper->AddInstalledFont(facename, FX_CHARSET_Hangul); pInfo->m_Charsets |= CHARSET_FLAG_KOREAN; } if (codepages & (1 << 31)) { - m_pMapper->AddInstalledFont(facename, FXFONT_SYMBOL_CHARSET); + m_pMapper->AddInstalledFont(facename, FX_CHARSET_Symbol); pInfo->m_Charsets |= CHARSET_FLAG_SYMBOL; } } - m_pMapper->AddInstalledFont(facename, FXFONT_ANSI_CHARSET); + m_pMapper->AddInstalledFont(facename, FX_CHARSET_ANSI); pInfo->m_Charsets |= CHARSET_FLAG_ANSI; pInfo->m_Styles = 0; if (style.Find("Bold") > -1) @@ -278,17 +279,16 @@ void* CFX_FolderFontInfo::FindFont(int weight, const char* family, bool bMatchName) { CFX_FontFaceInfo* pFind = nullptr; - if (charset == FXFONT_ANSI_CHARSET && (pitch_family & FXFONT_FF_FIXEDPITCH)) + if (charset == FX_CHARSET_ANSI && (pitch_family & FXFONT_FF_FIXEDPITCH)) return GetFont("Courier New"); uint32_t charset_flag = GetCharset(charset); int32_t iBestSimilar = 0; for (const auto& it : m_FontList) { const CFX_ByteString& bsName = it.first; CFX_FontFaceInfo* pFont = it.second; - if (!(pFont->m_Charsets & charset_flag) && - charset != FXFONT_DEFAULT_CHARSET) { + if (!(pFont->m_Charsets & charset_flag) && charset != FX_CHARSET_Default) continue; - } + int32_t index = bsName.Find(family); if (bMatchName && index < 0) continue; diff --git a/core/fxge/ge/cfx_font.cpp b/core/fxge/ge/cfx_font.cpp index 068f0b032c..2ae34f11b9 100644 --- a/core/fxge/ge/cfx_font.cpp +++ b/core/fxge/ge/cfx_font.cpp @@ -13,6 +13,7 @@ #include #include "core/fpdfapi/font/cpdf_font.h" +#include "core/fxcrt/fx_codepage.h" #include "core/fxge/cfx_facecache.h" #include "core/fxge/cfx_fontcache.h" #include "core/fxge/cfx_fontmgr.h" @@ -644,7 +645,7 @@ CFX_PathData* CFX_Font::LoadGlyphPathImpl(uint32_t glyph_index, uint32_t index = (m_pSubstFont->m_Weight - 400) / 10; index = std::min(index, static_cast(kWeightPowArraySize - 1)); int level = 0; - if (m_pSubstFont->m_Charset == FXFONT_SHIFTJIS_CHARSET) + if (m_pSubstFont->m_Charset == FX_CHARSET_ShiftJIS) level = s_WeightPow_SHIFTJIS[index] * 2 * 65536 / 36655; else level = s_WeightPow[index] * 2; diff --git a/core/fxge/ge/cfx_fontmapper.cpp b/core/fxge/ge/cfx_fontmapper.cpp index ff80685d96..4d5e9c4831 100644 --- a/core/fxge/ge/cfx_fontmapper.cpp +++ b/core/fxge/ge/cfx_fontmapper.cpp @@ -11,6 +11,7 @@ #include #include +#include "core/fxcrt/fx_codepage.h" #include "core/fxge/cfx_substfont.h" #include "core/fxge/fx_font.h" #include "core/fxge/ifx_systemfontinfo.h" @@ -202,7 +203,7 @@ uint8_t GetCharsetFromCodePage(uint16_t codepage) { }); if (pCharmap < pEnd && codepage == pCharmap->codepage) return pCharmap->charset; - return FXFONT_DEFAULT_CHARSET; + return FX_CHARSET_Default; } CFX_ByteString GetFontFamily(CFX_ByteString fontName, int nStyle) { @@ -335,8 +336,8 @@ void CFX_FontMapper::AddInstalledFont(const CFX_ByteString& name, int charset) { void* hFont = m_pFontInfo->GetFont(name.c_str()); if (!hFont) { int iExact; - hFont = m_pFontInfo->MapFont(0, 0, FXFONT_DEFAULT_CHARSET, 0, - name.c_str(), iExact); + hFont = m_pFontInfo->MapFont(0, 0, FX_CHARSET_Default, 0, name.c_str(), + iExact); if (!hFont) return; } @@ -434,12 +435,12 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, PDF_GetStandardFontName(&SubstName); if (SubstName == "Symbol" && !bTrueType) { pSubstFont->m_Family = "Chrome Symbol"; - pSubstFont->m_Charset = FXFONT_SYMBOL_CHARSET; + pSubstFont->m_Charset = FX_CHARSET_Symbol; return UseInternalSubst(pSubstFont, 12, italic_angle, weight, 0); } if (SubstName == "ZapfDingbats") { pSubstFont->m_Family = "Chrome Dingbats"; - pSubstFont->m_Charset = FXFONT_SYMBOL_CHARSET; + pSubstFont->m_Charset = FX_CHARSET_Symbol; return UseInternalSubst(pSubstFont, 13, italic_angle, weight, 0); } int iBaseFont = 0; @@ -552,15 +553,15 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, if (nStyle & FX_FONT_STYLE_Italic) bItalic = true; int iExact = 0; - int Charset = FXFONT_ANSI_CHARSET; + int Charset = FX_CHARSET_ANSI; if (WindowCP) Charset = GetCharsetFromCodePage(WindowCP); 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); + Charset = FX_CHARSET_Symbol; + bool bCJK = (Charset == FX_CHARSET_ShiftJIS || + Charset == FX_CHARSET_ChineseSimplified || + Charset == FX_CHARSET_Hangul || + Charset == FX_CHARSET_ChineseTraditional); if (!m_pFontInfo) { return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight, PitchFamily); @@ -640,12 +641,12 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, PitchFamily); } } else { - if (Charset == FXFONT_SYMBOL_CHARSET) { + if (Charset == FX_CHARSET_Symbol) { #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ || \ _FXM_PLATFORM_ == _FXM_PLATFORM_ANDROID_ if (SubstName == "Symbol") { pSubstFont->m_Family = "Chrome Symbol"; - pSubstFont->m_Charset = FXFONT_SYMBOL_CHARSET; + pSubstFont->m_Charset = FX_CHARSET_Symbol; return UseInternalSubst(pSubstFont, 12, italic_angle, old_weight, PitchFamily); } @@ -653,7 +654,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, return FindSubstFont(family, bTrueType, flags & ~FXFONT_SYMBOLIC, weight, italic_angle, 0, pSubstFont); } - if (Charset == FXFONT_ANSI_CHARSET) { + if (Charset == FX_CHARSET_ANSI) { return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight, PitchFamily); } @@ -674,7 +675,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, return nullptr; m_pFontInfo->GetFaceName(hFont, &SubstName); - if (Charset == FXFONT_DEFAULT_CHARSET) + if (Charset == FX_CHARSET_Default) m_pFontInfo->GetFontCharset(hFont, &Charset); uint32_t ttc_size = m_pFontInfo->GetFontData(hFont, kTableTTCF, nullptr, 0); uint32_t font_size = m_pFontInfo->GetFontData(hFont, 0, nullptr, 0); diff --git a/core/fxge/ge/cfx_substfont.cpp b/core/fxge/ge/cfx_substfont.cpp index 475372e3d9..27d3bc3059 100644 --- a/core/fxge/ge/cfx_substfont.cpp +++ b/core/fxge/ge/cfx_substfont.cpp @@ -6,10 +6,11 @@ #include "core/fxge/cfx_substfont.h" +#include "core/fxcrt/fx_codepage.h" #include "core/fxge/fx_font.h" CFX_SubstFont::CFX_SubstFont() - : m_Charset(FXFONT_ANSI_CHARSET), + : m_Charset(FX_CHARSET_ANSI), m_SubstFlags(0), m_Weight(0), m_ItalicAngle(0), diff --git a/core/fxge/ge/cfx_unicodeencoding.cpp b/core/fxge/ge/cfx_unicodeencoding.cpp index cba67ba354..494ae33bb0 100644 --- a/core/fxge/ge/cfx_unicodeencoding.cpp +++ b/core/fxge/ge/cfx_unicodeencoding.cpp @@ -6,6 +6,7 @@ #include "core/fxge/cfx_unicodeencoding.h" +#include "core/fxcrt/fx_codepage.h" #include "core/fxge/fx_font.h" #include "core/fxge/fx_freetype.h" @@ -22,7 +23,7 @@ uint32_t CFX_UnicodeEncoding::GlyphFromCharCode(uint32_t charcode) { return FXFT_Get_Char_Index(face, charcode); if (m_pFont->GetSubstFont() && - m_pFont->GetSubstFont()->m_Charset == FXFONT_SYMBOL_CHARSET) { + m_pFont->GetSubstFont()->m_Charset == FX_CHARSET_Symbol) { uint32_t index = 0; if (FXFT_Select_Charmap(face, FXFT_ENCODING_MS_SYMBOL) == 0) index = FXFT_Get_Char_Index(face, charcode); diff --git a/core/fxge/ge/fx_ge_linux.cpp b/core/fxge/ge/fx_ge_linux.cpp index 502a3674ab..8d2c496c19 100644 --- a/core/fxge/ge/fx_ge_linux.cpp +++ b/core/fxge/ge/fx_ge_linux.cpp @@ -6,6 +6,7 @@ #include +#include "core/fxcrt/fx_codepage.h" #include "core/fxge/cfx_gemodule.h" #include "core/fxge/ge/cfx_folderfontinfo.h" #include "core/fxge/ifx_systemfontinfo.h" @@ -90,7 +91,7 @@ void* CFX_LinuxFontInfo::MapFont(int weight, } bool bCJK = true; switch (charset) { - case FXFONT_SHIFTJIS_CHARSET: { + case FX_CHARSET_ShiftJIS: { size_t index = GetJapanesePreference(cstr_face, weight, pitch_family); ASSERT(index < FX_ArraySize(g_LinuxGpFontList)); for (size_t i = 0; i < kLinuxGpNameSize; i++) { @@ -100,7 +101,7 @@ void* CFX_LinuxFontInfo::MapFont(int weight, } break; } - case FXFONT_GB2312_CHARSET: { + case FX_CHARSET_ChineseSimplified: { for (size_t i = 0; i < FX_ArraySize(g_LinuxGbFontList); ++i) { auto it = m_FontList.find(g_LinuxGbFontList[i]); if (it != m_FontList.end()) @@ -108,7 +109,7 @@ void* CFX_LinuxFontInfo::MapFont(int weight, } break; } - case FXFONT_CHINESEBIG5_CHARSET: { + case FX_CHARSET_ChineseTraditional: { for (size_t i = 0; i < FX_ArraySize(g_LinuxB5FontList); ++i) { auto it = m_FontList.find(g_LinuxB5FontList[i]); if (it != m_FontList.end()) @@ -116,7 +117,7 @@ void* CFX_LinuxFontInfo::MapFont(int weight, } break; } - case FXFONT_HANGUL_CHARSET: { + case FX_CHARSET_Hangul: { for (size_t i = 0; i < FX_ArraySize(g_LinuxHGFontList); ++i) { auto it = m_FontList.find(g_LinuxHGFontList[i]); if (it != m_FontList.end()) diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp index 73a1ac6a0e..986839ee88 100644 --- a/core/fxge/win32/fx_win32_device.cpp +++ b/core/fxge/win32/fx_win32_device.cpp @@ -12,6 +12,7 @@ #include "core/fxcodec/fx_codec.h" #include "core/fxcrt/cfx_maybe_owned.h" +#include "core/fxcrt/fx_codepage.h" #include "core/fxcrt/fx_memory.h" #include "core/fxcrt/fx_system.h" #include "core/fxge/cfx_windowsdevice.h" @@ -448,7 +449,7 @@ bool CFX_Win32FontInfo::EnumFontList(CFX_FontMapper* pMapper) { m_pMapper = pMapper; LOGFONTA lf; memset(&lf, 0, sizeof(LOGFONTA)); - lf.lfCharSet = FXFONT_DEFAULT_CHARSET; + lf.lfCharSet = FX_CHARSET_Default; lf.lfFaceName[0] = 0; lf.lfPitchAndFamily = 0; EnumFontFamiliesExA(m_hDC, &lf, (FONTENUMPROCA)FontEnumProc, (uintptr_t) this, @@ -486,10 +487,10 @@ void* CFX_Win32FallbackFontInfo::MapFont(int weight, } bool bCJK = true; switch (charset) { - case FXFONT_SHIFTJIS_CHARSET: - case FXFONT_GB2312_CHARSET: - case FXFONT_CHINESEBIG5_CHARSET: - case FXFONT_HANGUL_CHARSET: + case FX_CHARSET_ShiftJIS: + case FX_CHARSET_ChineseSimplified: + case FX_CHARSET_ChineseTraditional: + case FX_CHARSET_Hangul: break; default: bCJK = false; @@ -582,17 +583,17 @@ void* CFX_Win32FontInfo::MapFont(int weight, iExact = true; break; } - if (charset == FXFONT_ANSI_CHARSET || charset == FXFONT_SYMBOL_CHARSET) { - charset = FXFONT_DEFAULT_CHARSET; - } + if (charset == FX_CHARSET_ANSI || charset == FX_CHARSET_Symbol) + charset = FX_CHARSET_Default; + int subst_pitch_family = pitch_family; switch (charset) { - case FXFONT_SHIFTJIS_CHARSET: + case FX_CHARSET_ShiftJIS: subst_pitch_family = FF_ROMAN; break; - case FXFONT_CHINESEBIG5_CHARSET: - case FXFONT_HANGUL_CHARSET: - case FXFONT_GB2312_CHARSET: + case FX_CHARSET_ChineseTraditional: + case FX_CHARSET_Hangul: + case FX_CHARSET_ChineseSimplified: subst_pitch_family = 0; break; } @@ -619,20 +620,20 @@ void* CFX_Win32FontInfo::MapFont(int weight, return hFont; } ::DeleteObject(hFont); - if (charset == FXFONT_DEFAULT_CHARSET) + if (charset == FX_CHARSET_Default) return nullptr; switch (charset) { - case FXFONT_SHIFTJIS_CHARSET: + case FX_CHARSET_ShiftJIS: GetJapanesePreference(face, weight, pitch_family); break; - case FXFONT_GB2312_CHARSET: + case FX_CHARSET_ChineseSimplified: GetGBPreference(face, weight, pitch_family); break; - case FXFONT_HANGUL_CHARSET: + case FX_CHARSET_Hangul: face = "Gulim"; break; - case FXFONT_CHINESEBIG5_CHARSET: + case FX_CHARSET_ChineseTraditional: if (face.Find("MSung") >= 0) { face = "MingLiU"; } else { -- cgit v1.2.3