| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "../../../include/fpdfapi/fpdf_page.h" | 7 #include "../../../include/fpdfapi/fpdf_page.h" |
| 8 #include "../../../include/fpdfapi/fpdf_module.h" | 8 #include "../../../include/fpdfapi/fpdf_module.h" |
| 9 #include "../../../include/fpdfapi/fpdf_pageobj.h" | 9 #include "../../../include/fpdfapi/fpdf_pageobj.h" |
| 10 #include "font_int.h" | 10 #include "font_int.h" |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 } | 405 } |
| 406 CPDF_Dictionary* pDict = CPDF_Dictionary::Create(); | 406 CPDF_Dictionary* pDict = CPDF_Dictionary::Create(); |
| 407 pDict->SetAtName(FX_BSTRC("Type"), FX_BSTRC("Font")); | 407 pDict->SetAtName(FX_BSTRC("Type"), FX_BSTRC("Font")); |
| 408 pDict->SetAtName(FX_BSTRC("Subtype"), FX_BSTRC("Type1")); | 408 pDict->SetAtName(FX_BSTRC("Subtype"), FX_BSTRC("Type1")); |
| 409 pDict->SetAtName(FX_BSTRC("BaseFont"), fontname); | 409 pDict->SetAtName(FX_BSTRC("BaseFont"), fontname); |
| 410 pDict->SetAtName(FX_BSTRC("Encoding"), FX_BSTRC("WinAnsiEncoding")); | 410 pDict->SetAtName(FX_BSTRC("Encoding"), FX_BSTRC("WinAnsiEncoding")); |
| 411 pFont = CPDF_Font::CreateFontF(NULL, pDict); | 411 pFont = CPDF_Font::CreateFontF(NULL, pDict); |
| 412 pFontGlobals->Set(pDoc, font_id, pFont); | 412 pFontGlobals->Set(pDoc, font_id, pFont); |
| 413 return pFont; | 413 return pFont; |
| 414 } | 414 } |
| 415 const FX_BYTE ChineseFontNames[][5] = { | 415 const uint8_t ChineseFontNames[][5] = { |
| 416 {0xCB, 0xCE, 0xCC, 0xE5, 0x00}, | 416 {0xCB, 0xCE, 0xCC, 0xE5, 0x00}, |
| 417 {0xBF, 0xAC, 0xCC, 0xE5, 0x00}, | 417 {0xBF, 0xAC, 0xCC, 0xE5, 0x00}, |
| 418 {0xBA, 0xDA, 0xCC, 0xE5, 0x00}, | 418 {0xBA, 0xDA, 0xCC, 0xE5, 0x00}, |
| 419 {0xB7, 0xC2, 0xCB, 0xCE, 0x00}, | 419 {0xB7, 0xC2, 0xCB, 0xCE, 0x00}, |
| 420 {0xD0, 0xC2, 0xCB, 0xCE, 0x00} | 420 {0xD0, 0xC2, 0xCB, 0xCE, 0x00} |
| 421 }; | 421 }; |
| 422 CPDF_Font* CPDF_Font::CreateFontF(CPDF_Document* pDoc, CPDF_Dictionary* pFontDic
t) | 422 CPDF_Font* CPDF_Font::CreateFontF(CPDF_Document* pDoc, CPDF_Dictionary* pFontDic
t) |
| 423 { | 423 { |
| 424 CFX_ByteString type = pFontDict->GetString(FX_BSTRC("Subtype")); | 424 CFX_ByteString type = pFontDict->GetString(FX_BSTRC("Subtype")); |
| 425 CPDF_Font* pFont; | 425 CPDF_Font* pFont; |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 return FALSE; | 809 return FALSE; |
| 810 } | 810 } |
| 811 if (m_pFontFile != NULL) { | 811 if (m_pFontFile != NULL) { |
| 812 return FALSE; | 812 return FALSE; |
| 813 } | 813 } |
| 814 if (((CPDF_Type1Font*)this)->GetBase14Font() < 0) { | 814 if (((CPDF_Type1Font*)this)->GetBase14Font() < 0) { |
| 815 return FALSE; | 815 return FALSE; |
| 816 } | 816 } |
| 817 return TRUE; | 817 return TRUE; |
| 818 } | 818 } |
| 819 extern FX_LPCSTR PDF_CharNameFromPredefinedCharSet(int encoding, FX_BYTE charcod
e); | 819 extern FX_LPCSTR PDF_CharNameFromPredefinedCharSet(int encoding, uint8_t charcod
e); |
| 820 CPDF_SimpleFont::CPDF_SimpleFont(int fonttype) : CPDF_Font(fonttype) | 820 CPDF_SimpleFont::CPDF_SimpleFont(int fonttype) : CPDF_Font(fonttype) |
| 821 { | 821 { |
| 822 FXSYS_memset8(m_CharBBox, 0xff, sizeof m_CharBBox); | 822 FXSYS_memset8(m_CharBBox, 0xff, sizeof m_CharBBox); |
| 823 FXSYS_memset8(m_CharWidth, 0xff, sizeof m_CharWidth); | 823 FXSYS_memset8(m_CharWidth, 0xff, sizeof m_CharWidth); |
| 824 FXSYS_memset8(m_GlyphIndex, 0xff, sizeof m_GlyphIndex); | 824 FXSYS_memset8(m_GlyphIndex, 0xff, sizeof m_GlyphIndex); |
| 825 FXSYS_memset8(m_ExtGID, 0xff, sizeof m_ExtGID); | 825 FXSYS_memset8(m_ExtGID, 0xff, sizeof m_ExtGID); |
| 826 m_pCharNames = NULL; | 826 m_pCharNames = NULL; |
| 827 m_BaseEncoding = PDFFONT_ENCODING_BUILTIN; | 827 m_BaseEncoding = PDFFONT_ENCODING_BUILTIN; |
| 828 } | 828 } |
| 829 CPDF_SimpleFont::~CPDF_SimpleFont() | 829 CPDF_SimpleFont::~CPDF_SimpleFont() |
| 830 { | 830 { |
| 831 delete[] m_pCharNames; | 831 delete[] m_pCharNames; |
| 832 } | 832 } |
| 833 int CPDF_SimpleFont::GlyphFromCharCode(FX_DWORD charcode, FX_BOOL *pVertGlyph) | 833 int CPDF_SimpleFont::GlyphFromCharCode(FX_DWORD charcode, FX_BOOL *pVertGlyph) |
| 834 { | 834 { |
| 835 if (pVertGlyph) { | 835 if (pVertGlyph) { |
| 836 *pVertGlyph = FALSE; | 836 *pVertGlyph = FALSE; |
| 837 } | 837 } |
| 838 if (charcode > 0xff) { | 838 if (charcode > 0xff) { |
| 839 return -1; | 839 return -1; |
| 840 } | 840 } |
| 841 int index = m_GlyphIndex[(FX_BYTE)charcode]; | 841 int index = m_GlyphIndex[(uint8_t)charcode]; |
| 842 if (index == 0xffff) { | 842 if (index == 0xffff) { |
| 843 return -1; | 843 return -1; |
| 844 } | 844 } |
| 845 return index; | 845 return index; |
| 846 } | 846 } |
| 847 void CPDF_SimpleFont::LoadCharMetrics(int charcode) | 847 void CPDF_SimpleFont::LoadCharMetrics(int charcode) |
| 848 { | 848 { |
| 849 if (m_Font.m_Face == NULL) { | 849 if (m_Font.m_Face == NULL) { |
| 850 return; | 850 return; |
| 851 } | 851 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 885 { | 885 { |
| 886 if (charcode > 0xff) { | 886 if (charcode > 0xff) { |
| 887 charcode = 0; | 887 charcode = 0; |
| 888 } | 888 } |
| 889 if (m_CharWidth[charcode] == 0xffff) { | 889 if (m_CharWidth[charcode] == 0xffff) { |
| 890 LoadCharMetrics(charcode); | 890 LoadCharMetrics(charcode); |
| 891 if (m_CharWidth[charcode] == 0xffff) { | 891 if (m_CharWidth[charcode] == 0xffff) { |
| 892 m_CharWidth[charcode] = 0; | 892 m_CharWidth[charcode] = 0; |
| 893 } | 893 } |
| 894 } | 894 } |
| 895 return (FX_INT16)m_CharWidth[charcode]; | 895 return (int16_t)m_CharWidth[charcode]; |
| 896 } | 896 } |
| 897 void CPDF_SimpleFont::GetCharBBox(FX_DWORD charcode, FX_RECT& rect, int level) | 897 void CPDF_SimpleFont::GetCharBBox(FX_DWORD charcode, FX_RECT& rect, int level) |
| 898 { | 898 { |
| 899 if (charcode > 0xff) { | 899 if (charcode > 0xff) { |
| 900 charcode = 0; | 900 charcode = 0; |
| 901 } | 901 } |
| 902 if (m_CharBBox[charcode].Left == (FX_SHORT)0xffff) { | 902 if (m_CharBBox[charcode].Left == (int16_t)0xffff) { |
| 903 LoadCharMetrics(charcode); | 903 LoadCharMetrics(charcode); |
| 904 } | 904 } |
| 905 rect.left = m_CharBBox[charcode].Left; | 905 rect.left = m_CharBBox[charcode].Left; |
| 906 rect.right = m_CharBBox[charcode].Right; | 906 rect.right = m_CharBBox[charcode].Right; |
| 907 rect.bottom = m_CharBBox[charcode].Bottom; | 907 rect.bottom = m_CharBBox[charcode].Bottom; |
| 908 rect.top = m_CharBBox[charcode].Top; | 908 rect.top = m_CharBBox[charcode].Top; |
| 909 } | 909 } |
| 910 FX_LPCSTR GetAdobeCharName(int iBaseEncoding, const CFX_ByteString* pCharNames,
int charcode) | 910 FX_LPCSTR GetAdobeCharName(int iBaseEncoding, const CFX_ByteString* pCharNames,
int charcode) |
| 911 { | 911 { |
| 912 ASSERT(charcode >= 0 && charcode < 256); | 912 ASSERT(charcode >= 0 && charcode < 256); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1066 } | 1066 } |
| 1067 extern FX_WCHAR FT_UnicodeFromCharCode(int encoding, FX_DWORD charcode); | 1067 extern FX_WCHAR FT_UnicodeFromCharCode(int encoding, FX_DWORD charcode); |
| 1068 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 1068 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| 1069 #include "../../fxge/apple/apple_int.h" | 1069 #include "../../fxge/apple/apple_int.h" |
| 1070 #endif | 1070 #endif |
| 1071 int CPDF_Type1Font::GlyphFromCharCodeExt(FX_DWORD charcode) | 1071 int CPDF_Type1Font::GlyphFromCharCodeExt(FX_DWORD charcode) |
| 1072 { | 1072 { |
| 1073 if (charcode > 0xff) { | 1073 if (charcode > 0xff) { |
| 1074 return -1; | 1074 return -1; |
| 1075 } | 1075 } |
| 1076 int index = m_ExtGID[(FX_BYTE)charcode]; | 1076 int index = m_ExtGID[(uint8_t)charcode]; |
| 1077 if (index == 0xffff) { | 1077 if (index == 0xffff) { |
| 1078 return -1; | 1078 return -1; |
| 1079 } | 1079 } |
| 1080 return index; | 1080 return index; |
| 1081 } | 1081 } |
| 1082 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 1082 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| 1083 struct _GlyphNameMap { | 1083 struct _GlyphNameMap { |
| 1084 FX_LPCSTR m_pStrAdobe; | 1084 FX_LPCSTR m_pStrAdobe; |
| 1085 FX_LPCSTR m_pStrUnicode; | 1085 FX_LPCSTR m_pStrUnicode; |
| 1086 }; | 1086 }; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1123 m_Font.m_pPlatformFont = quartz2d.CreateFont(m_Font.m_pFontData, m_Font.
m_dwSize); | 1123 m_Font.m_pPlatformFont = quartz2d.CreateFont(m_Font.m_pFontData, m_Font.
m_dwSize); |
| 1124 if (NULL == m_Font.m_pPlatformFont) { | 1124 if (NULL == m_Font.m_pPlatformFont) { |
| 1125 bCoreText = FALSE; | 1125 bCoreText = FALSE; |
| 1126 } | 1126 } |
| 1127 } | 1127 } |
| 1128 #endif | 1128 #endif |
| 1129 if (!IsEmbedded() && (m_Base14Font < 12) && m_Font.IsTTFont()) { | 1129 if (!IsEmbedded() && (m_Base14Font < 12) && m_Font.IsTTFont()) { |
| 1130 if (FT_UseTTCharmap(m_Font.m_Face, 3, 0)) { | 1130 if (FT_UseTTCharmap(m_Font.m_Face, 3, 0)) { |
| 1131 FX_BOOL bGotOne = FALSE; | 1131 FX_BOOL bGotOne = FALSE; |
| 1132 for (int charcode = 0; charcode < 256; charcode ++) { | 1132 for (int charcode = 0; charcode < 256; charcode ++) { |
| 1133 const FX_BYTE prefix[4] = {0x00, 0xf0, 0xf1, 0xf2}; | 1133 const uint8_t prefix[4] = {0x00, 0xf0, 0xf1, 0xf2}; |
| 1134 for (int j = 0; j < 4; j ++) { | 1134 for (int j = 0; j < 4; j ++) { |
| 1135 FX_WORD unicode = prefix[j] * 256 + charcode; | 1135 FX_WORD unicode = prefix[j] * 256 + charcode; |
| 1136 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face,
unicode); | 1136 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face,
unicode); |
| 1137 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 1137 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| 1138 FX_CHAR name_glyph[256]; | 1138 FX_CHAR name_glyph[256]; |
| 1139 FXFT_Get_Glyph_Name(m_Font.m_Face, m_GlyphIndex[charcode], n
ame_glyph, 256); | 1139 FXFT_Get_Glyph_Name(m_Font.m_Face, m_GlyphIndex[charcode], n
ame_glyph, 256); |
| 1140 name_glyph[255] = 0; | 1140 name_glyph[255] = 0; |
| 1141 CFStringRef name_ct = CFStringCreateWithCStringNoCopy(kCFAll
ocatorDefault, name_glyph, kCFStringEncodingASCII, kCFAllocatorNull); | 1141 CFStringRef name_ct = CFStringCreateWithCStringNoCopy(kCFAll
ocatorDefault, name_glyph, kCFStringEncodingASCII, kCFAllocatorNull); |
| 1142 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName((CGFontRef)
m_Font.m_pPlatformFont, name_ct); | 1142 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName((CGFontRef)
m_Font.m_pPlatformFont, name_ct); |
| 1143 if (name_ct) { | 1143 if (name_ct) { |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1475 } | 1475 } |
| 1476 FX_BOOL bToUnicode = m_pFontDict->KeyExist(FX_BSTRC("ToUnicode")); | 1476 FX_BOOL bToUnicode = m_pFontDict->KeyExist(FX_BSTRC("ToUnicode")); |
| 1477 for (int charcode = 0; charcode < 256; charcode ++) { | 1477 for (int charcode = 0; charcode < 256; charcode ++) { |
| 1478 FX_LPCSTR name = GetAdobeCharName(baseEncoding, m_pCharNames, charco
de); | 1478 FX_LPCSTR name = GetAdobeCharName(baseEncoding, m_pCharNames, charco
de); |
| 1479 if (name == NULL) { | 1479 if (name == NULL) { |
| 1480 m_GlyphIndex[charcode] = m_pFontFile ? FXFT_Get_Char_Index(m_Fon
t.m_Face, charcode) : -1; | 1480 m_GlyphIndex[charcode] = m_pFontFile ? FXFT_Get_Char_Index(m_Fon
t.m_Face, charcode) : -1; |
| 1481 continue; | 1481 continue; |
| 1482 } | 1482 } |
| 1483 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); | 1483 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); |
| 1484 if (bMSSymbol) { | 1484 if (bMSSymbol) { |
| 1485 const FX_BYTE prefix[4] = {0x00, 0xf0, 0xf1, 0xf2}; | 1485 const uint8_t prefix[4] = {0x00, 0xf0, 0xf1, 0xf2}; |
| 1486 for (int j = 0; j < 4; j ++) { | 1486 for (int j = 0; j < 4; j ++) { |
| 1487 FX_WORD unicode = prefix[j] * 256 + charcode; | 1487 FX_WORD unicode = prefix[j] * 256 + charcode; |
| 1488 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face,
unicode); | 1488 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face,
unicode); |
| 1489 if (m_GlyphIndex[charcode]) { | 1489 if (m_GlyphIndex[charcode]) { |
| 1490 break; | 1490 break; |
| 1491 } | 1491 } |
| 1492 } | 1492 } |
| 1493 } else if (m_Encoding.m_Unicodes[charcode]) { | 1493 } else if (m_Encoding.m_Unicodes[charcode]) { |
| 1494 if (bMSUnicode) { | 1494 if (bMSUnicode) { |
| 1495 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face,
m_Encoding.m_Unicodes[charcode]); | 1495 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face,
m_Encoding.m_Unicodes[charcode]); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1518 if (m_GlyphIndex[charcode] == 0) { | 1518 if (m_GlyphIndex[charcode] == 0) { |
| 1519 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.
m_Face, charcode); | 1519 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.
m_Face, charcode); |
| 1520 } | 1520 } |
| 1521 } | 1521 } |
| 1522 } | 1522 } |
| 1523 } | 1523 } |
| 1524 } | 1524 } |
| 1525 return; | 1525 return; |
| 1526 } | 1526 } |
| 1527 if (FT_UseTTCharmap(m_Font.m_Face, 3, 0)) { | 1527 if (FT_UseTTCharmap(m_Font.m_Face, 3, 0)) { |
| 1528 const FX_BYTE prefix[4] = {0x00, 0xf0, 0xf1, 0xf2}; | 1528 const uint8_t prefix[4] = {0x00, 0xf0, 0xf1, 0xf2}; |
| 1529 FX_BOOL bGotOne = FALSE; | 1529 FX_BOOL bGotOne = FALSE; |
| 1530 for (int charcode = 0; charcode < 256; charcode ++) { | 1530 for (int charcode = 0; charcode < 256; charcode ++) { |
| 1531 for (int j = 0; j < 4; j ++) { | 1531 for (int j = 0; j < 4; j ++) { |
| 1532 FX_WORD unicode = prefix[j] * 256 + charcode; | 1532 FX_WORD unicode = prefix[j] * 256 + charcode; |
| 1533 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face, unic
ode); | 1533 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face, unic
ode); |
| 1534 if (m_GlyphIndex[charcode]) { | 1534 if (m_GlyphIndex[charcode]) { |
| 1535 bGotOne = TRUE; | 1535 bGotOne = TRUE; |
| 1536 break; | 1536 break; |
| 1537 } | 1537 } |
| 1538 } | 1538 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1620 m_pFontResources = m_pFontDict->GetDict(FX_BSTRC("Resources")); | 1620 m_pFontResources = m_pFontDict->GetDict(FX_BSTRC("Resources")); |
| 1621 CPDF_Array* pMatrix = m_pFontDict->GetArray(FX_BSTRC("FontMatrix")); | 1621 CPDF_Array* pMatrix = m_pFontDict->GetArray(FX_BSTRC("FontMatrix")); |
| 1622 FX_FLOAT xscale = 1.0f, yscale = 1.0f; | 1622 FX_FLOAT xscale = 1.0f, yscale = 1.0f; |
| 1623 if (pMatrix) { | 1623 if (pMatrix) { |
| 1624 m_FontMatrix = pMatrix->GetMatrix(); | 1624 m_FontMatrix = pMatrix->GetMatrix(); |
| 1625 xscale = m_FontMatrix.a; | 1625 xscale = m_FontMatrix.a; |
| 1626 yscale = m_FontMatrix.d; | 1626 yscale = m_FontMatrix.d; |
| 1627 } | 1627 } |
| 1628 CPDF_Array* pBBox = m_pFontDict->GetArray(FX_BSTRC("FontBBox")); | 1628 CPDF_Array* pBBox = m_pFontDict->GetArray(FX_BSTRC("FontBBox")); |
| 1629 if (pBBox) { | 1629 if (pBBox) { |
| 1630 m_FontBBox.left = (FX_INT32)(FXSYS_Mul(pBBox->GetNumber(0), xscale) * 10
00); | 1630 m_FontBBox.left = (int32_t)(FXSYS_Mul(pBBox->GetNumber(0), xscale) * 100
0); |
| 1631 m_FontBBox.bottom = (FX_INT32)(FXSYS_Mul(pBBox->GetNumber(1), yscale) *
1000); | 1631 m_FontBBox.bottom = (int32_t)(FXSYS_Mul(pBBox->GetNumber(1), yscale) * 1
000); |
| 1632 m_FontBBox.right = (FX_INT32)(FXSYS_Mul(pBBox->GetNumber(2), xscale) * 1
000); | 1632 m_FontBBox.right = (int32_t)(FXSYS_Mul(pBBox->GetNumber(2), xscale) * 10
00); |
| 1633 m_FontBBox.top = (FX_INT32)(FXSYS_Mul(pBBox->GetNumber(3), yscale) * 100
0); | 1633 m_FontBBox.top = (int32_t)(FXSYS_Mul(pBBox->GetNumber(3), yscale) * 1000
); |
| 1634 } | 1634 } |
| 1635 int StartChar = m_pFontDict->GetInteger(FX_BSTRC("FirstChar")); | 1635 int StartChar = m_pFontDict->GetInteger(FX_BSTRC("FirstChar")); |
| 1636 CPDF_Array* pWidthArray = m_pFontDict->GetArray(FX_BSTRC("Widths")); | 1636 CPDF_Array* pWidthArray = m_pFontDict->GetArray(FX_BSTRC("Widths")); |
| 1637 if (pWidthArray && (StartChar >= 0 && StartChar < 256)) { | 1637 if (pWidthArray && (StartChar >= 0 && StartChar < 256)) { |
| 1638 FX_DWORD count = pWidthArray->GetCount(); | 1638 FX_DWORD count = pWidthArray->GetCount(); |
| 1639 if (count > 256) { | 1639 if (count > 256) { |
| 1640 count = 256; | 1640 count = 256; |
| 1641 } | 1641 } |
| 1642 if (StartChar + count > 256) { | 1642 if (StartChar + count > 256) { |
| 1643 count = 256 - StartChar; | 1643 count = 256 - StartChar; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1664 void CPDF_Type3Font::CheckType3FontMetrics() | 1664 void CPDF_Type3Font::CheckType3FontMetrics() |
| 1665 { | 1665 { |
| 1666 CheckFontMetrics(); | 1666 CheckFontMetrics(); |
| 1667 } | 1667 } |
| 1668 CPDF_Type3Char* CPDF_Type3Font::LoadChar(FX_DWORD charcode, int level) | 1668 CPDF_Type3Char* CPDF_Type3Font::LoadChar(FX_DWORD charcode, int level) |
| 1669 { | 1669 { |
| 1670 if (level >= _FPDF_MAX_TYPE3_FORM_LEVEL_) { | 1670 if (level >= _FPDF_MAX_TYPE3_FORM_LEVEL_) { |
| 1671 return NULL; | 1671 return NULL; |
| 1672 } | 1672 } |
| 1673 CPDF_Type3Char* pChar = NULL; | 1673 CPDF_Type3Char* pChar = NULL; |
| 1674 if (m_CacheMap.Lookup((FX_LPVOID)(FX_UINTPTR)charcode, (FX_LPVOID&)pChar)) { | 1674 if (m_CacheMap.Lookup((FX_LPVOID)(uintptr_t)charcode, (FX_LPVOID&)pChar)) { |
| 1675 if (pChar->m_bPageRequired && m_pPageResources) { | 1675 if (pChar->m_bPageRequired && m_pPageResources) { |
| 1676 delete pChar; | 1676 delete pChar; |
| 1677 m_CacheMap.RemoveKey((FX_LPVOID)(FX_UINTPTR)charcode); | 1677 m_CacheMap.RemoveKey((FX_LPVOID)(uintptr_t)charcode); |
| 1678 return LoadChar(charcode, level + 1); | 1678 return LoadChar(charcode, level + 1); |
| 1679 } | 1679 } |
| 1680 return pChar; | 1680 return pChar; |
| 1681 } | 1681 } |
| 1682 FX_LPCSTR name = GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); | 1682 FX_LPCSTR name = GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); |
| 1683 if (name == NULL) { | 1683 if (name == NULL) { |
| 1684 return NULL; | 1684 return NULL; |
| 1685 } | 1685 } |
| 1686 CPDF_Stream* pStream = (CPDF_Stream*)(m_pCharProcs ? m_pCharProcs->GetElemen
tValue(name) : NULL); | 1686 CPDF_Stream* pStream = (CPDF_Stream*)(m_pCharProcs ? m_pCharProcs->GetElemen
tValue(name) : NULL); |
| 1687 if (pStream == NULL || pStream->GetType() != PDFOBJ_STREAM) { | 1687 if (pStream == NULL || pStream->GetType() != PDFOBJ_STREAM) { |
| 1688 return NULL; | 1688 return NULL; |
| 1689 } | 1689 } |
| 1690 pChar = new CPDF_Type3Char; | 1690 pChar = new CPDF_Type3Char; |
| 1691 pChar->m_pForm = new CPDF_Form(m_pDocument, m_pFontResources ? m_pFontResour
ces : m_pPageResources, pStream, NULL); | 1691 pChar->m_pForm = new CPDF_Form(m_pDocument, m_pFontResources ? m_pFontResour
ces : m_pPageResources, pStream, NULL); |
| 1692 pChar->m_pForm->ParseContent(NULL, NULL, pChar, NULL, level + 1); | 1692 pChar->m_pForm->ParseContent(NULL, NULL, pChar, NULL, level + 1); |
| 1693 FX_FLOAT scale = m_FontMatrix.GetXUnit(); | 1693 FX_FLOAT scale = m_FontMatrix.GetXUnit(); |
| 1694 pChar->m_Width = (FX_INT32)(pChar->m_Width * scale + 0.5f); | 1694 pChar->m_Width = (int32_t)(pChar->m_Width * scale + 0.5f); |
| 1695 FX_RECT &rcBBox = pChar->m_BBox; | 1695 FX_RECT &rcBBox = pChar->m_BBox; |
| 1696 CFX_FloatRect char_rect((FX_FLOAT)rcBBox.left / 1000.0f, (FX_FLOAT)rcBBox.bo
ttom / 1000.0f, | 1696 CFX_FloatRect char_rect((FX_FLOAT)rcBBox.left / 1000.0f, (FX_FLOAT)rcBBox.bo
ttom / 1000.0f, |
| 1697 (FX_FLOAT)rcBBox.right / 1000.0f, (FX_FLOAT)rcBBox.t
op / 1000.0f); | 1697 (FX_FLOAT)rcBBox.right / 1000.0f, (FX_FLOAT)rcBBox.t
op / 1000.0f); |
| 1698 if (rcBBox.right <= rcBBox.left || rcBBox.bottom >= rcBBox.top) { | 1698 if (rcBBox.right <= rcBBox.left || rcBBox.bottom >= rcBBox.top) { |
| 1699 char_rect = pChar->m_pForm->CalcBoundingBox(); | 1699 char_rect = pChar->m_pForm->CalcBoundingBox(); |
| 1700 } | 1700 } |
| 1701 char_rect.Transform(&m_FontMatrix); | 1701 char_rect.Transform(&m_FontMatrix); |
| 1702 rcBBox.left = FXSYS_round(char_rect.left * 1000); | 1702 rcBBox.left = FXSYS_round(char_rect.left * 1000); |
| 1703 rcBBox.right = FXSYS_round(char_rect.right * 1000); | 1703 rcBBox.right = FXSYS_round(char_rect.right * 1000); |
| 1704 rcBBox.top = FXSYS_round(char_rect.top * 1000); | 1704 rcBBox.top = FXSYS_round(char_rect.top * 1000); |
| 1705 rcBBox.bottom = FXSYS_round(char_rect.bottom * 1000); | 1705 rcBBox.bottom = FXSYS_round(char_rect.bottom * 1000); |
| 1706 m_CacheMap.SetAt((FX_LPVOID)(FX_UINTPTR)charcode, pChar); | 1706 m_CacheMap.SetAt((FX_LPVOID)(uintptr_t)charcode, pChar); |
| 1707 if (pChar->m_pForm->CountObjects() == 0) { | 1707 if (pChar->m_pForm->CountObjects() == 0) { |
| 1708 delete pChar->m_pForm; | 1708 delete pChar->m_pForm; |
| 1709 pChar->m_pForm = NULL; | 1709 pChar->m_pForm = NULL; |
| 1710 } | 1710 } |
| 1711 return pChar; | 1711 return pChar; |
| 1712 } | 1712 } |
| 1713 int CPDF_Type3Font::GetCharWidthF(FX_DWORD charcode, int level) | 1713 int CPDF_Type3Font::GetCharWidthF(FX_DWORD charcode, int level) |
| 1714 { | 1714 { |
| 1715 if (charcode > 0xff) { | 1715 if (charcode > 0xff) { |
| 1716 charcode = 0; | 1716 charcode = 0; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1742 } | 1742 } |
| 1743 CPDF_Type3Char::~CPDF_Type3Char() | 1743 CPDF_Type3Char::~CPDF_Type3Char() |
| 1744 { | 1744 { |
| 1745 if (m_pForm) { | 1745 if (m_pForm) { |
| 1746 delete m_pForm; | 1746 delete m_pForm; |
| 1747 } | 1747 } |
| 1748 if (m_pBitmap) { | 1748 if (m_pBitmap) { |
| 1749 delete m_pBitmap; | 1749 delete m_pBitmap; |
| 1750 } | 1750 } |
| 1751 } | 1751 } |
| OLD | NEW |