summaryrefslogtreecommitdiff
path: root/xfa/fgas/font
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fgas/font')
-rw-r--r--xfa/fgas/font/cfgas_fontmgr.cpp136
-rw-r--r--xfa/fgas/font/fgas_fontutils.cpp311
-rw-r--r--xfa/fgas/font/fgas_fontutils.h4
3 files changed, 289 insertions, 162 deletions
diff --git a/xfa/fgas/font/cfgas_fontmgr.cpp b/xfa/fgas/font/cfgas_fontmgr.cpp
index 1746a2427d..7b8e19a5bc 100644
--- a/xfa/fgas/font/cfgas_fontmgr.cpp
+++ b/xfa/fgas/font/cfgas_fontmgr.cpp
@@ -95,6 +95,36 @@ const FX_FONTDESCRIPTOR* MatchDefaultFont(
return iBestSimilar < 1 ? nullptr : pBestFont;
}
+uint32_t GetFontHashCode(uint16_t wCodePage, uint32_t dwFontStyles) {
+ uint32_t dwHash = wCodePage;
+ if (dwFontStyles & FX_FONTSTYLE_FixedPitch)
+ dwHash |= 0x00010000;
+ if (dwFontStyles & FX_FONTSTYLE_Serif)
+ dwHash |= 0x00020000;
+ if (dwFontStyles & FX_FONTSTYLE_Symbolic)
+ dwHash |= 0x00040000;
+ if (dwFontStyles & FX_FONTSTYLE_Script)
+ dwHash |= 0x00080000;
+ if (dwFontStyles & FX_FONTSTYLE_Italic)
+ dwHash |= 0x00100000;
+ if (dwFontStyles & FX_FONTSTYLE_Bold)
+ dwHash |= 0x00200000;
+ return dwHash;
+}
+
+uint32_t GetFontFamilyHash(const wchar_t* pszFontFamily,
+ uint32_t dwFontStyles,
+ uint16_t wCodePage) {
+ CFX_WideString wsFont(pszFontFamily);
+ if (dwFontStyles & FX_FONTSTYLE_Bold)
+ wsFont += L"Bold";
+ if (dwFontStyles & FX_FONTSTYLE_Italic)
+ wsFont += L"Italic";
+
+ wsFont += wCodePage;
+ return FX_HashCode_GetW(wsFont.AsStringC(), false);
+}
+
} // namespace
std::unique_ptr<CFGAS_FontMgr> CFGAS_FontMgr::Create(
@@ -114,7 +144,7 @@ CFX_RetainPtr<CFGAS_GEFont> CFGAS_FontMgr::GetFontByCodePage(
uint16_t wCodePage,
uint32_t dwFontStyles,
const wchar_t* pszFontFamily) {
- uint32_t dwHash = FGAS_GetFontHashCode(wCodePage, dwFontStyles);
+ uint32_t dwHash = GetFontHashCode(wCodePage, dwFontStyles);
auto it = m_CPFonts.find(dwHash);
if (it != m_CPFonts.end()) {
return it->second ? LoadFont(it->second, dwFontStyles, wCodePage) : nullptr;
@@ -135,7 +165,7 @@ CFX_RetainPtr<CFGAS_GEFont> CFGAS_FontMgr::GetFontByCodePage(
m_Fonts.push_back(pFont);
m_CPFonts[dwHash] = pFont;
- dwHash = FGAS_GetFontFamilyHash(pFD->wsFontFace, dwFontStyles, wCodePage);
+ dwHash = GetFontFamilyHash(pFD->wsFontFace, dwFontStyles, wCodePage);
m_FamilyFonts[dwHash] = pFont;
return LoadFont(pFont, dwFontStyles, wCodePage);
}
@@ -149,7 +179,7 @@ CFX_RetainPtr<CFGAS_GEFont> CFGAS_FontMgr::GetFontByUnicode(
return nullptr;
uint32_t dwHash =
- FGAS_GetFontFamilyHash(pszFontFamily, dwFontStyles, pRet->wBitField);
+ GetFontFamilyHash(pszFontFamily, dwFontStyles, pRet->wBitField);
auto it = m_UnicodeFonts.find(dwHash);
if (it != m_UnicodeFonts.end()) {
return it->second ? LoadFont(it->second, dwFontStyles, pRet->wCodePage)
@@ -174,9 +204,8 @@ CFX_RetainPtr<CFGAS_GEFont> CFGAS_FontMgr::GetFontByUnicode(
m_Fonts.push_back(pFont);
m_UnicodeFonts[dwHash] = pFont;
- m_CPFonts[FGAS_GetFontHashCode(wCodePage, dwFontStyles)] = pFont;
- m_FamilyFonts[FGAS_GetFontFamilyHash(pFontFace, dwFontStyles, wCodePage)] =
- pFont;
+ m_CPFonts[GetFontHashCode(wCodePage, dwFontStyles)] = pFont;
+ m_FamilyFonts[GetFontFamilyHash(pFontFace, dwFontStyles, wCodePage)] = pFont;
return LoadFont(pFont, dwFontStyles, wCodePage);
}
@@ -185,8 +214,7 @@ CFX_RetainPtr<CFGAS_GEFont> CFGAS_FontMgr::LoadFont(
uint32_t dwFontStyles,
uint16_t wCodePage) {
CFX_RetainPtr<CFGAS_GEFont> pFont;
- uint32_t dwHash =
- FGAS_GetFontFamilyHash(pszFontFamily, dwFontStyles, wCodePage);
+ uint32_t dwHash = GetFontFamilyHash(pszFontFamily, dwFontStyles, wCodePage);
auto it = m_FamilyFonts.find(dwHash);
if (it != m_FamilyFonts.end())
return it->second ? LoadFont(it->second, dwFontStyles, wCodePage) : nullptr;
@@ -208,7 +236,7 @@ CFX_RetainPtr<CFGAS_GEFont> CFGAS_FontMgr::LoadFont(
m_Fonts.push_back(pFont);
m_FamilyFonts[dwHash] = pFont;
- dwHash = FGAS_GetFontHashCode(wCodePage, dwFontStyles);
+ dwHash = GetFontHashCode(wCodePage, dwFontStyles);
m_CPFonts[dwHash] = pFont;
return LoadFont(pFont, dwFontStyles, wCodePage);
}
@@ -369,29 +397,75 @@ const char* g_FontFolders[] = {
#endif
};
-struct FX_BitCodePage {
- uint16_t wBit;
- uint16_t wCodePage;
-};
-
-const FX_BitCodePage g_Bit2CodePage[] = {
- {0, 1252}, {1, 1250}, {2, 1251}, {3, 1253}, {4, 1254}, {5, 1255},
- {6, 1256}, {7, 1257}, {8, 1258}, {9, 0}, {10, 0}, {11, 0},
- {12, 0}, {13, 0}, {14, 0}, {15, 0}, {16, 874}, {17, 932},
- {18, 936}, {19, 949}, {20, 950}, {21, 1361}, {22, 0}, {23, 0},
- {24, 0}, {25, 0}, {26, 0}, {27, 0}, {28, 0}, {29, 0},
- {30, 0}, {31, 0}, {32, 0}, {33, 0}, {34, 0}, {35, 0},
- {36, 0}, {37, 0}, {38, 0}, {39, 0}, {40, 0}, {41, 0},
- {42, 0}, {43, 0}, {44, 0}, {45, 0}, {46, 0}, {47, 0},
- {48, 869}, {49, 866}, {50, 865}, {51, 864}, {52, 863}, {53, 862},
- {54, 861}, {55, 860}, {56, 857}, {57, 855}, {58, 852}, {59, 775},
- {60, 737}, {61, 708}, {62, 850}, {63, 437},
-};
+const uint16_t g_CodePages[] = {FX_CODEPAGE_MSWin_WesternEuropean,
+ FX_CODEPAGE_MSWin_EasternEuropean,
+ FX_CODEPAGE_MSWin_Cyrillic,
+ FX_CODEPAGE_MSWin_Greek,
+ FX_CODEPAGE_MSWin_Turkish,
+ FX_CODEPAGE_MSWin_Hebrew,
+ FX_CODEPAGE_MSWin_Arabic,
+ FX_CODEPAGE_MSWin_Baltic,
+ FX_CODEPAGE_MSWin_Vietnamese,
+ FX_CODEPAGE_DefANSI,
+ FX_CODEPAGE_DefANSI,
+ FX_CODEPAGE_DefANSI,
+ FX_CODEPAGE_DefANSI,
+ FX_CODEPAGE_DefANSI,
+ FX_CODEPAGE_DefANSI,
+ FX_CODEPAGE_DefANSI,
+ FX_CODEPAGE_MSDOS_Thai,
+ FX_CODEPAGE_ShiftJIS,
+ FX_CODEPAGE_ChineseSimplified,
+ FX_CODEPAGE_Korean,
+ FX_CODEPAGE_ChineseTraditional,
+ FX_CODEPAGE_Johab,
+ FX_CODEPAGE_DefANSI,
+ FX_CODEPAGE_DefANSI,
+ FX_CODEPAGE_DefANSI,
+ FX_CODEPAGE_DefANSI,
+ FX_CODEPAGE_DefANSI,
+ FX_CODEPAGE_DefANSI,
+ FX_CODEPAGE_DefANSI,
+ FX_CODEPAGE_DefANSI,
+ FX_CODEPAGE_DefANSI,
+ FX_CODEPAGE_DefANSI,
+ FX_CODEPAGE_DefANSI,
+ FX_CODEPAGE_DefANSI,
+ FX_CODEPAGE_DefANSI,
+ FX_CODEPAGE_DefANSI,
+ FX_CODEPAGE_DefANSI,
+ FX_CODEPAGE_DefANSI,
+ FX_CODEPAGE_DefANSI,
+ FX_CODEPAGE_DefANSI,
+ FX_CODEPAGE_DefANSI,
+ FX_CODEPAGE_DefANSI,
+ FX_CODEPAGE_DefANSI,
+ FX_CODEPAGE_DefANSI,
+ FX_CODEPAGE_DefANSI,
+ FX_CODEPAGE_DefANSI,
+ FX_CODEPAGE_DefANSI,
+ FX_CODEPAGE_DefANSI,
+ FX_CODEPAGE_MSDOS_Greek2,
+ FX_CODEPAGE_MSDOS_Russian,
+ FX_CODEPAGE_MSDOS_Norwegian,
+ FX_CODEPAGE_MSDOS_Arabic,
+ FX_CODEPAGE_MSDOS_FrenchCanadian,
+ FX_CODEPAGE_MSDOS_Hebrew,
+ FX_CODEPAGE_MSDOS_Icelandic,
+ FX_CODEPAGE_MSDOS_Portuguese,
+ FX_CODEPAGE_MSDOS_Turkish,
+ FX_CODEPAGE_MSDOS_Cyrillic,
+ FX_CODEPAGE_MSDOS_EasternEuropean,
+ FX_CODEPAGE_MSDOS_Baltic,
+ FX_CODEPAGE_MSDOS_Greek1,
+ FX_CODEPAGE_Arabic_ASMO708,
+ FX_CODEPAGE_MSDOS_WesternEuropean,
+ FX_CODEPAGE_MSDOS_US};
uint16_t FX_GetCodePageBit(uint16_t wCodePage) {
- for (size_t i = 0; i < FX_ArraySize(g_Bit2CodePage); ++i) {
- if (g_Bit2CodePage[i].wCodePage == wCodePage)
- return g_Bit2CodePage[i].wBit;
+ for (size_t i = 0; i < FX_ArraySize(g_CodePages); ++i) {
+ if (g_CodePages[i] == wCodePage)
+ return static_cast<uint16_t>(i);
}
return static_cast<uint16_t>(-1);
}
@@ -941,7 +1015,7 @@ int32_t CFGAS_FontMgr::CalcPenalty(CFX_FontDescriptor* pInstalled,
if (nPenalty >= 0xFFFF)
return 0xFFFF;
- uint16_t wBit = (wCodePage == 0 || wCodePage == 0xFFFF)
+ uint16_t wBit = (wCodePage == FX_CODEPAGE_DefANSI || wCodePage == 0xFFFF)
? static_cast<uint16_t>(-1)
: FX_GetCodePageBit(wCodePage);
if (wBit != static_cast<uint16_t>(-1)) {
diff --git a/xfa/fgas/font/fgas_fontutils.cpp b/xfa/fgas/font/fgas_fontutils.cpp
index e775ebdf0c..4dc599cd4b 100644
--- a/xfa/fgas/font/fgas_fontutils.cpp
+++ b/xfa/fgas/font/fgas_fontutils.cpp
@@ -7,147 +7,204 @@
#include "xfa/fgas/font/fgas_fontutils.h"
#include "core/fxcrt/fx_ext.h"
+#include "xfa/fgas/crt/fgas_codepage.h"
#include "xfa/fgas/font/cfgas_fontmgr.h"
-uint32_t FGAS_GetFontHashCode(uint16_t wCodePage, uint32_t dwFontStyles) {
- uint32_t dwHash = wCodePage;
- if (dwFontStyles & FX_FONTSTYLE_FixedPitch) {
- dwHash |= 0x00010000;
- }
- if (dwFontStyles & FX_FONTSTYLE_Serif) {
- dwHash |= 0x00020000;
- }
- if (dwFontStyles & FX_FONTSTYLE_Symbolic) {
- dwHash |= 0x00040000;
- }
- if (dwFontStyles & FX_FONTSTYLE_Script) {
- dwHash |= 0x00080000;
- }
- if (dwFontStyles & FX_FONTSTYLE_Italic) {
- dwHash |= 0x00100000;
- }
- if (dwFontStyles & FX_FONTSTYLE_Bold) {
- dwHash |= 0x00200000;
- }
- return dwHash;
-}
-uint32_t FGAS_GetFontFamilyHash(const wchar_t* pszFontFamily,
- uint32_t dwFontStyles,
- uint16_t wCodePage) {
- CFX_WideString wsFont(pszFontFamily);
- if (dwFontStyles & FX_FONTSTYLE_Bold) {
- wsFont += L"Bold";
- }
- if (dwFontStyles & FX_FONTSTYLE_Italic) {
- wsFont += L"Italic";
- }
- wsFont += wCodePage;
- return FX_HashCode_GetW(wsFont.AsStringC(), false);
-}
-static const FGAS_FONTUSB g_FXGdiFontUSBTable[] = {
- {0x0000, 0x007F, 0, 1252}, {0x0080, 0x00FF, 1, 1252},
- {0x0100, 0x017F, 2, 1250}, {0x0180, 0x024F, 3, 1250},
- {0x0250, 0x02AF, 4, 0xFFFF}, {0x02B0, 0x02FF, 5, 0xFFFF},
- {0x0300, 0x036F, 6, 0xFFFF}, {0x0370, 0x03FF, 7, 1253},
- {0x0400, 0x04FF, 9, 1251}, {0x0500, 0x052F, 9, 0xFFFF},
- {0x0530, 0x058F, 10, 0xFFFF}, {0x0590, 0x05FF, 11, 1255},
- {0x0600, 0x06FF, 13, 1256}, {0x0700, 0x074F, 71, 0xFFFF},
- {0x0750, 0x077F, 13, 0xFFFF}, {0x0780, 0x07BF, 72, 0xFFFF},
- {0x07C0, 0x07FF, 14, 0xFFFF}, {0x0800, 0x08FF, 999, 0xFFFF},
- {0x0900, 0x097F, 15, 0xFFFF}, {0x0980, 0x09FF, 16, 0xFFFF},
- {0x0A00, 0x0A7F, 17, 0xFFFF}, {0x0A80, 0x0AFF, 18, 0xFFFF},
- {0x0B00, 0x0B7F, 19, 0xFFFF}, {0x0B80, 0x0BFF, 20, 0xFFFF},
- {0x0C00, 0x0C7F, 21, 0xFFFF}, {0x0C80, 0x0CFF, 22, 0xFFFF},
- {0x0D00, 0x0D7F, 23, 0xFFFF}, {0x0D80, 0x0DFF, 73, 0xFFFF},
- {0x0E00, 0x0E7F, 24, 874}, {0x0E80, 0x0EFF, 25, 0xFFFF},
- {0x0F00, 0x0FFF, 70, 0xFFFF}, {0x1000, 0x109F, 74, 0xFFFF},
- {0x10A0, 0x10FF, 26, 0xFFFF}, {0x1100, 0x11FF, 28, 0xFFFF},
- {0x1200, 0x137F, 75, 0xFFFF}, {0x1380, 0x139F, 75, 0xFFFF},
- {0x13A0, 0x13FF, 76, 0xFFFF}, {0x1400, 0x167F, 77, 0xFFFF},
- {0x1680, 0x169F, 78, 0xFFFF}, {0x16A0, 0x16FF, 79, 0xFFFF},
- {0x1700, 0x171F, 84, 0xFFFF}, {0x1720, 0x173F, 84, 0xFFFF},
- {0x1740, 0x175F, 84, 0xFFFF}, {0x1760, 0x177F, 84, 0xFFFF},
- {0x1780, 0x17FF, 80, 0xFFFF}, {0x1800, 0x18AF, 81, 0xFFFF},
- {0x18B0, 0x18FF, 999, 0xFFFF}, {0x1900, 0x194F, 93, 0xFFFF},
- {0x1950, 0x197F, 94, 0xFFFF}, {0x1980, 0x19DF, 95, 0xFFFF},
- {0x19E0, 0x19FF, 80, 0xFFFF}, {0x1A00, 0x1A1F, 96, 0xFFFF},
- {0x1A20, 0x1AFF, 999, 0xFFFF}, {0x1B00, 0x1B7F, 27, 0xFFFF},
- {0x1B80, 0x1BBF, 112, 0xFFFF}, {0x1BC0, 0x1BFF, 999, 0xFFFF},
- {0x1C00, 0x1C4F, 113, 0xFFFF}, {0x1C50, 0x1C7F, 114, 0xFFFF},
- {0x1C80, 0x1CFF, 999, 0xFFFF}, {0x1D00, 0x1D7F, 4, 0xFFFF},
- {0x1D80, 0x1DBF, 4, 0xFFFF}, {0x1DC0, 0x1DFF, 6, 0xFFFF},
- {0x1E00, 0x1EFF, 29, 0xFFFF}, {0x1F00, 0x1FFF, 30, 0xFFFF},
- {0x2000, 0x206F, 31, 0xFFFF}, {0x2070, 0x209F, 32, 0xFFFF},
- {0x20A0, 0x20CF, 33, 0xFFFF}, {0x20D0, 0x20FF, 34, 0xFFFF},
- {0x2100, 0x214F, 35, 0xFFFF}, {0x2150, 0x215F, 36, 0xFFFF},
- {0x2160, 0x216B, 36, 936}, {0x216C, 0x216F, 36, 0xFFFF},
- {0x2170, 0x2179, 36, 936}, {0x217A, 0x218F, 36, 0xFFFF},
- {0x2190, 0x2199, 37, 949}, {0x219A, 0x21FF, 37, 0xFFFF},
- {0x2200, 0x22FF, 38, 0xFFFF}, {0x2300, 0x23FF, 39, 0xFFFF},
- {0x2400, 0x243F, 40, 0xFFFF}, {0x2440, 0x245F, 41, 0xFFFF},
- {0x2460, 0x2473, 42, 932}, {0x2474, 0x249B, 42, 936},
- {0x249C, 0x24E9, 42, 949}, {0x24EA, 0x24FF, 42, 0xFFFF},
- {0x2500, 0x2573, 43, 936}, {0x2574, 0x257F, 43, 0xFFFF},
- {0x2580, 0x2580, 44, 0xFFFF}, {0x2581, 0x258F, 44, 936},
- {0x2590, 0x259F, 44, 0xFFFF}, {0x25A0, 0x25FF, 45, 0xFFFF},
- {0x2600, 0x26FF, 46, 0xFFFF}, {0x2700, 0x27BF, 47, 0xFFFF},
- {0x27C0, 0x27EF, 38, 0xFFFF}, {0x27F0, 0x27FF, 37, 0xFFFF},
- {0x2800, 0x28FF, 82, 0xFFFF}, {0x2900, 0x297F, 37, 0xFFFF},
- {0x2980, 0x29FF, 38, 0xFFFF}, {0x2A00, 0x2AFF, 38, 0xFFFF},
- {0x2B00, 0x2BFF, 37, 0xFFFF}, {0x2C00, 0x2C5F, 97, 0xFFFF},
- {0x2C60, 0x2C7F, 29, 0xFFFF}, {0x2C80, 0x2CFF, 8, 0xFFFF},
- {0x2D00, 0x2D2F, 26, 0xFFFF}, {0x2D30, 0x2D7F, 98, 0xFFFF},
- {0x2D80, 0x2DDF, 75, 0xFFFF}, {0x2DE0, 0x2DFF, 9, 0xFFFF},
- {0x2E00, 0x2E7F, 31, 0xFFFF}, {0x2E80, 0x2EFF, 59, 0xFFFF},
- {0x2F00, 0x2FDF, 59, 0xFFFF}, {0x2FE0, 0x2FEF, 999, 0xFFFF},
- {0x2FF0, 0x2FFF, 59, 0xFFFF}, {0x3000, 0x303F, 48, 0xFFFF},
- {0x3040, 0x309F, 49, 932}, {0x30A0, 0x30FF, 50, 932},
- {0x3100, 0x3129, 51, 936}, {0x312A, 0x312F, 51, 0xFFFF},
- {0x3130, 0x318F, 52, 949}, {0x3190, 0x319F, 59, 0xFFFF},
- {0x31A0, 0x31BF, 51, 0xFFFF}, {0x31C0, 0x31EF, 61, 0xFFFF},
- {0x31F0, 0x31FF, 50, 0xFFFF}, {0x3200, 0x321C, 54, 949},
- {0x321D, 0x325F, 54, 0xFFFF}, {0x3260, 0x327F, 54, 949},
- {0x3280, 0x32FF, 54, 0xFFFF}, {0x3300, 0x3387, 55, 0xFFFF},
- {0x3388, 0x33D0, 55, 949}, {0x33D1, 0x33FF, 55, 0xFFFF},
- {0x3400, 0x4DBF, 59, 0xFFFF}, {0x4DC0, 0x4DFF, 99, 0xFFFF},
- {0x4E00, 0x9FA5, 59, 936}, {0x9FA6, 0x9FFF, 59, 0xFFFF},
- {0xA000, 0xA48F, 83, 0xFFFF}, {0xA490, 0xA4CF, 83, 0xFFFF},
- {0xA4D0, 0xA4FF, 999, 0xFFFF}, {0xA500, 0xA63F, 12, 0xFFFF},
- {0xA640, 0xA69F, 9, 0xFFFF}, {0xA6A0, 0xA6FF, 999, 0xFFFF},
- {0xA700, 0xA71F, 5, 0xFFFF}, {0xA720, 0xA7FF, 29, 0xFFFF},
- {0xA800, 0xA82F, 100, 0xFFFF}, {0xA830, 0xA8FF, 999, 0xFFFF},
- {0xA840, 0xA87F, 53, 0xFFFF}, {0xA880, 0xA8DF, 115, 0xFFFF},
- {0xA8E0, 0xA8FF, 999, 0xFFFF}, {0xA900, 0xA92F, 116, 0xFFFF},
- {0xA930, 0xA95F, 117, 0xFFFF}, {0xA960, 0xA9FF, 999, 0xFFFF},
- {0xAA00, 0xAA5F, 118, 0xFFFF}, {0xAA60, 0xABFF, 999, 0xFFFF},
- {0xAC00, 0xD7AF, 56, 949}, {0xD7B0, 0xD7FF, 999, 0xFFFF},
- {0xD800, 0xDB7F, 57, 0xFFFF}, {0xDB80, 0xDBFF, 57, 0xFFFF},
- {0xDC00, 0xDFFF, 57, 0xFFFF}, {0xE000, 0xE814, 60, 0xFFFF},
- {0xE815, 0xE864, 60, 936}, {0xE865, 0xF8FF, 60, 0xFFFF},
- {0xF900, 0xFA0B, 61, 949}, {0xFA0C, 0xFA0D, 61, 936},
- {0xFA0E, 0xFA2D, 61, 932}, {0xFA2E, 0xFAFF, 61, 0xFFFF},
- {0xFB00, 0xFB4F, 62, 0xFFFF}, {0xFB50, 0xFDFF, 63, 1256},
- {0xFE00, 0xFE0F, 91, 0xFFFF}, {0xFE10, 0xFE1F, 65, 0xFFFF},
- {0xFE20, 0xFE2F, 64, 0xFFFF}, {0xFE30, 0xFE4F, 65, 0xFFFF},
- {0xFE50, 0xFE6F, 66, 0xFFFF}, {0xFE70, 0xFEFF, 67, 1256},
- {0xFF00, 0xFF5F, 68, 936}, {0xFF60, 0xFF9F, 68, 932},
+namespace {
+
+const FGAS_FONTUSB g_FXGdiFontUSBTable[] = {
+ {0x0000, 0x007F, 0, FX_CODEPAGE_MSWin_WesternEuropean},
+ {0x0080, 0x00FF, 1, FX_CODEPAGE_MSWin_WesternEuropean},
+ {0x0100, 0x017F, 2, FX_CODEPAGE_MSWin_EasternEuropean},
+ {0x0180, 0x024F, 3, FX_CODEPAGE_MSWin_EasternEuropean},
+ {0x0250, 0x02AF, 4, 0xFFFF},
+ {0x02B0, 0x02FF, 5, 0xFFFF},
+ {0x0300, 0x036F, 6, 0xFFFF},
+ {0x0370, 0x03FF, 7, FX_CODEPAGE_MSWin_Greek},
+ {0x0400, 0x04FF, 9, FX_CODEPAGE_MSWin_Cyrillic},
+ {0x0500, 0x052F, 9, 0xFFFF},
+ {0x0530, 0x058F, 10, 0xFFFF},
+ {0x0590, 0x05FF, 11, FX_CODEPAGE_MSWin_Hebrew},
+ {0x0600, 0x06FF, 13, FX_CODEPAGE_MSWin_Arabic},
+ {0x0700, 0x074F, 71, 0xFFFF},
+ {0x0750, 0x077F, 13, 0xFFFF},
+ {0x0780, 0x07BF, 72, 0xFFFF},
+ {0x07C0, 0x07FF, 14, 0xFFFF},
+ {0x0800, 0x08FF, 999, 0xFFFF},
+ {0x0900, 0x097F, 15, 0xFFFF},
+ {0x0980, 0x09FF, 16, 0xFFFF},
+ {0x0A00, 0x0A7F, 17, 0xFFFF},
+ {0x0A80, 0x0AFF, 18, 0xFFFF},
+ {0x0B00, 0x0B7F, 19, 0xFFFF},
+ {0x0B80, 0x0BFF, 20, 0xFFFF},
+ {0x0C00, 0x0C7F, 21, 0xFFFF},
+ {0x0C80, 0x0CFF, 22, 0xFFFF},
+ {0x0D00, 0x0D7F, 23, 0xFFFF},
+ {0x0D80, 0x0DFF, 73, 0xFFFF},
+ {0x0E00, 0x0E7F, 24, FX_CODEPAGE_MSDOS_Thai},
+ {0x0E80, 0x0EFF, 25, 0xFFFF},
+ {0x0F00, 0x0FFF, 70, 0xFFFF},
+ {0x1000, 0x109F, 74, 0xFFFF},
+ {0x10A0, 0x10FF, 26, 0xFFFF},
+ {0x1100, 0x11FF, 28, 0xFFFF},
+ {0x1200, 0x137F, 75, 0xFFFF},
+ {0x1380, 0x139F, 75, 0xFFFF},
+ {0x13A0, 0x13FF, 76, 0xFFFF},
+ {0x1400, 0x167F, 77, 0xFFFF},
+ {0x1680, 0x169F, 78, 0xFFFF},
+ {0x16A0, 0x16FF, 79, 0xFFFF},
+ {0x1700, 0x171F, 84, 0xFFFF},
+ {0x1720, 0x173F, 84, 0xFFFF},
+ {0x1740, 0x175F, 84, 0xFFFF},
+ {0x1760, 0x177F, 84, 0xFFFF},
+ {0x1780, 0x17FF, 80, 0xFFFF},
+ {0x1800, 0x18AF, 81, 0xFFFF},
+ {0x18B0, 0x18FF, 999, 0xFFFF},
+ {0x1900, 0x194F, 93, 0xFFFF},
+ {0x1950, 0x197F, 94, 0xFFFF},
+ {0x1980, 0x19DF, 95, 0xFFFF},
+ {0x19E0, 0x19FF, 80, 0xFFFF},
+ {0x1A00, 0x1A1F, 96, 0xFFFF},
+ {0x1A20, 0x1AFF, 999, 0xFFFF},
+ {0x1B00, 0x1B7F, 27, 0xFFFF},
+ {0x1B80, 0x1BBF, 112, 0xFFFF},
+ {0x1BC0, 0x1BFF, 999, 0xFFFF},
+ {0x1C00, 0x1C4F, 113, 0xFFFF},
+ {0x1C50, 0x1C7F, 114, 0xFFFF},
+ {0x1C80, 0x1CFF, 999, 0xFFFF},
+ {0x1D00, 0x1D7F, 4, 0xFFFF},
+ {0x1D80, 0x1DBF, 4, 0xFFFF},
+ {0x1DC0, 0x1DFF, 6, 0xFFFF},
+ {0x1E00, 0x1EFF, 29, 0xFFFF},
+ {0x1F00, 0x1FFF, 30, 0xFFFF},
+ {0x2000, 0x206F, 31, 0xFFFF},
+ {0x2070, 0x209F, 32, 0xFFFF},
+ {0x20A0, 0x20CF, 33, 0xFFFF},
+ {0x20D0, 0x20FF, 34, 0xFFFF},
+ {0x2100, 0x214F, 35, 0xFFFF},
+ {0x2150, 0x215F, 36, 0xFFFF},
+ {0x2160, 0x216B, 36, FX_CODEPAGE_ChineseSimplified},
+ {0x216C, 0x216F, 36, 0xFFFF},
+ {0x2170, 0x2179, 36, FX_CODEPAGE_ChineseSimplified},
+ {0x217A, 0x218F, 36, 0xFFFF},
+ {0x2190, 0x2199, 37, FX_CODEPAGE_Korean},
+ {0x219A, 0x21FF, 37, 0xFFFF},
+ {0x2200, 0x22FF, 38, 0xFFFF},
+ {0x2300, 0x23FF, 39, 0xFFFF},
+ {0x2400, 0x243F, 40, 0xFFFF},
+ {0x2440, 0x245F, 41, 0xFFFF},
+ {0x2460, 0x2473, 42, FX_CODEPAGE_ShiftJIS},
+ {0x2474, 0x249B, 42, FX_CODEPAGE_ChineseSimplified},
+ {0x249C, 0x24E9, 42, FX_CODEPAGE_Korean},
+ {0x24EA, 0x24FF, 42, 0xFFFF},
+ {0x2500, 0x2573, 43, FX_CODEPAGE_ChineseSimplified},
+ {0x2574, 0x257F, 43, 0xFFFF},
+ {0x2580, 0x2580, 44, 0xFFFF},
+ {0x2581, 0x258F, 44, FX_CODEPAGE_ChineseSimplified},
+ {0x2590, 0x259F, 44, 0xFFFF},
+ {0x25A0, 0x25FF, 45, 0xFFFF},
+ {0x2600, 0x26FF, 46, 0xFFFF},
+ {0x2700, 0x27BF, 47, 0xFFFF},
+ {0x27C0, 0x27EF, 38, 0xFFFF},
+ {0x27F0, 0x27FF, 37, 0xFFFF},
+ {0x2800, 0x28FF, 82, 0xFFFF},
+ {0x2900, 0x297F, 37, 0xFFFF},
+ {0x2980, 0x29FF, 38, 0xFFFF},
+ {0x2A00, 0x2AFF, 38, 0xFFFF},
+ {0x2B00, 0x2BFF, 37, 0xFFFF},
+ {0x2C00, 0x2C5F, 97, 0xFFFF},
+ {0x2C60, 0x2C7F, 29, 0xFFFF},
+ {0x2C80, 0x2CFF, 8, 0xFFFF},
+ {0x2D00, 0x2D2F, 26, 0xFFFF},
+ {0x2D30, 0x2D7F, 98, 0xFFFF},
+ {0x2D80, 0x2DDF, 75, 0xFFFF},
+ {0x2DE0, 0x2DFF, 9, 0xFFFF},
+ {0x2E00, 0x2E7F, 31, 0xFFFF},
+ {0x2E80, 0x2EFF, 59, 0xFFFF},
+ {0x2F00, 0x2FDF, 59, 0xFFFF},
+ {0x2FE0, 0x2FEF, 999, 0xFFFF},
+ {0x2FF0, 0x2FFF, 59, 0xFFFF},
+ {0x3000, 0x303F, 48, 0xFFFF},
+ {0x3040, 0x309F, 49, FX_CODEPAGE_ShiftJIS},
+ {0x30A0, 0x30FF, 50, FX_CODEPAGE_ShiftJIS},
+ {0x3100, 0x3129, 51, FX_CODEPAGE_ChineseSimplified},
+ {0x312A, 0x312F, 51, 0xFFFF},
+ {0x3130, 0x318F, 52, FX_CODEPAGE_Korean},
+ {0x3190, 0x319F, 59, 0xFFFF},
+ {0x31A0, 0x31BF, 51, 0xFFFF},
+ {0x31C0, 0x31EF, 61, 0xFFFF},
+ {0x31F0, 0x31FF, 50, 0xFFFF},
+ {0x3200, 0x321C, 54, FX_CODEPAGE_Korean},
+ {0x321D, 0x325F, 54, 0xFFFF},
+ {0x3260, 0x327F, 54, FX_CODEPAGE_Korean},
+ {0x3280, 0x32FF, 54, 0xFFFF},
+ {0x3300, 0x3387, 55, 0xFFFF},
+ {0x3388, 0x33D0, 55, FX_CODEPAGE_Korean},
+ {0x33D1, 0x33FF, 55, 0xFFFF},
+ {0x3400, 0x4DBF, 59, 0xFFFF},
+ {0x4DC0, 0x4DFF, 99, 0xFFFF},
+ {0x4E00, 0x9FA5, 59, FX_CODEPAGE_ChineseSimplified},
+ {0x9FA6, 0x9FFF, 59, 0xFFFF},
+ {0xA000, 0xA48F, 83, 0xFFFF},
+ {0xA490, 0xA4CF, 83, 0xFFFF},
+ {0xA4D0, 0xA4FF, 999, 0xFFFF},
+ {0xA500, 0xA63F, 12, 0xFFFF},
+ {0xA640, 0xA69F, 9, 0xFFFF},
+ {0xA6A0, 0xA6FF, 999, 0xFFFF},
+ {0xA700, 0xA71F, 5, 0xFFFF},
+ {0xA720, 0xA7FF, 29, 0xFFFF},
+ {0xA800, 0xA82F, 100, 0xFFFF},
+ {0xA830, 0xA8FF, 999, 0xFFFF},
+ {0xA840, 0xA87F, 53, 0xFFFF},
+ {0xA880, 0xA8DF, 115, 0xFFFF},
+ {0xA8E0, 0xA8FF, 999, 0xFFFF},
+ {0xA900, 0xA92F, 116, 0xFFFF},
+ {0xA930, 0xA95F, 117, 0xFFFF},
+ {0xA960, 0xA9FF, 999, 0xFFFF},
+ {0xAA00, 0xAA5F, 118, 0xFFFF},
+ {0xAA60, 0xABFF, 999, 0xFFFF},
+ {0xAC00, 0xD7AF, 56, FX_CODEPAGE_Korean},
+ {0xD7B0, 0xD7FF, 999, 0xFFFF},
+ {0xD800, 0xDB7F, 57, 0xFFFF},
+ {0xDB80, 0xDBFF, 57, 0xFFFF},
+ {0xDC00, 0xDFFF, 57, 0xFFFF},
+ {0xE000, 0xE814, 60, 0xFFFF},
+ {0xE815, 0xE864, 60, FX_CODEPAGE_ChineseSimplified},
+ {0xE865, 0xF8FF, 60, 0xFFFF},
+ {0xF900, 0xFA0B, 61, FX_CODEPAGE_Korean},
+ {0xFA0C, 0xFA0D, 61, FX_CODEPAGE_ChineseSimplified},
+ {0xFA0E, 0xFA2D, 61, FX_CODEPAGE_ShiftJIS},
+ {0xFA2E, 0xFAFF, 61, 0xFFFF},
+ {0xFB00, 0xFB4F, 62, 0xFFFF},
+ {0xFB50, 0xFDFF, 63, FX_CODEPAGE_MSWin_Arabic},
+ {0xFE00, 0xFE0F, 91, 0xFFFF},
+ {0xFE10, 0xFE1F, 65, 0xFFFF},
+ {0xFE20, 0xFE2F, 64, 0xFFFF},
+ {0xFE30, 0xFE4F, 65, 0xFFFF},
+ {0xFE50, 0xFE6F, 66, 0xFFFF},
+ {0xFE70, 0xFEFF, 67, FX_CODEPAGE_MSWin_Arabic},
+ {0xFF00, 0xFF5F, 68, FX_CODEPAGE_ChineseSimplified},
+ {0xFF60, 0xFF9F, 68, FX_CODEPAGE_ShiftJIS},
{0xFFA0, 0xFFEF, 68, 0xFFFF},
};
+} // namespace
+
const FGAS_FONTUSB* FGAS_GetUnicodeBitField(wchar_t wUnicode) {
int32_t iEnd = sizeof(g_FXGdiFontUSBTable) / sizeof(FGAS_FONTUSB) - 1;
ASSERT(iEnd >= 0);
- int32_t iStart = 0, iMid;
+
+ int32_t iStart = 0;
+ int32_t iMid;
do {
iMid = (iStart + iEnd) / 2;
const FGAS_FONTUSB& usb = g_FXGdiFontUSBTable[iMid];
- if (wUnicode < usb.wStartUnicode) {
+ if (wUnicode < usb.wStartUnicode)
iEnd = iMid - 1;
- } else if (wUnicode > usb.wEndUnicode) {
+ else if (wUnicode > usb.wEndUnicode)
iStart = iMid + 1;
- } else {
+ else
return &usb;
- }
} while (iStart <= iEnd);
return nullptr;
}
diff --git a/xfa/fgas/font/fgas_fontutils.h b/xfa/fgas/font/fgas_fontutils.h
index d92b469e7b..f247a1fe53 100644
--- a/xfa/fgas/font/fgas_fontutils.h
+++ b/xfa/fgas/font/fgas_fontutils.h
@@ -16,10 +16,6 @@ struct FGAS_FONTUSB {
uint16_t wCodePage;
};
-uint32_t FGAS_GetFontHashCode(uint16_t wCodePage, uint32_t dwFontStyles);
-uint32_t FGAS_GetFontFamilyHash(const wchar_t* pszFontFamily,
- uint32_t dwFontStyles,
- uint16_t wCodePage);
const FGAS_FONTUSB* FGAS_GetUnicodeBitField(wchar_t wUnicode);
#endif // XFA_FGAS_FONT_FGAS_FONTUTILS_H_