diff options
-rw-r--r-- | core/include/fxge/fx_font.h | 42 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp | 27 | ||||
-rw-r--r-- | core/src/fxge/ge/fx_ge_font.cpp | 205 | ||||
-rw-r--r-- | core/src/fxge/ge/text_int.h | 36 | ||||
-rw-r--r-- | xfa/src/fgas/src/font/fx_gefont.cpp | 23 | ||||
-rw-r--r-- | xfa/src/fgas/src/font/fx_gefont.h | 2 | ||||
-rw-r--r-- | xfa/src/fxbarcode/oned/BC_OneDimWriter.cpp | 11 | ||||
-rw-r--r-- | xfa/src/fxgraphics/src/fx_graphics.cpp | 9 | ||||
-rw-r--r-- | xfa/src/fxgraphics/src/fx_path_generator.h | 3 |
9 files changed, 127 insertions, 231 deletions
diff --git a/core/include/fxge/fx_font.h b/core/include/fxge/fx_font.h index ff664f9532..7eaa323717 100644 --- a/core/include/fxge/fx_font.h +++ b/core/include/fxge/fx_font.h @@ -140,18 +140,6 @@ class CFX_Font { #define ENCODING_INTERNAL 0 #define ENCODING_UNICODE 1 -class IFX_FontEncoding { - public: - virtual ~IFX_FontEncoding() {} - - virtual FX_DWORD GlyphFromCharCode(FX_DWORD charcode) = 0; - - virtual CFX_WideString UnicodeFromCharCode(FX_DWORD charcode) const = 0; - - virtual FX_DWORD CharCodeFromUnicode(FX_WCHAR Unicode) const = 0; -}; - -IFX_FontEncoding* FXGE_CreateUnicodeEncoding(CFX_Font* pFont); #define FXFM_ENC_TAG(a, b, c, d) \ (((FX_DWORD)(a) << 24) | ((FX_DWORD)(b) << 16) | ((FX_DWORD)(c) << 8) | \ (FX_DWORD)(d)) @@ -169,17 +157,37 @@ IFX_FontEncoding* FXGE_CreateUnicodeEncoding(CFX_Font* pFont); #define FXFM_ENCODING_ADOBE_LATIN_1 FXFM_ENC_TAG('l', 'a', 't', '1') #define FXFM_ENCODING_OLD_LATIN_2 FXFM_ENC_TAG('l', 'a', 't', '2') #define FXFM_ENCODING_APPLE_ROMAN FXFM_ENC_TAG('a', 'r', 'm', 'n') -class IFX_FontEncodingEx : public IFX_FontEncoding { + +class CFX_UnicodeEncoding { + public: + explicit CFX_UnicodeEncoding(CFX_Font* pFont); + virtual ~CFX_UnicodeEncoding(); + + virtual FX_DWORD GlyphFromCharCode(FX_DWORD charcode); + + protected: + // Unowned, not nullptr. + CFX_Font* m_pFont; +}; + +class CFX_UnicodeEncodingEx : public CFX_UnicodeEncoding { public: - virtual FX_DWORD GlyphIndexFromName(const FX_CHAR* pStrName) = 0; + CFX_UnicodeEncodingEx(CFX_Font* pFont, FX_DWORD EncodingID); + ~CFX_UnicodeEncodingEx() override; - virtual CFX_ByteString NameFromGlyphIndex(FX_DWORD dwGlyphIndex) = 0; + // CFX_UnicodeEncoding: + FX_DWORD GlyphFromCharCode(FX_DWORD charcode) override; - virtual FX_DWORD CharCodeFromGlyphIndex(FX_DWORD dwGlyphIndex) = 0; + FX_DWORD CharCodeFromUnicode(FX_WCHAR Unicode) const; + + private: + FX_DWORD m_nEncodingID; }; -IFX_FontEncodingEx* FX_CreateFontEncodingEx( + +CFX_UnicodeEncodingEx* FX_CreateFontEncodingEx( CFX_Font* pFont, FX_DWORD nEncodingID = FXFM_ENCODING_NONE); + #define FXFONT_SUBST_MM 0x01 #define FXFONT_SUBST_GLYPHPATH 0x04 #define FXFONT_SUBST_CLEARTYPE 0x08 diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp index 925693079f..1ff9876acc 100644 --- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp +++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp @@ -426,6 +426,7 @@ CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTA* pLogFont, return LoadFont(pBaseDict); } #endif + #if (_FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_) uint32_t FX_GetLangHashCode(const FX_CHAR* pStr) { FXSYS_assert(pStr != NULL); @@ -791,9 +792,10 @@ CPDF_Font* CPDF_Document::AddMacFont(CTFontRef pFont, CFRelease(languages); return LoadFont(pBaseDict); } -#endif +#endif // (_FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_) + static void _InsertWidthArray1(CFX_Font* pFont, - IFX_FontEncoding* pEncoding, + CFX_UnicodeEncoding* pEncoding, FX_WCHAR start, FX_WCHAR end, CPDF_Array* pWidthArray) { @@ -821,6 +823,7 @@ static void _InsertWidthArray1(CFX_Font* pFont, } FX_Free(widths); } + CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert) { if (pFont == NULL) { return NULL; @@ -843,7 +846,8 @@ CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert) { } CPDF_Dictionary* pBaseDict = new CPDF_Dictionary; pBaseDict->SetAtName("Type", "Font"); - IFX_FontEncoding* pEncoding = FXGE_CreateUnicodeEncoding(pFont); + nonstd::unique_ptr<CFX_UnicodeEncoding> pEncoding( + new CFX_UnicodeEncoding(pFont)); CPDF_Dictionary* pFontDict = pBaseDict; if (!bCJK) { CPDF_Array* pWidths = new CPDF_Array; @@ -921,35 +925,35 @@ CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert) { ordering = "CNS1"; supplement = 4; pWidthArray->AddInteger(1); - _InsertWidthArray1(pFont, pEncoding, 0x20, 0x7e, pWidthArray); + _InsertWidthArray1(pFont, pEncoding.get(), 0x20, 0x7e, pWidthArray); break; case FXFONT_GB2312_CHARSET: cmap = bVert ? "GBK-EUC-V" : "GBK-EUC-H"; ordering = "GB1", supplement = 2; pWidthArray->AddInteger(7716); - _InsertWidthArray1(pFont, pEncoding, 0x20, 0x20, pWidthArray); + _InsertWidthArray1(pFont, pEncoding.get(), 0x20, 0x20, pWidthArray); pWidthArray->AddInteger(814); - _InsertWidthArray1(pFont, pEncoding, 0x21, 0x7e, pWidthArray); + _InsertWidthArray1(pFont, pEncoding.get(), 0x21, 0x7e, pWidthArray); break; case FXFONT_HANGEUL_CHARSET: cmap = bVert ? "KSCms-UHC-V" : "KSCms-UHC-H"; ordering = "Korea1"; supplement = 2; pWidthArray->AddInteger(1); - _InsertWidthArray1(pFont, pEncoding, 0x20, 0x7e, pWidthArray); + _InsertWidthArray1(pFont, pEncoding.get(), 0x20, 0x7e, pWidthArray); break; case FXFONT_SHIFTJIS_CHARSET: cmap = bVert ? "90ms-RKSJ-V" : "90ms-RKSJ-H"; ordering = "Japan1"; supplement = 5; pWidthArray->AddInteger(231); - _InsertWidthArray1(pFont, pEncoding, 0x20, 0x7d, pWidthArray); + _InsertWidthArray1(pFont, pEncoding.get(), 0x20, 0x7d, pWidthArray); pWidthArray->AddInteger(326); - _InsertWidthArray1(pFont, pEncoding, 0xa0, 0xa0, pWidthArray); + _InsertWidthArray1(pFont, pEncoding.get(), 0xa0, 0xa0, pWidthArray); pWidthArray->AddInteger(327); - _InsertWidthArray1(pFont, pEncoding, 0xa1, 0xdf, pWidthArray); + _InsertWidthArray1(pFont, pEncoding.get(), 0xa1, 0xdf, pWidthArray); pWidthArray->AddInteger(631); - _InsertWidthArray1(pFont, pEncoding, 0x7e, 0x7e, pWidthArray); + _InsertWidthArray1(pFont, pEncoding.get(), 0x7e, 0x7e, pWidthArray); break; } pBaseDict->SetAtName("Subtype", "Type0"); @@ -1003,7 +1007,6 @@ CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert) { } } } - delete pEncoding; pFontDesc->SetAtInteger("StemV", nStemV); AddIndirectObject(pFontDesc); pFontDict->SetAtReference("FontDescriptor", this, pFontDesc); diff --git a/core/src/fxge/ge/fx_ge_font.cpp b/core/src/fxge/ge/fx_ge_font.cpp index 63e9b52954..c3e887146f 100644 --- a/core/src/fxge/ge/fx_ge_font.cpp +++ b/core/src/fxge/ge/fx_ge_font.cpp @@ -7,10 +7,39 @@ #include "../../../include/fxge/fx_ge.h" #include "../../../include/fxge/fx_freetype.h" #include "text_int.h" + #define EM_ADJUST(em, a) (em == 0 ? (a) : (a)*1000 / em) extern void _FPDFAPI_GetInternalFontData(int id1, const uint8_t*& data, FX_DWORD& size); + +namespace { + +const FX_DWORD g_EncodingID[] = { + FXFM_ENCODING_MS_SYMBOL, + FXFM_ENCODING_UNICODE, + FXFM_ENCODING_MS_SJIS, + FXFM_ENCODING_MS_GB2312, + FXFM_ENCODING_MS_BIG5, + FXFM_ENCODING_MS_WANSUNG, + FXFM_ENCODING_MS_JOHAB, + FXFM_ENCODING_ADOBE_STANDARD, + FXFM_ENCODING_ADOBE_EXPERT, + FXFM_ENCODING_ADOBE_CUSTOM, + FXFM_ENCODING_ADOBE_LATIN_1, + FXFM_ENCODING_OLD_LATIN_2, + FXFM_ENCODING_APPLE_ROMAN, +}; + +CFX_UnicodeEncodingEx* _FXFM_CreateFontEncoding(CFX_Font* pFont, + FX_DWORD nEncodingID) { + if (FXFT_Select_Charmap(pFont->m_Face, nEncodingID)) + return nullptr; + return new CFX_UnicodeEncodingEx(pFont, nEncodingID); +} + +} // namespace + CFX_Font::CFX_Font() { m_pSubstFont = NULL; m_Face = NULL; @@ -420,67 +449,41 @@ int CFX_Font::GetULthickness() { FXFT_Get_Face_UnderLineThickness(m_Face)); return thickness; } -CFX_UnicodeEncoding::CFX_UnicodeEncoding(CFX_Font* pFont) { - m_pFont = pFont; + +CFX_UnicodeEncoding::CFX_UnicodeEncoding(CFX_Font* pFont) : m_pFont(pFont) { } + +CFX_UnicodeEncoding::~CFX_UnicodeEncoding() { +} + FX_DWORD CFX_UnicodeEncoding::GlyphFromCharCode(FX_DWORD charcode) { FXFT_Face face = m_pFont->GetFace(); - if (!face) { + if (!face) return charcode; - } - if (FXFT_Select_Charmap(face, FXFT_ENCODING_UNICODE) == 0) { + + if (FXFT_Select_Charmap(face, FXFT_ENCODING_UNICODE) == 0) return FXFT_Get_Char_Index(face, charcode); - } + if (m_pFont->m_pSubstFont && m_pFont->m_pSubstFont->m_Charset == 2) { FX_DWORD index = 0; - if (FXFT_Select_Charmap(face, FXFT_ENCODING_MS_SYMBOL) == 0) { + if (FXFT_Select_Charmap(face, FXFT_ENCODING_MS_SYMBOL) == 0) index = FXFT_Get_Char_Index(face, charcode); - } - if (!index && !FXFT_Select_Charmap(face, FXFT_ENCODING_APPLE_ROMAN)) { + if (!index && !FXFT_Select_Charmap(face, FXFT_ENCODING_APPLE_ROMAN)) return FXFT_Get_Char_Index(face, charcode); - } } return charcode; } -FX_DWORD CFX_UnicodeEncoding::GlyphFromCharCodeEx(FX_DWORD charcode, - int encoding) { - FXFT_Face face = m_pFont->GetFace(); - if (!face) { - return charcode; - } - if (encoding == ENCODING_UNICODE) { - return GlyphFromCharCode(charcode); - } - int nmaps = FXFT_Get_Face_CharmapCount(m_pFont->m_Face); - int i = 0; - while (i < nmaps) { - int encoding = FXFT_Get_Charmap_Encoding(FXFT_Get_Face_Charmaps(face)[i++]); - if (encoding != FXFT_ENCODING_UNICODE) { - FXFT_Select_Charmap(face, encoding); - break; - } - } - return FXFT_Get_Char_Index(face, charcode); -} -IFX_FontEncoding* FXGE_CreateUnicodeEncoding(CFX_Font* pFont) { - CFX_UnicodeEncoding* pEncoding = NULL; - pEncoding = new CFX_UnicodeEncoding(pFont); - return pEncoding; -} -CFX_FontEncodingEX::CFX_FontEncodingEX() { - m_pFont = NULL; - m_nEncodingID = FXFM_ENCODING_NONE; + +CFX_UnicodeEncodingEx::CFX_UnicodeEncodingEx(CFX_Font* pFont, + FX_DWORD EncodingID) + : CFX_UnicodeEncoding(pFont), m_nEncodingID(EncodingID) { } -FX_BOOL CFX_FontEncodingEX::Init(CFX_Font* pFont, FX_DWORD EncodingID) { - if (!pFont) { - return FALSE; - } - m_pFont = pFont; - m_nEncodingID = EncodingID; - return TRUE; + +CFX_UnicodeEncodingEx::~CFX_UnicodeEncodingEx() { } -FX_DWORD CFX_FontEncodingEX::GlyphFromCharCode(FX_DWORD charcode) { - FXFT_Face face = m_pFont->m_Face; + +FX_DWORD CFX_UnicodeEncodingEx::GlyphFromCharCode(FX_DWORD charcode) { + FXFT_Face face = m_pFont->GetFace(); FT_UInt nIndex = FXFT_Get_Char_Index(face, charcode); if (nIndex > 0) { return nIndex; @@ -506,14 +509,8 @@ FX_DWORD CFX_FontEncodingEX::GlyphFromCharCode(FX_DWORD charcode) { FXFT_Select_Charmap(face, m_nEncodingID); return 0; } -CFX_WideString CFX_FontEncodingEX::UnicodeFromCharCode( - FX_DWORD charcode) const { - if (m_nEncodingID == FXFM_ENCODING_UNICODE) { - return CFX_WideString((FX_WCHAR)charcode); - } - return CFX_WideString((FX_WCHAR)0); -} -FX_DWORD CFX_FontEncodingEX::CharCodeFromUnicode(FX_WCHAR Unicode) const { + +FX_DWORD CFX_UnicodeEncodingEx::CharCodeFromUnicode(FX_WCHAR Unicode) const { if (m_nEncodingID == FXFM_ENCODING_UNICODE || m_nEncodingID == FXFM_ENCODING_MS_SYMBOL) { return Unicode; @@ -530,94 +527,18 @@ FX_DWORD CFX_FontEncodingEX::CharCodeFromUnicode(FX_WCHAR Unicode) const { } return -1; } -FX_BOOL CFX_FontEncodingEX::IsUnicodeCompatible() const { - return m_nEncodingID == FXFM_ENCODING_UNICODE; -} -FX_DWORD CFX_FontEncodingEX::GlyphIndexFromName(const FX_CHAR* pStrName) { - FXFT_Face face = m_pFont->m_Face; - return FT_Get_Name_Index(face, (FT_String*)pStrName); -} -CFX_ByteString CFX_FontEncodingEX::NameFromGlyphIndex(FX_DWORD dwGlyphIndex) { - FXFT_Face face = m_pFont->m_Face; - CFX_ByteString glyphName(" "); - if (FT_HAS_GLYPH_NAMES(((FT_Face)face))) { - if (FT_Get_Glyph_Name((FT_Face)face, dwGlyphIndex, - (FT_Pointer)(const FX_CHAR*)glyphName, 16)) { - glyphName.Empty(); - return glyphName; - } - return glyphName; - } else { - return glyphName; - } -} -FX_DWORD CFX_FontEncodingEX::CharCodeFromGlyphIndex(FX_DWORD dwGlyphIndex) { - FXFT_Face face = m_pFont->GetFace(); - FX_DWORD charcode; - FT_UInt gid; - charcode = FT_Get_First_Char((FT_Face)face, &gid); - while (gid != 0) { - if (dwGlyphIndex == gid) { - return charcode; - } - charcode = FT_Get_Next_Char((FT_Face)face, charcode, &gid); - } - int nmaps = FXFT_Get_Face_CharmapCount(face); - int m = 0; - while (m < nmaps) { - int nEncodingID = - FXFT_Get_Charmap_Encoding(FXFT_Get_Face_Charmaps(face)[m++]); - if (m_nEncodingID == nEncodingID) { - continue; - } - int error = FXFT_Select_Charmap(face, nEncodingID); - if (error) { - continue; - } - charcode = FT_Get_First_Char((FT_Face)face, &gid); - while (gid != 0) { - if (dwGlyphIndex == gid) { - m_nEncodingID = nEncodingID; - return charcode; - } - charcode = FT_Get_Next_Char((FT_Face)face, charcode, &gid); - } - } - return (FX_DWORD)-1; -} -static const FX_DWORD gs_EncodingID[] = { - FXFM_ENCODING_MS_SYMBOL, FXFM_ENCODING_UNICODE, - FXFM_ENCODING_MS_SJIS, FXFM_ENCODING_MS_GB2312, - FXFM_ENCODING_MS_BIG5, FXFM_ENCODING_MS_WANSUNG, - FXFM_ENCODING_MS_JOHAB, FXFM_ENCODING_ADOBE_STANDARD, - FXFM_ENCODING_ADOBE_EXPERT, FXFM_ENCODING_ADOBE_CUSTOM, - FXFM_ENCODING_ADOBE_LATIN_1, FXFM_ENCODING_OLD_LATIN_2, - FXFM_ENCODING_APPLE_ROMAN}; -static IFX_FontEncodingEx* _FXFM_CreateFontEncoding(CFX_Font* pFont, - FX_DWORD nEncodingID) { - int error = FXFT_Select_Charmap(pFont->m_Face, nEncodingID); - if (error) { - return NULL; - } - CFX_FontEncodingEX* pFontEncoding = new CFX_FontEncodingEX; - if (pFontEncoding && !pFontEncoding->Init(pFont, nEncodingID)) { - delete pFontEncoding; - pFontEncoding = NULL; - } - return pFontEncoding; -} -IFX_FontEncodingEx* FX_CreateFontEncodingEx(CFX_Font* pFont, - FX_DWORD nEncodingID) { - if (!pFont || !pFont->m_Face) { - return NULL; - } - if (nEncodingID != FXFM_ENCODING_NONE) { + +CFX_UnicodeEncodingEx* FX_CreateFontEncodingEx(CFX_Font* pFont, + FX_DWORD nEncodingID) { + if (!pFont || !pFont->m_Face) + return nullptr; + + if (nEncodingID != FXFM_ENCODING_NONE) return _FXFM_CreateFontEncoding(pFont, nEncodingID); - } - static int s_count = sizeof(gs_EncodingID) / sizeof(FX_DWORD); - for (int i = 0; i < s_count; i++) { - IFX_FontEncodingEx* pFontEncoding = - _FXFM_CreateFontEncoding(pFont, gs_EncodingID[i]); + + for (size_t i = 0; i < FX_ArraySize(g_EncodingID); ++i) { + CFX_UnicodeEncodingEx* pFontEncoding = + _FXFM_CreateFontEncoding(pFont, g_EncodingID[i]); if (pFontEncoding) { return pFontEncoding; } diff --git a/core/src/fxge/ge/text_int.h b/core/src/fxge/ge/text_int.h index 9279969e0a..b0193c4f2e 100644 --- a/core/src/fxge/ge/text_int.h +++ b/core/src/fxge/ge/text_int.h @@ -41,23 +41,7 @@ class CTTFontDesc { uint8_t* m_pFontData; int m_RefCount; }; -class CFX_UnicodeEncoding : public IFX_FontEncoding { - public: - CFX_UnicodeEncoding(CFX_Font* pFont); - virtual FX_DWORD GlyphFromCharCodeEx(FX_DWORD charcode, - int encoding = ENCODING_UNICODE); - private: - CFX_Font* m_pFont; - virtual FX_DWORD GlyphFromCharCode(FX_DWORD charcode); - virtual CFX_WideString UnicodeFromCharCode(FX_DWORD charcode) const { - return CFX_WideString((FX_WCHAR)charcode); - } - virtual FX_DWORD CharCodeFromUnicode(FX_WCHAR Unicode) const { - return Unicode; - } - virtual FX_BOOL IsUnicodeCompatible() const { return TRUE; } -}; #define CHARSET_FLAG_ANSI 1 #define CHARSET_FLAG_SYMBOL 2 #define CHARSET_FLAG_SHIFTJIS 4 @@ -105,25 +89,5 @@ class CFontFileFaceInfo { int m_PitchFamily; CFX_ByteString m_FontTables; }; -class CFX_FontEncodingEX : public IFX_FontEncodingEx { - public: - CFX_FontEncodingEX(); - FX_BOOL Init(CFX_Font* pFont, FX_DWORD EncodingID); - virtual FX_DWORD GlyphIndexFromName(const FX_CHAR* pStrName); - virtual CFX_ByteString NameFromGlyphIndex(FX_DWORD dwGlyphIndex); - virtual FX_DWORD CharCodeFromGlyphIndex(FX_DWORD dwGlyphIndex); - virtual FX_DWORD GlyphFromCharCode(FX_DWORD charcode); - virtual CFX_WideString UnicodeFromCharCode(FX_DWORD charcode) const; - virtual FX_DWORD CharCodeFromUnicode(FX_WCHAR Unicode) const; - virtual FX_BOOL IsUnicodeCompatible() const; - virtual FX_DWORD GlyphFromCharCodeEx(FX_DWORD charcode, - int encoding = ENCODING_UNICODE) { - return GlyphFromCharCode(charcode); - } - - private: - CFX_Font* m_pFont; - FX_DWORD m_nEncodingID; -}; #endif // CORE_SRC_FXGE_GE_TEXT_INT_H_ diff --git a/xfa/src/fgas/src/font/fx_gefont.cpp b/xfa/src/fgas/src/font/fx_gefont.cpp index 8c81f9a8e5..0da6720e2c 100644 --- a/xfa/src/fgas/src/font/fx_gefont.cpp +++ b/xfa/src/fgas/src/font/fx_gefont.cpp @@ -88,6 +88,10 @@ IFX_Font* IFX_Font::LoadFont(CFX_Font* pExtFont, }
CFX_GEFont::CFX_GEFont(IFX_FontMgr* pFontMgr)
: CFX_ThreadLock(),
+#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
+ m_bUseLogFontStyle(FALSE),
+ m_dwLogFontStyle(0),
+#endif
m_pFont(NULL),
m_pFontMgr(pFontMgr),
m_iRefCount(1),
@@ -98,19 +102,18 @@ CFX_GEFont::CFX_GEFont(IFX_FontMgr* pFontMgr) m_pCharWidthMap(NULL),
m_pRectArray(NULL),
m_pBBoxMap(NULL),
+ m_pProvider(NULL),
m_wCharSet(0xFFFF),
- m_pProvider(NULL)
-#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
- ,
- m_bUseLogFontStyle(FALSE),
- m_dwLogFontStyle(0)
-#endif
- ,
m_SubstFonts(),
m_FontMapper(16) {
}
+
CFX_GEFont::CFX_GEFont(const CFX_GEFont& src, FX_DWORD dwFontStyles)
: CFX_ThreadLock(),
+#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
+ m_bUseLogFontStyle(FALSE),
+ m_dwLogFontStyle(0),
+#endif
m_pFont(NULL),
m_pFontMgr(src.m_pFontMgr),
m_iRefCount(1),
@@ -121,8 +124,8 @@ CFX_GEFont::CFX_GEFont(const CFX_GEFont& src, FX_DWORD dwFontStyles) m_pCharWidthMap(NULL),
m_pRectArray(NULL),
m_pBBoxMap(NULL),
- m_wCharSet(0xFFFF),
m_pProvider(NULL),
+ m_wCharSet(0xFFFF),
m_SubstFonts(),
m_FontMapper(16) {
m_pFont = new CFX_Font;
@@ -334,11 +337,7 @@ void CFX_GEFont::InitFont() { return;
}
if (m_pFontEncoding == NULL) {
-#ifdef FXFM_ENCODING_NONE
m_pFontEncoding = FX_CreateFontEncodingEx(m_pFont);
-#else
- m_pFontEncoding = FXGE_CreateUnicodeEncoding(m_pFont);
-#endif
}
if (m_pCharWidthMap == NULL) {
m_pCharWidthMap = new CFX_WordDiscreteArray(1024);
diff --git a/xfa/src/fgas/src/font/fx_gefont.h b/xfa/src/fgas/src/font/fx_gefont.h index a0c9aa8e02..5620f07bf2 100644 --- a/xfa/src/fgas/src/font/fx_gefont.h +++ b/xfa/src/fgas/src/font/fx_gefont.h @@ -64,7 +64,7 @@ class CFX_GEFont : public IFX_Font, public CFX_ThreadLock { FX_BOOL m_bExtFont;
IFX_Stream* m_pStream;
IFX_FileRead* m_pFileRead;
- IFX_FontEncoding* m_pFontEncoding;
+ CFX_UnicodeEncoding* m_pFontEncoding;
CFX_WordDiscreteArray* m_pCharWidthMap;
CFX_RectMassArray* m_pRectArray;
CFX_MapPtrToPtr* m_pBBoxMap;
diff --git a/xfa/src/fxbarcode/oned/BC_OneDimWriter.cpp b/xfa/src/fxbarcode/oned/BC_OneDimWriter.cpp index aaab954380..8332986bae 100644 --- a/xfa/src/fxbarcode/oned/BC_OneDimWriter.cpp +++ b/xfa/src/fxbarcode/oned/BC_OneDimWriter.cpp @@ -20,6 +20,7 @@ * limitations under the License.
*/
+#include "../../../../third_party/base/nonstd_unique_ptr.h"
#include "../barcode.h"
#include "../BC_Writer.h"
#include "../common/BC_CommonBitMatrix.h"
@@ -129,11 +130,9 @@ void CBC_OneDimWriter::CalcTextInfo(const CFX_ByteString& text, FX_FLOAT geWidth,
int32_t fontSize,
FX_FLOAT& charsLen) {
-#ifdef FXFM_ENCODING_NONE
- IFX_FontEncodingEx* encoding = FX_CreateFontEncodingEx(cFont);
-#else
- IFX_FontEncoding* encoding = FXGE_CreateUnicodeEncoding(cFont);
-#endif
+ nonstd::unique_ptr<CFX_UnicodeEncodingEx> encoding(
+ FX_CreateFontEncodingEx(cFont));
+
int32_t length = text.GetLength();
FX_DWORD* pCharCode = FX_Alloc(FX_DWORD, text.GetLength());
FX_FLOAT charWidth = 0;
@@ -174,8 +173,6 @@ void CBC_OneDimWriter::CalcTextInfo(const CFX_ByteString& text, (FX_FLOAT)(charPos[i].m_FontCharWidth) * (FX_FLOAT)fontSize / 1000.0f;
}
FX_Free(pCharCode);
- delete encoding;
- encoding = NULL;
}
void CBC_OneDimWriter::ShowDeviceChars(CFX_RenderDevice* device,
const CFX_Matrix* matrix,
diff --git a/xfa/src/fxgraphics/src/fx_graphics.cpp b/xfa/src/fxgraphics/src/fx_graphics.cpp index c5eac42e87..df0ecbba22 100644 --- a/xfa/src/fxgraphics/src/fx_graphics.cpp +++ b/xfa/src/fxgraphics/src/fx_graphics.cpp @@ -4,8 +4,10 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "pre.h"
+#include "../../../../third_party/base/nonstd_unique_ptr.h"
#include "fx_path_generator.h"
+#include "pre.h"
+
class CAGG_Graphics {
public:
CAGG_Graphics();
@@ -1098,7 +1100,8 @@ FX_ERR CFX_Graphics::CalcTextInfo(const CFX_WideString& text, FX_DWORD* charCodes,
FXTEXT_CHARPOS* charPos,
CFX_RectF& rect) {
- IFX_FontEncoding* encoding = FXGE_CreateUnicodeEncoding(_info._font);
+ nonstd::unique_ptr<CFX_UnicodeEncoding> encoding(
+ new CFX_UnicodeEncoding(_info._font));
int32_t length = text.GetLength();
FX_FLOAT penX = (FX_FLOAT)rect.left;
FX_FLOAT penY = (FX_FLOAT)rect.top;
@@ -1135,8 +1138,6 @@ FX_ERR CFX_Graphics::CalcTextInfo(const CFX_WideString& text, }
rect.width = (FX_FLOAT)penX - rect.left;
rect.height = rect.top + _info._fontSize * _info._fontHScale - rect.top;
- delete encoding;
- encoding = NULL;
return FX_ERR_Succeeded;
}
CAGG_Graphics::CAGG_Graphics() {
diff --git a/xfa/src/fxgraphics/src/fx_path_generator.h b/xfa/src/fxgraphics/src/fx_path_generator.h index 7d34fe2d07..663087d4c3 100644 --- a/xfa/src/fxgraphics/src/fx_path_generator.h +++ b/xfa/src/fxgraphics/src/fx_path_generator.h @@ -6,6 +6,9 @@ #ifndef __H_FX_PATH_GENERATOR__
#define __H_FX_PATH_GENERATOR__
+
+#include "../../../../core/include/fxge/fx_ge.h"
+
class CFX_PathGenerator {
public:
CFX_PathGenerator();
|