diff options
30 files changed, 297 insertions, 333 deletions
@@ -772,6 +772,7 @@ static_library("fxcrt") { "core/fxcrt/fx_basic_util.cpp", "core/fxcrt/fx_bidi.cpp", "core/fxcrt/fx_bidi.h", + "core/fxcrt/fx_codepage.h", "core/fxcrt/fx_coordinates.h", "core/fxcrt/fx_ext.h", "core/fxcrt/fx_extension.cpp", @@ -830,7 +831,6 @@ static_library("fxcrt") { "core/fxcrt/cfx_wordbreak.h", "core/fxcrt/fx_arabic.cpp", "core/fxcrt/fx_arabic.h", - "core/fxcrt/fx_codepage.h", "core/fxcrt/ifx_chariter.h", "core/fxcrt/ifx_locale.h", "core/fxcrt/xml/cfx_saxcontext.h", 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 { diff --git a/fpdfsdk/cfx_systemhandler.cpp b/fpdfsdk/cfx_systemhandler.cpp index 906954354b..277e34b18c 100644 --- a/fpdfsdk/cfx_systemhandler.cpp +++ b/fpdfsdk/cfx_systemhandler.cpp @@ -9,6 +9,7 @@ #include <memory> #include "core/fpdfapi/parser/cpdf_document.h" +#include "core/fxcrt/fx_codepage.h" #include "core/fxge/cfx_fontmapper.h" #include "core/fxge/cfx_fontmgr.h" #include "core/fxge/cfx_gemodule.h" @@ -21,15 +22,15 @@ namespace { int CharSet2CP(int charset) { - if (charset == FXFONT_SHIFTJIS_CHARSET) - return 932; - if (charset == FXFONT_GB2312_CHARSET) - return 936; - if (charset == FXFONT_HANGUL_CHARSET) - return 949; - if (charset == FXFONT_CHINESEBIG5_CHARSET) - return 950; - return 0; + if (charset == FX_CHARSET_ShiftJIS) + return FX_CODEPAGE_ShiftJIS; + if (charset == FX_CHARSET_ChineseSimplified) + return FX_CODEPAGE_ChineseSimplified; + if (charset == FX_CHARSET_Hangul) + return FX_CODEPAGE_Hangul; + if (charset == FX_CHARSET_ChineseTraditional) + return FX_CODEPAGE_ChineseTraditional; + return FX_CODEPAGE_DefANSI; } } // namespace diff --git a/fpdfsdk/formfiller/cba_fontmap.cpp b/fpdfsdk/formfiller/cba_fontmap.cpp index 1c380e59c1..30f25d49cc 100644 --- a/fpdfsdk/formfiller/cba_fontmap.cpp +++ b/fpdfsdk/formfiller/cba_fontmap.cpp @@ -42,7 +42,7 @@ void CBA_FontMap::Reset() { } void CBA_FontMap::Initialize() { - int32_t nCharset = FXFONT_DEFAULT_CHARSET; + int32_t nCharset = FX_CHARSET_Default; if (!m_pDefaultFont) { m_pDefaultFont = GetAnnotDefaultFont(&m_sDefaultFontName); @@ -54,16 +54,16 @@ void CBA_FontMap::Initialize() { m_sDefaultFontName == "Wingdings2" || m_sDefaultFontName == "Wingdings3" || m_sDefaultFontName == "Webdings") - nCharset = FXFONT_SYMBOL_CHARSET; + nCharset = FX_CHARSET_Symbol; else - nCharset = FXFONT_ANSI_CHARSET; + nCharset = FX_CHARSET_ANSI; } AddFontData(m_pDefaultFont, m_sDefaultFontName, nCharset); AddFontToAnnotDict(m_pDefaultFont, m_sDefaultFontName); } } - if (nCharset != FXFONT_ANSI_CHARSET) + if (nCharset != FX_CHARSET_ANSI) CPWL_FontMap::Initialize(); } @@ -77,7 +77,7 @@ void CBA_FontMap::SetDefaultFont(CPDF_Font* pFont, m_pDefaultFont = pFont; m_sDefaultFontName = sFontName; - int32_t nCharset = FXFONT_DEFAULT_CHARSET; + int32_t nCharset = FX_CHARSET_Default; if (const CFX_SubstFont* pSubstFont = m_pDefaultFont->GetSubstFont()) nCharset = pSubstFont->m_Charset; AddFontData(m_pDefaultFont, m_sDefaultFontName, nCharset); diff --git a/fpdfsdk/formfiller/cffl_combobox.cpp b/fpdfsdk/formfiller/cffl_combobox.cpp index 7a6d497ad2..ef05a883c9 100644 --- a/fpdfsdk/formfiller/cffl_combobox.cpp +++ b/fpdfsdk/formfiller/cffl_combobox.cpp @@ -267,7 +267,7 @@ void CFFL_ComboBox::OnSetFocus(CPWL_Wnd* pWnd) { return; CPWL_Edit* pEdit = (CPWL_Edit*)pWnd; - pEdit->SetCharSet(FXFONT_GB2312_CHARSET); + pEdit->SetCharSet(FX_CHARSET_ChineseSimplified); pEdit->SetReadyToInput(); CFX_WideString wsText = pEdit->GetText(); diff --git a/fpdfsdk/formfiller/cffl_textfield.cpp b/fpdfsdk/formfiller/cffl_textfield.cpp index 19a87d04ae..71fc9291dc 100644 --- a/fpdfsdk/formfiller/cffl_textfield.cpp +++ b/fpdfsdk/formfiller/cffl_textfield.cpp @@ -275,7 +275,7 @@ void CFFL_TextField::OnSetFocus(CPWL_Wnd* pWnd) { return; CPWL_Edit* pEdit = (CPWL_Edit*)pWnd; - pEdit->SetCharSet(FXFONT_GB2312_CHARSET); + pEdit->SetCharSet(FX_CHARSET_ChineseSimplified); pEdit->SetReadyToInput(); CFX_WideString wsText = pEdit->GetText(); diff --git a/fpdfsdk/fpdf_sysfontinfo.cpp b/fpdfsdk/fpdf_sysfontinfo.cpp index 6939eba14d..32e573611b 100644 --- a/fpdfsdk/fpdf_sysfontinfo.cpp +++ b/fpdfsdk/fpdf_sysfontinfo.cpp @@ -8,6 +8,7 @@ #include <memory> +#include "core/fxcrt/fx_codepage.h" #include "core/fxge/cfx_fontmapper.h" #include "core/fxge/cfx_gemodule.h" #include "core/fxge/fx_font.h" @@ -15,6 +16,19 @@ #include "fpdfsdk/fsdk_define.h" #include "fpdfsdk/pdfwindow/PWL_FontMap.h" +static_assert(FXFONT_ANSI_CHARSET == FX_CHARSET_ANSI, "Charset must match"); +static_assert(FXFONT_DEFAULT_CHARSET == FX_CHARSET_Default, + "Charset must match"); +static_assert(FXFONT_SYMBOL_CHARSET == FX_CHARSET_Symbol, "Charset must match"); +static_assert(FXFONT_SHIFTJIS_CHARSET == FX_CHARSET_ShiftJIS, + "Charset must match"); +static_assert(FXFONT_HANGEUL_CHARSET == FX_CHARSET_Hangul, + "Charset must match"); +static_assert(FXFONT_GB2312_CHARSET == FX_CHARSET_ChineseSimplified, + "Charset must match"); +static_assert(FXFONT_CHINESEBIG5_CHARSET == FX_CHARSET_ChineseTraditional, + "Charset must match"); + class CFX_ExternalFontInfo final : public IFX_SystemFontInfo { public: explicit CFX_ExternalFontInfo(FPDF_SYSFONTINFO* pInfo) : m_pInfo(pInfo) {} diff --git a/fpdfsdk/fxedit/fxet_edit.cpp b/fpdfsdk/fxedit/fxet_edit.cpp index 7e2cf04b3f..5b84c9b95e 100644 --- a/fpdfsdk/fxedit/fxet_edit.cpp +++ b/fpdfsdk/fxedit/fxet_edit.cpp @@ -21,6 +21,7 @@ #include "core/fpdfdoc/cpvt_section.h" #include "core/fpdfdoc/cpvt_word.h" #include "core/fpdfdoc/ipvt_fontmap.h" +#include "core/fxcrt/fx_codepage.h" #include "core/fxge/cfx_graphstatedata.h" #include "core/fxge/cfx_pathdata.h" #include "core/fxge/cfx_renderdevice.h" @@ -476,7 +477,7 @@ void CFXEU_Clear::Undo() { if (m_pEdit) { m_pEdit->SelectNone(); m_pEdit->SetCaret(m_wrSel.BeginPos); - m_pEdit->InsertText(m_swText, FXFONT_DEFAULT_CHARSET, false, true); + m_pEdit->InsertText(m_swText, FX_CHARSET_Default, false, true); m_pEdit->SetSel(m_wrSel.BeginPos, m_wrSel.EndPos); } } @@ -1027,7 +1028,7 @@ CPVT_WordRange CFX_Edit::GetSelectWordRange() const { void CFX_Edit::SetText(const CFX_WideString& sText) { Empty(); - DoInsertText(CPVT_WordPlace(0, 0, -1), sText, FXFONT_DEFAULT_CHARSET); + DoInsertText(CPVT_WordPlace(0, 0, -1), sText, FX_CHARSET_Default); Paint(); } diff --git a/fpdfsdk/pdfwindow/PWL_Edit.cpp b/fpdfsdk/pdfwindow/PWL_Edit.cpp index 1212d7f853..b1285a8428 100644 --- a/fpdfsdk/pdfwindow/PWL_Edit.cpp +++ b/fpdfsdk/pdfwindow/PWL_Edit.cpp @@ -460,7 +460,7 @@ void CPWL_Edit::OnKillFocus() { ShowVScrollBar(false); m_pEdit->SelectNone(); SetCaret(false, CFX_PointF(), CFX_PointF()); - SetCharSet(FXFONT_ANSI_CHARSET); + SetCharSet(FX_CHARSET_ANSI); m_bFocus = false; } @@ -569,7 +569,7 @@ void CPWL_Edit::SetLimitChar(int32_t nLimitChar) { void CPWL_Edit::ReplaceSel(const CFX_WideString& wsText) { m_pEdit->Clear(); - m_pEdit->InsertText(wsText, FXFONT_DEFAULT_CHARSET); + m_pEdit->InsertText(wsText, FX_CHARSET_Default); } CFX_FloatRect CPWL_Edit::GetFocusRect() const { @@ -714,7 +714,7 @@ bool CPWL_Edit::OnChar(uint16_t nChar, uint32_t nFlag) { if (IPVT_FontMap* pFontMap = GetFontMap()) { int32_t nOldCharSet = GetCharSet(); int32_t nNewCharSet = - pFontMap->CharSetFromUnicode(nChar, FXFONT_DEFAULT_CHARSET); + pFontMap->CharSetFromUnicode(nChar, FX_CHARSET_Default); if (nOldCharSet != nNewCharSet) { SetCharSet(nNewCharSet); } diff --git a/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp b/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp index 19daae1413..c149e80f14 100644 --- a/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp +++ b/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp @@ -21,7 +21,7 @@ CPWL_EditCtrl::CPWL_EditCtrl() : m_pEdit(new CFX_Edit), m_pEditCaret(nullptr), m_bMouseDown(false), - m_nCharSet(FXFONT_DEFAULT_CHARSET) {} + m_nCharSet(FX_CHARSET_Default) {} CPWL_EditCtrl::~CPWL_EditCtrl() {} @@ -472,7 +472,7 @@ void CPWL_EditCtrl::IOnInvalidateRect(CFX_FloatRect* pRect) { } int32_t CPWL_EditCtrl::GetCharSet() const { - return m_nCharSet < 0 ? FXFONT_DEFAULT_CHARSET : m_nCharSet; + return m_nCharSet < 0 ? FX_CHARSET_Default : m_nCharSet; } void CPWL_EditCtrl::SetReadyToInput() { diff --git a/fpdfsdk/pdfwindow/PWL_FontMap.cpp b/fpdfsdk/pdfwindow/PWL_FontMap.cpp index ddf496fbb0..c981f18705 100644 --- a/fpdfsdk/pdfwindow/PWL_FontMap.cpp +++ b/fpdfsdk/pdfwindow/PWL_FontMap.cpp @@ -14,6 +14,7 @@ #include "core/fpdfapi/parser/cpdf_document.h" #include "core/fpdfapi/parser/cpdf_parser.h" #include "core/fpdfdoc/ipvt_fontmap.h" +#include "core/fxcrt/fx_codepage.h" #include "fpdfsdk/pdfwindow/PWL_Wnd.h" #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" @@ -85,9 +86,8 @@ int32_t CPWL_FontMap::GetWordFontIndex(uint16_t word, return nFontIndex; } else { if (const CPWL_FontMap_Data* pData = GetFontMapData(0)) { - if (nCharset == FXFONT_DEFAULT_CHARSET || - pData->nCharset == FXFONT_SYMBOL_CHARSET || - nCharset == pData->nCharset) { + if (nCharset == FX_CHARSET_Default || + pData->nCharset == FX_CHARSET_Symbol || nCharset == pData->nCharset) { if (KnowWord(0, word)) return 0; } @@ -100,8 +100,7 @@ int32_t CPWL_FontMap::GetWordFontIndex(uint16_t word, if (KnowWord(nNewFontIndex, word)) return nNewFontIndex; } - nNewFontIndex = - GetFontIndex("Arial Unicode MS", FXFONT_DEFAULT_CHARSET, false); + nNewFontIndex = GetFontIndex("Arial Unicode MS", FX_CHARSET_Default, false); if (nNewFontIndex >= 0) { if (KnowWord(nNewFontIndex, word)) return nNewFontIndex; @@ -146,7 +145,7 @@ void CPWL_FontMap::Empty() { } void CPWL_FontMap::Initialize() { - GetFontIndex(kDefaultFontName, FXFONT_ANSI_CHARSET, false); + GetFontIndex(kDefaultFontName, FX_CHARSET_ANSI, false); } bool CPWL_FontMap::IsStandardFont(const CFX_ByteString& sFontName) { @@ -163,7 +162,7 @@ int32_t CPWL_FontMap::FindFont(const CFX_ByteString& sFontName, int32_t i = 0; for (const auto& pData : m_Data) { if (pData && - (nCharset == FXFONT_DEFAULT_CHARSET || nCharset == pData->nCharset) && + (nCharset == FX_CHARSET_Default || nCharset == pData->nCharset) && (sFontName.IsEmpty() || pData->sFontName == sFontName)) { return i; } @@ -210,7 +209,7 @@ void CPWL_FontMap::AddedFont(CPDF_Font* pFont, const CFX_ByteString& sFontAlias) {} CFX_ByteString CPWL_FontMap::GetNativeFont(int32_t nCharset) { - if (nCharset == FXFONT_DEFAULT_CHARSET) + if (nCharset == FX_CHARSET_Default) nCharset = GetNativeCharset(); CFX_ByteString sFontName = GetDefaultFontByCharset(nCharset); @@ -254,7 +253,7 @@ CPDF_Font* CPWL_FontMap::AddSystemFont(CPDF_Document* pDoc, if (sFontName.IsEmpty()) sFontName = GetNativeFont(nCharset); - if (nCharset == FXFONT_DEFAULT_CHARSET) + if (nCharset == FX_CHARSET_Default) nCharset = GetNativeCharset(); return m_pSystemHandler->AddNativeTrueTypeFontToPDF(pDoc, sFontName, @@ -279,75 +278,75 @@ const CPWL_FontMap_Data* CPWL_FontMap::GetFontMapData(int32_t nIndex) const { } int32_t CPWL_FontMap::GetNativeCharset() { - uint8_t nCharset = FXFONT_ANSI_CHARSET; + uint8_t nCharset = FX_CHARSET_ANSI; int32_t iCodePage = FXSYS_GetACP(); switch (iCodePage) { - case 932: // Japan - nCharset = FXFONT_SHIFTJIS_CHARSET; + case FX_CODEPAGE_ShiftJIS: + nCharset = FX_CHARSET_ShiftJIS; break; - case 936: // Chinese (PRC, Singapore) - nCharset = FXFONT_GB2312_CHARSET; + case FX_CODEPAGE_ChineseSimplified: + nCharset = FX_CHARSET_ChineseSimplified; break; - case 950: // Chinese (Taiwan; Hong Kong SAR, PRC) - nCharset = FXFONT_GB2312_CHARSET; + case FX_CODEPAGE_ChineseTraditional: + nCharset = FX_CHARSET_ChineseTraditional; break; - case 1252: // Windows 3.1 Latin 1 (US, Western Europe) - nCharset = FXFONT_ANSI_CHARSET; + case FX_CODEPAGE_MSWin_WesternEuropean: + nCharset = FX_CHARSET_ANSI; break; - case 874: // Thai - nCharset = FXFONT_THAI_CHARSET; + case FX_CODEPAGE_MSDOS_Thai: + nCharset = FX_CHARSET_Thai; break; - case 949: // Korean - nCharset = FXFONT_HANGUL_CHARSET; + case FX_CODEPAGE_Hangul: + nCharset = FX_CHARSET_Hangul; break; - case 1200: // Unicode (BMP of ISO 10646) - nCharset = FXFONT_ANSI_CHARSET; + case FX_CODEPAGE_UTF16LE: + nCharset = FX_CHARSET_ANSI; break; - case 1250: // Windows 3.1 Eastern European - nCharset = FXFONT_EASTEUROPE_CHARSET; + case FX_CODEPAGE_MSWin_EasternEuropean: + nCharset = FX_CHARSET_MSWin_EasternEuropean; break; - case 1251: // Windows 3.1 Cyrillic - nCharset = FXFONT_RUSSIAN_CHARSET; + case FX_CODEPAGE_MSWin_Cyrillic: + nCharset = FX_CHARSET_MSWin_Cyrillic; break; - case 1253: // Windows 3.1 Greek - nCharset = FXFONT_GREEK_CHARSET; + case FX_CODEPAGE_MSWin_Greek: + nCharset = FX_CHARSET_MSWin_Greek; break; - case 1254: // Windows 3.1 Turkish - nCharset = FXFONT_TURKISH_CHARSET; + case FX_CODEPAGE_MSWin_Turkish: + nCharset = FX_CHARSET_MSWin_Turkish; break; - case 1255: // Hebrew - nCharset = FXFONT_HEBREW_CHARSET; + case FX_CODEPAGE_MSWin_Hebrew: + nCharset = FX_CHARSET_MSWin_Hebrew; break; - case 1256: // Arabic - nCharset = FXFONT_ARABIC_CHARSET; + case FX_CODEPAGE_MSWin_Arabic: + nCharset = FX_CHARSET_MSWin_Arabic; break; - case 1257: // Baltic - nCharset = FXFONT_BALTIC_CHARSET; + case FX_CODEPAGE_MSWin_Baltic: + nCharset = FX_CHARSET_MSWin_Baltic; break; - case 1258: // Vietnamese - nCharset = FXFONT_VIETNAMESE_CHARSET; + case FX_CODEPAGE_MSWin_Vietnamese: + nCharset = FX_CHARSET_MSWin_Vietnamese; break; - case 1361: // Korean(Johab) - nCharset = FXFONT_JOHAB_CHARSET; + case FX_CODEPAGE_Johab: + nCharset = FX_CHARSET_Johab; break; } return nCharset; } const FPDF_CharsetFontMap CPWL_FontMap::defaultTTFMap[] = { - {FXFONT_ANSI_CHARSET, "Helvetica"}, - {FXFONT_GB2312_CHARSET, "SimSun"}, - {FXFONT_CHINESEBIG5_CHARSET, "MingLiU"}, - {FXFONT_SHIFTJIS_CHARSET, "MS Gothic"}, - {FXFONT_HANGUL_CHARSET, "Batang"}, - {FXFONT_RUSSIAN_CHARSET, "Arial"}, + {FX_CHARSET_ANSI, "Helvetica"}, + {FX_CHARSET_ChineseSimplified, "SimSun"}, + {FX_CHARSET_ChineseTraditional, "MingLiU"}, + {FX_CHARSET_ShiftJIS, "MS Gothic"}, + {FX_CHARSET_Hangul, "Batang"}, + {FX_CHARSET_MSWin_Cyrillic, "Arial"}, #if _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ || \ _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ - {FXFONT_EASTEUROPE_CHARSET, "Arial"}, + {FX_CHARSET_MSWin_EasternEuropean, "Arial"}, #else - {FXFONT_EASTEUROPE_CHARSET, "Tahoma"}, + {FX_CHARSET_MSWin_EasternEuropean, "Tahoma"}, #endif - {FXFONT_ARABIC_CHARSET, "Arial"}, + {FX_CHARSET_MSWin_Arabic, "Arial"}, {-1, nullptr}}; CFX_ByteString CPWL_FontMap::GetDefaultFontByCharset(int32_t nCharset) { @@ -363,9 +362,9 @@ CFX_ByteString CPWL_FontMap::GetDefaultFontByCharset(int32_t nCharset) { int32_t CPWL_FontMap::CharSetFromUnicode(uint16_t word, int32_t nOldCharset) { // to avoid CJK Font to show ASCII if (word < 0x7F) - return FXFONT_ANSI_CHARSET; + return FX_CHARSET_ANSI; // follow the old charset - if (nOldCharset != FXFONT_DEFAULT_CHARSET) + if (nOldCharset != FX_CHARSET_Default) return nOldCharset; // find new charset @@ -373,42 +372,42 @@ int32_t CPWL_FontMap::CharSetFromUnicode(uint16_t word, int32_t nOldCharset) { (word >= 0xE7C7 && word <= 0xE7F3) || (word >= 0x3000 && word <= 0x303F) || (word >= 0x2000 && word <= 0x206F)) { - return FXFONT_GB2312_CHARSET; + return FX_CHARSET_ChineseSimplified; } if (((word >= 0x3040) && (word <= 0x309F)) || ((word >= 0x30A0) && (word <= 0x30FF)) || ((word >= 0x31F0) && (word <= 0x31FF)) || ((word >= 0xFF00) && (word <= 0xFFEF))) { - return FXFONT_SHIFTJIS_CHARSET; + return FX_CHARSET_ShiftJIS; } if (((word >= 0xAC00) && (word <= 0xD7AF)) || ((word >= 0x1100) && (word <= 0x11FF)) || ((word >= 0x3130) && (word <= 0x318F))) { - return FXFONT_HANGUL_CHARSET; + return FX_CHARSET_Hangul; } if (word >= 0x0E00 && word <= 0x0E7F) - return FXFONT_THAI_CHARSET; + return FX_CHARSET_Thai; if ((word >= 0x0370 && word <= 0x03FF) || (word >= 0x1F00 && word <= 0x1FFF)) - return FXFONT_GREEK_CHARSET; + return FX_CHARSET_MSWin_Greek; if ((word >= 0x0600 && word <= 0x06FF) || (word >= 0xFB50 && word <= 0xFEFC)) - return FXFONT_ARABIC_CHARSET; + return FX_CHARSET_MSWin_Arabic; if (word >= 0x0590 && word <= 0x05FF) - return FXFONT_HEBREW_CHARSET; + return FX_CHARSET_MSWin_Hebrew; if (word >= 0x0400 && word <= 0x04FF) - return FXFONT_RUSSIAN_CHARSET; + return FX_CHARSET_MSWin_Cyrillic; if (word >= 0x0100 && word <= 0x024F) - return FXFONT_EASTEUROPE_CHARSET; + return FX_CHARSET_MSWin_EasternEuropean; if (word >= 0x1E00 && word <= 0x1EFF) - return FXFONT_VIETNAMESE_CHARSET; + return FX_CHARSET_MSWin_Vietnamese; - return FXFONT_ANSI_CHARSET; + return FX_CHARSET_ANSI; } diff --git a/fpdfsdk/pdfwindow/PWL_FontMap.h b/fpdfsdk/pdfwindow/PWL_FontMap.h index 21535305ae..2a532197cb 100644 --- a/fpdfsdk/pdfwindow/PWL_FontMap.h +++ b/fpdfsdk/pdfwindow/PWL_FontMap.h @@ -11,6 +11,7 @@ #include <vector> #include "core/fpdfdoc/ipvt_fontmap.h" +#include "core/fxcrt/fx_codepage.h" #include "core/fxge/fx_font.h" #include "fpdfsdk/fxedit/fx_edit.h" #include "public/fpdf_sysfontinfo.h" @@ -65,7 +66,7 @@ class CPWL_FontMap : public IPVT_FontMap { bool bFind); int32_t AddFontData(CPDF_Font* pFont, const CFX_ByteString& sFontAlias, - int32_t nCharset = FXFONT_DEFAULT_CHARSET); + int32_t nCharset = FX_CHARSET_Default); CFX_ByteString EncodeFontAlias(const CFX_ByteString& sFontName, int32_t nCharset); @@ -76,7 +77,7 @@ class CPWL_FontMap : public IPVT_FontMap { private: int32_t FindFont(const CFX_ByteString& sFontName, - int32_t nCharset = FXFONT_DEFAULT_CHARSET); + int32_t nCharset = FX_CHARSET_Default); CFX_ByteString GetNativeFont(int32_t nCharset); CPDF_Font* AddFontToDocument(CPDF_Document* pDoc, diff --git a/xfa/fgas/font/cfgas_fontmgr.cpp b/xfa/fgas/font/cfgas_fontmgr.cpp index d1c4b3d580..e0b71118d9 100644 --- a/xfa/fgas/font/cfgas_fontmgr.cpp +++ b/xfa/fgas/font/cfgas_fontmgr.cpp @@ -38,7 +38,7 @@ const FX_CHARSET_MAP g_FXCharset2CodePageTable[] = { {FX_CHARSET_MAC_ShiftJIS, FX_CODEPAGE_MAC_ShiftJIS}, {FX_CHARSET_MAC_Korean, FX_CODEPAGE_MAC_Korean}, {FX_CHARSET_MAC_ChineseSimplified, FX_CODEPAGE_MAC_ChineseSimplified}, - {FX_CHARSET_MAC_ChineseTriditional, FX_CODEPAGE_MAC_ChineseTraditional}, + {FX_CHARSET_MAC_ChineseTraditional, FX_CODEPAGE_MAC_ChineseTraditional}, {FX_CHARSET_MAC_Hebrew, FX_CODEPAGE_MAC_Hebrew}, {FX_CHARSET_MAC_Arabic, FX_CODEPAGE_MAC_Arabic}, {FX_CHARSET_MAC_Greek, FX_CODEPAGE_MAC_Greek}, @@ -47,10 +47,10 @@ const FX_CHARSET_MAP g_FXCharset2CodePageTable[] = { {FX_CHARSET_MAC_EasternEuropean, FX_CODEPAGE_MAC_EasternEuropean}, {FX_CHARSET_MAC_Cyrillic, FX_CODEPAGE_MAC_Cyrillic}, {FX_CHARSET_ShiftJIS, FX_CODEPAGE_ShiftJIS}, - {FX_CHARSET_Korean, FX_CODEPAGE_Korean}, + {FX_CHARSET_Hangul, FX_CODEPAGE_Hangul}, {FX_CHARSET_Johab, FX_CODEPAGE_Johab}, {FX_CHARSET_ChineseSimplified, FX_CODEPAGE_ChineseSimplified}, - {FX_CHARSET_ChineseTriditional, FX_CODEPAGE_ChineseTraditional}, + {FX_CHARSET_ChineseTraditional, FX_CODEPAGE_ChineseTraditional}, {FX_CHARSET_MSWin_Greek, FX_CODEPAGE_MSWin_Greek}, {FX_CHARSET_MSWin_Turkish, FX_CODEPAGE_MSWin_Turkish}, {FX_CHARSET_MSWin_Vietnamese, FX_CODEPAGE_MSWin_Vietnamese}, @@ -59,7 +59,7 @@ const FX_CHARSET_MAP g_FXCharset2CodePageTable[] = { {FX_CHARSET_MSWin_Baltic, FX_CODEPAGE_MSWin_Baltic}, {FX_CHARSET_MSWin_Cyrillic, FX_CODEPAGE_MSWin_Cyrillic}, {FX_CHARSET_Thai, FX_CODEPAGE_MSDOS_Thai}, - {FX_CHARSET_MSWin_EasterEuropean, FX_CODEPAGE_MSWin_EasternEuropean}, + {FX_CHARSET_MSWin_EasternEuropean, FX_CODEPAGE_MSWin_EasternEuropean}, {FX_CHARSET_US, FX_CODEPAGE_MSDOS_US}, {FX_CHARSET_OEM, FX_CODEPAGE_MSDOS_WesternEuropean}, }; @@ -473,7 +473,7 @@ const uint16_t g_CodePages[] = {FX_CODEPAGE_MSWin_WesternEuropean, FX_CODEPAGE_MSDOS_Thai, FX_CODEPAGE_ShiftJIS, FX_CODEPAGE_ChineseSimplified, - FX_CODEPAGE_Korean, + FX_CODEPAGE_Hangul, FX_CODEPAGE_ChineseTraditional, FX_CODEPAGE_Johab, FX_CODEPAGE_DefANSI, @@ -547,7 +547,7 @@ struct FX_BIT2CHARSET { const FX_BIT2CHARSET g_FX_Bit2Charset[4][16] = { {{1 << 0, FX_CHARSET_ANSI}, - {1 << 1, FX_CHARSET_MSWin_EasterEuropean}, + {1 << 1, FX_CHARSET_MSWin_EasternEuropean}, {1 << 2, FX_CHARSET_MSWin_Cyrillic}, {1 << 3, FX_CHARSET_MSWin_Greek}, {1 << 4, FX_CHARSET_MSWin_Turkish}, @@ -565,8 +565,8 @@ const FX_BIT2CHARSET g_FX_Bit2Charset[4][16] = { {{1 << 0, FX_CHARSET_Thai}, {1 << 1, FX_CHARSET_ShiftJIS}, {1 << 2, FX_CHARSET_ChineseSimplified}, - {1 << 3, FX_CHARSET_Korean}, - {1 << 4, FX_CHARSET_ChineseTriditional}, + {1 << 3, FX_CHARSET_Hangul}, + {1 << 4, FX_CHARSET_ChineseTraditional}, {1 << 5, FX_CHARSET_Johab}, {1 << 6, FX_CHARSET_Default}, {1 << 7, FX_CHARSET_Default}, @@ -970,7 +970,7 @@ CFX_RetainPtr<IFX_SeekableReadStream> CFGAS_FontMgr::CreateFontStream( uint32_t index) { int iExact = 0; void* hFont = - pSystemFontInfo->MapFont(0, 0, FXFONT_DEFAULT_CHARSET, 0, + pSystemFontInfo->MapFont(0, 0, FX_CHARSET_Default, 0, pFontMapper->GetFaceName(index).c_str(), iExact); if (!hFont) return nullptr; diff --git a/xfa/fgas/font/fgas_fontutils.cpp b/xfa/fgas/font/fgas_fontutils.cpp index f5673de56b..82930094ec 100644 --- a/xfa/fgas/font/fgas_fontutils.cpp +++ b/xfa/fgas/font/fgas_fontutils.cpp @@ -87,7 +87,7 @@ const FGAS_FONTUSB g_FXGdiFontUSBTable[] = { {0x216C, 0x216F, 36, 0xFFFF}, {0x2170, 0x2179, 36, FX_CODEPAGE_ChineseSimplified}, {0x217A, 0x218F, 36, 0xFFFF}, - {0x2190, 0x2199, 37, FX_CODEPAGE_Korean}, + {0x2190, 0x2199, 37, FX_CODEPAGE_Hangul}, {0x219A, 0x21FF, 37, 0xFFFF}, {0x2200, 0x22FF, 38, 0xFFFF}, {0x2300, 0x23FF, 39, 0xFFFF}, @@ -95,7 +95,7 @@ const FGAS_FONTUSB g_FXGdiFontUSBTable[] = { {0x2440, 0x245F, 41, 0xFFFF}, {0x2460, 0x2473, 42, FX_CODEPAGE_ShiftJIS}, {0x2474, 0x249B, 42, FX_CODEPAGE_ChineseSimplified}, - {0x249C, 0x24E9, 42, FX_CODEPAGE_Korean}, + {0x249C, 0x24E9, 42, FX_CODEPAGE_Hangul}, {0x24EA, 0x24FF, 42, 0xFFFF}, {0x2500, 0x2573, 43, FX_CODEPAGE_ChineseSimplified}, {0x2574, 0x257F, 43, 0xFFFF}, @@ -129,17 +129,17 @@ const FGAS_FONTUSB g_FXGdiFontUSBTable[] = { {0x30A0, 0x30FF, 50, FX_CODEPAGE_ShiftJIS}, {0x3100, 0x3129, 51, FX_CODEPAGE_ChineseSimplified}, {0x312A, 0x312F, 51, 0xFFFF}, - {0x3130, 0x318F, 52, FX_CODEPAGE_Korean}, + {0x3130, 0x318F, 52, FX_CODEPAGE_Hangul}, {0x3190, 0x319F, 59, 0xFFFF}, {0x31A0, 0x31BF, 51, 0xFFFF}, {0x31C0, 0x31EF, 61, 0xFFFF}, {0x31F0, 0x31FF, 50, 0xFFFF}, - {0x3200, 0x321C, 54, FX_CODEPAGE_Korean}, + {0x3200, 0x321C, 54, FX_CODEPAGE_Hangul}, {0x321D, 0x325F, 54, 0xFFFF}, - {0x3260, 0x327F, 54, FX_CODEPAGE_Korean}, + {0x3260, 0x327F, 54, FX_CODEPAGE_Hangul}, {0x3280, 0x32FF, 54, 0xFFFF}, {0x3300, 0x3387, 55, 0xFFFF}, - {0x3388, 0x33D0, 55, FX_CODEPAGE_Korean}, + {0x3388, 0x33D0, 55, FX_CODEPAGE_Hangul}, {0x33D1, 0x33FF, 55, 0xFFFF}, {0x3400, 0x4DBF, 59, 0xFFFF}, {0x4DC0, 0x4DFF, 99, 0xFFFF}, @@ -163,7 +163,7 @@ const FGAS_FONTUSB g_FXGdiFontUSBTable[] = { {0xA960, 0xA9FF, 999, 0xFFFF}, {0xAA00, 0xAA5F, 118, 0xFFFF}, {0xAA60, 0xABFF, 999, 0xFFFF}, - {0xAC00, 0xD7AF, 56, FX_CODEPAGE_Korean}, + {0xAC00, 0xD7AF, 56, FX_CODEPAGE_Hangul}, {0xD7B0, 0xD7FF, 999, 0xFFFF}, {0xD800, 0xDB7F, 57, 0xFFFF}, {0xDB80, 0xDBFF, 57, 0xFFFF}, @@ -171,7 +171,7 @@ const FGAS_FONTUSB g_FXGdiFontUSBTable[] = { {0xE000, 0xE814, 60, 0xFFFF}, {0xE815, 0xE864, 60, FX_CODEPAGE_ChineseSimplified}, {0xE865, 0xF8FF, 60, 0xFFFF}, - {0xF900, 0xFA0B, 61, FX_CODEPAGE_Korean}, + {0xF900, 0xFA0B, 61, FX_CODEPAGE_Hangul}, {0xFA0C, 0xFA0D, 61, FX_CODEPAGE_ChineseSimplified}, {0xFA0E, 0xFA2D, 61, FX_CODEPAGE_ShiftJIS}, {0xFA2E, 0xFAFF, 61, 0xFFFF}, |