diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-04-19 12:46:53 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-04-19 17:08:38 +0000 |
commit | f51a02a29e10fcc490ba28f44d43f50104f940ed (patch) | |
tree | 354215ff5deeea419ce5a88b369535b5e4468a62 /core | |
parent | 2a473dbecab2b47c513de9127a2cddf4c2800306 (diff) | |
download | pdfium-f51a02a29e10fcc490ba28f44d43f50104f940ed.tar.xz |
Cleanup codepage and charset definitions.
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 <dsinclair@chromium.org>
Commit-Queue: Nicolás Peña <npm@chromium.org>
Reviewed-by: Nicolás Peña <npm@chromium.org>
Diffstat (limited to 'core')
-rw-r--r-- | core/fpdfapi/parser/cpdf_document.cpp | 54 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_interform.cpp | 77 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_variabletext.cpp | 5 | ||||
-rw-r--r-- | core/fpdfdoc/cpvt_fontmap.cpp | 3 | ||||
-rw-r--r-- | core/fpdfdoc/cpvt_wordinfo.cpp | 5 | ||||
-rw-r--r-- | core/fxcrt/fx_codepage.h | 56 | ||||
-rw-r--r-- | core/fxge/android/cfpf_skiafontmgr.cpp | 49 | ||||
-rw-r--r-- | core/fxge/apple/fx_mac_imp.cpp | 13 | ||||
-rw-r--r-- | core/fxge/fx_font.h | 19 | ||||
-rw-r--r-- | core/fxge/ge/cfx_facecache.cpp | 3 | ||||
-rw-r--r-- | core/fxge/ge/cfx_folderfontinfo.cpp | 32 | ||||
-rw-r--r-- | core/fxge/ge/cfx_font.cpp | 3 | ||||
-rw-r--r-- | core/fxge/ge/cfx_fontmapper.cpp | 31 | ||||
-rw-r--r-- | core/fxge/ge/cfx_substfont.cpp | 3 | ||||
-rw-r--r-- | core/fxge/ge/cfx_unicodeencoding.cpp | 3 | ||||
-rw-r--r-- | core/fxge/ge/fx_ge_linux.cpp | 9 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_device.cpp | 35 |
17 files changed, 174 insertions, 226 deletions
diff --git a/core/fpdfapi/parser/cpdf_document.cpp b/core/fpdfapi/parser/cpdf_document.cpp index 4d99ac910f..f34d433287 100644 --- a/core/fpdfapi/parser/cpdf_document.cpp +++ b/core/fpdfapi/parser/cpdf_document.cpp @@ -28,6 +28,7 @@ #include "core/fpdfapi/render/cpdf_dibsource.h" #include "core/fpdfapi/render/cpdf_docrenderdata.h" #include "core/fxcodec/JBig2_DocumentContext.h" +#include "core/fxcrt/fx_codepage.h" #include "core/fxge/cfx_unicodeencoding.h" #include "core/fxge/fx_font.h" #include "third_party/base/ptr_util.h" @@ -180,14 +181,14 @@ struct FX_CharsetUnicodes { }; const FX_CharsetUnicodes g_FX_CharsetUnicodes[] = { - {FXFONT_THAI_CHARSET, g_FX_CP874Unicodes}, - {FXFONT_EASTEUROPE_CHARSET, g_FX_CP1250Unicodes}, - {FXFONT_RUSSIAN_CHARSET, g_FX_CP1251Unicodes}, - {FXFONT_GREEK_CHARSET, g_FX_CP1253Unicodes}, - {FXFONT_TURKISH_CHARSET, g_FX_CP1254Unicodes}, - {FXFONT_HEBREW_CHARSET, g_FX_CP1255Unicodes}, - {FXFONT_ARABIC_CHARSET, g_FX_CP1256Unicodes}, - {FXFONT_BALTIC_CHARSET, g_FX_CP1257Unicodes}, + {FX_CHARSET_Thai, g_FX_CP874Unicodes}, + {FX_CHARSET_MSWin_EasternEuropean, g_FX_CP1250Unicodes}, + {FX_CHARSET_MSWin_Cyrillic, g_FX_CP1251Unicodes}, + {FX_CHARSET_MSWin_Greek, g_FX_CP1253Unicodes}, + {FX_CHARSET_MSWin_Turkish, g_FX_CP1254Unicodes}, + {FX_CHARSET_MSWin_Hebrew, g_FX_CP1255Unicodes}, + {FX_CHARSET_MSWin_Arabic, g_FX_CP1256Unicodes}, + {FX_CHARSET_MSWin_Baltic, g_FX_CP1257Unicodes}, }; void InsertWidthArrayImpl(int* widths, int size, CPDF_Array* pWidthArray) { @@ -817,14 +818,14 @@ CPDF_Dictionary* CPDF_Document::ProcessbCJK( int supplement = 0; CPDF_Array* pWidthArray = pFontDict->SetNewFor<CPDF_Array>("W"); switch (charset) { - case FXFONT_CHINESEBIG5_CHARSET: + case FX_CHARSET_ChineseTraditional: cmap = bVert ? "ETenms-B5-V" : "ETenms-B5-H"; ordering = "CNS1"; supplement = 4; pWidthArray->AddNew<CPDF_Number>(1); Insert(0x20, 0x7e, pWidthArray); break; - case FXFONT_GB2312_CHARSET: + case FX_CHARSET_ChineseSimplified: cmap = bVert ? "GBK-EUC-V" : "GBK-EUC-H"; ordering = "GB1"; supplement = 2; @@ -833,14 +834,14 @@ CPDF_Dictionary* CPDF_Document::ProcessbCJK( pWidthArray->AddNew<CPDF_Number>(814); Insert(0x21, 0x7e, pWidthArray); break; - case FXFONT_HANGUL_CHARSET: + case FX_CHARSET_Hangul: cmap = bVert ? "KSCms-UHC-V" : "KSCms-UHC-H"; ordering = "Korea1"; supplement = 2; pWidthArray->AddNew<CPDF_Number>(1); Insert(0x20, 0x7e, pWidthArray); break; - case FXFONT_SHIFTJIS_CHARSET: + case FX_CHARSET_ShiftJIS: cmap = bVert ? "90ms-RKSJ-V" : "90ms-RKSJ-H"; ordering = "Japan1"; supplement = 5; @@ -876,15 +877,14 @@ CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, bool bVert) { if (!pFont) return nullptr; - bool bCJK = charset == FXFONT_CHINESEBIG5_CHARSET || - charset == FXFONT_GB2312_CHARSET || - charset == FXFONT_HANGUL_CHARSET || - charset == FXFONT_SHIFTJIS_CHARSET; + bool bCJK = charset == FX_CHARSET_ChineseTraditional || + charset == FX_CHARSET_ChineseSimplified || + charset == FX_CHARSET_Hangul || charset == FX_CHARSET_ShiftJIS; CFX_ByteString basefont = pFont->GetFamilyName(); basefont.Replace(" ", ""); int flags = CalculateFlags(pFont->IsBold(), pFont->IsItalic(), pFont->IsFixedWidth(), - false, false, charset == FXFONT_SYMBOL_CHARSET); + false, false, charset == FX_CHARSET_Symbol); CPDF_Dictionary* pBaseDict = NewIndirect<CPDF_Dictionary>(); pBaseDict->SetNewFor<CPDF_Name>("Type", "Font"); @@ -898,8 +898,8 @@ CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, bool bVert) { int char_width = pFont->GetGlyphWidth(glyph_index); pWidths->AddNew<CPDF_Number>(char_width); } - if (charset == FXFONT_ANSI_CHARSET || charset == FXFONT_DEFAULT_CHARSET || - charset == FXFONT_SYMBOL_CHARSET) { + if (charset == FX_CHARSET_ANSI || charset == FX_CHARSET_Default || + charset == FX_CHARSET_Symbol) { pBaseDict->SetNewFor<CPDF_Name>("Encoding", "WinAnsiEncoding"); for (int charcode = 128; charcode <= 255; charcode++) { int glyph_index = pEncoding->GlyphFromCharCode(charcode); @@ -996,12 +996,12 @@ CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTA* pLogFont, (pLogFont->lfPitchAndFamily & 3) == FIXED_PITCH, (pLogFont->lfPitchAndFamily & 0xf8) == FF_ROMAN, (pLogFont->lfPitchAndFamily & 0xf8) == FF_SCRIPT, - pLogFont->lfCharSet == FXFONT_SYMBOL_CHARSET); + pLogFont->lfCharSet == FX_CHARSET_Symbol); - bool bCJK = pLogFont->lfCharSet == FXFONT_CHINESEBIG5_CHARSET || - pLogFont->lfCharSet == FXFONT_GB2312_CHARSET || - pLogFont->lfCharSet == FXFONT_HANGUL_CHARSET || - pLogFont->lfCharSet == FXFONT_SHIFTJIS_CHARSET; + bool bCJK = pLogFont->lfCharSet == FX_CHARSET_ChineseTraditional || + pLogFont->lfCharSet == FX_CHARSET_ChineseSimplified || + pLogFont->lfCharSet == FX_CHARSET_Hangul || + pLogFont->lfCharSet == FX_CHARSET_ShiftJIS; CFX_ByteString basefont; if (bTranslateName && bCJK) basefont = FPDF_GetPSNameFromTT(hDC); @@ -1021,9 +1021,9 @@ CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTA* pLogFont, pBaseDict->SetNewFor<CPDF_Name>("Type", "Font"); CPDF_Dictionary* pFontDict = pBaseDict; if (!bCJK) { - if (pLogFont->lfCharSet == FXFONT_ANSI_CHARSET || - pLogFont->lfCharSet == FXFONT_DEFAULT_CHARSET || - pLogFont->lfCharSet == FXFONT_SYMBOL_CHARSET) { + if (pLogFont->lfCharSet == FX_CHARSET_ANSI || + pLogFont->lfCharSet == FX_CHARSET_Default || + pLogFont->lfCharSet == FX_CHARSET_Symbol) { pBaseDict->SetNewFor<CPDF_Name>("Encoding", "WinAnsiEncoding"); } else { CalculateEncodingDict(pLogFont->lfCharSet, pBaseDict); diff --git a/core/fpdfdoc/cpdf_interform.cpp b/core/fpdfdoc/cpdf_interform.cpp index ebe5079f3b..23102a20ad 100644 --- a/core/fpdfdoc/cpdf_interform.cpp +++ b/core/fpdfdoc/cpdf_interform.cpp @@ -20,6 +20,7 @@ #include "core/fpdfapi/parser/cpdf_string.h" #include "core/fpdfdoc/cpdf_filespec.h" #include "core/fpdfdoc/cpdf_formcontrol.h" +#include "core/fxcrt/fx_codepage.h" #include "core/fxge/cfx_substfont.h" #include "core/fxge/fx_font.h" #include "third_party/base/stl_util.h" @@ -75,7 +76,7 @@ void InitDict(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument) { if (pFont) AddFont(pFormDict, pDocument, pFont, &csBaseName); - if (charSet != FXFONT_ANSI_CHARSET) { + if (charSet != FX_CHARSET_ANSI) { CFX_ByteString csFontName = CPDF_InterForm::GetNativeFont(charSet, nullptr); if (!pFont || csFontName != "Helvetica") { @@ -571,56 +572,56 @@ CPDF_Font* AddNativeInterFormFont(CPDF_Dictionary*& pFormDict, // static uint8_t CPDF_InterForm::GetNativeCharSet() { #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ - uint8_t charSet = FXFONT_ANSI_CHARSET; + uint8_t charSet = FX_CHARSET_ANSI; UINT iCodePage = ::GetACP(); switch (iCodePage) { - case 932: - charSet = FXFONT_SHIFTJIS_CHARSET; + case FX_CODEPAGE_ShiftJIS: + charSet = FX_CHARSET_ShiftJIS; break; - case 936: - charSet = FXFONT_GB2312_CHARSET; + case FX_CODEPAGE_ChineseSimplified: + charSet = FX_CHARSET_ChineseSimplified; break; - case 950: - charSet = FXFONT_CHINESEBIG5_CHARSET; + case FX_CODEPAGE_ChineseTraditional: + charSet = FX_CHARSET_ChineseTraditional; break; - case 1252: - charSet = FXFONT_ANSI_CHARSET; + case FX_CODEPAGE_MSWin_WesternEuropean: + charSet = FX_CHARSET_ANSI; break; - case 874: - charSet = FXFONT_THAI_CHARSET; + case FX_CODEPAGE_MSDOS_Thai: + charSet = FX_CHARSET_Thai; break; - case 949: - charSet = FXFONT_HANGUL_CHARSET; + case FX_CODEPAGE_Hangul: + charSet = FX_CHARSET_Hangul; break; - case 1200: - charSet = FXFONT_ANSI_CHARSET; + case FX_CODEPAGE_UTF16LE: + charSet = FX_CHARSET_ANSI; break; - case 1250: - charSet = FXFONT_EASTEUROPE_CHARSET; + case FX_CODEPAGE_MSWin_EasternEuropean: + charSet = FX_CHARSET_MSWin_EasternEuropean; break; - case 1251: - charSet = FXFONT_RUSSIAN_CHARSET; + case FX_CODEPAGE_MSWin_Cyrillic: + charSet = FX_CHARSET_MSWin_Cyrillic; break; - case 1253: - charSet = FXFONT_GREEK_CHARSET; + case FX_CODEPAGE_MSWin_Greek: + charSet = FX_CHARSET_MSWin_Greek; break; - case 1254: - charSet = FXFONT_TURKISH_CHARSET; + case FX_CODEPAGE_MSWin_Turkish: + charSet = FX_CHARSET_MSWin_Turkish; break; - case 1255: - charSet = FXFONT_HEBREW_CHARSET; + case FX_CODEPAGE_MSWin_Hebrew: + charSet = FX_CHARSET_MSWin_Hebrew; break; - case 1256: - charSet = FXFONT_ARABIC_CHARSET; + case FX_CODEPAGE_MSWin_Arabic: + charSet = FX_CHARSET_MSWin_Arabic; break; - case 1257: - charSet = FXFONT_BALTIC_CHARSET; + case FX_CODEPAGE_MSWin_Baltic: + charSet = FX_CHARSET_MSWin_Baltic; break; - case 1258: - charSet = FXFONT_VIETNAMESE_CHARSET; + case FX_CODEPAGE_MSWin_Vietnamese: + charSet = FX_CHARSET_MSWin_Vietnamese; break; - case 1361: - charSet = FXFONT_JOHAB_CHARSET; + case FX_CODEPAGE_Johab: + charSet = FX_CHARSET_Johab; break; } return charSet; @@ -734,18 +735,18 @@ CFX_ByteString CPDF_InterForm::GetNativeFont(uint8_t charSet, void* pLogFont) { CFX_ByteString csFontName; #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ LOGFONTA lf = {}; - if (charSet == FXFONT_ANSI_CHARSET) { + if (charSet == FX_CHARSET_ANSI) { csFontName = "Helvetica"; return csFontName; } bool bRet = false; - if (charSet == FXFONT_SHIFTJIS_CHARSET) { + if (charSet == FX_CHARSET_ShiftJIS) { bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, "MS Mincho", lf); - } else if (charSet == FXFONT_GB2312_CHARSET) { + } else if (charSet == FX_CHARSET_ChineseSimplified) { bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, "SimSun", lf); - } else if (charSet == FXFONT_CHINESEBIG5_CHARSET) { + } else if (charSet == FX_CHARSET_ChineseTraditional) { bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, "MingLiU", lf); } diff --git a/core/fpdfdoc/cpdf_variabletext.cpp b/core/fpdfdoc/cpdf_variabletext.cpp index ab5c5e8050..1fc32946fc 100644 --- a/core/fpdfdoc/cpdf_variabletext.cpp +++ b/core/fpdfdoc/cpdf_variabletext.cpp @@ -16,6 +16,7 @@ #include "core/fpdfdoc/cpvt_wordinfo.h" #include "core/fpdfdoc/csection.h" #include "core/fpdfdoc/ipvt_fontmap.h" +#include "core/fxcrt/fx_codepage.h" #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" @@ -378,7 +379,7 @@ CPVT_WordPlace CPDF_VariableText::InsertText(const CPVT_WordPlace& place, case 0x09: word = 0x20; default: - wp = InsertWord(wp, word, FXFONT_DEFAULT_CHARSET, nullptr); + wp = InsertWord(wp, word, FX_CHARSET_Default, nullptr); break; } if (wp == oldwp) @@ -448,7 +449,7 @@ void CPDF_VariableText::SetText(const CFX_WideString& swText) { case 0x09: word = 0x20; default: - wp = InsertWord(wp, word, FXFONT_DEFAULT_CHARSET, nullptr); + wp = InsertWord(wp, word, FX_CHARSET_Default, nullptr); break; } nCharCount++; diff --git a/core/fpdfdoc/cpvt_fontmap.cpp b/core/fpdfdoc/cpvt_fontmap.cpp index 17ce673fde..42774d43d2 100644 --- a/core/fpdfdoc/cpvt_fontmap.cpp +++ b/core/fpdfdoc/cpvt_fontmap.cpp @@ -11,6 +11,7 @@ #include "core/fpdfapi/parser/cpdf_document.h" #include "core/fpdfapi/parser/cpdf_reference.h" #include "core/fpdfdoc/cpdf_interform.h" +#include "core/fxcrt/fx_codepage.h" CPVT_FontMap::CPVT_FontMap(CPDF_Document* pDoc, CPDF_Dictionary* pResDict, @@ -88,5 +89,5 @@ int32_t CPVT_FontMap::CharCodeFromUnicode(int32_t nFontIndex, uint16_t word) { int32_t CPVT_FontMap::CharSetFromUnicode(uint16_t word, int32_t nOldCharset) { ASSERT(false); - return FXFONT_ANSI_CHARSET; + return FX_CHARSET_ANSI; } diff --git a/core/fpdfdoc/cpvt_wordinfo.cpp b/core/fpdfdoc/cpvt_wordinfo.cpp index f1ea11915c..36859c2309 100644 --- a/core/fpdfdoc/cpvt_wordinfo.cpp +++ b/core/fpdfdoc/cpvt_wordinfo.cpp @@ -5,11 +5,12 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "core/fpdfdoc/cpvt_wordinfo.h" +#include "core/fxcrt/fx_codepage.h" #include "third_party/base/ptr_util.h" CPVT_WordInfo::CPVT_WordInfo() : Word(0), - nCharset(FXFONT_ANSI_CHARSET), + nCharset(FX_CHARSET_ANSI), fWordX(0.0f), fWordY(0.0f), fWordTail(0.0f), @@ -28,7 +29,7 @@ CPVT_WordInfo::CPVT_WordInfo(uint16_t word, CPVT_WordInfo::CPVT_WordInfo(const CPVT_WordInfo& word) : Word(0), - nCharset(FXFONT_ANSI_CHARSET), + nCharset(FX_CHARSET_ANSI), fWordX(0.0f), fWordY(0.0f), fWordTail(0.0f), diff --git a/core/fxcrt/fx_codepage.h b/core/fxcrt/fx_codepage.h index db8655dbf6..874f96db7f 100644 --- a/core/fxcrt/fx_codepage.h +++ b/core/fxcrt/fx_codepage.h @@ -7,28 +7,16 @@ #ifndef CORE_FXCRT_FX_CODEPAGE_H_ #define CORE_FXCRT_FX_CODEPAGE_H_ -#include "core/fxcrt/fx_basic.h" - #define FX_CODEPAGE_DefANSI 0 -#define FX_CODEPAGE_DefOEM 1 -#define FX_CODEPAGE_DefMAC 2 -#define FX_CODEPAGE_Thread 3 #define FX_CODEPAGE_Symbol 42 #define FX_CODEPAGE_MSDOS_US 437 #define FX_CODEPAGE_Arabic_ASMO708 708 -#define FX_CODEPAGE_Arabic_ASMO449Plus 709 -#define FX_CODEPAGE_Arabic_Transparent 710 -#define FX_CODEPAGE_Arabic_NafithaEnhanced 711 -#define FX_CODEPAGE_Arabic_TransparentASMO 720 #define FX_CODEPAGE_MSDOS_Greek1 737 #define FX_CODEPAGE_MSDOS_Baltic 775 -#define FX_CODEPAGE_MSWin31_WesternEuropean 819 #define FX_CODEPAGE_MSDOS_WesternEuropean 850 #define FX_CODEPAGE_MSDOS_EasternEuropean 852 -#define FX_CODEPAGE_MSDOS_Latin3 853 #define FX_CODEPAGE_MSDOS_Cyrillic 855 #define FX_CODEPAGE_MSDOS_Turkish 857 -#define FX_CODEPAGE_MSDOS_Latin1Euro 858 #define FX_CODEPAGE_MSDOS_Portuguese 860 #define FX_CODEPAGE_MSDOS_Icelandic 861 #define FX_CODEPAGE_MSDOS_Hebrew 862 @@ -38,10 +26,9 @@ #define FX_CODEPAGE_MSDOS_Russian 866 #define FX_CODEPAGE_MSDOS_Greek2 869 #define FX_CODEPAGE_MSDOS_Thai 874 -#define FX_CODEPAGE_MSDOS_KamenickyCS 895 #define FX_CODEPAGE_ShiftJIS 932 #define FX_CODEPAGE_ChineseSimplified 936 -#define FX_CODEPAGE_Korean 949 +#define FX_CODEPAGE_Hangul 949 #define FX_CODEPAGE_ChineseTraditional 950 #define FX_CODEPAGE_UTF16LE 1200 #define FX_CODEPAGE_UTF16BE 1201 @@ -67,35 +54,6 @@ #define FX_CODEPAGE_MAC_Thai 10021 #define FX_CODEPAGE_MAC_EasternEuropean 10029 #define FX_CODEPAGE_MAC_Turkish 10081 -#define FX_CODEPAGE_UTF32LE 12000 -#define FX_CODEPAGE_UTF32BE 12001 -#define FX_CODEPAGE_ISO8859_1 28591 -#define FX_CODEPAGE_ISO8859_2 28592 -#define FX_CODEPAGE_ISO8859_3 28593 -#define FX_CODEPAGE_ISO8859_4 28594 -#define FX_CODEPAGE_ISO8859_5 28595 -#define FX_CODEPAGE_ISO8859_6 28596 -#define FX_CODEPAGE_ISO8859_7 28597 -#define FX_CODEPAGE_ISO8859_8 28598 -#define FX_CODEPAGE_ISO8859_9 28599 -#define FX_CODEPAGE_ISO8859_10 28600 -#define FX_CODEPAGE_ISO8859_11 28601 -#define FX_CODEPAGE_ISO8859_12 28602 -#define FX_CODEPAGE_ISO8859_13 28603 -#define FX_CODEPAGE_ISO8859_14 28604 -#define FX_CODEPAGE_ISO8859_15 28605 -#define FX_CODEPAGE_ISO8859_16 28606 -#define FX_CODEPAGE_ISCII_Devanagari 57002 -#define FX_CODEPAGE_ISCII_Bengali 57003 -#define FX_CODEPAGE_ISCII_Tamil 57004 -#define FX_CODEPAGE_ISCII_Telugu 57005 -#define FX_CODEPAGE_ISCII_Assamese 57006 -#define FX_CODEPAGE_ISCII_Oriya 57007 -#define FX_CODEPAGE_ISCII_Kannada 57008 -#define FX_CODEPAGE_ISCII_Malayalam 57009 -#define FX_CODEPAGE_ISCII_Gujarati 57010 -#define FX_CODEPAGE_ISCII_Punjabi 57011 -#define FX_CODEPAGE_UTF7 65000 #define FX_CODEPAGE_UTF8 65001 #define FX_CHARSET_ANSI 0 @@ -105,8 +63,7 @@ #define FX_CHARSET_MAC_ShiftJIS 78 #define FX_CHARSET_MAC_Korean 79 #define FX_CHARSET_MAC_ChineseSimplified 80 -#define FX_CHARSET_MAC_ChineseTriditional 81 -#define FX_CHARSET_MAC_Johab 82 +#define FX_CHARSET_MAC_ChineseTraditional 81 #define FX_CHARSET_MAC_Hebrew 83 #define FX_CHARSET_MAC_Arabic 84 #define FX_CHARSET_MAC_Greek 85 @@ -115,22 +72,19 @@ #define FX_CHARSET_MAC_EasternEuropean 88 #define FX_CHARSET_MAC_Cyrillic 89 #define FX_CHARSET_ShiftJIS 128 -#define FX_CHARSET_Korean 129 +#define FX_CHARSET_Hangul 129 #define FX_CHARSET_Johab 130 #define FX_CHARSET_ChineseSimplified 134 -#define FX_CHARSET_ChineseTriditional 136 +#define FX_CHARSET_ChineseTraditional 136 #define FX_CHARSET_MSWin_Greek 161 #define FX_CHARSET_MSWin_Turkish 162 #define FX_CHARSET_MSWin_Vietnamese 163 #define FX_CHARSET_MSWin_Hebrew 177 #define FX_CHARSET_MSWin_Arabic 178 -#define FX_CHARSET_ArabicTraditional 179 -#define FX_CHARSET_ArabicUser 180 -#define FX_CHARSET_HebrewUser 181 #define FX_CHARSET_MSWin_Baltic 186 #define FX_CHARSET_MSWin_Cyrillic 204 #define FX_CHARSET_Thai 222 -#define FX_CHARSET_MSWin_EasterEuropean 238 +#define FX_CHARSET_MSWin_EasternEuropean 238 #define FX_CHARSET_US 254 #define FX_CHARSET_OEM 255 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 <algorithm> +#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 <memory> +#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 <limits> #include <memory> +#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<signed long> 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 <limits> +#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 <vector> #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<uint32_t>(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 <utility> #include <vector> +#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 <memory> +#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 { |