Chromium Code Reviews| Index: core/src/fpdfapi/fpdf_font/fpdf_font.cpp |
| diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp |
| index 8eae7cf3f8aaf8e436256bba3fa70ebb876747cb..dc2e4dcb8faf0d0b6e5f8715bd6a664f5d4b955a 100644 |
| --- a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp |
| +++ b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp |
| @@ -212,6 +212,7 @@ CFX_ByteString CPDF_Font::EncodeString(const CFX_WideString& str) const { |
| result.ReleaseBuffer(dest_pos); |
| return result; |
| } |
| + |
| void CPDF_Font::LoadFontDescriptor(CPDF_Dictionary* pFontDesc) { |
| m_Flags = pFontDesc->GetInteger(FX_BSTRC("Flags"), PDFFONT_NONSYMBOLIC); |
| int ItalicAngle = 0; |
| @@ -257,26 +258,27 @@ void CPDF_Font::LoadFontDescriptor(CPDF_Dictionary* pFontDesc) { |
| m_FontBBox.right = pBBox->GetInteger(2); |
| m_FontBBox.top = pBBox->GetInteger(3); |
| } |
| + |
| CPDF_Stream* pFontFile = pFontDesc->GetStream(FX_BSTRC("FontFile")); |
| - if (pFontFile == NULL) { |
| + if (!pFontFile) |
| pFontFile = pFontDesc->GetStream(FX_BSTRC("FontFile2")); |
| - } |
| - if (pFontFile == NULL) { |
| + if (!pFontFile) |
| pFontFile = pFontDesc->GetStream(FX_BSTRC("FontFile3")); |
| - } |
| - if (pFontFile) { |
| - m_pFontFile = m_pDocument->LoadFontFile(pFontFile); |
| - if (m_pFontFile == NULL) { |
| - return; |
| - } |
| - const uint8_t* pFontData = m_pFontFile->GetData(); |
| - FX_DWORD dwFontSize = m_pFontFile->GetSize(); |
| - m_Font.LoadEmbedded(pFontData, dwFontSize); |
| - if (m_Font.m_Face == NULL) { |
| - m_pFontFile = NULL; |
| - } |
| + if (!pFontFile) |
| + return; |
| + |
| + m_pFontFile = m_pDocument->LoadFontFile(pFontFile); |
| + if (!m_pFontFile) |
| + return; |
| + |
| + const uint8_t* pFontData = m_pFontFile->GetData(); |
| + FX_DWORD dwFontSize = m_pFontFile->GetSize(); |
| + m_Font.LoadEmbedded(pFontData, dwFontSize); |
| + if (!m_Font.GetFace()) { |
| + m_pFontFile = nullptr; |
|
Tom Sepez
2015/08/17 18:38:01
is this a leak?
Lei Zhang
2015/08/18 06:10:53
Probably. Also weird that it doesn't check the Loa
|
| } |
| } |
| + |
| short TT2PDF(int m, FXFT_Face face) { |
| int upm = FXFT_Get_Face_UnitsPerEM(face); |
| if (upm == 0) { |
| @@ -287,16 +289,14 @@ short TT2PDF(int m, FXFT_Face face) { |
| void CPDF_Font::CheckFontMetrics() { |
| if (m_FontBBox.top == 0 && m_FontBBox.bottom == 0 && m_FontBBox.left == 0 && |
| m_FontBBox.right == 0) { |
| - if (m_Font.m_Face) { |
| - m_FontBBox.left = |
| - TT2PDF(FXFT_Get_Face_xMin(m_Font.m_Face), m_Font.m_Face); |
| - m_FontBBox.bottom = |
| - TT2PDF(FXFT_Get_Face_yMin(m_Font.m_Face), m_Font.m_Face); |
| - m_FontBBox.right = |
| - TT2PDF(FXFT_Get_Face_xMax(m_Font.m_Face), m_Font.m_Face); |
| - m_FontBBox.top = TT2PDF(FXFT_Get_Face_yMax(m_Font.m_Face), m_Font.m_Face); |
| - m_Ascent = TT2PDF(FXFT_Get_Face_Ascender(m_Font.m_Face), m_Font.m_Face); |
| - m_Descent = TT2PDF(FXFT_Get_Face_Descender(m_Font.m_Face), m_Font.m_Face); |
| + FXFT_Face face = m_Font.GetFace(); |
| + if (face) { |
| + m_FontBBox.left = TT2PDF(FXFT_Get_Face_xMin(face), face); |
| + m_FontBBox.bottom = TT2PDF(FXFT_Get_Face_yMin(face), face); |
| + m_FontBBox.right = TT2PDF(FXFT_Get_Face_xMax(face), face); |
| + m_FontBBox.top = TT2PDF(FXFT_Get_Face_yMax(face), face); |
| + m_Ascent = TT2PDF(FXFT_Get_Face_Ascender(face), face); |
| + m_Descent = TT2PDF(FXFT_Get_Face_Descender(face), face); |
| } else { |
| FX_BOOL bFirst = TRUE; |
| for (int i = 0; i < 256; i++) { |
| @@ -360,9 +360,9 @@ int CPDF_Font::GetStringWidth(const FX_CHAR* pString, int size) { |
| return width; |
| } |
| int CPDF_Font::GetCharTypeWidth(FX_DWORD charcode) { |
| - if (m_Font.m_Face == NULL) { |
| + if (!m_Font.GetFace()) |
| return 0; |
| - } |
| + |
| int glyph_index = GlyphFromCharCode(charcode); |
| if (glyph_index == 0xffff) { |
| return 0; |
| @@ -822,9 +822,9 @@ int CPDF_SimpleFont::GlyphFromCharCode(FX_DWORD charcode, FX_BOOL* pVertGlyph) { |
| return index; |
| } |
| void CPDF_SimpleFont::LoadCharMetrics(int charcode) { |
| - if (m_Font.m_Face == NULL) { |
| + if (!m_Font.GetFace()) |
| return; |
| - } |
| + |
| if (charcode < 0 || charcode > 0xff) { |
| return; |
| } |
| @@ -839,27 +839,21 @@ void CPDF_SimpleFont::LoadCharMetrics(int charcode) { |
| } |
| return; |
| } |
| + FXFT_Face face = m_Font.GetFace(); |
| int err = FXFT_Load_Glyph( |
| - m_Font.m_Face, glyph_index, |
| + face, glyph_index, |
| FXFT_LOAD_NO_SCALE | FXFT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH); |
| if (err) { |
| return; |
| } |
| - m_CharBBox[charcode].Left = |
| - TT2PDF(FXFT_Get_Glyph_HoriBearingX(m_Font.m_Face), m_Font.m_Face); |
| - m_CharBBox[charcode].Right = |
| - TT2PDF(FXFT_Get_Glyph_HoriBearingX(m_Font.m_Face) + |
| - FXFT_Get_Glyph_Width(m_Font.m_Face), |
| - m_Font.m_Face); |
| - m_CharBBox[charcode].Top = |
| - TT2PDF(FXFT_Get_Glyph_HoriBearingY(m_Font.m_Face), m_Font.m_Face); |
| - m_CharBBox[charcode].Bottom = |
| - TT2PDF(FXFT_Get_Glyph_HoriBearingY(m_Font.m_Face) - |
| - FXFT_Get_Glyph_Height(m_Font.m_Face), |
| - m_Font.m_Face); |
| + m_CharBBox[charcode].Left = TT2PDF(FXFT_Get_Glyph_HoriBearingX(face), face); |
| + m_CharBBox[charcode].Right = TT2PDF( |
| + FXFT_Get_Glyph_HoriBearingX(face) + FXFT_Get_Glyph_Width(face), face); |
| + m_CharBBox[charcode].Top = TT2PDF(FXFT_Get_Glyph_HoriBearingY(face), face); |
| + m_CharBBox[charcode].Bottom = TT2PDF( |
| + FXFT_Get_Glyph_HoriBearingY(face) - FXFT_Get_Glyph_Height(face), face); |
| if (m_bUseFontWidth) { |
| - int TT_Width = |
| - TT2PDF(FXFT_Get_Glyph_HoriAdvance(m_Font.m_Face), m_Font.m_Face); |
| + int TT_Width = TT2PDF(FXFT_Get_Glyph_HoriAdvance(face), face); |
| if (m_CharWidth[charcode] == 0xffff) { |
| m_CharWidth[charcode] = TT_Width; |
| } else if (TT_Width && !IsEmbedded()) { |
| @@ -960,9 +954,9 @@ FX_BOOL CPDF_SimpleFont::LoadCommon() { |
| LoadGlyphMap(); |
| delete[] m_pCharNames; |
| m_pCharNames = NULL; |
| - if (m_Font.m_Face == NULL) { |
| + if (!m_Font.GetFace()) |
| return TRUE; |
| - } |
| + |
| if (m_Flags & PDFFONT_ALLCAP) { |
| unsigned char lowercases[] = {'a', 'z', 0xe0, 0xf6, 0xf8, 0xfd}; |
| for (size_t range = 0; range < sizeof lowercases / 2; range++) { |
| @@ -1001,7 +995,7 @@ void CPDF_SimpleFont::LoadSubstFont() { |
| int weight = m_StemV < 140 ? m_StemV * 5 : (m_StemV * 4 + 140); |
| m_Font.LoadSubst(m_BaseFont, IsFontType(PDFFONT_TRUETYPE), m_Flags, weight, |
| m_ItalicAngle, 0); |
| - if (m_Font.m_pSubstFont->m_SubstFlags & FXFONT_SUBST_NONSYMBOL) { |
| + if (m_Font.GetSubstFont()->m_SubstFlags & FXFONT_SUBST_NONSYMBOL) { |
| } |
| } |
| FX_BOOL CPDF_SimpleFont::IsUnicodeCompatible() const { |
| @@ -1095,9 +1089,10 @@ static const FX_CHAR* _GlyphNameRemap(const FX_CHAR* pStrAdobe) { |
| } |
| #endif |
| void CPDF_Type1Font::LoadGlyphMap() { |
| - if (m_Font.m_Face == NULL) { |
| + FXFT_Face face = m_Font.GetFace(); |
|
Tom Sepez
2015/08/17 18:38:01
We're sure no other methods change this value?
Lei Zhang
2015/08/18 06:10:53
I'll just change it back to GetFace() to be on the
|
| + if (!face) |
| return; |
| - } |
| + |
| #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| FX_BOOL bCoreText = TRUE; |
| CQuartz2D& quartz2d = |
| @@ -1114,17 +1109,16 @@ void CPDF_Type1Font::LoadGlyphMap() { |
| } |
| #endif |
| if (!IsEmbedded() && (m_Base14Font < 12) && m_Font.IsTTFont()) { |
| - if (FT_UseTTCharmap(m_Font.m_Face, 3, 0)) { |
| + if (FT_UseTTCharmap(face, 3, 0)) { |
| FX_BOOL bGotOne = FALSE; |
| for (int charcode = 0; charcode < 256; charcode++) { |
| const uint8_t prefix[4] = {0x00, 0xf0, 0xf1, 0xf2}; |
| for (int j = 0; j < 4; j++) { |
| FX_WORD unicode = prefix[j] * 256 + charcode; |
| - m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face, unicode); |
| + m_GlyphIndex[charcode] = FXFT_Get_Char_Index(face, unicode); |
| #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| FX_CHAR name_glyph[256]; |
| - FXFT_Get_Glyph_Name(m_Font.m_Face, m_GlyphIndex[charcode], name_glyph, |
| - 256); |
| + FXFT_Get_Glyph_Name(face, m_GlyphIndex[charcode], name_glyph, 256); |
| name_glyph[255] = 0; |
| CFStringRef name_ct = CFStringCreateWithCStringNoCopy( |
| kCFAllocatorDefault, name_glyph, kCFStringEncodingASCII, |
| @@ -1150,7 +1144,7 @@ void CPDF_Type1Font::LoadGlyphMap() { |
| return; |
| } |
| } |
| - FXFT_Select_Charmap(m_Font.m_Face, FXFT_ENCODING_UNICODE); |
| + FXFT_Select_Charmap(face, FXFT_ENCODING_UNICODE); |
| if (m_BaseEncoding == 0) { |
| m_BaseEncoding = PDFFONT_ENCODING_STANDARD; |
| } |
| @@ -1162,11 +1156,10 @@ void CPDF_Type1Font::LoadGlyphMap() { |
| } |
| m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); |
| m_GlyphIndex[charcode] = |
| - FXFT_Get_Char_Index(m_Font.m_Face, m_Encoding.m_Unicodes[charcode]); |
| + FXFT_Get_Char_Index(face, m_Encoding.m_Unicodes[charcode]); |
| #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| FX_CHAR name_glyph[256]; |
| - FXFT_Get_Glyph_Name(m_Font.m_Face, m_GlyphIndex[charcode], name_glyph, |
| - 256); |
| + FXFT_Get_Glyph_Name(face, m_GlyphIndex[charcode], name_glyph, 256); |
| name_glyph[255] = 0; |
| CFStringRef name_ct = CFStringCreateWithCStringNoCopy( |
| kCFAllocatorDefault, name_glyph, kCFStringEncodingASCII, |
| @@ -1179,11 +1172,10 @@ void CPDF_Type1Font::LoadGlyphMap() { |
| #endif |
| if (m_GlyphIndex[charcode] == 0 && FXSYS_strcmp(name, ".notdef") == 0) { |
| m_Encoding.m_Unicodes[charcode] = 0x20; |
| - m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face, 0x20); |
| + m_GlyphIndex[charcode] = FXFT_Get_Char_Index(face, 0x20); |
| #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| FX_CHAR name_glyph[256]; |
| - FXFT_Get_Glyph_Name(m_Font.m_Face, m_GlyphIndex[charcode], name_glyph, |
| - 256); |
| + FXFT_Get_Glyph_Name(face, m_GlyphIndex[charcode], name_glyph, 256); |
| name_glyph[255] = 0; |
| CFStringRef name_ct = CFStringCreateWithCStringNoCopy( |
| kCFAllocatorDefault, name_glyph, kCFStringEncodingASCII, |
| @@ -1203,7 +1195,7 @@ void CPDF_Type1Font::LoadGlyphMap() { |
| #endif |
| return; |
| } |
| - FT_UseType1Charmap(m_Font.m_Face); |
| + FT_UseType1Charmap(face); |
| #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| if (bCoreText) { |
| if (m_Flags & PDFFONT_SYMBOLIC) { |
| @@ -1212,8 +1204,7 @@ void CPDF_Type1Font::LoadGlyphMap() { |
| GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); |
| if (name) { |
| m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); |
| - m_GlyphIndex[charcode] = |
| - FXFT_Get_Name_Index(m_Font.m_Face, (char*)name); |
| + m_GlyphIndex[charcode] = FXFT_Get_Name_Index(face, (char*)name); |
| CFStringRef name_ct = CFStringCreateWithCStringNoCopy( |
| kCFAllocatorDefault, name, kCFStringEncodingASCII, |
| kCFAllocatorNull); |
| @@ -1223,7 +1214,7 @@ void CPDF_Type1Font::LoadGlyphMap() { |
| CFRelease(name_ct); |
| } |
| } else { |
| - m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face, charcode); |
| + m_GlyphIndex[charcode] = FXFT_Get_Char_Index(face, charcode); |
| FX_WCHAR unicode = 0; |
| if (m_GlyphIndex[charcode]) { |
| unicode = |
| @@ -1231,8 +1222,7 @@ void CPDF_Type1Font::LoadGlyphMap() { |
| } |
| FX_CHAR name_glyph[256]; |
| FXSYS_memset(name_glyph, 0, sizeof(name_glyph)); |
| - FXFT_Get_Glyph_Name(m_Font.m_Face, m_GlyphIndex[charcode], name_glyph, |
| - 256); |
| + FXFT_Get_Glyph_Name(face, m_GlyphIndex[charcode], name_glyph, 256); |
| name_glyph[255] = 0; |
| if (unicode == 0 && name_glyph[0] != 0) { |
| unicode = PDF_UnicodeFromAdobeName(name_glyph); |
| @@ -1251,7 +1241,7 @@ void CPDF_Type1Font::LoadGlyphMap() { |
| return; |
| } |
| FX_BOOL bUnicode = FALSE; |
| - if (0 == FXFT_Select_Charmap(m_Font.m_Face, FXFT_ENCODING_UNICODE)) { |
| + if (0 == FXFT_Select_Charmap(face, FXFT_ENCODING_UNICODE)) { |
| bUnicode = TRUE; |
| } |
| for (int charcode = 0; charcode < 256; charcode++) { |
| @@ -1262,10 +1252,10 @@ void CPDF_Type1Font::LoadGlyphMap() { |
| } |
| m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); |
| const FX_CHAR* pStrUnicode = _GlyphNameRemap(name); |
| - if (pStrUnicode && 0 == FXFT_Get_Name_Index(m_Font.m_Face, (char*)name)) { |
| + if (pStrUnicode && 0 == FXFT_Get_Name_Index(face, (char*)name)) { |
| name = pStrUnicode; |
| } |
| - m_GlyphIndex[charcode] = FXFT_Get_Name_Index(m_Font.m_Face, (char*)name); |
| + m_GlyphIndex[charcode] = FXFT_Get_Name_Index(face, (char*)name); |
| CFStringRef name_ct = CFStringCreateWithCStringNoCopy( |
| kCFAllocatorDefault, name, kCFStringEncodingASCII, kCFAllocatorNull); |
| m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName( |
| @@ -1277,11 +1267,9 @@ void CPDF_Type1Font::LoadGlyphMap() { |
| if (FXSYS_strcmp(name, ".notdef") != 0 && |
| FXSYS_strcmp(name, "space") != 0) { |
| m_GlyphIndex[charcode] = FXFT_Get_Char_Index( |
| - m_Font.m_Face, |
| - bUnicode ? m_Encoding.m_Unicodes[charcode] : charcode); |
| + face, bUnicode ? m_Encoding.m_Unicodes[charcode] : charcode); |
| FX_CHAR name_glyph[256]; |
| - FXFT_Get_Glyph_Name(m_Font.m_Face, m_GlyphIndex[charcode], name_glyph, |
| - 256); |
| + FXFT_Get_Glyph_Name(face, m_GlyphIndex[charcode], name_glyph, 256); |
| name_glyph[255] = 0; |
| CFStringRef name_ct = CFStringCreateWithCStringNoCopy( |
| kCFAllocatorDefault, name_glyph, kCFStringEncodingASCII, |
| @@ -1294,10 +1282,9 @@ void CPDF_Type1Font::LoadGlyphMap() { |
| } else { |
| m_Encoding.m_Unicodes[charcode] = 0x20; |
| m_GlyphIndex[charcode] = |
| - bUnicode ? FXFT_Get_Char_Index(m_Font.m_Face, 0x20) : 0xffff; |
| + bUnicode ? FXFT_Get_Char_Index(face, 0x20) : 0xffff; |
| FX_CHAR name_glyph[256]; |
| - FXFT_Get_Glyph_Name(m_Font.m_Face, m_GlyphIndex[charcode], name_glyph, |
| - 256); |
| + FXFT_Get_Glyph_Name(face, m_GlyphIndex[charcode], name_glyph, 256); |
| name_glyph[255] = 0; |
| CFStringRef name_ct = CFStringCreateWithCStringNoCopy( |
| kCFAllocatorDefault, name_glyph, kCFStringEncodingASCII, |
| @@ -1319,18 +1306,16 @@ void CPDF_Type1Font::LoadGlyphMap() { |
| GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); |
| if (name) { |
| m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); |
| - m_GlyphIndex[charcode] = |
| - FXFT_Get_Name_Index(m_Font.m_Face, (char*)name); |
| + m_GlyphIndex[charcode] = FXFT_Get_Name_Index(face, (char*)name); |
| } else { |
| - m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face, charcode); |
| + m_GlyphIndex[charcode] = FXFT_Get_Char_Index(face, charcode); |
| if (m_GlyphIndex[charcode]) { |
| FX_WCHAR unicode = |
| FT_UnicodeFromCharCode(PDFFONT_ENCODING_STANDARD, charcode); |
| if (unicode == 0) { |
| FX_CHAR name_glyph[256]; |
| FXSYS_memset(name_glyph, 0, sizeof(name_glyph)); |
| - FXFT_Get_Glyph_Name(m_Font.m_Face, m_GlyphIndex[charcode], |
| - name_glyph, 256); |
| + FXFT_Get_Glyph_Name(face, m_GlyphIndex[charcode], name_glyph, 256); |
| name_glyph[255] = 0; |
| if (name_glyph[0] != 0) { |
| unicode = PDF_UnicodeFromAdobeName(name_glyph); |
| @@ -1348,7 +1333,7 @@ void CPDF_Type1Font::LoadGlyphMap() { |
| return; |
| } |
| FX_BOOL bUnicode = FALSE; |
| - if (0 == FXFT_Select_Charmap(m_Font.m_Face, FXFT_ENCODING_UNICODE)) { |
| + if (0 == FXFT_Select_Charmap(face, FXFT_ENCODING_UNICODE)) { |
| bUnicode = TRUE; |
| } |
| for (int charcode = 0; charcode < 256; charcode++) { |
| @@ -1358,13 +1343,12 @@ void CPDF_Type1Font::LoadGlyphMap() { |
| continue; |
| } |
| m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); |
| - m_GlyphIndex[charcode] = FXFT_Get_Name_Index(m_Font.m_Face, (char*)name); |
| + m_GlyphIndex[charcode] = FXFT_Get_Name_Index(face, (char*)name); |
| if (m_GlyphIndex[charcode] == 0) { |
| if (FXSYS_strcmp(name, ".notdef") != 0 && |
| FXSYS_strcmp(name, "space") != 0) { |
| m_GlyphIndex[charcode] = FXFT_Get_Char_Index( |
| - m_Font.m_Face, |
| - bUnicode ? m_Encoding.m_Unicodes[charcode] : charcode); |
| + face, bUnicode ? m_Encoding.m_Unicodes[charcode] : charcode); |
| } else { |
| m_Encoding.m_Unicodes[charcode] = 0x20; |
| m_GlyphIndex[charcode] = 0xffff; |
| @@ -1449,19 +1433,20 @@ FX_BOOL CPDF_TrueTypeFont::_Load() { |
| return LoadCommon(); |
| } |
| void CPDF_TrueTypeFont::LoadGlyphMap() { |
| - if (m_Font.m_Face == NULL) { |
| + FXFT_Face face = m_Font.GetFace(); |
|
Tom Sepez
2015/08/17 18:38:01
ditto
Lei Zhang
2015/08/18 06:10:53
ditto ditto
|
| + if (!face) |
| return; |
| - } |
| + |
| int baseEncoding = m_BaseEncoding; |
| - if (m_pFontFile && m_Font.m_Face->num_charmaps > 0 && |
| + if (m_pFontFile && face->num_charmaps > 0 && |
| (baseEncoding == PDFFONT_ENCODING_MACROMAN || |
| baseEncoding == PDFFONT_ENCODING_WINANSI) && |
| (m_Flags & PDFFONT_SYMBOLIC)) { |
| FX_BOOL bSupportWin = FALSE; |
| FX_BOOL bSupportMac = FALSE; |
| - for (int i = 0; i < FXFT_Get_Face_CharmapCount(m_Font.m_Face); i++) { |
| + for (int i = 0; i < FXFT_Get_Face_CharmapCount(face); i++) { |
| int platform_id = |
| - FXFT_Get_Charmap_PlatformID(FXFT_Get_Face_Charmaps(m_Font.m_Face)[i]); |
| + FXFT_Get_Charmap_PlatformID(FXFT_Get_Face_Charmaps(face)[i]); |
| if (platform_id == 0 || platform_id == 3) { |
| bSupportWin = TRUE; |
| } else if (platform_id == 0 || platform_id == 1) { |
| @@ -1480,8 +1465,8 @@ void CPDF_TrueTypeFont::LoadGlyphMap() { |
| baseEncoding == PDFFONT_ENCODING_WINANSI) && |
| m_pCharNames == NULL) || |
| (m_Flags & PDFFONT_NONSYMBOLIC)) { |
| - if (!FXFT_Has_Glyph_Names(m_Font.m_Face) && |
| - (!m_Font.m_Face->num_charmaps || !m_Font.m_Face->charmaps)) { |
| + if (!FXFT_Has_Glyph_Names(face) && |
| + (!face->num_charmaps || !face->charmaps)) { |
| int nStartChar = m_pFontDict->GetInteger(FX_BSTRC("FirstChar")); |
| if (nStartChar < 0 || nStartChar > 255) |
| return; |
| @@ -1496,15 +1481,15 @@ void CPDF_TrueTypeFont::LoadGlyphMap() { |
| } |
| return; |
| } |
| - FX_BOOL bMSUnicode = FT_UseTTCharmap(m_Font.m_Face, 3, 1); |
| + FX_BOOL bMSUnicode = FT_UseTTCharmap(face, 3, 1); |
| FX_BOOL bMacRoman = FALSE, bMSSymbol = FALSE; |
| if (!bMSUnicode) { |
| if (m_Flags & PDFFONT_NONSYMBOLIC) { |
| - bMacRoman = FT_UseTTCharmap(m_Font.m_Face, 1, 0); |
| - bMSSymbol = !bMacRoman && FT_UseTTCharmap(m_Font.m_Face, 3, 0); |
| + bMacRoman = FT_UseTTCharmap(face, 1, 0); |
| + bMSSymbol = !bMacRoman && FT_UseTTCharmap(face, 3, 0); |
| } else { |
| - bMSSymbol = FT_UseTTCharmap(m_Font.m_Face, 3, 0); |
| - bMacRoman = !bMSSymbol && FT_UseTTCharmap(m_Font.m_Face, 1, 0); |
| + bMSSymbol = FT_UseTTCharmap(face, 3, 0); |
| + bMacRoman = !bMSSymbol && FT_UseTTCharmap(face, 1, 0); |
| } |
| } |
| FX_BOOL bToUnicode = m_pFontDict->KeyExist(FX_BSTRC("ToUnicode")); |
| @@ -1513,7 +1498,7 @@ void CPDF_TrueTypeFont::LoadGlyphMap() { |
| GetAdobeCharName(baseEncoding, m_pCharNames, charcode); |
| if (name == NULL) { |
| m_GlyphIndex[charcode] = |
| - m_pFontFile ? FXFT_Get_Char_Index(m_Font.m_Face, charcode) : -1; |
| + m_pFontFile ? FXFT_Get_Char_Index(face, charcode) : -1; |
| continue; |
| } |
| m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); |
| @@ -1521,46 +1506,42 @@ void CPDF_TrueTypeFont::LoadGlyphMap() { |
| const uint8_t prefix[4] = {0x00, 0xf0, 0xf1, 0xf2}; |
| for (int j = 0; j < 4; j++) { |
| FX_WORD unicode = prefix[j] * 256 + charcode; |
| - m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face, unicode); |
| + m_GlyphIndex[charcode] = FXFT_Get_Char_Index(face, unicode); |
| if (m_GlyphIndex[charcode]) { |
| break; |
| } |
| } |
| } else if (m_Encoding.m_Unicodes[charcode]) { |
| if (bMSUnicode) { |
| - m_GlyphIndex[charcode] = FXFT_Get_Char_Index( |
| - m_Font.m_Face, m_Encoding.m_Unicodes[charcode]); |
| + m_GlyphIndex[charcode] = |
| + FXFT_Get_Char_Index(face, m_Encoding.m_Unicodes[charcode]); |
| } else if (bMacRoman) { |
| FX_DWORD maccode = FT_CharCodeFromUnicode( |
| FXFT_ENCODING_APPLE_ROMAN, m_Encoding.m_Unicodes[charcode]); |
| if (!maccode) { |
| - m_GlyphIndex[charcode] = |
| - FXFT_Get_Name_Index(m_Font.m_Face, (char*)name); |
| + m_GlyphIndex[charcode] = FXFT_Get_Name_Index(face, (char*)name); |
| } else { |
| - m_GlyphIndex[charcode] = |
| - FXFT_Get_Char_Index(m_Font.m_Face, maccode); |
| + m_GlyphIndex[charcode] = FXFT_Get_Char_Index(face, maccode); |
| } |
| } |
| } |
| if ((m_GlyphIndex[charcode] == 0 || m_GlyphIndex[charcode] == 0xffff) && |
| name != NULL) { |
| if (name[0] == '.' && FXSYS_strcmp(name, ".notdef") == 0) { |
| - m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face, 32); |
| + m_GlyphIndex[charcode] = FXFT_Get_Char_Index(face, 32); |
| } else { |
| - m_GlyphIndex[charcode] = |
| - FXFT_Get_Name_Index(m_Font.m_Face, (char*)name); |
| + m_GlyphIndex[charcode] = FXFT_Get_Name_Index(face, (char*)name); |
| if (m_GlyphIndex[charcode] == 0) { |
| if (bToUnicode) { |
| CFX_WideString wsUnicode = UnicodeFromCharCode(charcode); |
| if (!wsUnicode.IsEmpty()) { |
| m_GlyphIndex[charcode] = |
| - FXFT_Get_Char_Index(m_Font.m_Face, wsUnicode[0]); |
| + FXFT_Get_Char_Index(face, wsUnicode[0]); |
| m_Encoding.m_Unicodes[charcode] = wsUnicode[0]; |
| } |
| } |
| if (m_GlyphIndex[charcode] == 0) { |
| - m_GlyphIndex[charcode] = |
| - FXFT_Get_Char_Index(m_Font.m_Face, charcode); |
| + m_GlyphIndex[charcode] = FXFT_Get_Char_Index(face, charcode); |
| } |
| } |
| } |
| @@ -1568,13 +1549,13 @@ void CPDF_TrueTypeFont::LoadGlyphMap() { |
| } |
| return; |
| } |
| - if (FT_UseTTCharmap(m_Font.m_Face, 3, 0)) { |
| + if (FT_UseTTCharmap(face, 3, 0)) { |
| const uint8_t prefix[4] = {0x00, 0xf0, 0xf1, 0xf2}; |
| FX_BOOL bGotOne = FALSE; |
| for (int charcode = 0; charcode < 256; charcode++) { |
| for (int j = 0; j < 4; j++) { |
| FX_WORD unicode = prefix[j] * 256 + charcode; |
| - m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face, unicode); |
| + m_GlyphIndex[charcode] = FXFT_Get_Char_Index(face, unicode); |
| if (m_GlyphIndex[charcode]) { |
| bGotOne = TRUE; |
| break; |
| @@ -1591,7 +1572,7 @@ void CPDF_TrueTypeFont::LoadGlyphMap() { |
| } |
| m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); |
| } |
| - } else if (FT_UseTTCharmap(m_Font.m_Face, 1, 0)) { |
| + } else if (FT_UseTTCharmap(face, 1, 0)) { |
| for (int charcode = 0; charcode < 256; charcode++) { |
| m_Encoding.m_Unicodes[charcode] = |
| FT_UnicodeFromCharCode(FXFT_ENCODING_APPLE_ROMAN, charcode); |
| @@ -1600,10 +1581,10 @@ void CPDF_TrueTypeFont::LoadGlyphMap() { |
| return; |
| } |
| } |
| - if (FT_UseTTCharmap(m_Font.m_Face, 1, 0)) { |
| + if (FT_UseTTCharmap(face, 1, 0)) { |
| FX_BOOL bGotOne = FALSE; |
| for (int charcode = 0; charcode < 256; charcode++) { |
| - m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face, charcode); |
| + m_GlyphIndex[charcode] = FXFT_Get_Char_Index(face, charcode); |
| m_Encoding.m_Unicodes[charcode] = |
| FT_UnicodeFromCharCode(FXFT_ENCODING_APPLE_ROMAN, charcode); |
| if (m_GlyphIndex[charcode]) { |
| @@ -1614,7 +1595,7 @@ void CPDF_TrueTypeFont::LoadGlyphMap() { |
| return; |
| } |
| } |
| - if (FXFT_Select_Charmap(m_Font.m_Face, FXFT_ENCODING_UNICODE) == 0) { |
| + if (FXFT_Select_Charmap(face, FXFT_ENCODING_UNICODE) == 0) { |
| FX_BOOL bGotOne = FALSE; |
| const FX_WORD* pUnicodes = PDF_UnicodesForPredefinedCharSet(baseEncoding); |
| for (int charcode = 0; charcode < 256; charcode++) { |
| @@ -1629,7 +1610,7 @@ void CPDF_TrueTypeFont::LoadGlyphMap() { |
| m_Encoding.m_Unicodes[charcode] = charcode; |
| } |
| m_GlyphIndex[charcode] = |
| - FXFT_Get_Char_Index(m_Font.m_Face, m_Encoding.m_Unicodes[charcode]); |
| + FXFT_Get_Char_Index(face, m_Encoding.m_Unicodes[charcode]); |
| if (m_GlyphIndex[charcode]) { |
| bGotOne = TRUE; |
| } |