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_module.h" | 7 #include "../../../include/fpdfapi/fpdf_module.h" |
8 #include "../../../include/fpdfapi/fpdf_page.h" | 8 #include "../../../include/fpdfapi/fpdf_page.h" |
9 #include "../../../include/fpdfapi/fpdf_pageobj.h" | 9 #include "../../../include/fpdfapi/fpdf_pageobj.h" |
10 #include "../../../include/fpdfapi/fpdf_resource.h" | 10 #include "../../../include/fpdfapi/fpdf_resource.h" |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 FX_CHAR* dest_buf = result.GetBuffer(src_len * 2); | 205 FX_CHAR* dest_buf = result.GetBuffer(src_len * 2); |
206 const FX_WCHAR* src_buf = str.c_str(); | 206 const FX_WCHAR* src_buf = str.c_str(); |
207 int dest_pos = 0; | 207 int dest_pos = 0; |
208 for (int src_pos = 0; src_pos < src_len; src_pos++) { | 208 for (int src_pos = 0; src_pos < src_len; src_pos++) { |
209 FX_DWORD charcode = CharCodeFromUnicode(src_buf[src_pos]); | 209 FX_DWORD charcode = CharCodeFromUnicode(src_buf[src_pos]); |
210 dest_pos += AppendChar(dest_buf + dest_pos, charcode); | 210 dest_pos += AppendChar(dest_buf + dest_pos, charcode); |
211 } | 211 } |
212 result.ReleaseBuffer(dest_pos); | 212 result.ReleaseBuffer(dest_pos); |
213 return result; | 213 return result; |
214 } | 214 } |
| 215 |
215 void CPDF_Font::LoadFontDescriptor(CPDF_Dictionary* pFontDesc) { | 216 void CPDF_Font::LoadFontDescriptor(CPDF_Dictionary* pFontDesc) { |
216 m_Flags = pFontDesc->GetInteger(FX_BSTRC("Flags"), PDFFONT_NONSYMBOLIC); | 217 m_Flags = pFontDesc->GetInteger(FX_BSTRC("Flags"), PDFFONT_NONSYMBOLIC); |
217 int ItalicAngle = 0; | 218 int ItalicAngle = 0; |
218 FX_BOOL bExistItalicAngle = FALSE; | 219 FX_BOOL bExistItalicAngle = FALSE; |
219 if (pFontDesc->KeyExist(FX_BSTRC("ItalicAngle"))) { | 220 if (pFontDesc->KeyExist(FX_BSTRC("ItalicAngle"))) { |
220 ItalicAngle = pFontDesc->GetInteger(FX_BSTRC("ItalicAngle")); | 221 ItalicAngle = pFontDesc->GetInteger(FX_BSTRC("ItalicAngle")); |
221 bExistItalicAngle = TRUE; | 222 bExistItalicAngle = TRUE; |
222 } | 223 } |
223 if (ItalicAngle < 0) { | 224 if (ItalicAngle < 0) { |
224 m_Flags |= PDFFONT_ITALIC; | 225 m_Flags |= PDFFONT_ITALIC; |
(...skipping 25 matching lines...) Expand all Loading... |
250 if (m_Descent > 10) { | 251 if (m_Descent > 10) { |
251 m_Descent = -m_Descent; | 252 m_Descent = -m_Descent; |
252 } | 253 } |
253 CPDF_Array* pBBox = pFontDesc->GetArray(FX_BSTRC("FontBBox")); | 254 CPDF_Array* pBBox = pFontDesc->GetArray(FX_BSTRC("FontBBox")); |
254 if (pBBox) { | 255 if (pBBox) { |
255 m_FontBBox.left = pBBox->GetInteger(0); | 256 m_FontBBox.left = pBBox->GetInteger(0); |
256 m_FontBBox.bottom = pBBox->GetInteger(1); | 257 m_FontBBox.bottom = pBBox->GetInteger(1); |
257 m_FontBBox.right = pBBox->GetInteger(2); | 258 m_FontBBox.right = pBBox->GetInteger(2); |
258 m_FontBBox.top = pBBox->GetInteger(3); | 259 m_FontBBox.top = pBBox->GetInteger(3); |
259 } | 260 } |
| 261 |
260 CPDF_Stream* pFontFile = pFontDesc->GetStream(FX_BSTRC("FontFile")); | 262 CPDF_Stream* pFontFile = pFontDesc->GetStream(FX_BSTRC("FontFile")); |
261 if (pFontFile == NULL) { | 263 if (!pFontFile) |
262 pFontFile = pFontDesc->GetStream(FX_BSTRC("FontFile2")); | 264 pFontFile = pFontDesc->GetStream(FX_BSTRC("FontFile2")); |
263 } | 265 if (!pFontFile) |
264 if (pFontFile == NULL) { | |
265 pFontFile = pFontDesc->GetStream(FX_BSTRC("FontFile3")); | 266 pFontFile = pFontDesc->GetStream(FX_BSTRC("FontFile3")); |
266 } | 267 if (!pFontFile) |
267 if (pFontFile) { | 268 return; |
268 m_pFontFile = m_pDocument->LoadFontFile(pFontFile); | 269 |
269 if (m_pFontFile == NULL) { | 270 m_pFontFile = m_pDocument->LoadFontFile(pFontFile); |
270 return; | 271 if (!m_pFontFile) |
271 } | 272 return; |
272 const uint8_t* pFontData = m_pFontFile->GetData(); | 273 |
273 FX_DWORD dwFontSize = m_pFontFile->GetSize(); | 274 const uint8_t* pFontData = m_pFontFile->GetData(); |
274 m_Font.LoadEmbedded(pFontData, dwFontSize); | 275 FX_DWORD dwFontSize = m_pFontFile->GetSize(); |
275 if (m_Font.m_Face == NULL) { | 276 if (!m_Font.LoadEmbedded(pFontData, dwFontSize)) { |
276 m_pFontFile = NULL; | 277 m_pDocument->GetPageData()->ReleaseFontFileStreamAcc( |
277 } | 278 (CPDF_Stream*)m_pFontFile->GetStream()); |
| 279 m_pFontFile = nullptr; |
278 } | 280 } |
279 } | 281 } |
| 282 |
280 short TT2PDF(int m, FXFT_Face face) { | 283 short TT2PDF(int m, FXFT_Face face) { |
281 int upm = FXFT_Get_Face_UnitsPerEM(face); | 284 int upm = FXFT_Get_Face_UnitsPerEM(face); |
282 if (upm == 0) { | 285 if (upm == 0) { |
283 return (short)m; | 286 return (short)m; |
284 } | 287 } |
285 return (m * 1000 + upm / 2) / upm; | 288 return (m * 1000 + upm / 2) / upm; |
286 } | 289 } |
287 void CPDF_Font::CheckFontMetrics() { | 290 void CPDF_Font::CheckFontMetrics() { |
288 if (m_FontBBox.top == 0 && m_FontBBox.bottom == 0 && m_FontBBox.left == 0 && | 291 if (m_FontBBox.top == 0 && m_FontBBox.bottom == 0 && m_FontBBox.left == 0 && |
289 m_FontBBox.right == 0) { | 292 m_FontBBox.right == 0) { |
290 if (m_Font.m_Face) { | 293 FXFT_Face face = m_Font.GetFace(); |
291 m_FontBBox.left = | 294 if (face) { |
292 TT2PDF(FXFT_Get_Face_xMin(m_Font.m_Face), m_Font.m_Face); | 295 m_FontBBox.left = TT2PDF(FXFT_Get_Face_xMin(face), face); |
293 m_FontBBox.bottom = | 296 m_FontBBox.bottom = TT2PDF(FXFT_Get_Face_yMin(face), face); |
294 TT2PDF(FXFT_Get_Face_yMin(m_Font.m_Face), m_Font.m_Face); | 297 m_FontBBox.right = TT2PDF(FXFT_Get_Face_xMax(face), face); |
295 m_FontBBox.right = | 298 m_FontBBox.top = TT2PDF(FXFT_Get_Face_yMax(face), face); |
296 TT2PDF(FXFT_Get_Face_xMax(m_Font.m_Face), m_Font.m_Face); | 299 m_Ascent = TT2PDF(FXFT_Get_Face_Ascender(face), face); |
297 m_FontBBox.top = TT2PDF(FXFT_Get_Face_yMax(m_Font.m_Face), m_Font.m_Face); | 300 m_Descent = TT2PDF(FXFT_Get_Face_Descender(face), face); |
298 m_Ascent = TT2PDF(FXFT_Get_Face_Ascender(m_Font.m_Face), m_Font.m_Face); | |
299 m_Descent = TT2PDF(FXFT_Get_Face_Descender(m_Font.m_Face), m_Font.m_Face); | |
300 } else { | 301 } else { |
301 FX_BOOL bFirst = TRUE; | 302 FX_BOOL bFirst = TRUE; |
302 for (int i = 0; i < 256; i++) { | 303 for (int i = 0; i < 256; i++) { |
303 FX_RECT rect; | 304 FX_RECT rect; |
304 GetCharBBox(i, rect); | 305 GetCharBBox(i, rect); |
305 if (rect.left == rect.right) { | 306 if (rect.left == rect.right) { |
306 continue; | 307 continue; |
307 } | 308 } |
308 if (bFirst) { | 309 if (bFirst) { |
309 m_FontBBox = rect; | 310 m_FontBBox = rect; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 int CPDF_Font::GetStringWidth(const FX_CHAR* pString, int size) { | 354 int CPDF_Font::GetStringWidth(const FX_CHAR* pString, int size) { |
354 int offset = 0; | 355 int offset = 0; |
355 int width = 0; | 356 int width = 0; |
356 while (offset < size) { | 357 while (offset < size) { |
357 FX_DWORD charcode = GetNextChar(pString, size, offset); | 358 FX_DWORD charcode = GetNextChar(pString, size, offset); |
358 width += GetCharWidthF(charcode); | 359 width += GetCharWidthF(charcode); |
359 } | 360 } |
360 return width; | 361 return width; |
361 } | 362 } |
362 int CPDF_Font::GetCharTypeWidth(FX_DWORD charcode) { | 363 int CPDF_Font::GetCharTypeWidth(FX_DWORD charcode) { |
363 if (m_Font.m_Face == NULL) { | 364 if (!m_Font.GetFace()) |
364 return 0; | 365 return 0; |
365 } | 366 |
366 int glyph_index = GlyphFromCharCode(charcode); | 367 int glyph_index = GlyphFromCharCode(charcode); |
367 if (glyph_index == 0xffff) { | 368 if (glyph_index == 0xffff) { |
368 return 0; | 369 return 0; |
369 } | 370 } |
370 return m_Font.GetGlyphWidth(glyph_index); | 371 return m_Font.GetGlyphWidth(glyph_index); |
371 } | 372 } |
372 int _PDF_GetStandardFontName(CFX_ByteString& name); | 373 int _PDF_GetStandardFontName(CFX_ByteString& name); |
373 CPDF_Font* CPDF_Font::GetStockFont(CPDF_Document* pDoc, | 374 CPDF_Font* CPDF_Font::GetStockFont(CPDF_Document* pDoc, |
374 const CFX_ByteStringC& name) { | 375 const CFX_ByteStringC& name) { |
375 CFX_ByteString fontname(name); | 376 CFX_ByteString fontname(name); |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 if (cur_code < 256) { | 776 if (cur_code < 256) { |
776 pCharNames[cur_code] = ((CPDF_Name*)pElement)->GetString(); | 777 pCharNames[cur_code] = ((CPDF_Name*)pElement)->GetString(); |
777 } | 778 } |
778 cur_code++; | 779 cur_code++; |
779 } else { | 780 } else { |
780 cur_code = pElement->GetInteger(); | 781 cur_code = pElement->GetInteger(); |
781 } | 782 } |
782 } | 783 } |
783 } | 784 } |
784 FX_BOOL CPDF_Font::IsStandardFont() const { | 785 FX_BOOL CPDF_Font::IsStandardFont() const { |
785 if (m_FontType != PDFFONT_TYPE1) { | 786 if (m_FontType != PDFFONT_TYPE1) |
786 return FALSE; | 787 return FALSE; |
787 } | 788 if (m_pFontFile) |
788 if (m_pFontFile != NULL) { | |
789 return FALSE; | 789 return FALSE; |
790 } | 790 if (((CPDF_Type1Font*)this)->GetBase14Font() < 0) |
791 if (((CPDF_Type1Font*)this)->GetBase14Font() < 0) { | |
792 return FALSE; | 791 return FALSE; |
793 } | |
794 return TRUE; | 792 return TRUE; |
795 } | 793 } |
796 CPDF_SimpleFont::CPDF_SimpleFont(int fonttype) : CPDF_Font(fonttype) { | 794 CPDF_SimpleFont::CPDF_SimpleFont(int fonttype) : CPDF_Font(fonttype) { |
797 FXSYS_memset(m_CharBBox, 0xff, sizeof m_CharBBox); | 795 FXSYS_memset(m_CharBBox, 0xff, sizeof m_CharBBox); |
798 FXSYS_memset(m_CharWidth, 0xff, sizeof m_CharWidth); | 796 FXSYS_memset(m_CharWidth, 0xff, sizeof m_CharWidth); |
799 FXSYS_memset(m_GlyphIndex, 0xff, sizeof m_GlyphIndex); | 797 FXSYS_memset(m_GlyphIndex, 0xff, sizeof m_GlyphIndex); |
800 FXSYS_memset(m_ExtGID, 0xff, sizeof m_ExtGID); | 798 FXSYS_memset(m_ExtGID, 0xff, sizeof m_ExtGID); |
801 m_pCharNames = NULL; | 799 m_pCharNames = NULL; |
802 m_BaseEncoding = PDFFONT_ENCODING_BUILTIN; | 800 m_BaseEncoding = PDFFONT_ENCODING_BUILTIN; |
803 } | 801 } |
804 CPDF_SimpleFont::~CPDF_SimpleFont() { | 802 CPDF_SimpleFont::~CPDF_SimpleFont() { |
805 delete[] m_pCharNames; | 803 delete[] m_pCharNames; |
806 } | 804 } |
807 int CPDF_SimpleFont::GlyphFromCharCode(FX_DWORD charcode, FX_BOOL* pVertGlyph) { | 805 int CPDF_SimpleFont::GlyphFromCharCode(FX_DWORD charcode, FX_BOOL* pVertGlyph) { |
808 if (pVertGlyph) { | 806 if (pVertGlyph) { |
809 *pVertGlyph = FALSE; | 807 *pVertGlyph = FALSE; |
810 } | 808 } |
811 if (charcode > 0xff) { | 809 if (charcode > 0xff) { |
812 return -1; | 810 return -1; |
813 } | 811 } |
814 int index = m_GlyphIndex[(uint8_t)charcode]; | 812 int index = m_GlyphIndex[(uint8_t)charcode]; |
815 if (index == 0xffff) { | 813 if (index == 0xffff) { |
816 return -1; | 814 return -1; |
817 } | 815 } |
818 return index; | 816 return index; |
819 } | 817 } |
820 void CPDF_SimpleFont::LoadCharMetrics(int charcode) { | 818 void CPDF_SimpleFont::LoadCharMetrics(int charcode) { |
821 if (m_Font.m_Face == NULL) { | 819 if (!m_Font.GetFace()) |
822 return; | 820 return; |
823 } | 821 |
824 if (charcode < 0 || charcode > 0xff) { | 822 if (charcode < 0 || charcode > 0xff) { |
825 return; | 823 return; |
826 } | 824 } |
827 int glyph_index = m_GlyphIndex[charcode]; | 825 int glyph_index = m_GlyphIndex[charcode]; |
828 if (glyph_index == 0xffff) { | 826 if (glyph_index == 0xffff) { |
829 if (m_pFontFile == NULL && charcode != 32) { | 827 if (!m_pFontFile && charcode != 32) { |
830 LoadCharMetrics(32); | 828 LoadCharMetrics(32); |
831 m_CharBBox[charcode] = m_CharBBox[32]; | 829 m_CharBBox[charcode] = m_CharBBox[32]; |
832 if (m_bUseFontWidth) { | 830 if (m_bUseFontWidth) { |
833 m_CharWidth[charcode] = m_CharWidth[32]; | 831 m_CharWidth[charcode] = m_CharWidth[32]; |
834 } | 832 } |
835 } | 833 } |
836 return; | 834 return; |
837 } | 835 } |
| 836 FXFT_Face face = m_Font.GetFace(); |
838 int err = FXFT_Load_Glyph( | 837 int err = FXFT_Load_Glyph( |
839 m_Font.m_Face, glyph_index, | 838 face, glyph_index, |
840 FXFT_LOAD_NO_SCALE | FXFT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH); | 839 FXFT_LOAD_NO_SCALE | FXFT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH); |
841 if (err) { | 840 if (err) { |
842 return; | 841 return; |
843 } | 842 } |
844 m_CharBBox[charcode].Left = | 843 m_CharBBox[charcode].Left = TT2PDF(FXFT_Get_Glyph_HoriBearingX(face), face); |
845 TT2PDF(FXFT_Get_Glyph_HoriBearingX(m_Font.m_Face), m_Font.m_Face); | 844 m_CharBBox[charcode].Right = TT2PDF( |
846 m_CharBBox[charcode].Right = | 845 FXFT_Get_Glyph_HoriBearingX(face) + FXFT_Get_Glyph_Width(face), face); |
847 TT2PDF(FXFT_Get_Glyph_HoriBearingX(m_Font.m_Face) + | 846 m_CharBBox[charcode].Top = TT2PDF(FXFT_Get_Glyph_HoriBearingY(face), face); |
848 FXFT_Get_Glyph_Width(m_Font.m_Face), | 847 m_CharBBox[charcode].Bottom = TT2PDF( |
849 m_Font.m_Face); | 848 FXFT_Get_Glyph_HoriBearingY(face) - FXFT_Get_Glyph_Height(face), face); |
850 m_CharBBox[charcode].Top = | |
851 TT2PDF(FXFT_Get_Glyph_HoriBearingY(m_Font.m_Face), m_Font.m_Face); | |
852 m_CharBBox[charcode].Bottom = | |
853 TT2PDF(FXFT_Get_Glyph_HoriBearingY(m_Font.m_Face) - | |
854 FXFT_Get_Glyph_Height(m_Font.m_Face), | |
855 m_Font.m_Face); | |
856 if (m_bUseFontWidth) { | 849 if (m_bUseFontWidth) { |
857 int TT_Width = | 850 int TT_Width = TT2PDF(FXFT_Get_Glyph_HoriAdvance(face), face); |
858 TT2PDF(FXFT_Get_Glyph_HoriAdvance(m_Font.m_Face), m_Font.m_Face); | |
859 if (m_CharWidth[charcode] == 0xffff) { | 851 if (m_CharWidth[charcode] == 0xffff) { |
860 m_CharWidth[charcode] = TT_Width; | 852 m_CharWidth[charcode] = TT_Width; |
861 } else if (TT_Width && !IsEmbedded()) { | 853 } else if (TT_Width && !IsEmbedded()) { |
862 m_CharBBox[charcode].Right = | 854 m_CharBBox[charcode].Right = |
863 m_CharBBox[charcode].Right * m_CharWidth[charcode] / TT_Width; | 855 m_CharBBox[charcode].Right * m_CharWidth[charcode] / TT_Width; |
864 m_CharBBox[charcode].Left = | 856 m_CharBBox[charcode].Left = |
865 m_CharBBox[charcode].Left * m_CharWidth[charcode] / TT_Width; | 857 m_CharBBox[charcode].Left * m_CharWidth[charcode] / TT_Width; |
866 } | 858 } |
867 } | 859 } |
868 } | 860 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 width_end = width_start + pWidthArray->GetCount() - 1; | 925 width_end = width_start + pWidthArray->GetCount() - 1; |
934 } | 926 } |
935 if (width_end > 255) { | 927 if (width_end > 255) { |
936 width_end = 255; | 928 width_end = 255; |
937 } | 929 } |
938 for (int i = width_start; i <= width_end; i++) { | 930 for (int i = width_start; i <= width_end; i++) { |
939 m_CharWidth[i] = pWidthArray->GetInteger(i - width_start); | 931 m_CharWidth[i] = pWidthArray->GetInteger(i - width_start); |
940 } | 932 } |
941 } | 933 } |
942 } | 934 } |
943 if (m_pFontFile == NULL) { | 935 if (m_pFontFile) { |
944 LoadSubstFont(); | |
945 } else { | |
946 if (m_BaseFont.GetLength() > 8 && m_BaseFont[7] == '+') { | 936 if (m_BaseFont.GetLength() > 8 && m_BaseFont[7] == '+') { |
947 m_BaseFont = m_BaseFont.Mid(8); | 937 m_BaseFont = m_BaseFont.Mid(8); |
948 } | 938 } |
| 939 } else { |
| 940 LoadSubstFont(); |
949 } | 941 } |
950 if (!(m_Flags & PDFFONT_SYMBOLIC)) { | 942 if (!(m_Flags & PDFFONT_SYMBOLIC)) { |
951 m_BaseEncoding = PDFFONT_ENCODING_STANDARD; | 943 m_BaseEncoding = PDFFONT_ENCODING_STANDARD; |
952 } | 944 } |
953 CPDF_Object* pEncoding = m_pFontDict->GetElementValue(FX_BSTRC("Encoding")); | 945 CPDF_Object* pEncoding = m_pFontDict->GetElementValue(FX_BSTRC("Encoding")); |
954 LoadPDFEncoding(pEncoding, m_BaseEncoding, m_pCharNames, m_pFontFile != NULL, | 946 LoadPDFEncoding(pEncoding, m_BaseEncoding, m_pCharNames, m_pFontFile != NULL, |
955 m_Font.IsTTFont()); | 947 m_Font.IsTTFont()); |
956 LoadGlyphMap(); | 948 LoadGlyphMap(); |
957 delete[] m_pCharNames; | 949 delete[] m_pCharNames; |
958 m_pCharNames = NULL; | 950 m_pCharNames = NULL; |
959 if (m_Font.m_Face == NULL) { | 951 if (!m_Font.GetFace()) |
960 return TRUE; | 952 return TRUE; |
961 } | 953 |
962 if (m_Flags & PDFFONT_ALLCAP) { | 954 if (m_Flags & PDFFONT_ALLCAP) { |
963 unsigned char lowercases[] = {'a', 'z', 0xe0, 0xf6, 0xf8, 0xfd}; | 955 unsigned char lowercases[] = {'a', 'z', 0xe0, 0xf6, 0xf8, 0xfd}; |
964 for (size_t range = 0; range < sizeof lowercases / 2; range++) { | 956 for (size_t range = 0; range < sizeof lowercases / 2; range++) { |
965 for (int i = lowercases[range * 2]; i <= lowercases[range * 2 + 1]; i++) { | 957 for (int i = lowercases[range * 2]; i <= lowercases[range * 2 + 1]; i++) { |
966 if (m_GlyphIndex[i] != 0xffff && m_pFontFile != NULL) { | 958 if (m_GlyphIndex[i] != 0xffff && m_pFontFile) { |
967 continue; | 959 continue; |
968 } | 960 } |
969 m_GlyphIndex[i] = m_GlyphIndex[i - 32]; | 961 m_GlyphIndex[i] = m_GlyphIndex[i - 32]; |
970 if (m_CharWidth[i - 32]) { | 962 if (m_CharWidth[i - 32]) { |
971 m_CharWidth[i] = m_CharWidth[i - 32]; | 963 m_CharWidth[i] = m_CharWidth[i - 32]; |
972 m_CharBBox[i] = m_CharBBox[i - 32]; | 964 m_CharBBox[i] = m_CharBBox[i - 32]; |
973 } | 965 } |
974 } | 966 } |
975 } | 967 } |
976 } | 968 } |
(...skipping 13 matching lines...) Expand all Loading... |
990 break; | 982 break; |
991 } | 983 } |
992 } | 984 } |
993 if (i == 256 && width) { | 985 if (i == 256 && width) { |
994 m_Flags |= PDFFONT_FIXEDPITCH; | 986 m_Flags |= PDFFONT_FIXEDPITCH; |
995 } | 987 } |
996 } | 988 } |
997 int weight = m_StemV < 140 ? m_StemV * 5 : (m_StemV * 4 + 140); | 989 int weight = m_StemV < 140 ? m_StemV * 5 : (m_StemV * 4 + 140); |
998 m_Font.LoadSubst(m_BaseFont, IsFontType(PDFFONT_TRUETYPE), m_Flags, weight, | 990 m_Font.LoadSubst(m_BaseFont, IsFontType(PDFFONT_TRUETYPE), m_Flags, weight, |
999 m_ItalicAngle, 0); | 991 m_ItalicAngle, 0); |
1000 if (m_Font.m_pSubstFont->m_SubstFlags & FXFONT_SUBST_NONSYMBOL) { | 992 if (m_Font.GetSubstFont()->m_SubstFlags & FXFONT_SUBST_NONSYMBOL) { |
1001 } | 993 } |
1002 } | 994 } |
1003 FX_BOOL CPDF_SimpleFont::IsUnicodeCompatible() const { | 995 FX_BOOL CPDF_SimpleFont::IsUnicodeCompatible() const { |
1004 return m_BaseEncoding != PDFFONT_ENCODING_BUILTIN && | 996 return m_BaseEncoding != PDFFONT_ENCODING_BUILTIN && |
1005 m_BaseEncoding != PDFFONT_ENCODING_ADOBE_SYMBOL && | 997 m_BaseEncoding != PDFFONT_ENCODING_ADOBE_SYMBOL && |
1006 m_BaseEncoding != PDFFONT_ENCODING_ZAPFDINGBATS; | 998 m_BaseEncoding != PDFFONT_ENCODING_ZAPFDINGBATS; |
1007 } | 999 } |
1008 CPDF_Type1Font::CPDF_Type1Font() : CPDF_SimpleFont(PDFFONT_TYPE1) { | 1000 CPDF_Type1Font::CPDF_Type1Font() : CPDF_SimpleFont(PDFFONT_TYPE1) { |
1009 m_Base14Font = -1; | 1001 m_Base14Font = -1; |
1010 } | 1002 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1084 pStrAdobe, g_GlyphNameSubsts, | 1076 pStrAdobe, g_GlyphNameSubsts, |
1085 sizeof g_GlyphNameSubsts / sizeof(_GlyphNameMap), sizeof(_GlyphNameMap), | 1077 sizeof g_GlyphNameSubsts / sizeof(_GlyphNameMap), sizeof(_GlyphNameMap), |
1086 compareString); | 1078 compareString); |
1087 if (found) { | 1079 if (found) { |
1088 return found->m_pStrUnicode; | 1080 return found->m_pStrUnicode; |
1089 } | 1081 } |
1090 return NULL; | 1082 return NULL; |
1091 } | 1083 } |
1092 #endif | 1084 #endif |
1093 void CPDF_Type1Font::LoadGlyphMap() { | 1085 void CPDF_Type1Font::LoadGlyphMap() { |
1094 if (m_Font.m_Face == NULL) { | 1086 if (!m_Font.GetFace()) |
1095 return; | 1087 return; |
1096 } | 1088 |
1097 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 1089 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
1098 FX_BOOL bCoreText = TRUE; | 1090 FX_BOOL bCoreText = TRUE; |
1099 CQuartz2D& quartz2d = | 1091 CQuartz2D& quartz2d = |
1100 ((CApplePlatform*)CFX_GEModule::Get()->GetPlatformData())->_quartz2d; | 1092 ((CApplePlatform*)CFX_GEModule::Get()->GetPlatformData())->_quartz2d; |
1101 if (!m_Font.m_pPlatformFont) { | 1093 if (!m_Font.m_pPlatformFont) { |
1102 if (m_Font.GetPsName() == CFX_WideString::FromLocal("DFHeiStd-W5")) { | 1094 if (m_Font.GetPsName() == CFX_WideString::FromLocal("DFHeiStd-W5")) { |
1103 bCoreText = FALSE; | 1095 bCoreText = FALSE; |
1104 } | 1096 } |
1105 m_Font.m_pPlatformFont = | 1097 m_Font.m_pPlatformFont = |
1106 quartz2d.CreateFont(m_Font.m_pFontData, m_Font.m_dwSize); | 1098 quartz2d.CreateFont(m_Font.m_pFontData, m_Font.m_dwSize); |
1107 if (NULL == m_Font.m_pPlatformFont) { | 1099 if (NULL == m_Font.m_pPlatformFont) { |
1108 bCoreText = FALSE; | 1100 bCoreText = FALSE; |
1109 } | 1101 } |
1110 } | 1102 } |
1111 #endif | 1103 #endif |
1112 if (!IsEmbedded() && (m_Base14Font < 12) && m_Font.IsTTFont()) { | 1104 if (!IsEmbedded() && (m_Base14Font < 12) && m_Font.IsTTFont()) { |
1113 if (FT_UseTTCharmap(m_Font.m_Face, 3, 0)) { | 1105 if (FT_UseTTCharmap(m_Font.GetFace(), 3, 0)) { |
1114 FX_BOOL bGotOne = FALSE; | 1106 FX_BOOL bGotOne = FALSE; |
1115 for (int charcode = 0; charcode < 256; charcode++) { | 1107 for (int charcode = 0; charcode < 256; charcode++) { |
1116 const uint8_t prefix[4] = {0x00, 0xf0, 0xf1, 0xf2}; | 1108 const uint8_t prefix[4] = {0x00, 0xf0, 0xf1, 0xf2}; |
1117 for (int j = 0; j < 4; j++) { | 1109 for (int j = 0; j < 4; j++) { |
1118 FX_WORD unicode = prefix[j] * 256 + charcode; | 1110 FX_WORD unicode = prefix[j] * 256 + charcode; |
1119 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face, unicode); | 1111 m_GlyphIndex[charcode] = |
| 1112 FXFT_Get_Char_Index(m_Font.GetFace(), unicode); |
1120 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 1113 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
1121 FX_CHAR name_glyph[256]; | 1114 FX_CHAR name_glyph[256]; |
1122 FXFT_Get_Glyph_Name(m_Font.m_Face, m_GlyphIndex[charcode], name_glyph, | 1115 FXFT_Get_Glyph_Name(m_Font.GetFace(), m_GlyphIndex[charcode], |
1123 256); | 1116 name_glyph, 256); |
1124 name_glyph[255] = 0; | 1117 name_glyph[255] = 0; |
1125 CFStringRef name_ct = CFStringCreateWithCStringNoCopy( | 1118 CFStringRef name_ct = CFStringCreateWithCStringNoCopy( |
1126 kCFAllocatorDefault, name_glyph, kCFStringEncodingASCII, | 1119 kCFAllocatorDefault, name_glyph, kCFStringEncodingASCII, |
1127 kCFAllocatorNull); | 1120 kCFAllocatorNull); |
1128 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName( | 1121 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName( |
1129 (CGFontRef)m_Font.m_pPlatformFont, name_ct); | 1122 (CGFontRef)m_Font.m_pPlatformFont, name_ct); |
1130 if (name_ct) { | 1123 if (name_ct) { |
1131 CFRelease(name_ct); | 1124 CFRelease(name_ct); |
1132 } | 1125 } |
1133 #endif | 1126 #endif |
1134 if (m_GlyphIndex[charcode]) { | 1127 if (m_GlyphIndex[charcode]) { |
1135 bGotOne = TRUE; | 1128 bGotOne = TRUE; |
1136 break; | 1129 break; |
1137 } | 1130 } |
1138 } | 1131 } |
1139 } | 1132 } |
1140 if (bGotOne) { | 1133 if (bGotOne) { |
1141 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 1134 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
1142 if (!bCoreText) { | 1135 if (!bCoreText) { |
1143 FXSYS_memcpy(m_ExtGID, m_GlyphIndex, 256); | 1136 FXSYS_memcpy(m_ExtGID, m_GlyphIndex, 256); |
1144 } | 1137 } |
1145 #endif | 1138 #endif |
1146 return; | 1139 return; |
1147 } | 1140 } |
1148 } | 1141 } |
1149 FXFT_Select_Charmap(m_Font.m_Face, FXFT_ENCODING_UNICODE); | 1142 FXFT_Select_Charmap(m_Font.GetFace(), FXFT_ENCODING_UNICODE); |
1150 if (m_BaseEncoding == 0) { | 1143 if (m_BaseEncoding == 0) { |
1151 m_BaseEncoding = PDFFONT_ENCODING_STANDARD; | 1144 m_BaseEncoding = PDFFONT_ENCODING_STANDARD; |
1152 } | 1145 } |
1153 for (int charcode = 0; charcode < 256; charcode++) { | 1146 for (int charcode = 0; charcode < 256; charcode++) { |
1154 const FX_CHAR* name = | 1147 const FX_CHAR* name = |
1155 GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); | 1148 GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); |
1156 if (name == NULL) { | 1149 if (name == NULL) { |
1157 continue; | 1150 continue; |
1158 } | 1151 } |
1159 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); | 1152 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); |
1160 m_GlyphIndex[charcode] = | 1153 m_GlyphIndex[charcode] = FXFT_Get_Char_Index( |
1161 FXFT_Get_Char_Index(m_Font.m_Face, m_Encoding.m_Unicodes[charcode]); | 1154 m_Font.GetFace(), m_Encoding.m_Unicodes[charcode]); |
1162 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 1155 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
1163 FX_CHAR name_glyph[256]; | 1156 FX_CHAR name_glyph[256]; |
1164 FXFT_Get_Glyph_Name(m_Font.m_Face, m_GlyphIndex[charcode], name_glyph, | 1157 FXFT_Get_Glyph_Name(m_Font.GetFace(), m_GlyphIndex[charcode], name_glyph, |
1165 256); | 1158 256); |
1166 name_glyph[255] = 0; | 1159 name_glyph[255] = 0; |
1167 CFStringRef name_ct = CFStringCreateWithCStringNoCopy( | 1160 CFStringRef name_ct = CFStringCreateWithCStringNoCopy( |
1168 kCFAllocatorDefault, name_glyph, kCFStringEncodingASCII, | 1161 kCFAllocatorDefault, name_glyph, kCFStringEncodingASCII, |
1169 kCFAllocatorNull); | 1162 kCFAllocatorNull); |
1170 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName( | 1163 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName( |
1171 (CGFontRef)m_Font.m_pPlatformFont, name_ct); | 1164 (CGFontRef)m_Font.m_pPlatformFont, name_ct); |
1172 if (name_ct) { | 1165 if (name_ct) { |
1173 CFRelease(name_ct); | 1166 CFRelease(name_ct); |
1174 } | 1167 } |
1175 #endif | 1168 #endif |
1176 if (m_GlyphIndex[charcode] == 0 && FXSYS_strcmp(name, ".notdef") == 0) { | 1169 if (m_GlyphIndex[charcode] == 0 && FXSYS_strcmp(name, ".notdef") == 0) { |
1177 m_Encoding.m_Unicodes[charcode] = 0x20; | 1170 m_Encoding.m_Unicodes[charcode] = 0x20; |
1178 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face, 0x20); | 1171 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.GetFace(), 0x20); |
1179 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 1172 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
1180 FX_CHAR name_glyph[256]; | 1173 FX_CHAR name_glyph[256]; |
1181 FXFT_Get_Glyph_Name(m_Font.m_Face, m_GlyphIndex[charcode], name_glyph, | 1174 FXFT_Get_Glyph_Name(m_Font.GetFace(), m_GlyphIndex[charcode], |
1182 256); | 1175 name_glyph, 256); |
1183 name_glyph[255] = 0; | 1176 name_glyph[255] = 0; |
1184 CFStringRef name_ct = CFStringCreateWithCStringNoCopy( | 1177 CFStringRef name_ct = CFStringCreateWithCStringNoCopy( |
1185 kCFAllocatorDefault, name_glyph, kCFStringEncodingASCII, | 1178 kCFAllocatorDefault, name_glyph, kCFStringEncodingASCII, |
1186 kCFAllocatorNull); | 1179 kCFAllocatorNull); |
1187 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName( | 1180 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName( |
1188 (CGFontRef)m_Font.m_pPlatformFont, name_ct); | 1181 (CGFontRef)m_Font.m_pPlatformFont, name_ct); |
1189 if (name_ct) { | 1182 if (name_ct) { |
1190 CFRelease(name_ct); | 1183 CFRelease(name_ct); |
1191 } | 1184 } |
1192 #endif | 1185 #endif |
1193 } | 1186 } |
1194 } | 1187 } |
1195 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 1188 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
1196 if (!bCoreText) { | 1189 if (!bCoreText) { |
1197 FXSYS_memcpy(m_ExtGID, m_GlyphIndex, 256); | 1190 FXSYS_memcpy(m_ExtGID, m_GlyphIndex, 256); |
1198 } | 1191 } |
1199 #endif | 1192 #endif |
1200 return; | 1193 return; |
1201 } | 1194 } |
1202 FT_UseType1Charmap(m_Font.m_Face); | 1195 FT_UseType1Charmap(m_Font.GetFace()); |
1203 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 1196 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
1204 if (bCoreText) { | 1197 if (bCoreText) { |
1205 if (m_Flags & PDFFONT_SYMBOLIC) { | 1198 if (m_Flags & PDFFONT_SYMBOLIC) { |
1206 for (int charcode = 0; charcode < 256; charcode++) { | 1199 for (int charcode = 0; charcode < 256; charcode++) { |
1207 const FX_CHAR* name = | 1200 const FX_CHAR* name = |
1208 GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); | 1201 GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); |
1209 if (name) { | 1202 if (name) { |
1210 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); | 1203 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); |
1211 m_GlyphIndex[charcode] = | 1204 m_GlyphIndex[charcode] = |
1212 FXFT_Get_Name_Index(m_Font.m_Face, (char*)name); | 1205 FXFT_Get_Name_Index(m_Font.GetFace(), (char*)name); |
1213 CFStringRef name_ct = CFStringCreateWithCStringNoCopy( | 1206 CFStringRef name_ct = CFStringCreateWithCStringNoCopy( |
1214 kCFAllocatorDefault, name, kCFStringEncodingASCII, | 1207 kCFAllocatorDefault, name, kCFStringEncodingASCII, |
1215 kCFAllocatorNull); | 1208 kCFAllocatorNull); |
1216 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName( | 1209 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName( |
1217 (CGFontRef)m_Font.m_pPlatformFont, name_ct); | 1210 (CGFontRef)m_Font.m_pPlatformFont, name_ct); |
1218 if (name_ct) { | 1211 if (name_ct) { |
1219 CFRelease(name_ct); | 1212 CFRelease(name_ct); |
1220 } | 1213 } |
1221 } else { | 1214 } else { |
1222 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face, charcode); | 1215 m_GlyphIndex[charcode] = |
| 1216 FXFT_Get_Char_Index(m_Font.GetFace(), charcode); |
1223 FX_WCHAR unicode = 0; | 1217 FX_WCHAR unicode = 0; |
1224 if (m_GlyphIndex[charcode]) { | 1218 if (m_GlyphIndex[charcode]) { |
1225 unicode = | 1219 unicode = |
1226 FT_UnicodeFromCharCode(PDFFONT_ENCODING_STANDARD, charcode); | 1220 FT_UnicodeFromCharCode(PDFFONT_ENCODING_STANDARD, charcode); |
1227 } | 1221 } |
1228 FX_CHAR name_glyph[256]; | 1222 FX_CHAR name_glyph[256]; |
1229 FXSYS_memset(name_glyph, 0, sizeof(name_glyph)); | 1223 FXSYS_memset(name_glyph, 0, sizeof(name_glyph)); |
1230 FXFT_Get_Glyph_Name(m_Font.m_Face, m_GlyphIndex[charcode], name_glyph, | 1224 FXFT_Get_Glyph_Name(m_Font.GetFace(), m_GlyphIndex[charcode], |
1231 256); | 1225 name_glyph, 256); |
1232 name_glyph[255] = 0; | 1226 name_glyph[255] = 0; |
1233 if (unicode == 0 && name_glyph[0] != 0) { | 1227 if (unicode == 0 && name_glyph[0] != 0) { |
1234 unicode = PDF_UnicodeFromAdobeName(name_glyph); | 1228 unicode = PDF_UnicodeFromAdobeName(name_glyph); |
1235 } | 1229 } |
1236 m_Encoding.m_Unicodes[charcode] = unicode; | 1230 m_Encoding.m_Unicodes[charcode] = unicode; |
1237 CFStringRef name_ct = CFStringCreateWithCStringNoCopy( | 1231 CFStringRef name_ct = CFStringCreateWithCStringNoCopy( |
1238 kCFAllocatorDefault, name_glyph, kCFStringEncodingASCII, | 1232 kCFAllocatorDefault, name_glyph, kCFStringEncodingASCII, |
1239 kCFAllocatorNull); | 1233 kCFAllocatorNull); |
1240 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName( | 1234 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName( |
1241 (CGFontRef)m_Font.m_pPlatformFont, name_ct); | 1235 (CGFontRef)m_Font.m_pPlatformFont, name_ct); |
1242 if (name_ct) { | 1236 if (name_ct) { |
1243 CFRelease(name_ct); | 1237 CFRelease(name_ct); |
1244 } | 1238 } |
1245 } | 1239 } |
1246 } | 1240 } |
1247 return; | 1241 return; |
1248 } | 1242 } |
1249 FX_BOOL bUnicode = FALSE; | 1243 FX_BOOL bUnicode = FALSE; |
1250 if (0 == FXFT_Select_Charmap(m_Font.m_Face, FXFT_ENCODING_UNICODE)) { | 1244 if (0 == FXFT_Select_Charmap(m_Font.GetFace(), FXFT_ENCODING_UNICODE)) { |
1251 bUnicode = TRUE; | 1245 bUnicode = TRUE; |
1252 } | 1246 } |
1253 for (int charcode = 0; charcode < 256; charcode++) { | 1247 for (int charcode = 0; charcode < 256; charcode++) { |
1254 const FX_CHAR* name = | 1248 const FX_CHAR* name = |
1255 GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); | 1249 GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); |
1256 if (name == NULL) { | 1250 if (name == NULL) { |
1257 continue; | 1251 continue; |
1258 } | 1252 } |
1259 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); | 1253 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); |
1260 const FX_CHAR* pStrUnicode = _GlyphNameRemap(name); | 1254 const FX_CHAR* pStrUnicode = _GlyphNameRemap(name); |
1261 if (pStrUnicode && 0 == FXFT_Get_Name_Index(m_Font.m_Face, (char*)name)) { | 1255 if (pStrUnicode && |
| 1256 0 == FXFT_Get_Name_Index(m_Font.GetFace(), (char*)name)) { |
1262 name = pStrUnicode; | 1257 name = pStrUnicode; |
1263 } | 1258 } |
1264 m_GlyphIndex[charcode] = FXFT_Get_Name_Index(m_Font.m_Face, (char*)name); | 1259 m_GlyphIndex[charcode] = |
| 1260 FXFT_Get_Name_Index(m_Font.GetFace(), (char*)name); |
1265 CFStringRef name_ct = CFStringCreateWithCStringNoCopy( | 1261 CFStringRef name_ct = CFStringCreateWithCStringNoCopy( |
1266 kCFAllocatorDefault, name, kCFStringEncodingASCII, kCFAllocatorNull); | 1262 kCFAllocatorDefault, name, kCFStringEncodingASCII, kCFAllocatorNull); |
1267 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName( | 1263 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName( |
1268 (CGFontRef)m_Font.m_pPlatformFont, name_ct); | 1264 (CGFontRef)m_Font.m_pPlatformFont, name_ct); |
1269 if (name_ct) { | 1265 if (name_ct) { |
1270 CFRelease(name_ct); | 1266 CFRelease(name_ct); |
1271 } | 1267 } |
1272 if (m_GlyphIndex[charcode] == 0) { | 1268 if (m_GlyphIndex[charcode] == 0) { |
1273 if (FXSYS_strcmp(name, ".notdef") != 0 && | 1269 if (FXSYS_strcmp(name, ".notdef") != 0 && |
1274 FXSYS_strcmp(name, "space") != 0) { | 1270 FXSYS_strcmp(name, "space") != 0) { |
1275 m_GlyphIndex[charcode] = FXFT_Get_Char_Index( | 1271 m_GlyphIndex[charcode] = FXFT_Get_Char_Index( |
1276 m_Font.m_Face, | 1272 m_Font.GetFace(), |
1277 bUnicode ? m_Encoding.m_Unicodes[charcode] : charcode); | 1273 bUnicode ? m_Encoding.m_Unicodes[charcode] : charcode); |
1278 FX_CHAR name_glyph[256]; | 1274 FX_CHAR name_glyph[256]; |
1279 FXFT_Get_Glyph_Name(m_Font.m_Face, m_GlyphIndex[charcode], name_glyph, | 1275 FXFT_Get_Glyph_Name(m_Font.GetFace(), m_GlyphIndex[charcode], |
1280 256); | 1276 name_glyph, 256); |
1281 name_glyph[255] = 0; | 1277 name_glyph[255] = 0; |
1282 CFStringRef name_ct = CFStringCreateWithCStringNoCopy( | 1278 CFStringRef name_ct = CFStringCreateWithCStringNoCopy( |
1283 kCFAllocatorDefault, name_glyph, kCFStringEncodingASCII, | 1279 kCFAllocatorDefault, name_glyph, kCFStringEncodingASCII, |
1284 kCFAllocatorNull); | 1280 kCFAllocatorNull); |
1285 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName( | 1281 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName( |
1286 (CGFontRef)m_Font.m_pPlatformFont, name_ct); | 1282 (CGFontRef)m_Font.m_pPlatformFont, name_ct); |
1287 if (name_ct) { | 1283 if (name_ct) { |
1288 CFRelease(name_ct); | 1284 CFRelease(name_ct); |
1289 } | 1285 } |
1290 } else { | 1286 } else { |
1291 m_Encoding.m_Unicodes[charcode] = 0x20; | 1287 m_Encoding.m_Unicodes[charcode] = 0x20; |
1292 m_GlyphIndex[charcode] = | 1288 m_GlyphIndex[charcode] = |
1293 bUnicode ? FXFT_Get_Char_Index(m_Font.m_Face, 0x20) : 0xffff; | 1289 bUnicode ? FXFT_Get_Char_Index(m_Font.GetFace(), 0x20) : 0xffff; |
1294 FX_CHAR name_glyph[256]; | 1290 FX_CHAR name_glyph[256]; |
1295 FXFT_Get_Glyph_Name(m_Font.m_Face, m_GlyphIndex[charcode], name_glyph, | 1291 FXFT_Get_Glyph_Name(m_Font.GetFace(), m_GlyphIndex[charcode], |
1296 256); | 1292 name_glyph, 256); |
1297 name_glyph[255] = 0; | 1293 name_glyph[255] = 0; |
1298 CFStringRef name_ct = CFStringCreateWithCStringNoCopy( | 1294 CFStringRef name_ct = CFStringCreateWithCStringNoCopy( |
1299 kCFAllocatorDefault, name_glyph, kCFStringEncodingASCII, | 1295 kCFAllocatorDefault, name_glyph, kCFStringEncodingASCII, |
1300 kCFAllocatorNull); | 1296 kCFAllocatorNull); |
1301 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName( | 1297 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName( |
1302 (CGFontRef)m_Font.m_pPlatformFont, name_ct); | 1298 (CGFontRef)m_Font.m_pPlatformFont, name_ct); |
1303 if (name_ct) { | 1299 if (name_ct) { |
1304 CFRelease(name_ct); | 1300 CFRelease(name_ct); |
1305 } | 1301 } |
1306 } | 1302 } |
1307 } | 1303 } |
1308 } | 1304 } |
1309 return; | 1305 return; |
1310 } | 1306 } |
1311 #endif | 1307 #endif |
1312 if (m_Flags & PDFFONT_SYMBOLIC) { | 1308 if (m_Flags & PDFFONT_SYMBOLIC) { |
1313 for (int charcode = 0; charcode < 256; charcode++) { | 1309 for (int charcode = 0; charcode < 256; charcode++) { |
1314 const FX_CHAR* name = | 1310 const FX_CHAR* name = |
1315 GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); | 1311 GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); |
1316 if (name) { | 1312 if (name) { |
1317 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); | 1313 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); |
1318 m_GlyphIndex[charcode] = | 1314 m_GlyphIndex[charcode] = |
1319 FXFT_Get_Name_Index(m_Font.m_Face, (char*)name); | 1315 FXFT_Get_Name_Index(m_Font.GetFace(), (char*)name); |
1320 } else { | 1316 } else { |
1321 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face, charcode); | 1317 m_GlyphIndex[charcode] = |
| 1318 FXFT_Get_Char_Index(m_Font.GetFace(), charcode); |
1322 if (m_GlyphIndex[charcode]) { | 1319 if (m_GlyphIndex[charcode]) { |
1323 FX_WCHAR unicode = | 1320 FX_WCHAR unicode = |
1324 FT_UnicodeFromCharCode(PDFFONT_ENCODING_STANDARD, charcode); | 1321 FT_UnicodeFromCharCode(PDFFONT_ENCODING_STANDARD, charcode); |
1325 if (unicode == 0) { | 1322 if (unicode == 0) { |
1326 FX_CHAR name_glyph[256]; | 1323 FX_CHAR name_glyph[256]; |
1327 FXSYS_memset(name_glyph, 0, sizeof(name_glyph)); | 1324 FXSYS_memset(name_glyph, 0, sizeof(name_glyph)); |
1328 FXFT_Get_Glyph_Name(m_Font.m_Face, m_GlyphIndex[charcode], | 1325 FXFT_Get_Glyph_Name(m_Font.GetFace(), m_GlyphIndex[charcode], |
1329 name_glyph, 256); | 1326 name_glyph, 256); |
1330 name_glyph[255] = 0; | 1327 name_glyph[255] = 0; |
1331 if (name_glyph[0] != 0) { | 1328 if (name_glyph[0] != 0) { |
1332 unicode = PDF_UnicodeFromAdobeName(name_glyph); | 1329 unicode = PDF_UnicodeFromAdobeName(name_glyph); |
1333 } | 1330 } |
1334 } | 1331 } |
1335 m_Encoding.m_Unicodes[charcode] = unicode; | 1332 m_Encoding.m_Unicodes[charcode] = unicode; |
1336 } | 1333 } |
1337 } | 1334 } |
1338 } | 1335 } |
1339 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 1336 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
1340 if (!bCoreText) { | 1337 if (!bCoreText) { |
1341 FXSYS_memcpy(m_ExtGID, m_GlyphIndex, 256); | 1338 FXSYS_memcpy(m_ExtGID, m_GlyphIndex, 256); |
1342 } | 1339 } |
1343 #endif | 1340 #endif |
1344 return; | 1341 return; |
1345 } | 1342 } |
1346 FX_BOOL bUnicode = FALSE; | 1343 FX_BOOL bUnicode = FALSE; |
1347 if (0 == FXFT_Select_Charmap(m_Font.m_Face, FXFT_ENCODING_UNICODE)) { | 1344 if (0 == FXFT_Select_Charmap(m_Font.GetFace(), FXFT_ENCODING_UNICODE)) { |
1348 bUnicode = TRUE; | 1345 bUnicode = TRUE; |
1349 } | 1346 } |
1350 for (int charcode = 0; charcode < 256; charcode++) { | 1347 for (int charcode = 0; charcode < 256; charcode++) { |
1351 const FX_CHAR* name = | 1348 const FX_CHAR* name = |
1352 GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); | 1349 GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); |
1353 if (name == NULL) { | 1350 if (name == NULL) { |
1354 continue; | 1351 continue; |
1355 } | 1352 } |
1356 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); | 1353 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); |
1357 m_GlyphIndex[charcode] = FXFT_Get_Name_Index(m_Font.m_Face, (char*)name); | 1354 m_GlyphIndex[charcode] = FXFT_Get_Name_Index(m_Font.GetFace(), (char*)name); |
1358 if (m_GlyphIndex[charcode] == 0) { | 1355 if (m_GlyphIndex[charcode] == 0) { |
1359 if (FXSYS_strcmp(name, ".notdef") != 0 && | 1356 if (FXSYS_strcmp(name, ".notdef") != 0 && |
1360 FXSYS_strcmp(name, "space") != 0) { | 1357 FXSYS_strcmp(name, "space") != 0) { |
1361 m_GlyphIndex[charcode] = FXFT_Get_Char_Index( | 1358 m_GlyphIndex[charcode] = FXFT_Get_Char_Index( |
1362 m_Font.m_Face, | 1359 m_Font.GetFace(), |
1363 bUnicode ? m_Encoding.m_Unicodes[charcode] : charcode); | 1360 bUnicode ? m_Encoding.m_Unicodes[charcode] : charcode); |
1364 } else { | 1361 } else { |
1365 m_Encoding.m_Unicodes[charcode] = 0x20; | 1362 m_Encoding.m_Unicodes[charcode] = 0x20; |
1366 m_GlyphIndex[charcode] = 0xffff; | 1363 m_GlyphIndex[charcode] = 0xffff; |
1367 } | 1364 } |
1368 } | 1365 } |
1369 } | 1366 } |
1370 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 1367 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
1371 if (!bCoreText) { | 1368 if (!bCoreText) { |
1372 FXSYS_memcpy(m_ExtGID, m_GlyphIndex, 256); | 1369 FXSYS_memcpy(m_ExtGID, m_GlyphIndex, 256); |
1373 } | 1370 } |
1374 #endif | 1371 #endif |
1375 } | 1372 } |
| 1373 |
1376 CPDF_FontEncoding::CPDF_FontEncoding() { | 1374 CPDF_FontEncoding::CPDF_FontEncoding() { |
1377 FXSYS_memset(m_Unicodes, 0, sizeof(m_Unicodes)); | 1375 FXSYS_memset(m_Unicodes, 0, sizeof(m_Unicodes)); |
1378 } | 1376 } |
1379 int CPDF_FontEncoding::CharCodeFromUnicode(FX_WCHAR unicode) const { | 1377 int CPDF_FontEncoding::CharCodeFromUnicode(FX_WCHAR unicode) const { |
1380 for (int i = 0; i < 256; i++) | 1378 for (int i = 0; i < 256; i++) |
1381 if (m_Unicodes[i] == unicode) { | 1379 if (m_Unicodes[i] == unicode) { |
1382 return i; | 1380 return i; |
1383 } | 1381 } |
1384 return -1; | 1382 return -1; |
1385 } | 1383 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1438 pDiff->Add(CPDF_Name::Create(PDF_AdobeNameFromUnicode(m_Unicodes[i]))); | 1436 pDiff->Add(CPDF_Name::Create(PDF_AdobeNameFromUnicode(m_Unicodes[i]))); |
1439 } | 1437 } |
1440 pDict->SetAt(FX_BSTRC("Differences"), pDiff); | 1438 pDict->SetAt(FX_BSTRC("Differences"), pDiff); |
1441 return pDict; | 1439 return pDict; |
1442 } | 1440 } |
1443 CPDF_TrueTypeFont::CPDF_TrueTypeFont() : CPDF_SimpleFont(PDFFONT_TRUETYPE) {} | 1441 CPDF_TrueTypeFont::CPDF_TrueTypeFont() : CPDF_SimpleFont(PDFFONT_TRUETYPE) {} |
1444 FX_BOOL CPDF_TrueTypeFont::_Load() { | 1442 FX_BOOL CPDF_TrueTypeFont::_Load() { |
1445 return LoadCommon(); | 1443 return LoadCommon(); |
1446 } | 1444 } |
1447 void CPDF_TrueTypeFont::LoadGlyphMap() { | 1445 void CPDF_TrueTypeFont::LoadGlyphMap() { |
1448 if (m_Font.m_Face == NULL) { | 1446 if (!m_Font.GetFace()) |
1449 return; | 1447 return; |
1450 } | 1448 |
1451 int baseEncoding = m_BaseEncoding; | 1449 int baseEncoding = m_BaseEncoding; |
1452 if (m_pFontFile && m_Font.m_Face->num_charmaps > 0 && | 1450 if (m_pFontFile && m_Font.GetFace()->num_charmaps > 0 && |
1453 (baseEncoding == PDFFONT_ENCODING_MACROMAN || | 1451 (baseEncoding == PDFFONT_ENCODING_MACROMAN || |
1454 baseEncoding == PDFFONT_ENCODING_WINANSI) && | 1452 baseEncoding == PDFFONT_ENCODING_WINANSI) && |
1455 (m_Flags & PDFFONT_SYMBOLIC)) { | 1453 (m_Flags & PDFFONT_SYMBOLIC)) { |
1456 FX_BOOL bSupportWin = FALSE; | 1454 FX_BOOL bSupportWin = FALSE; |
1457 FX_BOOL bSupportMac = FALSE; | 1455 FX_BOOL bSupportMac = FALSE; |
1458 for (int i = 0; i < FXFT_Get_Face_CharmapCount(m_Font.m_Face); i++) { | 1456 for (int i = 0; i < FXFT_Get_Face_CharmapCount(m_Font.GetFace()); i++) { |
1459 int platform_id = | 1457 int platform_id = FXFT_Get_Charmap_PlatformID( |
1460 FXFT_Get_Charmap_PlatformID(FXFT_Get_Face_Charmaps(m_Font.m_Face)[i]); | 1458 FXFT_Get_Face_Charmaps(m_Font.GetFace())[i]); |
1461 if (platform_id == 0 || platform_id == 3) { | 1459 if (platform_id == 0 || platform_id == 3) { |
1462 bSupportWin = TRUE; | 1460 bSupportWin = TRUE; |
1463 } else if (platform_id == 0 || platform_id == 1) { | 1461 } else if (platform_id == 0 || platform_id == 1) { |
1464 bSupportMac = TRUE; | 1462 bSupportMac = TRUE; |
1465 } | 1463 } |
1466 } | 1464 } |
1467 if (baseEncoding == PDFFONT_ENCODING_WINANSI && !bSupportWin) { | 1465 if (baseEncoding == PDFFONT_ENCODING_WINANSI && !bSupportWin) { |
1468 baseEncoding = | 1466 baseEncoding = |
1469 bSupportMac ? PDFFONT_ENCODING_MACROMAN : PDFFONT_ENCODING_BUILTIN; | 1467 bSupportMac ? PDFFONT_ENCODING_MACROMAN : PDFFONT_ENCODING_BUILTIN; |
1470 } else if (baseEncoding == PDFFONT_ENCODING_MACROMAN && !bSupportMac) { | 1468 } else if (baseEncoding == PDFFONT_ENCODING_MACROMAN && !bSupportMac) { |
1471 baseEncoding = | 1469 baseEncoding = |
1472 bSupportWin ? PDFFONT_ENCODING_WINANSI : PDFFONT_ENCODING_BUILTIN; | 1470 bSupportWin ? PDFFONT_ENCODING_WINANSI : PDFFONT_ENCODING_BUILTIN; |
1473 } | 1471 } |
1474 } | 1472 } |
1475 if (((baseEncoding == PDFFONT_ENCODING_MACROMAN || | 1473 if (((baseEncoding == PDFFONT_ENCODING_MACROMAN || |
1476 baseEncoding == PDFFONT_ENCODING_WINANSI) && | 1474 baseEncoding == PDFFONT_ENCODING_WINANSI) && |
1477 m_pCharNames == NULL) || | 1475 m_pCharNames == NULL) || |
1478 (m_Flags & PDFFONT_NONSYMBOLIC)) { | 1476 (m_Flags & PDFFONT_NONSYMBOLIC)) { |
1479 if (!FXFT_Has_Glyph_Names(m_Font.m_Face) && | 1477 if (!FXFT_Has_Glyph_Names(m_Font.GetFace()) && |
1480 (!m_Font.m_Face->num_charmaps || !m_Font.m_Face->charmaps)) { | 1478 (!m_Font.GetFace()->num_charmaps || !m_Font.GetFace()->charmaps)) { |
1481 int nStartChar = m_pFontDict->GetInteger(FX_BSTRC("FirstChar")); | 1479 int nStartChar = m_pFontDict->GetInteger(FX_BSTRC("FirstChar")); |
1482 if (nStartChar < 0 || nStartChar > 255) | 1480 if (nStartChar < 0 || nStartChar > 255) |
1483 return; | 1481 return; |
1484 | 1482 |
1485 int charcode = 0; | 1483 int charcode = 0; |
1486 for (; charcode < nStartChar; charcode++) { | 1484 for (; charcode < nStartChar; charcode++) { |
1487 m_GlyphIndex[charcode] = 0; | 1485 m_GlyphIndex[charcode] = 0; |
1488 } | 1486 } |
1489 FX_WORD nGlyph = charcode - nStartChar + 3; | 1487 FX_WORD nGlyph = charcode - nStartChar + 3; |
1490 for (; charcode < 256; charcode++, nGlyph++) { | 1488 for (; charcode < 256; charcode++, nGlyph++) { |
1491 m_GlyphIndex[charcode] = nGlyph; | 1489 m_GlyphIndex[charcode] = nGlyph; |
1492 } | 1490 } |
1493 return; | 1491 return; |
1494 } | 1492 } |
1495 FX_BOOL bMSUnicode = FT_UseTTCharmap(m_Font.m_Face, 3, 1); | 1493 FX_BOOL bMSUnicode = FT_UseTTCharmap(m_Font.GetFace(), 3, 1); |
1496 FX_BOOL bMacRoman = FALSE, bMSSymbol = FALSE; | 1494 FX_BOOL bMacRoman = FALSE, bMSSymbol = FALSE; |
1497 if (!bMSUnicode) { | 1495 if (!bMSUnicode) { |
1498 if (m_Flags & PDFFONT_NONSYMBOLIC) { | 1496 if (m_Flags & PDFFONT_NONSYMBOLIC) { |
1499 bMacRoman = FT_UseTTCharmap(m_Font.m_Face, 1, 0); | 1497 bMacRoman = FT_UseTTCharmap(m_Font.GetFace(), 1, 0); |
1500 bMSSymbol = !bMacRoman && FT_UseTTCharmap(m_Font.m_Face, 3, 0); | 1498 bMSSymbol = !bMacRoman && FT_UseTTCharmap(m_Font.GetFace(), 3, 0); |
1501 } else { | 1499 } else { |
1502 bMSSymbol = FT_UseTTCharmap(m_Font.m_Face, 3, 0); | 1500 bMSSymbol = FT_UseTTCharmap(m_Font.GetFace(), 3, 0); |
1503 bMacRoman = !bMSSymbol && FT_UseTTCharmap(m_Font.m_Face, 1, 0); | 1501 bMacRoman = !bMSSymbol && FT_UseTTCharmap(m_Font.GetFace(), 1, 0); |
1504 } | 1502 } |
1505 } | 1503 } |
1506 FX_BOOL bToUnicode = m_pFontDict->KeyExist(FX_BSTRC("ToUnicode")); | 1504 FX_BOOL bToUnicode = m_pFontDict->KeyExist(FX_BSTRC("ToUnicode")); |
1507 for (int charcode = 0; charcode < 256; charcode++) { | 1505 for (int charcode = 0; charcode < 256; charcode++) { |
1508 const FX_CHAR* name = | 1506 const FX_CHAR* name = |
1509 GetAdobeCharName(baseEncoding, m_pCharNames, charcode); | 1507 GetAdobeCharName(baseEncoding, m_pCharNames, charcode); |
1510 if (name == NULL) { | 1508 if (name == NULL) { |
1511 m_GlyphIndex[charcode] = | 1509 m_GlyphIndex[charcode] = |
1512 m_pFontFile ? FXFT_Get_Char_Index(m_Font.m_Face, charcode) : -1; | 1510 m_pFontFile ? FXFT_Get_Char_Index(m_Font.GetFace(), charcode) : -1; |
1513 continue; | 1511 continue; |
1514 } | 1512 } |
1515 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); | 1513 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); |
1516 if (bMSSymbol) { | 1514 if (bMSSymbol) { |
1517 const uint8_t prefix[4] = {0x00, 0xf0, 0xf1, 0xf2}; | 1515 const uint8_t prefix[4] = {0x00, 0xf0, 0xf1, 0xf2}; |
1518 for (int j = 0; j < 4; j++) { | 1516 for (int j = 0; j < 4; j++) { |
1519 FX_WORD unicode = prefix[j] * 256 + charcode; | 1517 FX_WORD unicode = prefix[j] * 256 + charcode; |
1520 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face, unicode); | 1518 m_GlyphIndex[charcode] = |
| 1519 FXFT_Get_Char_Index(m_Font.GetFace(), unicode); |
1521 if (m_GlyphIndex[charcode]) { | 1520 if (m_GlyphIndex[charcode]) { |
1522 break; | 1521 break; |
1523 } | 1522 } |
1524 } | 1523 } |
1525 } else if (m_Encoding.m_Unicodes[charcode]) { | 1524 } else if (m_Encoding.m_Unicodes[charcode]) { |
1526 if (bMSUnicode) { | 1525 if (bMSUnicode) { |
1527 m_GlyphIndex[charcode] = FXFT_Get_Char_Index( | 1526 m_GlyphIndex[charcode] = FXFT_Get_Char_Index( |
1528 m_Font.m_Face, m_Encoding.m_Unicodes[charcode]); | 1527 m_Font.GetFace(), m_Encoding.m_Unicodes[charcode]); |
1529 } else if (bMacRoman) { | 1528 } else if (bMacRoman) { |
1530 FX_DWORD maccode = FT_CharCodeFromUnicode( | 1529 FX_DWORD maccode = FT_CharCodeFromUnicode( |
1531 FXFT_ENCODING_APPLE_ROMAN, m_Encoding.m_Unicodes[charcode]); | 1530 FXFT_ENCODING_APPLE_ROMAN, m_Encoding.m_Unicodes[charcode]); |
1532 if (!maccode) { | 1531 if (!maccode) { |
1533 m_GlyphIndex[charcode] = | 1532 m_GlyphIndex[charcode] = |
1534 FXFT_Get_Name_Index(m_Font.m_Face, (char*)name); | 1533 FXFT_Get_Name_Index(m_Font.GetFace(), (char*)name); |
1535 } else { | 1534 } else { |
1536 m_GlyphIndex[charcode] = | 1535 m_GlyphIndex[charcode] = |
1537 FXFT_Get_Char_Index(m_Font.m_Face, maccode); | 1536 FXFT_Get_Char_Index(m_Font.GetFace(), maccode); |
1538 } | 1537 } |
1539 } | 1538 } |
1540 } | 1539 } |
1541 if ((m_GlyphIndex[charcode] == 0 || m_GlyphIndex[charcode] == 0xffff) && | 1540 if ((m_GlyphIndex[charcode] == 0 || m_GlyphIndex[charcode] == 0xffff) && |
1542 name != NULL) { | 1541 name != NULL) { |
1543 if (name[0] == '.' && FXSYS_strcmp(name, ".notdef") == 0) { | 1542 if (name[0] == '.' && FXSYS_strcmp(name, ".notdef") == 0) { |
1544 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face, 32); | 1543 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.GetFace(), 32); |
1545 } else { | 1544 } else { |
1546 m_GlyphIndex[charcode] = | 1545 m_GlyphIndex[charcode] = |
1547 FXFT_Get_Name_Index(m_Font.m_Face, (char*)name); | 1546 FXFT_Get_Name_Index(m_Font.GetFace(), (char*)name); |
1548 if (m_GlyphIndex[charcode] == 0) { | 1547 if (m_GlyphIndex[charcode] == 0) { |
1549 if (bToUnicode) { | 1548 if (bToUnicode) { |
1550 CFX_WideString wsUnicode = UnicodeFromCharCode(charcode); | 1549 CFX_WideString wsUnicode = UnicodeFromCharCode(charcode); |
1551 if (!wsUnicode.IsEmpty()) { | 1550 if (!wsUnicode.IsEmpty()) { |
1552 m_GlyphIndex[charcode] = | 1551 m_GlyphIndex[charcode] = |
1553 FXFT_Get_Char_Index(m_Font.m_Face, wsUnicode[0]); | 1552 FXFT_Get_Char_Index(m_Font.GetFace(), wsUnicode[0]); |
1554 m_Encoding.m_Unicodes[charcode] = wsUnicode[0]; | 1553 m_Encoding.m_Unicodes[charcode] = wsUnicode[0]; |
1555 } | 1554 } |
1556 } | 1555 } |
1557 if (m_GlyphIndex[charcode] == 0) { | 1556 if (m_GlyphIndex[charcode] == 0) { |
1558 m_GlyphIndex[charcode] = | 1557 m_GlyphIndex[charcode] = |
1559 FXFT_Get_Char_Index(m_Font.m_Face, charcode); | 1558 FXFT_Get_Char_Index(m_Font.GetFace(), charcode); |
1560 } | 1559 } |
1561 } | 1560 } |
1562 } | 1561 } |
1563 } | 1562 } |
1564 } | 1563 } |
1565 return; | 1564 return; |
1566 } | 1565 } |
1567 if (FT_UseTTCharmap(m_Font.m_Face, 3, 0)) { | 1566 if (FT_UseTTCharmap(m_Font.GetFace(), 3, 0)) { |
1568 const uint8_t prefix[4] = {0x00, 0xf0, 0xf1, 0xf2}; | 1567 const uint8_t prefix[4] = {0x00, 0xf0, 0xf1, 0xf2}; |
1569 FX_BOOL bGotOne = FALSE; | 1568 FX_BOOL bGotOne = FALSE; |
1570 for (int charcode = 0; charcode < 256; charcode++) { | 1569 for (int charcode = 0; charcode < 256; charcode++) { |
1571 for (int j = 0; j < 4; j++) { | 1570 for (int j = 0; j < 4; j++) { |
1572 FX_WORD unicode = prefix[j] * 256 + charcode; | 1571 FX_WORD unicode = prefix[j] * 256 + charcode; |
1573 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face, unicode); | 1572 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.GetFace(), unicode); |
1574 if (m_GlyphIndex[charcode]) { | 1573 if (m_GlyphIndex[charcode]) { |
1575 bGotOne = TRUE; | 1574 bGotOne = TRUE; |
1576 break; | 1575 break; |
1577 } | 1576 } |
1578 } | 1577 } |
1579 } | 1578 } |
1580 if (bGotOne) { | 1579 if (bGotOne) { |
1581 if (baseEncoding != PDFFONT_ENCODING_BUILTIN) { | 1580 if (baseEncoding != PDFFONT_ENCODING_BUILTIN) { |
1582 for (int charcode = 0; charcode < 256; charcode++) { | 1581 for (int charcode = 0; charcode < 256; charcode++) { |
1583 const FX_CHAR* name = | 1582 const FX_CHAR* name = |
1584 GetAdobeCharName(baseEncoding, m_pCharNames, charcode); | 1583 GetAdobeCharName(baseEncoding, m_pCharNames, charcode); |
1585 if (name == NULL) { | 1584 if (name == NULL) { |
1586 continue; | 1585 continue; |
1587 } | 1586 } |
1588 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); | 1587 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); |
1589 } | 1588 } |
1590 } else if (FT_UseTTCharmap(m_Font.m_Face, 1, 0)) { | 1589 } else if (FT_UseTTCharmap(m_Font.GetFace(), 1, 0)) { |
1591 for (int charcode = 0; charcode < 256; charcode++) { | 1590 for (int charcode = 0; charcode < 256; charcode++) { |
1592 m_Encoding.m_Unicodes[charcode] = | 1591 m_Encoding.m_Unicodes[charcode] = |
1593 FT_UnicodeFromCharCode(FXFT_ENCODING_APPLE_ROMAN, charcode); | 1592 FT_UnicodeFromCharCode(FXFT_ENCODING_APPLE_ROMAN, charcode); |
1594 } | 1593 } |
1595 } | 1594 } |
1596 return; | 1595 return; |
1597 } | 1596 } |
1598 } | 1597 } |
1599 if (FT_UseTTCharmap(m_Font.m_Face, 1, 0)) { | 1598 if (FT_UseTTCharmap(m_Font.GetFace(), 1, 0)) { |
1600 FX_BOOL bGotOne = FALSE; | 1599 FX_BOOL bGotOne = FALSE; |
1601 for (int charcode = 0; charcode < 256; charcode++) { | 1600 for (int charcode = 0; charcode < 256; charcode++) { |
1602 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face, charcode); | 1601 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.GetFace(), charcode); |
1603 m_Encoding.m_Unicodes[charcode] = | 1602 m_Encoding.m_Unicodes[charcode] = |
1604 FT_UnicodeFromCharCode(FXFT_ENCODING_APPLE_ROMAN, charcode); | 1603 FT_UnicodeFromCharCode(FXFT_ENCODING_APPLE_ROMAN, charcode); |
1605 if (m_GlyphIndex[charcode]) { | 1604 if (m_GlyphIndex[charcode]) { |
1606 bGotOne = TRUE; | 1605 bGotOne = TRUE; |
1607 } | 1606 } |
1608 } | 1607 } |
1609 if (m_pFontFile || bGotOne) { | 1608 if (m_pFontFile || bGotOne) { |
1610 return; | 1609 return; |
1611 } | 1610 } |
1612 } | 1611 } |
1613 if (FXFT_Select_Charmap(m_Font.m_Face, FXFT_ENCODING_UNICODE) == 0) { | 1612 if (FXFT_Select_Charmap(m_Font.GetFace(), FXFT_ENCODING_UNICODE) == 0) { |
1614 FX_BOOL bGotOne = FALSE; | 1613 FX_BOOL bGotOne = FALSE; |
1615 const FX_WORD* pUnicodes = PDF_UnicodesForPredefinedCharSet(baseEncoding); | 1614 const FX_WORD* pUnicodes = PDF_UnicodesForPredefinedCharSet(baseEncoding); |
1616 for (int charcode = 0; charcode < 256; charcode++) { | 1615 for (int charcode = 0; charcode < 256; charcode++) { |
1617 if (m_pFontFile == NULL) { | 1616 if (m_pFontFile) { |
| 1617 m_Encoding.m_Unicodes[charcode] = charcode; |
| 1618 } else { |
1618 const FX_CHAR* name = GetAdobeCharName(0, m_pCharNames, charcode); | 1619 const FX_CHAR* name = GetAdobeCharName(0, m_pCharNames, charcode); |
1619 if (name != NULL) { | 1620 if (name) { |
1620 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); | 1621 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); |
1621 } else if (pUnicodes) { | 1622 } else if (pUnicodes) { |
1622 m_Encoding.m_Unicodes[charcode] = pUnicodes[charcode]; | 1623 m_Encoding.m_Unicodes[charcode] = pUnicodes[charcode]; |
1623 } | 1624 } |
1624 } else { | |
1625 m_Encoding.m_Unicodes[charcode] = charcode; | |
1626 } | 1625 } |
1627 m_GlyphIndex[charcode] = | 1626 m_GlyphIndex[charcode] = FXFT_Get_Char_Index( |
1628 FXFT_Get_Char_Index(m_Font.m_Face, m_Encoding.m_Unicodes[charcode]); | 1627 m_Font.GetFace(), m_Encoding.m_Unicodes[charcode]); |
1629 if (m_GlyphIndex[charcode]) { | 1628 if (m_GlyphIndex[charcode]) { |
1630 bGotOne = TRUE; | 1629 bGotOne = TRUE; |
1631 } | 1630 } |
1632 } | 1631 } |
1633 if (bGotOne) { | 1632 if (bGotOne) { |
1634 return; | 1633 return; |
1635 } | 1634 } |
1636 } | 1635 } |
1637 for (int charcode = 0; charcode < 256; charcode++) { | 1636 for (int charcode = 0; charcode < 256; charcode++) { |
1638 m_GlyphIndex[charcode] = charcode; | 1637 m_GlyphIndex[charcode] = charcode; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1782 CPDF_Type3Char::CPDF_Type3Char() { | 1781 CPDF_Type3Char::CPDF_Type3Char() { |
1783 m_pForm = NULL; | 1782 m_pForm = NULL; |
1784 m_pBitmap = NULL; | 1783 m_pBitmap = NULL; |
1785 m_bPageRequired = FALSE; | 1784 m_bPageRequired = FALSE; |
1786 m_bColored = FALSE; | 1785 m_bColored = FALSE; |
1787 } | 1786 } |
1788 CPDF_Type3Char::~CPDF_Type3Char() { | 1787 CPDF_Type3Char::~CPDF_Type3Char() { |
1789 delete m_pForm; | 1788 delete m_pForm; |
1790 delete m_pBitmap; | 1789 delete m_pBitmap; |
1791 } | 1790 } |
OLD | NEW |