diff options
author | npm <npm@chromium.org> | 2016-09-19 07:24:33 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-09-19 07:24:33 -0700 |
commit | ea3c3be83dae12ef682c68fc7cf906d790fd9f84 (patch) | |
tree | cdaca6bc4a4b9de627e45b90c64d4bd197fd8940 | |
parent | 2f8568ef91156d2deb8411c427fbb52f880ccc34 (diff) | |
download | pdfium-ea3c3be83dae12ef682c68fc7cf906d790fd9f84.tar.xz |
Remove duplicated charset definitions, and move them to fx_font.h
PWL_FontMap does not need its own charset definitions. fx_edit.h does
not need to define DEFAULT_CHARSET. XFA have their own definitions.
They look different in that most are MAC or MSWin charset definitions.
So they are left untouched. public/fpdf_sysfontinfo.h duplicate ones
were left untouched due to being in public folder.
Review-Url: https://codereview.chromium.org/2347313002
-rw-r--r-- | core/fpdfapi/fpdf_parser/cpdf_document.cpp | 20 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_interform.cpp | 42 | ||||
-rw-r--r-- | core/fxge/android/fpf_skiafontmgr.cpp | 4 | ||||
-rw-r--r-- | core/fxge/apple/fx_mac_imp.cpp | 2 | ||||
-rw-r--r-- | core/fxge/ge/cfx_folderfontinfo.cpp | 4 | ||||
-rw-r--r-- | core/fxge/ge/cfx_fontmapper.cpp | 2 | ||||
-rw-r--r-- | core/fxge/ge/fx_ge_linux.cpp | 2 | ||||
-rw-r--r-- | core/fxge/include/fx_font.h | 33 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_device.cpp | 26 | ||||
-rw-r--r-- | fpdfsdk/cfx_systemhandler.cpp | 2 | ||||
-rw-r--r-- | fpdfsdk/formfiller/cba_fontmap.cpp | 10 | ||||
-rw-r--r-- | fpdfsdk/fxedit/fxet_edit.cpp | 4 | ||||
-rw-r--r-- | fpdfsdk/fxedit/include/fx_edit.h | 4 | ||||
-rw-r--r-- | fpdfsdk/pdfwindow/PWL_Edit.cpp | 6 | ||||
-rw-r--r-- | fpdfsdk/pdfwindow/PWL_EditCtrl.cpp | 7 | ||||
-rw-r--r-- | fpdfsdk/pdfwindow/PWL_FontMap.cpp | 90 | ||||
-rw-r--r-- | fpdfsdk/pdfwindow/PWL_FontMap.h | 27 |
17 files changed, 139 insertions, 146 deletions
diff --git a/core/fpdfapi/fpdf_parser/cpdf_document.cpp b/core/fpdfapi/fpdf_parser/cpdf_document.cpp index 75a88b726f..d3909ceaec 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_document.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_document.cpp @@ -779,7 +779,7 @@ CPDF_Dictionary* CPDF_Document::ProcessbCJK( pWidthArray->AddInteger(814); Insert(0x21, 0x7e, pWidthArray); break; - case FXFONT_HANGEUL_CHARSET: + case FXFONT_HANGUL_CHARSET: cmap = bVert ? "KSCms-UHC-V" : "KSCms-UHC-H"; ordering = "Korea1"; supplement = 2; @@ -825,7 +825,7 @@ CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert) { bool bCJK = charset == FXFONT_CHINESEBIG5_CHARSET || charset == FXFONT_GB2312_CHARSET || - charset == FXFONT_HANGEUL_CHARSET || + charset == FXFONT_HANGUL_CHARSET || charset == FXFONT_SHIFTJIS_CHARSET; CFX_ByteString basefont = pFont->GetFamilyName(); basefont.Replace(" ", ""); @@ -944,12 +944,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 == SYMBOL_CHARSET); + pLogFont->lfCharSet == FXFONT_SYMBOL_CHARSET); - bool bCJK = pLogFont->lfCharSet == CHINESEBIG5_CHARSET || - pLogFont->lfCharSet == GB2312_CHARSET || - pLogFont->lfCharSet == HANGEUL_CHARSET || - pLogFont->lfCharSet == SHIFTJIS_CHARSET; + bool bCJK = pLogFont->lfCharSet == FXFONT_CHINESEBIG5_CHARSET || + pLogFont->lfCharSet == FXFONT_GB2312_CHARSET || + pLogFont->lfCharSet == FXFONT_HANGUL_CHARSET || + pLogFont->lfCharSet == FXFONT_SHIFTJIS_CHARSET; CFX_ByteString basefont; if (bTranslateName && bCJK) basefont = FPDF_GetPSNameFromTT(hDC); @@ -969,9 +969,9 @@ CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTA* pLogFont, pBaseDict->SetNameFor("Type", "Font"); CPDF_Dictionary* pFontDict = pBaseDict; if (!bCJK) { - if (pLogFont->lfCharSet == ANSI_CHARSET || - pLogFont->lfCharSet == DEFAULT_CHARSET || - pLogFont->lfCharSet == SYMBOL_CHARSET) { + if (pLogFont->lfCharSet == FXFONT_ANSI_CHARSET || + pLogFont->lfCharSet == FXFONT_DEFAULT_CHARSET || + pLogFont->lfCharSet == FXFONT_SYMBOL_CHARSET) { pBaseDict->SetNameFor("Encoding", "WinAnsiEncoding"); } else { CalculateEncodingDict(pLogFont->lfCharSet, pBaseDict); diff --git a/core/fpdfdoc/cpdf_interform.cpp b/core/fpdfdoc/cpdf_interform.cpp index 196eeccfba..e06af867bb 100644 --- a/core/fpdfdoc/cpdf_interform.cpp +++ b/core/fpdfdoc/cpdf_interform.cpp @@ -748,56 +748,56 @@ CPDF_Font* AddNativeInterFormFont(CPDF_Dictionary*& pFormDict, // static uint8_t CPDF_InterForm::GetNativeCharSet() { #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ - uint8_t charSet = ANSI_CHARSET; + uint8_t charSet = FXFONT_ANSI_CHARSET; UINT iCodePage = ::GetACP(); switch (iCodePage) { case 932: - charSet = SHIFTJIS_CHARSET; + charSet = FXFONT_SHIFTJIS_CHARSET; break; case 936: - charSet = GB2312_CHARSET; + charSet = FXFONT_GB2312_CHARSET; break; case 950: - charSet = CHINESEBIG5_CHARSET; + charSet = FXFONT_CHINESEBIG5_CHARSET; break; case 1252: - charSet = ANSI_CHARSET; + charSet = FXFONT_ANSI_CHARSET; break; case 874: - charSet = THAI_CHARSET; + charSet = FXFONT_THAI_CHARSET; break; case 949: - charSet = HANGUL_CHARSET; + charSet = FXFONT_HANGUL_CHARSET; break; case 1200: - charSet = ANSI_CHARSET; + charSet = FXFONT_ANSI_CHARSET; break; case 1250: - charSet = EASTEUROPE_CHARSET; + charSet = FXFONT_EASTEUROPE_CHARSET; break; case 1251: - charSet = RUSSIAN_CHARSET; + charSet = FXFONT_RUSSIAN_CHARSET; break; case 1253: - charSet = GREEK_CHARSET; + charSet = FXFONT_GREEK_CHARSET; break; case 1254: - charSet = TURKISH_CHARSET; + charSet = FXFONT_TURKISH_CHARSET; break; case 1255: - charSet = HEBREW_CHARSET; + charSet = FXFONT_HEBREW_CHARSET; break; case 1256: - charSet = ARABIC_CHARSET; + charSet = FXFONT_ARABIC_CHARSET; break; case 1257: - charSet = BALTIC_CHARSET; + charSet = FXFONT_BALTIC_CHARSET; break; case 1258: - charSet = VIETNAMESE_CHARSET; + charSet = FXFONT_VIETNAMESE_CHARSET; break; case 1361: - charSet = JOHAB_CHARSET; + charSet = FXFONT_JOHAB_CHARSET; break; } return charSet; @@ -916,18 +916,18 @@ CFX_ByteString CPDF_InterForm::GetNativeFont(uint8_t charSet, void* pLogFont) { CFX_ByteString csFontName; #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ LOGFONTA lf = {}; - if (charSet == ANSI_CHARSET) { + if (charSet == FXFONT_ANSI_CHARSET) { csFontName = "Helvetica"; return csFontName; } FX_BOOL bRet = FALSE; - if (charSet == SHIFTJIS_CHARSET) { + if (charSet == FXFONT_SHIFTJIS_CHARSET) { bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, "MS Mincho", lf); - } else if (charSet == GB2312_CHARSET) { + } else if (charSet == FXFONT_GB2312_CHARSET) { bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, "SimSun", lf); - } else if (charSet == CHINESEBIG5_CHARSET) { + } else if (charSet == FXFONT_CHINESEBIG5_CHARSET) { bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, "MingLiU", lf); } diff --git a/core/fxge/android/fpf_skiafontmgr.cpp b/core/fxge/android/fpf_skiafontmgr.cpp index 4b2ad98ddd..b7400fc47f 100644 --- a/core/fxge/android/fpf_skiafontmgr.cpp +++ b/core/fxge/android/fpf_skiafontmgr.cpp @@ -147,7 +147,7 @@ static uint32_t FPF_SkiaGetCharset(uint8_t uCharset) { return FPF_SKIACHARSET_Symbol; case FXFONT_SHIFTJIS_CHARSET: return FPF_SKIACHARSET_ShiftJIS; - case FXFONT_HANGEUL_CHARSET: + case FXFONT_HANGUL_CHARSET: return FPF_SKIACHARSET_Korean; case FXFONT_GB2312_CHARSET: return FPF_SKIACHARSET_GB2312; @@ -204,7 +204,7 @@ static uint32_t FPF_SKIAGetFamilyHash(const CFX_ByteStringC& bsFamily, static FX_BOOL FPF_SkiaIsCJK(uint8_t uCharset) { return (uCharset == FXFONT_GB2312_CHARSET) || (uCharset == FXFONT_CHINESEBIG5_CHARSET) || - (uCharset == FXFONT_HANGEUL_CHARSET) || + (uCharset == FXFONT_HANGUL_CHARSET) || (uCharset == FXFONT_SHIFTJIS_CHARSET); } static FX_BOOL FPF_SkiaMaybeSymbol(const CFX_ByteStringC& bsFacename) { diff --git a/core/fxge/apple/fx_mac_imp.cpp b/core/fxge/apple/fx_mac_imp.cpp index 78bb90fdc2..addcb6d815 100644 --- a/core/fxge/apple/fx_mac_imp.cpp +++ b/core/fxge/apple/fx_mac_imp.cpp @@ -107,7 +107,7 @@ void* CFX_MacFontInfo::MapFont(int weight, case FXFONT_GB2312_CHARSET: face = "STSong"; break; - case FXFONT_HANGEUL_CHARSET: + case FXFONT_HANGUL_CHARSET: face = "AppleMyungjo"; break; case FXFONT_CHINESEBIG5_CHARSET: diff --git a/core/fxge/ge/cfx_folderfontinfo.cpp b/core/fxge/ge/cfx_folderfontinfo.cpp index 5bd5b29c79..d4fe325576 100644 --- a/core/fxge/ge/cfx_folderfontinfo.cpp +++ b/core/fxge/ge/cfx_folderfontinfo.cpp @@ -63,7 +63,7 @@ uint32_t GetCharset(int charset) { return CHARSET_FLAG_GB; case FXFONT_CHINESEBIG5_CHARSET: return CHARSET_FLAG_BIG5; - case FXFONT_HANGEUL_CHARSET: + case FXFONT_HANGUL_CHARSET: return CHARSET_FLAG_KOREAN; case FXFONT_SYMBOL_CHARSET: return CHARSET_FLAG_SYMBOL; @@ -239,7 +239,7 @@ void CFX_FolderFontInfo::ReportFace(const CFX_ByteString& path, pInfo->m_Charsets |= CHARSET_FLAG_BIG5; } if ((codepages & (1 << 19)) || (codepages & (1 << 21))) { - m_pMapper->AddInstalledFont(facename, FXFONT_HANGEUL_CHARSET); + m_pMapper->AddInstalledFont(facename, FXFONT_HANGUL_CHARSET); pInfo->m_Charsets |= CHARSET_FLAG_KOREAN; } if (codepages & (1 << 31)) { diff --git a/core/fxge/ge/cfx_fontmapper.cpp b/core/fxge/ge/cfx_fontmapper.cpp index 08677ee650..f383730e8f 100644 --- a/core/fxge/ge/cfx_fontmapper.cpp +++ b/core/fxge/ge/cfx_fontmapper.cpp @@ -578,7 +578,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, Charset = FXFONT_SYMBOL_CHARSET; bool bCJK = (Charset == FXFONT_SHIFTJIS_CHARSET || Charset == FXFONT_GB2312_CHARSET || - Charset == FXFONT_HANGEUL_CHARSET || + Charset == FXFONT_HANGUL_CHARSET || Charset == FXFONT_CHINESEBIG5_CHARSET); if (!m_pFontInfo) { pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; diff --git a/core/fxge/ge/fx_ge_linux.cpp b/core/fxge/ge/fx_ge_linux.cpp index f57efe8a32..b13a133bc1 100644 --- a/core/fxge/ge/fx_ge_linux.cpp +++ b/core/fxge/ge/fx_ge_linux.cpp @@ -123,7 +123,7 @@ void* CFX_LinuxFontInfo::MapFont(int weight, } break; } - case FXFONT_HANGEUL_CHARSET: { + case FXFONT_HANGUL_CHARSET: { 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/include/fx_font.h b/core/fxge/include/fx_font.h index 00c9d6f559..58d12bbb2a 100644 --- a/core/fxge/include/fx_font.h +++ b/core/fxge/include/fx_font.h @@ -29,22 +29,12 @@ class SkTypeface; using CFX_TypeFace = SkTypeface; #endif -#define FXFONT_FIXED_PITCH 0x01 -#define FXFONT_SERIF 0x02 -#define FXFONT_SYMBOLIC 0x04 -#define FXFONT_SCRIPT 0x08 -#define FXFONT_ITALIC 0x40 -#define FXFONT_BOLD 0x40000 -#define FXFONT_USEEXTERNATTR 0x80000 -#define FXFONT_CIDFONT 0x100000 -#ifdef PDF_ENABLE_XFA -#define FXFONT_EXACTMATCH 0x80000000 -#endif // PDF_ENABLE_XFA +/* 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_HANGEUL_CHARSET 129 +#define FXFONT_HANGUL_CHARSET 129 #define FXFONT_GB2312_CHARSET 134 #define FXFONT_CHINESEBIG5_CHARSET 136 #define FXFONT_THAI_CHARSET 222 @@ -55,12 +45,31 @@ using CFX_TypeFace = SkTypeface; #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) #define FXFONT_FF_SCRIPT (4 << 4) + +/* Typical weight values */ #define FXFONT_FW_NORMAL 400 #define FXFONT_FW_BOLD 700 +/* Font styles */ +#define FXFONT_FIXED_PITCH 0x01 +#define FXFONT_SERIF 0x02 +#define FXFONT_SYMBOLIC 0x04 +#define FXFONT_SCRIPT 0x08 +#define FXFONT_ITALIC 0x40 +#define FXFONT_BOLD 0x40000 +#define FXFONT_USEEXTERNATTR 0x80000 +#define FXFONT_CIDFONT 0x100000 +#ifdef PDF_ENABLE_XFA +#define FXFONT_EXACTMATCH 0x80000000 +#endif // PDF_ENABLE_XFA + #define CHARSET_FLAG_ANSI 1 #define CHARSET_FLAG_SYMBOL 2 #define CHARSET_FLAG_SHIFTJIS 4 diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp index 9a54dd7f73..061bc0a4d0 100644 --- a/core/fxge/win32/fx_win32_device.cpp +++ b/core/fxge/win32/fx_win32_device.cpp @@ -459,7 +459,7 @@ FX_BOOL CFX_Win32FontInfo::EnumFontList(CFX_FontMapper* pMapper) { m_pMapper = pMapper; LOGFONTA lf; FXSYS_memset(&lf, 0, sizeof(LOGFONTA)); - lf.lfCharSet = DEFAULT_CHARSET; + lf.lfCharSet = FXFONT_DEFAULT_CHARSET; lf.lfFaceName[0] = 0; lf.lfPitchAndFamily = 0; EnumFontFamiliesExA(m_hDC, &lf, (FONTENUMPROCA)FontEnumProc, (uintptr_t) this, @@ -500,7 +500,7 @@ void* CFX_Win32FallbackFontInfo::MapFont(int weight, case FXFONT_SHIFTJIS_CHARSET: case FXFONT_GB2312_CHARSET: case FXFONT_CHINESEBIG5_CHARSET: - case FXFONT_HANGEUL_CHARSET: + case FXFONT_HANGUL_CHARSET: default: bCJK = FALSE; break; @@ -592,17 +592,17 @@ void* CFX_Win32FontInfo::MapFont(int weight, iExact = TRUE; break; } - if (charset == ANSI_CHARSET || charset == SYMBOL_CHARSET) { - charset = DEFAULT_CHARSET; + if (charset == FXFONT_ANSI_CHARSET || charset == FXFONT_SYMBOL_CHARSET) { + charset = FXFONT_DEFAULT_CHARSET; } int subst_pitch_family = pitch_family; switch (charset) { - case SHIFTJIS_CHARSET: + case FXFONT_SHIFTJIS_CHARSET: subst_pitch_family = FF_ROMAN; break; - case CHINESEBIG5_CHARSET: - case HANGUL_CHARSET: - case GB2312_CHARSET: + case FXFONT_CHINESEBIG5_CHARSET: + case FXFONT_HANGUL_CHARSET: + case FXFONT_GB2312_CHARSET: subst_pitch_family = 0; break; } @@ -629,20 +629,20 @@ void* CFX_Win32FontInfo::MapFont(int weight, return hFont; } ::DeleteObject(hFont); - if (charset == DEFAULT_CHARSET) + if (charset == FXFONT_DEFAULT_CHARSET) return nullptr; switch (charset) { - case SHIFTJIS_CHARSET: + case FXFONT_SHIFTJIS_CHARSET: GetJapanesePreference(face, weight, pitch_family); break; - case GB2312_CHARSET: + case FXFONT_GB2312_CHARSET: GetGBPreference(face, weight, pitch_family); break; - case HANGUL_CHARSET: + case FXFONT_HANGUL_CHARSET: face = "Gulim"; break; - case CHINESEBIG5_CHARSET: + case FXFONT_CHINESEBIG5_CHARSET: if (face.Find("MSung") >= 0) { face = "MingLiU"; } else { diff --git a/fpdfsdk/cfx_systemhandler.cpp b/fpdfsdk/cfx_systemhandler.cpp index 08d9743993..cbd929f5c2 100644 --- a/fpdfsdk/cfx_systemhandler.cpp +++ b/fpdfsdk/cfx_systemhandler.cpp @@ -26,7 +26,7 @@ int CharSet2CP(int charset) { return 932; if (charset == FXFONT_GB2312_CHARSET) return 936; - if (charset == FXFONT_HANGEUL_CHARSET) + if (charset == FXFONT_HANGUL_CHARSET) return 949; if (charset == FXFONT_CHINESEBIG5_CHARSET) return 950; diff --git a/fpdfsdk/formfiller/cba_fontmap.cpp b/fpdfsdk/formfiller/cba_fontmap.cpp index 8a981690f1..264366bfa4 100644 --- a/fpdfsdk/formfiller/cba_fontmap.cpp +++ b/fpdfsdk/formfiller/cba_fontmap.cpp @@ -39,7 +39,7 @@ void CBA_FontMap::Reset() { } void CBA_FontMap::Initialize() { - int32_t nCharset = DEFAULT_CHARSET; + int32_t nCharset = FXFONT_DEFAULT_CHARSET; if (!m_pDefaultFont) { m_pDefaultFont = GetAnnotDefaultFont(m_sDefaultFontName); @@ -51,16 +51,16 @@ void CBA_FontMap::Initialize() { m_sDefaultFontName == "Wingdings2" || m_sDefaultFontName == "Wingdings3" || m_sDefaultFontName == "Webdings") - nCharset = SYMBOL_CHARSET; + nCharset = FXFONT_SYMBOL_CHARSET; else - nCharset = ANSI_CHARSET; + nCharset = FXFONT_ANSI_CHARSET; } AddFontData(m_pDefaultFont, m_sDefaultFontName, nCharset); AddFontToAnnotDict(m_pDefaultFont, m_sDefaultFontName); } } - if (nCharset != ANSI_CHARSET) + if (nCharset != FXFONT_ANSI_CHARSET) CPWL_FontMap::Initialize(); } @@ -74,7 +74,7 @@ void CBA_FontMap::SetDefaultFont(CPDF_Font* pFont, m_pDefaultFont = pFont; m_sDefaultFontName = sFontName; - int32_t nCharset = DEFAULT_CHARSET; + int32_t nCharset = FXFONT_DEFAULT_CHARSET; if (const CFX_SubstFont* pSubstFont = m_pDefaultFont->GetSubstFont()) nCharset = pSubstFont->m_Charset; AddFontData(m_pDefaultFont, m_sDefaultFontName, nCharset); diff --git a/fpdfsdk/fxedit/fxet_edit.cpp b/fpdfsdk/fxedit/fxet_edit.cpp index 4967961cfa..528a0ba061 100644 --- a/fpdfsdk/fxedit/fxet_edit.cpp +++ b/fpdfsdk/fxedit/fxet_edit.cpp @@ -633,7 +633,7 @@ void CFXEU_Clear::Undo() { if (m_pEdit) { m_pEdit->SelectNone(); m_pEdit->SetCaret(m_wrSel.BeginPos); - m_pEdit->InsertText(m_swText, DEFAULT_CHARSET, FALSE, TRUE); + m_pEdit->InsertText(m_swText, FXFONT_DEFAULT_CHARSET, FALSE, TRUE); m_pEdit->SetSel(m_wrSel.BeginPos, m_wrSel.EndPos); } } @@ -1271,7 +1271,7 @@ CPVT_WordRange CFX_Edit::GetSelectWordRange() const { void CFX_Edit::SetText(const CFX_WideString& sText) { Empty(); - DoInsertText(CPVT_WordPlace(0, 0, -1), sText, DEFAULT_CHARSET); + DoInsertText(CPVT_WordPlace(0, 0, -1), sText, FXFONT_DEFAULT_CHARSET); Paint(); } diff --git a/fpdfsdk/fxedit/include/fx_edit.h b/fpdfsdk/fxedit/include/fx_edit.h index 4ae6ec2a6c..e460416e18 100644 --- a/fpdfsdk/fxedit/include/fx_edit.h +++ b/fpdfsdk/fxedit/include/fx_edit.h @@ -15,10 +15,6 @@ class IPVT_FontMap; (u == 0x2D || (u <= 0x005A && u >= 0x0041) || \ (u <= 0x007A && u >= 0x0061) || (u <= 0x02AF && u >= 0x00C0)) -#ifndef DEFAULT_CHARSET -#define DEFAULT_CHARSET 1 -#endif - CFX_ByteString GetPDFWordString(IPVT_FontMap* pFontMap, int32_t nFontIndex, uint16_t Word, diff --git a/fpdfsdk/pdfwindow/PWL_Edit.cpp b/fpdfsdk/pdfwindow/PWL_Edit.cpp index 4b115d345b..bd9d3aac61 100644 --- a/fpdfsdk/pdfwindow/PWL_Edit.cpp +++ b/fpdfsdk/pdfwindow/PWL_Edit.cpp @@ -15,6 +15,7 @@ #include "core/fxge/include/cfx_graphstatedata.h" #include "core/fxge/include/cfx_pathdata.h" #include "core/fxge/include/cfx_renderdevice.h" +#include "core/fxge/include/fx_font.h" #include "fpdfsdk/fxedit/include/fxet_edit.h" #include "fpdfsdk/pdfwindow/PWL_Caret.h" #include "fpdfsdk/pdfwindow/PWL_EditCtrl.h" @@ -564,7 +565,7 @@ void CPWL_Edit::SetLimitChar(int32_t nLimitChar) { void CPWL_Edit::ReplaceSel(const CFX_WideString& wsText) { m_pEdit->Clear(); - m_pEdit->InsertText(wsText, DEFAULT_CHARSET); + m_pEdit->InsertText(wsText, FXFONT_DEFAULT_CHARSET); } CFX_FloatRect CPWL_Edit::GetFocusRect() const { @@ -708,7 +709,8 @@ FX_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, DEFAULT_CHARSET); + int32_t nNewCharSet = + pFontMap->CharSetFromUnicode(nChar, FXFONT_DEFAULT_CHARSET); if (nOldCharSet != nNewCharSet) { SetCharSet(nNewCharSet); } diff --git a/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp b/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp index 9d8b16a53c..2ec88cb15e 100644 --- a/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp +++ b/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp @@ -8,6 +8,7 @@ #include "core/fpdfdoc/include/cpvt_section.h" #include "core/fpdfdoc/include/cpvt_word.h" +#include "core/fxge/include/fx_font.h" #include "fpdfsdk/fxedit/include/fxet_edit.h" #include "fpdfsdk/pdfwindow/PWL_Caret.h" #include "fpdfsdk/pdfwindow/PWL_FontMap.h" @@ -20,7 +21,7 @@ CPWL_EditCtrl::CPWL_EditCtrl() : m_pEdit(new CFX_Edit), m_pEditCaret(nullptr), m_bMouseDown(FALSE), - m_nCharSet(DEFAULT_CHARSET), + m_nCharSet(FXFONT_DEFAULT_CHARSET), m_nCodePage(0) {} CPWL_EditCtrl::~CPWL_EditCtrl() {} @@ -476,7 +477,7 @@ void CPWL_EditCtrl::ShowVScrollBar(FX_BOOL bShow) {} void CPWL_EditCtrl::InsertText(const CFX_WideString& wsText) { if (!IsReadOnly()) - m_pEdit->InsertText(wsText, DEFAULT_CHARSET); + m_pEdit->InsertText(wsText, FXFONT_DEFAULT_CHARSET); } void CPWL_EditCtrl::InsertWord(uint16_t word, int32_t nCharset) { @@ -567,7 +568,7 @@ void CPWL_EditCtrl::IOnInvalidateRect(CFX_FloatRect* pRect) { } int32_t CPWL_EditCtrl::GetCharSet() const { - return m_nCharSet < 0 ? DEFAULT_CHARSET : m_nCharSet; + return m_nCharSet < 0 ? FXFONT_DEFAULT_CHARSET : m_nCharSet; } void CPWL_EditCtrl::GetTextRange(const CFX_FloatRect& rect, diff --git a/fpdfsdk/pdfwindow/PWL_FontMap.cpp b/fpdfsdk/pdfwindow/PWL_FontMap.cpp index 7bb9c76779..d49f4ec6c0 100644 --- a/fpdfsdk/pdfwindow/PWL_FontMap.cpp +++ b/fpdfsdk/pdfwindow/PWL_FontMap.cpp @@ -93,7 +93,8 @@ int32_t CPWL_FontMap::GetWordFontIndex(uint16_t word, return nFontIndex; } else { if (const CPWL_FontMap_Data* pData = GetFontMapData(0)) { - if (nCharset == DEFAULT_CHARSET || pData->nCharset == SYMBOL_CHARSET || + if (nCharset == FXFONT_DEFAULT_CHARSET || + pData->nCharset == FXFONT_SYMBOL_CHARSET || nCharset == pData->nCharset) { if (KnowWord(0, word)) return 0; @@ -107,7 +108,8 @@ int32_t CPWL_FontMap::GetWordFontIndex(uint16_t word, if (KnowWord(nNewFontIndex, word)) return nNewFontIndex; } - nNewFontIndex = GetFontIndex("Arial Unicode MS", DEFAULT_CHARSET, FALSE); + nNewFontIndex = + GetFontIndex("Arial Unicode MS", FXFONT_DEFAULT_CHARSET, FALSE); if (nNewFontIndex >= 0) { if (KnowWord(nNewFontIndex, word)) return nNewFontIndex; @@ -167,7 +169,7 @@ void CPWL_FontMap::Empty() { } void CPWL_FontMap::Initialize() { - GetFontIndex(kDefaultFontName, ANSI_CHARSET, FALSE); + GetFontIndex(kDefaultFontName, FXFONT_ANSI_CHARSET, FALSE); } FX_BOOL CPWL_FontMap::IsStandardFont(const CFX_ByteString& sFontName) { @@ -183,7 +185,7 @@ int32_t CPWL_FontMap::FindFont(const CFX_ByteString& sFontName, int32_t nCharset) { for (int32_t i = 0, sz = m_aData.GetSize(); i < sz; i++) { if (CPWL_FontMap_Data* pData = m_aData.GetAt(i)) { - if (nCharset == DEFAULT_CHARSET || nCharset == pData->nCharset) { + if (nCharset == FXFONT_DEFAULT_CHARSET || nCharset == pData->nCharset) { if (sFontName.IsEmpty() || pData->sFontName == sFontName) return i; } @@ -236,7 +238,7 @@ void CPWL_FontMap::AddedFont(CPDF_Font* pFont, const CFX_ByteString& sFontAlias) {} CFX_ByteString CPWL_FontMap::GetNativeFont(int32_t nCharset) { - if (nCharset == DEFAULT_CHARSET) + if (nCharset == FXFONT_DEFAULT_CHARSET) nCharset = GetNativeCharset(); CFX_ByteString sFontName = GetDefaultFontByCharset(nCharset); @@ -281,7 +283,7 @@ CPDF_Font* CPWL_FontMap::AddSystemFont(CPDF_Document* pDoc, if (sFontName.IsEmpty()) sFontName = GetNativeFont(nCharset); - if (nCharset == DEFAULT_CHARSET) + if (nCharset == FXFONT_DEFAULT_CHARSET) nCharset = GetNativeCharset(); return m_pSystemHandler->AddNativeTrueTypeFontToPDF(pDoc, sFontName, @@ -310,72 +312,76 @@ const CPWL_FontMap_Data* CPWL_FontMap::GetFontMapData(int32_t nIndex) const { } int32_t CPWL_FontMap::GetNativeCharset() { - uint8_t nCharset = ANSI_CHARSET; + uint8_t nCharset = FXFONT_ANSI_CHARSET; int32_t iCodePage = FXSYS_GetACP(); switch (iCodePage) { case 932: // Japan - nCharset = SHIFTJIS_CHARSET; + nCharset = FXFONT_SHIFTJIS_CHARSET; break; case 936: // Chinese (PRC, Singapore) - nCharset = GB2312_CHARSET; + nCharset = FXFONT_GB2312_CHARSET; break; case 950: // Chinese (Taiwan; Hong Kong SAR, PRC) - nCharset = GB2312_CHARSET; + nCharset = FXFONT_GB2312_CHARSET; break; case 1252: // Windows 3.1 Latin 1 (US, Western Europe) - nCharset = ANSI_CHARSET; + nCharset = FXFONT_ANSI_CHARSET; break; case 874: // Thai - nCharset = THAI_CHARSET; + nCharset = FXFONT_THAI_CHARSET; break; case 949: // Korean - nCharset = HANGUL_CHARSET; + nCharset = FXFONT_HANGUL_CHARSET; break; case 1200: // Unicode (BMP of ISO 10646) - nCharset = ANSI_CHARSET; + nCharset = FXFONT_ANSI_CHARSET; break; case 1250: // Windows 3.1 Eastern European - nCharset = EASTEUROPE_CHARSET; + nCharset = FXFONT_EASTEUROPE_CHARSET; break; case 1251: // Windows 3.1 Cyrillic - nCharset = RUSSIAN_CHARSET; + nCharset = FXFONT_RUSSIAN_CHARSET; break; case 1253: // Windows 3.1 Greek - nCharset = GREEK_CHARSET; + nCharset = FXFONT_GREEK_CHARSET; break; case 1254: // Windows 3.1 Turkish - nCharset = TURKISH_CHARSET; + nCharset = FXFONT_TURKISH_CHARSET; break; case 1255: // Hebrew - nCharset = HEBREW_CHARSET; + nCharset = FXFONT_HEBREW_CHARSET; break; case 1256: // Arabic - nCharset = ARABIC_CHARSET; + nCharset = FXFONT_ARABIC_CHARSET; break; case 1257: // Baltic - nCharset = BALTIC_CHARSET; + nCharset = FXFONT_BALTIC_CHARSET; break; case 1258: // Vietnamese - nCharset = VIETNAMESE_CHARSET; + nCharset = FXFONT_VIETNAMESE_CHARSET; break; case 1361: // Korean(Johab) - nCharset = JOHAB_CHARSET; + nCharset = FXFONT_JOHAB_CHARSET; break; } return nCharset; } const FPDF_CharsetFontMap CPWL_FontMap::defaultTTFMap[] = { - {ANSI_CHARSET, "Helvetica"}, {GB2312_CHARSET, "SimSun"}, - {CHINESEBIG5_CHARSET, "MingLiU"}, {SHIFTJIS_CHARSET, "MS Gothic"}, - {HANGUL_CHARSET, "Batang"}, {RUSSIAN_CHARSET, "Arial"}, + {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"}, #if _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ || \ _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ - {EASTEUROPE_CHARSET, "Arial"}, + {FXFONT_EASTEUROPE_CHARSET, "Arial"}, #else - {EASTEUROPE_CHARSET, "Tahoma"}, + {FXFONT_EASTEUROPE_CHARSET, "Tahoma"}, #endif - {ARABIC_CHARSET, "Arial"}, {-1, nullptr}}; + {FXFONT_ARABIC_CHARSET, "Arial"}, + {-1, nullptr}}; CFX_ByteString CPWL_FontMap::GetDefaultFontByCharset(int32_t nCharset) { int i = 0; @@ -390,9 +396,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 ANSI_CHARSET; + return FXFONT_ANSI_CHARSET; // follow the old charset - if (nOldCharset != DEFAULT_CHARSET) + if (nOldCharset != FXFONT_DEFAULT_CHARSET) return nOldCharset; // find new charset @@ -400,42 +406,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 GB2312_CHARSET; + return FXFONT_GB2312_CHARSET; } if (((word >= 0x3040) && (word <= 0x309F)) || ((word >= 0x30A0) && (word <= 0x30FF)) || ((word >= 0x31F0) && (word <= 0x31FF)) || ((word >= 0xFF00) && (word <= 0xFFEF))) { - return SHIFTJIS_CHARSET; + return FXFONT_SHIFTJIS_CHARSET; } if (((word >= 0xAC00) && (word <= 0xD7AF)) || ((word >= 0x1100) && (word <= 0x11FF)) || ((word >= 0x3130) && (word <= 0x318F))) { - return HANGUL_CHARSET; + return FXFONT_HANGUL_CHARSET; } if (word >= 0x0E00 && word <= 0x0E7F) - return THAI_CHARSET; + return FXFONT_THAI_CHARSET; if ((word >= 0x0370 && word <= 0x03FF) || (word >= 0x1F00 && word <= 0x1FFF)) - return GREEK_CHARSET; + return FXFONT_GREEK_CHARSET; if ((word >= 0x0600 && word <= 0x06FF) || (word >= 0xFB50 && word <= 0xFEFC)) - return ARABIC_CHARSET; + return FXFONT_ARABIC_CHARSET; if (word >= 0x0590 && word <= 0x05FF) - return HEBREW_CHARSET; + return FXFONT_HEBREW_CHARSET; if (word >= 0x0400 && word <= 0x04FF) - return RUSSIAN_CHARSET; + return FXFONT_RUSSIAN_CHARSET; if (word >= 0x0100 && word <= 0x024F) - return EASTEUROPE_CHARSET; + return FXFONT_EASTEUROPE_CHARSET; if (word >= 0x1E00 && word <= 0x1EFF) - return VIETNAMESE_CHARSET; + return FXFONT_VIETNAMESE_CHARSET; - return ANSI_CHARSET; + return FXFONT_ANSI_CHARSET; } diff --git a/fpdfsdk/pdfwindow/PWL_FontMap.h b/fpdfsdk/pdfwindow/PWL_FontMap.h index 0ebd059b08..bb3925d5c2 100644 --- a/fpdfsdk/pdfwindow/PWL_FontMap.h +++ b/fpdfsdk/pdfwindow/PWL_FontMap.h @@ -10,6 +10,7 @@ #include <memory> #include "core/fpdfdoc/include/ipvt_fontmap.h" +#include "core/fxge/include/fx_font.h" #include "fpdfsdk/fxedit/include/fx_edit.h" #include "public/fpdf_sysfontinfo.h" @@ -27,28 +28,6 @@ struct CPWL_FontMap_Native { CFX_ByteString sFontName; }; -#ifndef ANSI_CHARSET - -#define ANSI_CHARSET 0 -#define DEFAULT_CHARSET 1 -#define SYMBOL_CHARSET 2 -#define SHIFTJIS_CHARSET 128 -#define HANGUL_CHARSET 129 -#define GB2312_CHARSET 134 -#define CHINESEBIG5_CHARSET 136 -#define JOHAB_CHARSET 130 -#define HEBREW_CHARSET 177 -#define ARABIC_CHARSET 178 -#define GREEK_CHARSET 161 -#define TURKISH_CHARSET 162 -#define VIETNAMESE_CHARSET 163 -#define THAI_CHARSET 222 -#define EASTEUROPE_CHARSET 238 -#define RUSSIAN_CHARSET 204 -#define BALTIC_CHARSET 186 - -#endif - class CPWL_FontMap : public IPVT_FontMap { public: CPWL_FontMap(CFX_SystemHandler* pSystemHandler); @@ -85,7 +64,7 @@ class CPWL_FontMap : public IPVT_FontMap { FX_BOOL bFind); int32_t AddFontData(CPDF_Font* pFont, const CFX_ByteString& sFontAlias, - int32_t nCharset = DEFAULT_CHARSET); + int32_t nCharset = FXFONT_DEFAULT_CHARSET); CFX_ByteString EncodeFontAlias(const CFX_ByteString& sFontName, int32_t nCharset); @@ -96,7 +75,7 @@ class CPWL_FontMap : public IPVT_FontMap { private: int32_t FindFont(const CFX_ByteString& sFontName, - int32_t nCharset = DEFAULT_CHARSET); + int32_t nCharset = FXFONT_DEFAULT_CHARSET); CFX_ByteString GetNativeFont(int32_t nCharset); CPDF_Font* AddFontToDocument(CPDF_Document* pDoc, |