| Index: core/src/fxge/ge/fx_ge_fontmap.cpp
|
| diff --git a/core/src/fxge/ge/fx_ge_fontmap.cpp b/core/src/fxge/ge/fx_ge_fontmap.cpp
|
| index 52605a003cf02066299d5d3031c2df05c901258b..6b0d7bf7e80094935f9d0399b0c3fc2578136ad4 100644
|
| --- a/core/src/fxge/ge/fx_ge_fontmap.cpp
|
| +++ b/core/src/fxge/ge/fx_ge_fontmap.cpp
|
| @@ -1083,6 +1083,11 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name,
|
| pSubstFont->m_SubstFlags |= FXFONT_SUBST_EXACT;
|
| }
|
| if (hFont == NULL) {
|
| +#ifdef PDF_ENABLE_XFA
|
| + if (flags & FXFONT_EXACTMATCH) {
|
| + return NULL;
|
| + }
|
| +#endif
|
| if (bCJK) {
|
| if (italic_angle != 0) {
|
| bItalic = TRUE;
|
| @@ -1208,6 +1213,90 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name,
|
| m_pFontInfo->DeleteFont(hFont);
|
| return face;
|
| }
|
| +#ifdef PDF_ENABLE_XFA
|
| +FXFT_Face CFX_FontMapper::FindSubstFontByUnicode(FX_DWORD dwUnicode,
|
| + FX_DWORD flags,
|
| + int weight,
|
| + int italic_angle) {
|
| + if (m_pFontInfo == NULL) {
|
| + return NULL;
|
| + }
|
| + FX_BOOL bItalic = (flags & FXFONT_ITALIC) != 0;
|
| + int PitchFamily = 0;
|
| + if (flags & FXFONT_SERIF) {
|
| + PitchFamily |= FXFONT_FF_ROMAN;
|
| + }
|
| + if (flags & FXFONT_SCRIPT) {
|
| + PitchFamily |= FXFONT_FF_SCRIPT;
|
| + }
|
| + if (flags & FXFONT_FIXED_PITCH) {
|
| + PitchFamily |= FXFONT_FF_FIXEDPITCH;
|
| + }
|
| + void* hFont =
|
| + m_pFontInfo->MapFontByUnicode(dwUnicode, weight, bItalic, PitchFamily);
|
| + if (hFont == NULL) {
|
| + return NULL;
|
| + }
|
| + FX_DWORD ttc_size = m_pFontInfo->GetFontData(hFont, 0x74746366, NULL, 0);
|
| + FX_DWORD font_size = m_pFontInfo->GetFontData(hFont, 0, NULL, 0);
|
| + if (font_size == 0 && ttc_size == 0) {
|
| + m_pFontInfo->DeleteFont(hFont);
|
| + return NULL;
|
| + }
|
| + FXFT_Face face = NULL;
|
| + if (ttc_size) {
|
| + uint8_t temp[1024];
|
| + m_pFontInfo->GetFontData(hFont, 0x74746366, temp, 1024);
|
| + FX_DWORD checksum = 0;
|
| + for (int i = 0; i < 256; i++) {
|
| + checksum += ((FX_DWORD*)temp)[i];
|
| + }
|
| + uint8_t* pFontData;
|
| + face = m_pFontMgr->GetCachedTTCFace(ttc_size, checksum,
|
| + ttc_size - font_size, pFontData);
|
| + if (face == NULL) {
|
| + pFontData = FX_Alloc(uint8_t, ttc_size);
|
| + if (pFontData) {
|
| + m_pFontInfo->GetFontData(hFont, 0x74746366, pFontData, ttc_size);
|
| + face = m_pFontMgr->AddCachedTTCFace(ttc_size, checksum, pFontData,
|
| + ttc_size, ttc_size - font_size);
|
| + }
|
| + }
|
| + } else {
|
| + CFX_ByteString SubstName;
|
| + m_pFontInfo->GetFaceName(hFont, SubstName);
|
| + uint8_t* pFontData;
|
| + face = m_pFontMgr->GetCachedFace(SubstName, weight, bItalic, pFontData);
|
| + if (face == NULL) {
|
| + pFontData = FX_Alloc(uint8_t, font_size);
|
| + if (!pFontData) {
|
| + m_pFontInfo->DeleteFont(hFont);
|
| + return NULL;
|
| + }
|
| + m_pFontInfo->GetFontData(hFont, 0, pFontData, font_size);
|
| + face = m_pFontMgr->AddCachedFace(SubstName, weight, bItalic, pFontData,
|
| + font_size,
|
| + m_pFontInfo->GetFaceIndex(hFont));
|
| + }
|
| + }
|
| + m_pFontInfo->DeleteFont(hFont);
|
| + return face;
|
| +}
|
| +
|
| +FX_BOOL CFX_FontMapper::IsBuiltinFace(const FXFT_Face face) const {
|
| + for (int i = 0; i < MM_FACE_COUNT; ++i) {
|
| + if (m_MMFaces[i] == face) {
|
| + return TRUE;
|
| + }
|
| + }
|
| + for (int i = 0; i < FOXIT_FACE_COUNT; ++i) {
|
| + if (m_FoxitFaces[i] == face) {
|
| + return TRUE;
|
| + }
|
| + }
|
| + return FALSE;
|
| +}
|
| +#endif
|
| extern "C" {
|
| unsigned long _FTStreamRead(FXFT_Stream stream,
|
| unsigned long offset,
|
| @@ -1429,6 +1518,14 @@ void* CFX_FolderFontInfo::MapFont(int weight,
|
| int& iExact) {
|
| return NULL;
|
| }
|
| +#ifdef PDF_ENABLE_XFA
|
| +void* CFX_FolderFontInfo::MapFontByUnicode(FX_DWORD dwUnicode,
|
| + int weight,
|
| + FX_BOOL bItalic,
|
| + int pitch_family) {
|
| + return NULL;
|
| +}
|
| +#endif
|
| void* CFX_FolderFontInfo::GetFont(const FX_CHAR* face) {
|
| auto it = m_FontList.find(face);
|
| return it != m_FontList.end() ? it->second : nullptr;
|
|
|