Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: core/src/fpdfapi/fpdf_font/fpdf_font.cpp

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

Powered by Google App Engine
This is Rietveld 408576698