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" |
11 #include "../../../include/fxge/fx_freetype.h" | 11 #include "../../../include/fxge/fx_freetype.h" |
12 #include "../fpdf_page/pageint.h" | 12 #include "../fpdf_page/pageint.h" |
13 #include "font_int.h" | 13 #include "font_int.h" |
14 | 14 |
15 FX_BOOL FT_UseTTCharmap(FXFT_Face face, int platform_id, int encoding_id) | 15 bool FT_UseTTCharmap(FXFT_Face face, int platform_id, int encoding_id) |
16 { | 16 { |
17 for (int i = 0; i < FXFT_Get_Face_CharmapCount(face); i ++) { | 17 for (int i = 0; i < FXFT_Get_Face_CharmapCount(face); i ++) { |
18 if (FXFT_Get_Charmap_PlatformID(FXFT_Get_Face_Charmaps(face)[i]) == plat
form_id && | 18 if (FXFT_Get_Charmap_PlatformID(FXFT_Get_Face_Charmaps(face)[i]) == plat
form_id && |
19 FXFT_Get_Charmap_EncodingID(FXFT_Get_Face_Charmaps(face)[i]) ==
encoding_id) { | 19 FXFT_Get_Charmap_EncodingID(FXFT_Get_Face_Charmaps(face)[i]) ==
encoding_id) { |
20 FXFT_Set_Charmap(face, FXFT_Get_Face_Charmaps(face)[i]); | 20 FXFT_Set_Charmap(face, FXFT_Get_Face_Charmaps(face)[i]); |
21 return TRUE; | 21 return true; |
22 } | 22 } |
23 } | 23 } |
24 return FALSE; | 24 return false; |
25 } | 25 } |
26 CPDF_FontGlobals::CPDF_FontGlobals() | 26 CPDF_FontGlobals::CPDF_FontGlobals() |
27 : m_pContrastRamps(NULL) | 27 : m_pContrastRamps(NULL) |
28 { | 28 { |
29 FXSYS_memset(m_EmbeddedCharsets, 0, sizeof(m_EmbeddedCharsets)); | 29 FXSYS_memset(m_EmbeddedCharsets, 0, sizeof(m_EmbeddedCharsets)); |
30 FXSYS_memset(m_EmbeddedToUnicodes, 0, sizeof(m_EmbeddedToUnicodes)); | 30 FXSYS_memset(m_EmbeddedToUnicodes, 0, sizeof(m_EmbeddedToUnicodes)); |
31 } | 31 } |
32 CPDF_FontGlobals::~CPDF_FontGlobals() | 32 CPDF_FontGlobals::~CPDF_FontGlobals() |
33 { | 33 { |
34 ClearAll(); | 34 ClearAll(); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 m_pStockMap.RemoveKey(key); | 113 m_pStockMap.RemoveKey(key); |
114 } | 114 } |
115 } | 115 } |
116 CPDF_Font::CPDF_Font(int fonttype) : m_FontType(fonttype) | 116 CPDF_Font::CPDF_Font(int fonttype) : m_FontType(fonttype) |
117 { | 117 { |
118 m_FontBBox.left = m_FontBBox.right = m_FontBBox.top = m_FontBBox.bottom = 0; | 118 m_FontBBox.left = m_FontBBox.right = m_FontBBox.top = m_FontBBox.bottom = 0; |
119 m_StemV = m_Ascent = m_Descent = m_ItalicAngle = 0; | 119 m_StemV = m_Ascent = m_Descent = m_ItalicAngle = 0; |
120 m_pFontFile = NULL; | 120 m_pFontFile = NULL; |
121 m_Flags = 0; | 121 m_Flags = 0; |
122 m_pToUnicodeMap = NULL; | 122 m_pToUnicodeMap = NULL; |
123 m_bToUnicodeLoaded = FALSE; | 123 m_bToUnicodeLoaded = false; |
124 m_pCharMap = new CPDF_FontCharMap(this); | 124 m_pCharMap = new CPDF_FontCharMap(this); |
125 } | 125 } |
126 CPDF_Font::~CPDF_Font() | 126 CPDF_Font::~CPDF_Font() |
127 { | 127 { |
128 delete m_pCharMap; | 128 delete m_pCharMap; |
129 m_pCharMap = NULL; | 129 m_pCharMap = NULL; |
130 | 130 |
131 delete m_pToUnicodeMap; | 131 delete m_pToUnicodeMap; |
132 m_pToUnicodeMap = NULL; | 132 m_pToUnicodeMap = NULL; |
133 | 133 |
134 if (m_pFontFile) { | 134 if (m_pFontFile) { |
135 m_pDocument->GetPageData()->ReleaseFontFileStreamAcc((CPDF_Stream*)m_pFo
ntFile->GetStream()); | 135 m_pDocument->GetPageData()->ReleaseFontFileStreamAcc((CPDF_Stream*)m_pFo
ntFile->GetStream()); |
136 } | 136 } |
137 } | 137 } |
138 FX_BOOL CPDF_Font::IsVertWriting() const | 138 bool CPDF_Font::IsVertWriting() const |
139 { | 139 { |
140 FX_BOOL bVertWriting = FALSE; | 140 bool bVertWriting = false; |
141 CPDF_CIDFont* pCIDFont = GetCIDFont(); | 141 CPDF_CIDFont* pCIDFont = GetCIDFont(); |
142 if (pCIDFont) { | 142 if (pCIDFont) { |
143 bVertWriting = pCIDFont->IsVertWriting(); | 143 bVertWriting = pCIDFont->IsVertWriting(); |
144 } else { | 144 } else { |
145 bVertWriting = m_Font.IsVertical(); | 145 bVertWriting = m_Font.IsVertical(); |
146 } | 146 } |
147 return bVertWriting; | 147 return bVertWriting; |
148 } | 148 } |
149 CFX_ByteString CPDF_Font::GetFontTypeName() const | 149 CFX_ByteString CPDF_Font::GetFontTypeName() const |
150 { | 150 { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 FX_DWORD charcode = CharCodeFromUnicode(src_buf[src_pos]); | 229 FX_DWORD charcode = CharCodeFromUnicode(src_buf[src_pos]); |
230 dest_pos += AppendChar(dest_buf + dest_pos, charcode); | 230 dest_pos += AppendChar(dest_buf + dest_pos, charcode); |
231 } | 231 } |
232 result.ReleaseBuffer(dest_pos); | 232 result.ReleaseBuffer(dest_pos); |
233 return result; | 233 return result; |
234 } | 234 } |
235 void CPDF_Font::LoadFontDescriptor(CPDF_Dictionary* pFontDesc) | 235 void CPDF_Font::LoadFontDescriptor(CPDF_Dictionary* pFontDesc) |
236 { | 236 { |
237 m_Flags = pFontDesc->GetInteger(FX_BSTRC("Flags"), PDFFONT_NONSYMBOLIC); | 237 m_Flags = pFontDesc->GetInteger(FX_BSTRC("Flags"), PDFFONT_NONSYMBOLIC); |
238 int ItalicAngle = 0; | 238 int ItalicAngle = 0; |
239 FX_BOOL bExistItalicAngle = FALSE; | 239 bool bExistItalicAngle = false; |
240 if (pFontDesc->KeyExist(FX_BSTRC("ItalicAngle"))) { | 240 if (pFontDesc->KeyExist(FX_BSTRC("ItalicAngle"))) { |
241 ItalicAngle = pFontDesc->GetInteger(FX_BSTRC("ItalicAngle")); | 241 ItalicAngle = pFontDesc->GetInteger(FX_BSTRC("ItalicAngle")); |
242 bExistItalicAngle = TRUE; | 242 bExistItalicAngle = true; |
243 } | 243 } |
244 if (ItalicAngle < 0) { | 244 if (ItalicAngle < 0) { |
245 m_Flags |= PDFFONT_ITALIC; | 245 m_Flags |= PDFFONT_ITALIC; |
246 m_ItalicAngle = ItalicAngle; | 246 m_ItalicAngle = ItalicAngle; |
247 } | 247 } |
248 FX_BOOL bExistStemV = FALSE; | 248 bool bExistStemV = false; |
249 if (pFontDesc->KeyExist(FX_BSTRC("StemV"))) { | 249 if (pFontDesc->KeyExist(FX_BSTRC("StemV"))) { |
250 m_StemV = pFontDesc->GetInteger(FX_BSTRC("StemV")); | 250 m_StemV = pFontDesc->GetInteger(FX_BSTRC("StemV")); |
251 bExistStemV = TRUE; | 251 bExistStemV = true; |
252 } | 252 } |
253 FX_BOOL bExistAscent = FALSE; | 253 bool bExistAscent = false; |
254 if (pFontDesc->KeyExist(FX_BSTRC("Ascent"))) { | 254 if (pFontDesc->KeyExist(FX_BSTRC("Ascent"))) { |
255 m_Ascent = pFontDesc->GetInteger(FX_BSTRC("Ascent")); | 255 m_Ascent = pFontDesc->GetInteger(FX_BSTRC("Ascent")); |
256 bExistAscent = TRUE; | 256 bExistAscent = true; |
257 } | 257 } |
258 FX_BOOL bExistDescent = FALSE; | 258 bool bExistDescent = false; |
259 if (pFontDesc->KeyExist(FX_BSTRC("Descent"))) { | 259 if (pFontDesc->KeyExist(FX_BSTRC("Descent"))) { |
260 m_Descent = pFontDesc->GetInteger(FX_BSTRC("Descent")); | 260 m_Descent = pFontDesc->GetInteger(FX_BSTRC("Descent")); |
261 bExistDescent = TRUE; | 261 bExistDescent = true; |
262 } | 262 } |
263 FX_BOOL bExistCapHeight = FALSE; | 263 bool bExistCapHeight = false; |
264 if (pFontDesc->KeyExist(FX_BSTRC("CapHeight"))) { | 264 if (pFontDesc->KeyExist(FX_BSTRC("CapHeight"))) { |
265 bExistCapHeight = TRUE; | 265 bExistCapHeight = true; |
266 } | 266 } |
267 if (bExistItalicAngle && bExistAscent && bExistCapHeight && bExistDescent &&
bExistStemV) { | 267 if (bExistItalicAngle && bExistAscent && bExistCapHeight && bExistDescent &&
bExistStemV) { |
268 m_Flags |= PDFFONT_USEEXTERNATTR; | 268 m_Flags |= PDFFONT_USEEXTERNATTR; |
269 } | 269 } |
270 if (m_Descent > 10) { | 270 if (m_Descent > 10) { |
271 m_Descent = -m_Descent; | 271 m_Descent = -m_Descent; |
272 } | 272 } |
273 CPDF_Array* pBBox = pFontDesc->GetArray(FX_BSTRC("FontBBox")); | 273 CPDF_Array* pBBox = pFontDesc->GetArray(FX_BSTRC("FontBBox")); |
274 if (pBBox) { | 274 if (pBBox) { |
275 m_FontBBox.left = pBBox->GetInteger(0); | 275 m_FontBBox.left = pBBox->GetInteger(0); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 { | 309 { |
310 if (m_FontBBox.top == 0 && m_FontBBox.bottom == 0 && m_FontBBox.left == 0 &&
m_FontBBox.right == 0) { | 310 if (m_FontBBox.top == 0 && m_FontBBox.bottom == 0 && m_FontBBox.left == 0 &&
m_FontBBox.right == 0) { |
311 if (m_Font.m_Face) { | 311 if (m_Font.m_Face) { |
312 m_FontBBox.left = TT2PDF(FXFT_Get_Face_xMin(m_Font.m_Face), m_Font.m
_Face); | 312 m_FontBBox.left = TT2PDF(FXFT_Get_Face_xMin(m_Font.m_Face), m_Font.m
_Face); |
313 m_FontBBox.bottom = TT2PDF(FXFT_Get_Face_yMin(m_Font.m_Face), m_Font
.m_Face); | 313 m_FontBBox.bottom = TT2PDF(FXFT_Get_Face_yMin(m_Font.m_Face), m_Font
.m_Face); |
314 m_FontBBox.right = TT2PDF(FXFT_Get_Face_xMax(m_Font.m_Face), m_Font.
m_Face); | 314 m_FontBBox.right = TT2PDF(FXFT_Get_Face_xMax(m_Font.m_Face), m_Font.
m_Face); |
315 m_FontBBox.top = TT2PDF(FXFT_Get_Face_yMax(m_Font.m_Face), m_Font.m_
Face); | 315 m_FontBBox.top = TT2PDF(FXFT_Get_Face_yMax(m_Font.m_Face), m_Font.m_
Face); |
316 m_Ascent = TT2PDF(FXFT_Get_Face_Ascender(m_Font.m_Face), m_Font.m_Fa
ce); | 316 m_Ascent = TT2PDF(FXFT_Get_Face_Ascender(m_Font.m_Face), m_Font.m_Fa
ce); |
317 m_Descent = TT2PDF(FXFT_Get_Face_Descender(m_Font.m_Face), m_Font.m_
Face); | 317 m_Descent = TT2PDF(FXFT_Get_Face_Descender(m_Font.m_Face), m_Font.m_
Face); |
318 } else { | 318 } else { |
319 FX_BOOL bFirst = TRUE; | 319 bool bFirst = true; |
320 for (int i = 0; i < 256; i ++) { | 320 for (int i = 0; i < 256; i ++) { |
321 FX_RECT rect; | 321 FX_RECT rect; |
322 GetCharBBox(i, rect); | 322 GetCharBBox(i, rect); |
323 if (rect.left == rect.right) { | 323 if (rect.left == rect.right) { |
324 continue; | 324 continue; |
325 } | 325 } |
326 if (bFirst) { | 326 if (bFirst) { |
327 m_FontBBox = rect; | 327 m_FontBBox = rect; |
328 bFirst = FALSE; | 328 bFirst = false; |
329 } else { | 329 } else { |
330 if (m_FontBBox.top < rect.top) { | 330 if (m_FontBBox.top < rect.top) { |
331 m_FontBBox.top = rect.top; | 331 m_FontBBox.top = rect.top; |
332 } | 332 } |
333 if (m_FontBBox.right < rect.right) { | 333 if (m_FontBBox.right < rect.right) { |
334 m_FontBBox.right = rect.right; | 334 m_FontBBox.right = rect.right; |
335 } | 335 } |
336 if (m_FontBBox.left > rect.left) { | 336 if (m_FontBBox.left > rect.left) { |
337 m_FontBBox.left = rect.left; | 337 m_FontBBox.left = rect.left; |
338 } | 338 } |
(...skipping 15 matching lines...) Expand all Loading... |
354 GetCharBBox('g', rect); | 354 GetCharBBox('g', rect); |
355 if (rect.bottom == rect.top) { | 355 if (rect.bottom == rect.top) { |
356 m_Descent = m_FontBBox.bottom; | 356 m_Descent = m_FontBBox.bottom; |
357 } else { | 357 } else { |
358 m_Descent = rect.bottom; | 358 m_Descent = rect.bottom; |
359 } | 359 } |
360 } | 360 } |
361 } | 361 } |
362 void CPDF_Font::LoadUnicodeMap() | 362 void CPDF_Font::LoadUnicodeMap() |
363 { | 363 { |
364 m_bToUnicodeLoaded = TRUE; | 364 m_bToUnicodeLoaded = true; |
365 CPDF_Stream* pStream = m_pFontDict->GetStream(FX_BSTRC("ToUnicode")); | 365 CPDF_Stream* pStream = m_pFontDict->GetStream(FX_BSTRC("ToUnicode")); |
366 if (pStream == NULL) { | 366 if (pStream == NULL) { |
367 return; | 367 return; |
368 } | 368 } |
369 m_pToUnicodeMap = new CPDF_ToUnicodeMap; | 369 m_pToUnicodeMap = new CPDF_ToUnicodeMap; |
370 m_pToUnicodeMap->Load(pStream); | 370 m_pToUnicodeMap->Load(pStream); |
371 } | 371 } |
372 int CPDF_Font::GetStringWidth(const FX_CHAR* pString, int size) | 372 int CPDF_Font::GetStringWidth(const FX_CHAR* pString, int size) |
373 { | 373 { |
374 int offset = 0; | 374 int offset = 0; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 pFont = new CPDF_Type1Font; | 459 pFont = new CPDF_Type1Font; |
460 } | 460 } |
461 pFont->m_pFontDict = pFontDict; | 461 pFont->m_pFontDict = pFontDict; |
462 pFont->m_pDocument = pDoc; | 462 pFont->m_pDocument = pDoc; |
463 if (!pFont->Load()) { | 463 if (!pFont->Load()) { |
464 delete pFont; | 464 delete pFont; |
465 return NULL; | 465 return NULL; |
466 } | 466 } |
467 return pFont; | 467 return pFont; |
468 } | 468 } |
469 FX_BOOL CPDF_Font::Load() | 469 bool CPDF_Font::Load() |
470 { | 470 { |
471 if (m_pFontDict == NULL) { | 471 if (m_pFontDict == NULL) { |
472 return FALSE; | 472 return false; |
473 } | 473 } |
474 CFX_ByteString type = m_pFontDict->GetString(FX_BSTRC("Subtype")); | 474 CFX_ByteString type = m_pFontDict->GetString(FX_BSTRC("Subtype")); |
475 m_BaseFont = m_pFontDict->GetString(FX_BSTRC("BaseFont")); | 475 m_BaseFont = m_pFontDict->GetString(FX_BSTRC("BaseFont")); |
476 if (type == FX_BSTRC("MMType1")) { | 476 if (type == FX_BSTRC("MMType1")) { |
477 type = FX_BSTRC("Type1"); | 477 type = FX_BSTRC("Type1"); |
478 } | 478 } |
479 return _Load(); | 479 return _Load(); |
480 } | 480 } |
481 static CFX_WideString _FontMap_GetWideString(CFX_CharMap* pMap, const CFX_ByteSt
ring& bytestr) | 481 static CFX_WideString _FontMap_GetWideString(CFX_CharMap* pMap, const CFX_ByteSt
ring& bytestr) |
482 { | 482 { |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 return result; | 617 return result; |
618 } | 618 } |
619 if (buf[0] == '(') { | 619 if (buf[0] == '(') { |
620 } | 620 } |
621 return result; | 621 return result; |
622 } | 622 } |
623 void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) | 623 void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) |
624 { | 624 { |
625 int CIDSet = 0; | 625 int CIDSet = 0; |
626 CPDF_StreamAcc stream; | 626 CPDF_StreamAcc stream; |
627 stream.LoadAllData(pStream, FALSE); | 627 stream.LoadAllData(pStream, false); |
628 CPDF_SimpleParser parser(stream.GetData(), stream.GetSize()); | 628 CPDF_SimpleParser parser(stream.GetData(), stream.GetSize()); |
629 m_Map.EstimateSize(stream.GetSize() / 8, 1024); | 629 m_Map.EstimateSize(stream.GetSize() / 8, 1024); |
630 while (1) { | 630 while (1) { |
631 CFX_ByteStringC word = parser.GetWord(); | 631 CFX_ByteStringC word = parser.GetWord(); |
632 if (word.IsEmpty()) { | 632 if (word.IsEmpty()) { |
633 break; | 633 break; |
634 } | 634 } |
635 if (word == FX_BSTRC("beginbfchar")) { | 635 if (word == FX_BSTRC("beginbfchar")) { |
636 while (1) { | 636 while (1) { |
637 word = parser.GetWord(); | 637 word = parser.GetWord(); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 CIDSet = CIDSET_KOREA1; | 713 CIDSet = CIDSET_KOREA1; |
714 } else if (word == FX_BSTRC("/Adobe-Japan1-UCS2")) { | 714 } else if (word == FX_BSTRC("/Adobe-Japan1-UCS2")) { |
715 CIDSet = CIDSET_JAPAN1; | 715 CIDSet = CIDSET_JAPAN1; |
716 } else if (word == FX_BSTRC("/Adobe-CNS1-UCS2")) { | 716 } else if (word == FX_BSTRC("/Adobe-CNS1-UCS2")) { |
717 CIDSet = CIDSET_CNS1; | 717 CIDSet = CIDSET_CNS1; |
718 } else if (word == FX_BSTRC("/Adobe-GB1-UCS2")) { | 718 } else if (word == FX_BSTRC("/Adobe-GB1-UCS2")) { |
719 CIDSet = CIDSET_GB1; | 719 CIDSet = CIDSET_GB1; |
720 } | 720 } |
721 } | 721 } |
722 if (CIDSet) { | 722 if (CIDSet) { |
723 m_pBaseMap = CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals()->m
_CMapManager.GetCID2UnicodeMap(CIDSet, FALSE); | 723 m_pBaseMap = CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals()->m
_CMapManager.GetCID2UnicodeMap(CIDSet, false); |
724 } else { | 724 } else { |
725 m_pBaseMap = NULL; | 725 m_pBaseMap = NULL; |
726 } | 726 } |
727 } | 727 } |
728 static FX_BOOL GetPredefinedEncoding(int& basemap, const CFX_ByteString& value) | 728 static bool GetPredefinedEncoding(int& basemap, const CFX_ByteString& value) |
729 { | 729 { |
730 if (value == FX_BSTRC("WinAnsiEncoding")) { | 730 if (value == FX_BSTRC("WinAnsiEncoding")) { |
731 basemap = PDFFONT_ENCODING_WINANSI; | 731 basemap = PDFFONT_ENCODING_WINANSI; |
732 } else if (value == FX_BSTRC("MacRomanEncoding")) { | 732 } else if (value == FX_BSTRC("MacRomanEncoding")) { |
733 basemap = PDFFONT_ENCODING_MACROMAN; | 733 basemap = PDFFONT_ENCODING_MACROMAN; |
734 } else if (value == FX_BSTRC("MacExpertEncoding")) { | 734 } else if (value == FX_BSTRC("MacExpertEncoding")) { |
735 basemap = PDFFONT_ENCODING_MACEXPERT; | 735 basemap = PDFFONT_ENCODING_MACEXPERT; |
736 } else if (value == FX_BSTRC("PDFDocEncoding")) { | 736 } else if (value == FX_BSTRC("PDFDocEncoding")) { |
737 basemap = PDFFONT_ENCODING_PDFDOC; | 737 basemap = PDFFONT_ENCODING_PDFDOC; |
738 } else { | 738 } else { |
739 return FALSE; | 739 return false; |
740 } | 740 } |
741 return TRUE; | 741 return true; |
742 } | 742 } |
743 void CPDF_Font::LoadPDFEncoding(CPDF_Object* pEncoding, int& iBaseEncoding, CFX_
ByteString*& pCharNames, | 743 void CPDF_Font::LoadPDFEncoding(CPDF_Object* pEncoding, int& iBaseEncoding, CFX_
ByteString*& pCharNames, |
744 FX_BOOL bEmbedded, FX_BOOL bTrueType) | 744 bool bEmbedded, bool bTrueType) |
745 { | 745 { |
746 if (pEncoding == NULL) { | 746 if (pEncoding == NULL) { |
747 if (m_BaseFont == FX_BSTRC("Symbol")) { | 747 if (m_BaseFont == FX_BSTRC("Symbol")) { |
748 iBaseEncoding = bTrueType ? PDFFONT_ENCODING_MS_SYMBOL : PDFFONT_ENC
ODING_ADOBE_SYMBOL; | 748 iBaseEncoding = bTrueType ? PDFFONT_ENCODING_MS_SYMBOL : PDFFONT_ENC
ODING_ADOBE_SYMBOL; |
749 } else if (!bEmbedded && iBaseEncoding == PDFFONT_ENCODING_BUILTIN) { | 749 } else if (!bEmbedded && iBaseEncoding == PDFFONT_ENCODING_BUILTIN) { |
750 iBaseEncoding = PDFFONT_ENCODING_WINANSI; | 750 iBaseEncoding = PDFFONT_ENCODING_WINANSI; |
751 } | 751 } |
752 return; | 752 return; |
753 } | 753 } |
754 if (pEncoding->GetType() == PDFOBJ_NAME) { | 754 if (pEncoding->GetType() == PDFOBJ_NAME) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 if (pElement->GetType() == PDFOBJ_NAME) { | 796 if (pElement->GetType() == PDFOBJ_NAME) { |
797 if (cur_code < 256) { | 797 if (cur_code < 256) { |
798 pCharNames[cur_code] = ((CPDF_Name*)pElement)->GetString(); | 798 pCharNames[cur_code] = ((CPDF_Name*)pElement)->GetString(); |
799 } | 799 } |
800 cur_code ++; | 800 cur_code ++; |
801 } else { | 801 } else { |
802 cur_code = pElement->GetInteger(); | 802 cur_code = pElement->GetInteger(); |
803 } | 803 } |
804 } | 804 } |
805 } | 805 } |
806 FX_BOOL CPDF_Font::IsStandardFont() const | 806 bool CPDF_Font::IsStandardFont() const |
807 { | 807 { |
808 if (m_FontType != PDFFONT_TYPE1) { | 808 if (m_FontType != PDFFONT_TYPE1) { |
809 return FALSE; | 809 return false; |
810 } | 810 } |
811 if (m_pFontFile != NULL) { | 811 if (m_pFontFile != NULL) { |
812 return FALSE; | 812 return false; |
813 } | 813 } |
814 if (((CPDF_Type1Font*)this)->GetBase14Font() < 0) { | 814 if (((CPDF_Type1Font*)this)->GetBase14Font() < 0) { |
815 return FALSE; | 815 return false; |
816 } | 816 } |
817 return TRUE; | 817 return true; |
818 } | 818 } |
819 CPDF_SimpleFont::CPDF_SimpleFont(int fonttype) : CPDF_Font(fonttype) | 819 CPDF_SimpleFont::CPDF_SimpleFont(int fonttype) : CPDF_Font(fonttype) |
820 { | 820 { |
821 FXSYS_memset(m_CharBBox, 0xff, sizeof m_CharBBox); | 821 FXSYS_memset(m_CharBBox, 0xff, sizeof m_CharBBox); |
822 FXSYS_memset(m_CharWidth, 0xff, sizeof m_CharWidth); | 822 FXSYS_memset(m_CharWidth, 0xff, sizeof m_CharWidth); |
823 FXSYS_memset(m_GlyphIndex, 0xff, sizeof m_GlyphIndex); | 823 FXSYS_memset(m_GlyphIndex, 0xff, sizeof m_GlyphIndex); |
824 FXSYS_memset(m_ExtGID, 0xff, sizeof m_ExtGID); | 824 FXSYS_memset(m_ExtGID, 0xff, sizeof m_ExtGID); |
825 m_pCharNames = NULL; | 825 m_pCharNames = NULL; |
826 m_BaseEncoding = PDFFONT_ENCODING_BUILTIN; | 826 m_BaseEncoding = PDFFONT_ENCODING_BUILTIN; |
827 } | 827 } |
828 CPDF_SimpleFont::~CPDF_SimpleFont() | 828 CPDF_SimpleFont::~CPDF_SimpleFont() |
829 { | 829 { |
830 delete[] m_pCharNames; | 830 delete[] m_pCharNames; |
831 } | 831 } |
832 int CPDF_SimpleFont::GlyphFromCharCode(FX_DWORD charcode, FX_BOOL *pVertGlyph) | 832 int CPDF_SimpleFont::GlyphFromCharCode(FX_DWORD charcode, bool *pVertGlyph) |
833 { | 833 { |
834 if (pVertGlyph) { | 834 if (pVertGlyph) { |
835 *pVertGlyph = FALSE; | 835 *pVertGlyph = false; |
836 } | 836 } |
837 if (charcode > 0xff) { | 837 if (charcode > 0xff) { |
838 return -1; | 838 return -1; |
839 } | 839 } |
840 int index = m_GlyphIndex[(uint8_t)charcode]; | 840 int index = m_GlyphIndex[(uint8_t)charcode]; |
841 if (index == 0xffff) { | 841 if (index == 0xffff) { |
842 return -1; | 842 return -1; |
843 } | 843 } |
844 return index; | 844 return index; |
845 } | 845 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
917 name = pCharNames[charcode]; | 917 name = pCharNames[charcode]; |
918 } | 918 } |
919 if ((name == NULL || name[0] == 0) && iBaseEncoding) { | 919 if ((name == NULL || name[0] == 0) && iBaseEncoding) { |
920 name = PDF_CharNameFromPredefinedCharSet(iBaseEncoding, charcode); | 920 name = PDF_CharNameFromPredefinedCharSet(iBaseEncoding, charcode); |
921 } | 921 } |
922 if (name == NULL || name[0] == 0) { | 922 if (name == NULL || name[0] == 0) { |
923 return NULL; | 923 return NULL; |
924 } | 924 } |
925 return name; | 925 return name; |
926 } | 926 } |
927 FX_BOOL CPDF_SimpleFont::LoadCommon() | 927 bool CPDF_SimpleFont::LoadCommon() |
928 { | 928 { |
929 CPDF_Dictionary* pFontDesc = m_pFontDict->GetDict(FX_BSTRC("FontDescriptor")
); | 929 CPDF_Dictionary* pFontDesc = m_pFontDict->GetDict(FX_BSTRC("FontDescriptor")
); |
930 if (pFontDesc) { | 930 if (pFontDesc) { |
931 LoadFontDescriptor(pFontDesc); | 931 LoadFontDescriptor(pFontDesc); |
932 } | 932 } |
933 CPDF_Array* pWidthArray = m_pFontDict->GetArray(FX_BSTRC("Widths")); | 933 CPDF_Array* pWidthArray = m_pFontDict->GetArray(FX_BSTRC("Widths")); |
934 int width_start = 0, width_end = -1; | 934 int width_start = 0, width_end = -1; |
935 m_bUseFontWidth = TRUE; | 935 m_bUseFontWidth = true; |
936 if (pWidthArray) { | 936 if (pWidthArray) { |
937 m_bUseFontWidth = FALSE; | 937 m_bUseFontWidth = false; |
938 if (pFontDesc && pFontDesc->KeyExist(FX_BSTRC("MissingWidth"))) { | 938 if (pFontDesc && pFontDesc->KeyExist(FX_BSTRC("MissingWidth"))) { |
939 int MissingWidth = pFontDesc->GetInteger(FX_BSTRC("MissingWidth")); | 939 int MissingWidth = pFontDesc->GetInteger(FX_BSTRC("MissingWidth")); |
940 for (int i = 0; i < 256; i ++) { | 940 for (int i = 0; i < 256; i ++) { |
941 m_CharWidth[i] = MissingWidth; | 941 m_CharWidth[i] = MissingWidth; |
942 } | 942 } |
943 } | 943 } |
944 width_start = m_pFontDict->GetInteger(FX_BSTRC("FirstChar"), 0); | 944 width_start = m_pFontDict->GetInteger(FX_BSTRC("FirstChar"), 0); |
945 width_end = m_pFontDict->GetInteger(FX_BSTRC("LastChar"), 0); | 945 width_end = m_pFontDict->GetInteger(FX_BSTRC("LastChar"), 0); |
946 if (width_start >= 0 && width_start <= 255) { | 946 if (width_start >= 0 && width_start <= 255) { |
947 if (width_end <= 0 || width_end >= width_start + (int)pWidthArray->G
etCount()) { | 947 if (width_end <= 0 || width_end >= width_start + (int)pWidthArray->G
etCount()) { |
(...skipping 16 matching lines...) Expand all Loading... |
964 } | 964 } |
965 if (!(m_Flags & PDFFONT_SYMBOLIC)) { | 965 if (!(m_Flags & PDFFONT_SYMBOLIC)) { |
966 m_BaseEncoding = PDFFONT_ENCODING_STANDARD; | 966 m_BaseEncoding = PDFFONT_ENCODING_STANDARD; |
967 } | 967 } |
968 CPDF_Object* pEncoding = m_pFontDict->GetElementValue(FX_BSTRC("Encoding")); | 968 CPDF_Object* pEncoding = m_pFontDict->GetElementValue(FX_BSTRC("Encoding")); |
969 LoadPDFEncoding(pEncoding, m_BaseEncoding, m_pCharNames, m_pFontFile != NULL
, m_Font.IsTTFont()); | 969 LoadPDFEncoding(pEncoding, m_BaseEncoding, m_pCharNames, m_pFontFile != NULL
, m_Font.IsTTFont()); |
970 LoadGlyphMap(); | 970 LoadGlyphMap(); |
971 delete[] m_pCharNames; | 971 delete[] m_pCharNames; |
972 m_pCharNames = NULL; | 972 m_pCharNames = NULL; |
973 if (m_Font.m_Face == NULL) { | 973 if (m_Font.m_Face == NULL) { |
974 return TRUE; | 974 return true; |
975 } | 975 } |
976 if (m_Flags & PDFFONT_ALLCAP) { | 976 if (m_Flags & PDFFONT_ALLCAP) { |
977 unsigned char lowercases[] = {'a', 'z', 0xe0, 0xf6, 0xf8, 0xfd}; | 977 unsigned char lowercases[] = {'a', 'z', 0xe0, 0xf6, 0xf8, 0xfd}; |
978 for (size_t range = 0; range < sizeof lowercases / 2; range ++) { | 978 for (size_t range = 0; range < sizeof lowercases / 2; range ++) { |
979 for (int i = lowercases[range * 2]; i <= lowercases[range * 2 + 1];
i ++) { | 979 for (int i = lowercases[range * 2]; i <= lowercases[range * 2 + 1];
i ++) { |
980 if (m_GlyphIndex[i] != 0xffff && m_pFontFile != NULL) { | 980 if (m_GlyphIndex[i] != 0xffff && m_pFontFile != NULL) { |
981 continue; | 981 continue; |
982 } | 982 } |
983 m_GlyphIndex[i] = m_GlyphIndex[i - 32]; | 983 m_GlyphIndex[i] = m_GlyphIndex[i - 32]; |
984 if (m_CharWidth[i - 32]) { | 984 if (m_CharWidth[i - 32]) { |
985 m_CharWidth[i] = m_CharWidth[i - 32]; | 985 m_CharWidth[i] = m_CharWidth[i - 32]; |
986 m_CharBBox[i] = m_CharBBox[i - 32]; | 986 m_CharBBox[i] = m_CharBBox[i - 32]; |
987 } | 987 } |
988 } | 988 } |
989 } | 989 } |
990 } | 990 } |
991 CheckFontMetrics(); | 991 CheckFontMetrics(); |
992 return TRUE; | 992 return true; |
993 } | 993 } |
994 void CPDF_SimpleFont::LoadSubstFont() | 994 void CPDF_SimpleFont::LoadSubstFont() |
995 { | 995 { |
996 if (!m_bUseFontWidth && !(m_Flags & PDFFONT_FIXEDPITCH)) { | 996 if (!m_bUseFontWidth && !(m_Flags & PDFFONT_FIXEDPITCH)) { |
997 int width = 0, i; | 997 int width = 0, i; |
998 for (i = 0; i < 256; i ++) { | 998 for (i = 0; i < 256; i ++) { |
999 if (m_CharWidth[i] == 0 || m_CharWidth[i] == 0xffff) { | 999 if (m_CharWidth[i] == 0 || m_CharWidth[i] == 0xffff) { |
1000 continue; | 1000 continue; |
1001 } | 1001 } |
1002 if (width == 0) { | 1002 if (width == 0) { |
1003 width = m_CharWidth[i]; | 1003 width = m_CharWidth[i]; |
1004 } else if (width != m_CharWidth[i]) { | 1004 } else if (width != m_CharWidth[i]) { |
1005 break; | 1005 break; |
1006 } | 1006 } |
1007 } | 1007 } |
1008 if (i == 256 && width) { | 1008 if (i == 256 && width) { |
1009 m_Flags |= PDFFONT_FIXEDPITCH; | 1009 m_Flags |= PDFFONT_FIXEDPITCH; |
1010 } | 1010 } |
1011 } | 1011 } |
1012 int weight = m_StemV < 140 ? m_StemV * 5 : (m_StemV * 4 + 140); | 1012 int weight = m_StemV < 140 ? m_StemV * 5 : (m_StemV * 4 + 140); |
1013 m_Font.LoadSubst(m_BaseFont, IsFontType(PDFFONT_TRUETYPE), m_Flags, weight,
m_ItalicAngle, 0); | 1013 m_Font.LoadSubst(m_BaseFont, IsFontType(PDFFONT_TRUETYPE), m_Flags, weight,
m_ItalicAngle, 0); |
1014 if (m_Font.m_pSubstFont->m_SubstFlags & FXFONT_SUBST_NONSYMBOL) { | 1014 if (m_Font.m_pSubstFont->m_SubstFlags & FXFONT_SUBST_NONSYMBOL) { |
1015 } | 1015 } |
1016 } | 1016 } |
1017 FX_BOOL CPDF_SimpleFont::IsUnicodeCompatible() const | 1017 bool CPDF_SimpleFont::IsUnicodeCompatible() const |
1018 { | 1018 { |
1019 return m_BaseEncoding != PDFFONT_ENCODING_BUILTIN && m_BaseEncoding != PDFFO
NT_ENCODING_ADOBE_SYMBOL && | 1019 return m_BaseEncoding != PDFFONT_ENCODING_BUILTIN && m_BaseEncoding != PDFFO
NT_ENCODING_ADOBE_SYMBOL && |
1020 m_BaseEncoding != PDFFONT_ENCODING_ZAPFDINGBATS; | 1020 m_BaseEncoding != PDFFONT_ENCODING_ZAPFDINGBATS; |
1021 } | 1021 } |
1022 CPDF_Type1Font::CPDF_Type1Font() : CPDF_SimpleFont(PDFFONT_TYPE1) | 1022 CPDF_Type1Font::CPDF_Type1Font() : CPDF_SimpleFont(PDFFONT_TYPE1) |
1023 { | 1023 { |
1024 m_Base14Font = -1; | 1024 m_Base14Font = -1; |
1025 } | 1025 } |
1026 FX_BOOL CPDF_Type1Font::_Load() | 1026 bool CPDF_Type1Font::_Load() |
1027 { | 1027 { |
1028 m_Base14Font = _PDF_GetStandardFontName(m_BaseFont); | 1028 m_Base14Font = _PDF_GetStandardFontName(m_BaseFont); |
1029 if (m_Base14Font >= 0) { | 1029 if (m_Base14Font >= 0) { |
1030 CPDF_Dictionary* pFontDesc = m_pFontDict->GetDict(FX_BSTRC("FontDescript
or")); | 1030 CPDF_Dictionary* pFontDesc = m_pFontDict->GetDict(FX_BSTRC("FontDescript
or")); |
1031 if (pFontDesc && pFontDesc->KeyExist(FX_BSTRC("Flags"))) { | 1031 if (pFontDesc && pFontDesc->KeyExist(FX_BSTRC("Flags"))) { |
1032 m_Flags = pFontDesc->GetInteger(FX_BSTRC("Flags")); | 1032 m_Flags = pFontDesc->GetInteger(FX_BSTRC("Flags")); |
1033 } else { | 1033 } else { |
1034 m_Flags = m_Base14Font >= 12 ? PDFFONT_SYMBOLIC : PDFFONT_NONSYMBOLI
C; | 1034 m_Flags = m_Base14Font >= 12 ? PDFFONT_SYMBOLIC : PDFFONT_NONSYMBOLI
C; |
1035 } | 1035 } |
1036 if (m_Base14Font < 4) | 1036 if (m_Base14Font < 4) |
1037 for (int i = 0; i < 256; i ++) { | 1037 for (int i = 0; i < 256; i ++) { |
1038 m_CharWidth[i] = 600; | 1038 m_CharWidth[i] = 600; |
1039 } | 1039 } |
1040 if (m_Base14Font == 12) { | 1040 if (m_Base14Font == 12) { |
1041 m_BaseEncoding = PDFFONT_ENCODING_ADOBE_SYMBOL; | 1041 m_BaseEncoding = PDFFONT_ENCODING_ADOBE_SYMBOL; |
1042 } else if (m_Base14Font == 13) { | 1042 } else if (m_Base14Font == 13) { |
1043 m_BaseEncoding = PDFFONT_ENCODING_ZAPFDINGBATS; | 1043 m_BaseEncoding = PDFFONT_ENCODING_ZAPFDINGBATS; |
1044 } else if (m_Flags & PDFFONT_NONSYMBOLIC) { | 1044 } else if (m_Flags & PDFFONT_NONSYMBOLIC) { |
1045 m_BaseEncoding = PDFFONT_ENCODING_STANDARD; | 1045 m_BaseEncoding = PDFFONT_ENCODING_STANDARD; |
1046 } | 1046 } |
1047 } | 1047 } |
1048 return LoadCommon(); | 1048 return LoadCommon(); |
1049 } | 1049 } |
1050 static FX_BOOL FT_UseType1Charmap(FXFT_Face face) | 1050 static bool FT_UseType1Charmap(FXFT_Face face) |
1051 { | 1051 { |
1052 if (FXFT_Get_Face_CharmapCount(face) == 0) { | 1052 if (FXFT_Get_Face_CharmapCount(face) == 0) { |
1053 return FALSE; | 1053 return false; |
1054 } | 1054 } |
1055 if (FXFT_Get_Face_CharmapCount(face) == 1 && | 1055 if (FXFT_Get_Face_CharmapCount(face) == 1 && |
1056 FXFT_Get_Charmap_Encoding(FXFT_Get_Face_Charmaps(face)[0]) == FXFT_E
NCODING_UNICODE) { | 1056 FXFT_Get_Charmap_Encoding(FXFT_Get_Face_Charmaps(face)[0]) == FXFT_E
NCODING_UNICODE) { |
1057 return FALSE; | 1057 return false; |
1058 } | 1058 } |
1059 if (FXFT_Get_Charmap_Encoding(FXFT_Get_Face_Charmaps(face)[0]) == FXFT_ENCOD
ING_UNICODE) { | 1059 if (FXFT_Get_Charmap_Encoding(FXFT_Get_Face_Charmaps(face)[0]) == FXFT_ENCOD
ING_UNICODE) { |
1060 FXFT_Set_Charmap(face, FXFT_Get_Face_Charmaps(face)[1]); | 1060 FXFT_Set_Charmap(face, FXFT_Get_Face_Charmaps(face)[1]); |
1061 } else { | 1061 } else { |
1062 FXFT_Set_Charmap(face, FXFT_Get_Face_Charmaps(face)[0]); | 1062 FXFT_Set_Charmap(face, FXFT_Get_Face_Charmaps(face)[0]); |
1063 } | 1063 } |
1064 return TRUE; | 1064 return true; |
1065 } | 1065 } |
1066 extern FX_WCHAR FT_UnicodeFromCharCode(int encoding, FX_DWORD charcode); | 1066 extern FX_WCHAR FT_UnicodeFromCharCode(int encoding, FX_DWORD charcode); |
1067 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 1067 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
1068 #include "../../fxge/apple/apple_int.h" | 1068 #include "../../fxge/apple/apple_int.h" |
1069 #endif | 1069 #endif |
1070 int CPDF_Type1Font::GlyphFromCharCodeExt(FX_DWORD charcode) | 1070 int CPDF_Type1Font::GlyphFromCharCodeExt(FX_DWORD charcode) |
1071 { | 1071 { |
1072 if (charcode > 0xff) { | 1072 if (charcode > 0xff) { |
1073 return -1; | 1073 return -1; |
1074 } | 1074 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1106 } | 1106 } |
1107 return NULL; | 1107 return NULL; |
1108 } | 1108 } |
1109 #endif | 1109 #endif |
1110 void CPDF_Type1Font::LoadGlyphMap() | 1110 void CPDF_Type1Font::LoadGlyphMap() |
1111 { | 1111 { |
1112 if (m_Font.m_Face == NULL) { | 1112 if (m_Font.m_Face == NULL) { |
1113 return; | 1113 return; |
1114 } | 1114 } |
1115 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 1115 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
1116 FX_BOOL bCoreText = TRUE; | 1116 bool bCoreText = true; |
1117 CQuartz2D & quartz2d = ((CApplePlatform *) CFX_GEModule::Get()->GetPlatformD
ata())->_quartz2d; | 1117 CQuartz2D & quartz2d = ((CApplePlatform *) CFX_GEModule::Get()->GetPlatformD
ata())->_quartz2d; |
1118 if (!m_Font.m_pPlatformFont) { | 1118 if (!m_Font.m_pPlatformFont) { |
1119 if (m_Font.GetPsName() == CFX_WideString::FromLocal("DFHeiStd-W5")) { | 1119 if (m_Font.GetPsName() == CFX_WideString::FromLocal("DFHeiStd-W5")) { |
1120 bCoreText = FALSE; | 1120 bCoreText = false; |
1121 } | 1121 } |
1122 m_Font.m_pPlatformFont = quartz2d.CreateFont(m_Font.m_pFontData, m_Font.
m_dwSize); | 1122 m_Font.m_pPlatformFont = quartz2d.CreateFont(m_Font.m_pFontData, m_Font.
m_dwSize); |
1123 if (NULL == m_Font.m_pPlatformFont) { | 1123 if (NULL == m_Font.m_pPlatformFont) { |
1124 bCoreText = FALSE; | 1124 bCoreText = false; |
1125 } | 1125 } |
1126 } | 1126 } |
1127 #endif | 1127 #endif |
1128 if (!IsEmbedded() && (m_Base14Font < 12) && m_Font.IsTTFont()) { | 1128 if (!IsEmbedded() && (m_Base14Font < 12) && m_Font.IsTTFont()) { |
1129 if (FT_UseTTCharmap(m_Font.m_Face, 3, 0)) { | 1129 if (FT_UseTTCharmap(m_Font.m_Face, 3, 0)) { |
1130 FX_BOOL bGotOne = FALSE; | 1130 bool bGotOne = false; |
1131 for (int charcode = 0; charcode < 256; charcode ++) { | 1131 for (int charcode = 0; charcode < 256; charcode ++) { |
1132 const uint8_t prefix[4] = {0x00, 0xf0, 0xf1, 0xf2}; | 1132 const uint8_t prefix[4] = {0x00, 0xf0, 0xf1, 0xf2}; |
1133 for (int j = 0; j < 4; j ++) { | 1133 for (int j = 0; j < 4; j ++) { |
1134 FX_WORD unicode = prefix[j] * 256 + charcode; | 1134 FX_WORD unicode = prefix[j] * 256 + charcode; |
1135 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face,
unicode); | 1135 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face,
unicode); |
1136 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 1136 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
1137 FX_CHAR name_glyph[256]; | 1137 FX_CHAR name_glyph[256]; |
1138 FXFT_Get_Glyph_Name(m_Font.m_Face, m_GlyphIndex[charcode], n
ame_glyph, 256); | 1138 FXFT_Get_Glyph_Name(m_Font.m_Face, m_GlyphIndex[charcode], n
ame_glyph, 256); |
1139 name_glyph[255] = 0; | 1139 name_glyph[255] = 0; |
1140 CFStringRef name_ct = CFStringCreateWithCStringNoCopy(kCFAll
ocatorDefault, name_glyph, kCFStringEncodingASCII, kCFAllocatorNull); | 1140 CFStringRef name_ct = CFStringCreateWithCStringNoCopy(kCFAll
ocatorDefault, name_glyph, kCFStringEncodingASCII, kCFAllocatorNull); |
1141 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName((CGFontRef)
m_Font.m_pPlatformFont, name_ct); | 1141 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName((CGFontRef)
m_Font.m_pPlatformFont, name_ct); |
1142 if (name_ct) { | 1142 if (name_ct) { |
1143 CFRelease(name_ct); | 1143 CFRelease(name_ct); |
1144 } | 1144 } |
1145 #endif | 1145 #endif |
1146 if (m_GlyphIndex[charcode]) { | 1146 if (m_GlyphIndex[charcode]) { |
1147 bGotOne = TRUE; | 1147 bGotOne = true; |
1148 break; | 1148 break; |
1149 } | 1149 } |
1150 } | 1150 } |
1151 } | 1151 } |
1152 if (bGotOne) { | 1152 if (bGotOne) { |
1153 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 1153 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
1154 if (!bCoreText) { | 1154 if (!bCoreText) { |
1155 FXSYS_memcpy(m_ExtGID, m_GlyphIndex, 256); | 1155 FXSYS_memcpy(m_ExtGID, m_GlyphIndex, 256); |
1156 } | 1156 } |
1157 #endif | 1157 #endif |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1231 m_Encoding.m_Unicodes[charcode] = unicode; | 1231 m_Encoding.m_Unicodes[charcode] = unicode; |
1232 CFStringRef name_ct = CFStringCreateWithCStringNoCopy(kCFAll
ocatorDefault, name_glyph, kCFStringEncodingASCII, kCFAllocatorNull); | 1232 CFStringRef name_ct = CFStringCreateWithCStringNoCopy(kCFAll
ocatorDefault, name_glyph, kCFStringEncodingASCII, kCFAllocatorNull); |
1233 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName((CGFontRef)
m_Font.m_pPlatformFont, name_ct); | 1233 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName((CGFontRef)
m_Font.m_pPlatformFont, name_ct); |
1234 if (name_ct) { | 1234 if (name_ct) { |
1235 CFRelease(name_ct); | 1235 CFRelease(name_ct); |
1236 } | 1236 } |
1237 } | 1237 } |
1238 } | 1238 } |
1239 return; | 1239 return; |
1240 } | 1240 } |
1241 FX_BOOL bUnicode = FALSE; | 1241 bool bUnicode = false; |
1242 if (0 == FXFT_Select_Charmap(m_Font.m_Face, FXFT_ENCODING_UNICODE)) { | 1242 if (0 == FXFT_Select_Charmap(m_Font.m_Face, FXFT_ENCODING_UNICODE)) { |
1243 bUnicode = TRUE; | 1243 bUnicode = true; |
1244 } | 1244 } |
1245 for (int charcode = 0; charcode < 256; charcode ++) { | 1245 for (int charcode = 0; charcode < 256; charcode ++) { |
1246 const FX_CHAR* name = GetAdobeCharName(m_BaseEncoding, m_pCharNames,
charcode); | 1246 const FX_CHAR* name = GetAdobeCharName(m_BaseEncoding, m_pCharNames,
charcode); |
1247 if (name == NULL) { | 1247 if (name == NULL) { |
1248 continue; | 1248 continue; |
1249 } | 1249 } |
1250 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); | 1250 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); |
1251 const FX_CHAR* pStrUnicode = _GlyphNameRemap(name); | 1251 const FX_CHAR* pStrUnicode = _GlyphNameRemap(name); |
1252 if (pStrUnicode && 0 == FXFT_Get_Name_Index(m_Font.m_Face, (char*)na
me)) { | 1252 if (pStrUnicode && 0 == FXFT_Get_Name_Index(m_Font.m_Face, (char*)na
me)) { |
1253 name = pStrUnicode; | 1253 name = pStrUnicode; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1309 } | 1309 } |
1310 } | 1310 } |
1311 } | 1311 } |
1312 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 1312 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
1313 if (!bCoreText) { | 1313 if (!bCoreText) { |
1314 FXSYS_memcpy(m_ExtGID, m_GlyphIndex, 256); | 1314 FXSYS_memcpy(m_ExtGID, m_GlyphIndex, 256); |
1315 } | 1315 } |
1316 #endif | 1316 #endif |
1317 return; | 1317 return; |
1318 } | 1318 } |
1319 FX_BOOL bUnicode = FALSE; | 1319 bool bUnicode = false; |
1320 if (0 == FXFT_Select_Charmap(m_Font.m_Face, FXFT_ENCODING_UNICODE)) { | 1320 if (0 == FXFT_Select_Charmap(m_Font.m_Face, FXFT_ENCODING_UNICODE)) { |
1321 bUnicode = TRUE; | 1321 bUnicode = true; |
1322 } | 1322 } |
1323 for (int charcode = 0; charcode < 256; charcode ++) { | 1323 for (int charcode = 0; charcode < 256; charcode ++) { |
1324 const FX_CHAR* name = GetAdobeCharName(m_BaseEncoding, m_pCharNames, cha
rcode); | 1324 const FX_CHAR* name = GetAdobeCharName(m_BaseEncoding, m_pCharNames, cha
rcode); |
1325 if (name == NULL) { | 1325 if (name == NULL) { |
1326 continue; | 1326 continue; |
1327 } | 1327 } |
1328 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); | 1328 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); |
1329 m_GlyphIndex[charcode] = FXFT_Get_Name_Index(m_Font.m_Face, (char*)name)
; | 1329 m_GlyphIndex[charcode] = FXFT_Get_Name_Index(m_Font.m_Face, (char*)name)
; |
1330 if (m_GlyphIndex[charcode] == 0) { | 1330 if (m_GlyphIndex[charcode] == 0) { |
1331 if (FXSYS_strcmp(name, ".notdef") != 0 && FXSYS_strcmp(name, "space"
) != 0) { | 1331 if (FXSYS_strcmp(name, ".notdef") != 0 && FXSYS_strcmp(name, "space"
) != 0) { |
(...skipping 25 matching lines...) Expand all Loading... |
1357 CPDF_FontEncoding::CPDF_FontEncoding(int PredefinedEncoding) | 1357 CPDF_FontEncoding::CPDF_FontEncoding(int PredefinedEncoding) |
1358 { | 1358 { |
1359 const FX_WORD* pSrc = PDF_UnicodesForPredefinedCharSet(PredefinedEncoding); | 1359 const FX_WORD* pSrc = PDF_UnicodesForPredefinedCharSet(PredefinedEncoding); |
1360 if (!pSrc) { | 1360 if (!pSrc) { |
1361 FXSYS_memset(m_Unicodes, 0, sizeof(m_Unicodes)); | 1361 FXSYS_memset(m_Unicodes, 0, sizeof(m_Unicodes)); |
1362 } else | 1362 } else |
1363 for (int i = 0; i < 256; i++) { | 1363 for (int i = 0; i < 256; i++) { |
1364 m_Unicodes[i] = pSrc[i]; | 1364 m_Unicodes[i] = pSrc[i]; |
1365 } | 1365 } |
1366 } | 1366 } |
1367 FX_BOOL CPDF_FontEncoding::IsIdentical(CPDF_FontEncoding* pAnother) const | 1367 bool CPDF_FontEncoding::IsIdentical(CPDF_FontEncoding* pAnother) const |
1368 { | 1368 { |
1369 return FXSYS_memcmp(m_Unicodes, pAnother->m_Unicodes, sizeof(m_Unicodes)) ==
0; | 1369 return FXSYS_memcmp(m_Unicodes, pAnother->m_Unicodes, sizeof(m_Unicodes)) ==
0; |
1370 } | 1370 } |
1371 CPDF_Object* CPDF_FontEncoding::Realize() | 1371 CPDF_Object* CPDF_FontEncoding::Realize() |
1372 { | 1372 { |
1373 int predefined = 0; | 1373 int predefined = 0; |
1374 for (int cs = PDFFONT_ENCODING_WINANSI; cs < PDFFONT_ENCODING_ZAPFDINGBATS;
cs ++) { | 1374 for (int cs = PDFFONT_ENCODING_WINANSI; cs < PDFFONT_ENCODING_ZAPFDINGBATS;
cs ++) { |
1375 const FX_WORD* pSrc = PDF_UnicodesForPredefinedCharSet(cs); | 1375 const FX_WORD* pSrc = PDF_UnicodesForPredefinedCharSet(cs); |
1376 FX_BOOL match = TRUE; | 1376 bool match = true; |
1377 for (int i = 0; i < 256; ++i) { | 1377 for (int i = 0; i < 256; ++i) { |
1378 if (m_Unicodes[i] != pSrc[i]) { | 1378 if (m_Unicodes[i] != pSrc[i]) { |
1379 match = FALSE; | 1379 match = false; |
1380 break; | 1380 break; |
1381 } | 1381 } |
1382 } | 1382 } |
1383 if (match) { | 1383 if (match) { |
1384 predefined = cs; | 1384 predefined = cs; |
1385 break; | 1385 break; |
1386 } | 1386 } |
1387 } | 1387 } |
1388 if (predefined) { | 1388 if (predefined) { |
1389 if (predefined == PDFFONT_ENCODING_WINANSI) { | 1389 if (predefined == PDFFONT_ENCODING_WINANSI) { |
(...skipping 17 matching lines...) Expand all Loading... |
1407 } | 1407 } |
1408 pDiff->Add(CPDF_Number::Create(i)); | 1408 pDiff->Add(CPDF_Number::Create(i)); |
1409 pDiff->Add(CPDF_Name::Create(PDF_AdobeNameFromUnicode(m_Unicodes[i]))); | 1409 pDiff->Add(CPDF_Name::Create(PDF_AdobeNameFromUnicode(m_Unicodes[i]))); |
1410 } | 1410 } |
1411 pDict->SetAt(FX_BSTRC("Differences"), pDiff); | 1411 pDict->SetAt(FX_BSTRC("Differences"), pDiff); |
1412 return pDict; | 1412 return pDict; |
1413 } | 1413 } |
1414 CPDF_TrueTypeFont::CPDF_TrueTypeFont() : CPDF_SimpleFont(PDFFONT_TRUETYPE) | 1414 CPDF_TrueTypeFont::CPDF_TrueTypeFont() : CPDF_SimpleFont(PDFFONT_TRUETYPE) |
1415 { | 1415 { |
1416 } | 1416 } |
1417 FX_BOOL CPDF_TrueTypeFont::_Load() | 1417 bool CPDF_TrueTypeFont::_Load() |
1418 { | 1418 { |
1419 return LoadCommon(); | 1419 return LoadCommon(); |
1420 } | 1420 } |
1421 void CPDF_TrueTypeFont::LoadGlyphMap() | 1421 void CPDF_TrueTypeFont::LoadGlyphMap() |
1422 { | 1422 { |
1423 if (m_Font.m_Face == NULL) { | 1423 if (m_Font.m_Face == NULL) { |
1424 return; | 1424 return; |
1425 } | 1425 } |
1426 int baseEncoding = m_BaseEncoding; | 1426 int baseEncoding = m_BaseEncoding; |
1427 if (m_pFontFile && m_Font.m_Face->num_charmaps > 0 | 1427 if (m_pFontFile && m_Font.m_Face->num_charmaps > 0 |
1428 && (baseEncoding == PDFFONT_ENCODING_MACROMAN || baseEncoding == PDF
FONT_ENCODING_WINANSI) | 1428 && (baseEncoding == PDFFONT_ENCODING_MACROMAN || baseEncoding == PDF
FONT_ENCODING_WINANSI) |
1429 && (m_Flags & PDFFONT_SYMBOLIC)) { | 1429 && (m_Flags & PDFFONT_SYMBOLIC)) { |
1430 FX_BOOL bSupportWin = FALSE; | 1430 bool bSupportWin = false; |
1431 FX_BOOL bSupportMac = FALSE; | 1431 bool bSupportMac = false; |
1432 for (int i = 0; i < FXFT_Get_Face_CharmapCount(m_Font.m_Face); i++) { | 1432 for (int i = 0; i < FXFT_Get_Face_CharmapCount(m_Font.m_Face); i++) { |
1433 int platform_id = FXFT_Get_Charmap_PlatformID(FXFT_Get_Face_Charmaps
(m_Font.m_Face)[i]); | 1433 int platform_id = FXFT_Get_Charmap_PlatformID(FXFT_Get_Face_Charmaps
(m_Font.m_Face)[i]); |
1434 if (platform_id == 0 || platform_id == 3) { | 1434 if (platform_id == 0 || platform_id == 3) { |
1435 bSupportWin = TRUE; | 1435 bSupportWin = true; |
1436 } else if (platform_id == 0 || platform_id == 1) { | 1436 } else if (platform_id == 0 || platform_id == 1) { |
1437 bSupportMac = TRUE; | 1437 bSupportMac = true; |
1438 } | 1438 } |
1439 } | 1439 } |
1440 if (baseEncoding == PDFFONT_ENCODING_WINANSI && !bSupportWin) { | 1440 if (baseEncoding == PDFFONT_ENCODING_WINANSI && !bSupportWin) { |
1441 baseEncoding = bSupportMac ? PDFFONT_ENCODING_MACROMAN : PDFFONT_ENC
ODING_BUILTIN; | 1441 baseEncoding = bSupportMac ? PDFFONT_ENCODING_MACROMAN : PDFFONT_ENC
ODING_BUILTIN; |
1442 } else if (baseEncoding == PDFFONT_ENCODING_MACROMAN && !bSupportMac) { | 1442 } else if (baseEncoding == PDFFONT_ENCODING_MACROMAN && !bSupportMac) { |
1443 baseEncoding = bSupportWin ? PDFFONT_ENCODING_WINANSI : PDFFONT_ENCO
DING_BUILTIN; | 1443 baseEncoding = bSupportWin ? PDFFONT_ENCODING_WINANSI : PDFFONT_ENCO
DING_BUILTIN; |
1444 } | 1444 } |
1445 } | 1445 } |
1446 if (((baseEncoding == PDFFONT_ENCODING_MACROMAN || baseEncoding == PDFFONT_E
NCODING_WINANSI) | 1446 if (((baseEncoding == PDFFONT_ENCODING_MACROMAN || baseEncoding == PDFFONT_E
NCODING_WINANSI) |
1447 && m_pCharNames == NULL) || (m_Flags & PDFFONT_NONSYMBOLIC)) { | 1447 && m_pCharNames == NULL) || (m_Flags & PDFFONT_NONSYMBOLIC)) { |
1448 if (!FXFT_Has_Glyph_Names(m_Font.m_Face) && (!m_Font.m_Face->num_charmap
s || !m_Font.m_Face->charmaps)) { | 1448 if (!FXFT_Has_Glyph_Names(m_Font.m_Face) && (!m_Font.m_Face->num_charmap
s || !m_Font.m_Face->charmaps)) { |
1449 int nStartChar = m_pFontDict->GetInteger(FX_BSTRC("FirstChar")); | 1449 int nStartChar = m_pFontDict->GetInteger(FX_BSTRC("FirstChar")); |
1450 if(nStartChar < 0 || nStartChar > 255) | 1450 if(nStartChar < 0 || nStartChar > 255) |
1451 return; | 1451 return; |
1452 | 1452 |
1453 int charcode = 0; | 1453 int charcode = 0; |
1454 for (; charcode < nStartChar; charcode ++) { | 1454 for (; charcode < nStartChar; charcode ++) { |
1455 m_GlyphIndex[charcode] = 0; | 1455 m_GlyphIndex[charcode] = 0; |
1456 } | 1456 } |
1457 FX_WORD nGlyph = charcode - nStartChar + 3; | 1457 FX_WORD nGlyph = charcode - nStartChar + 3; |
1458 for (; charcode < 256; charcode ++, nGlyph ++) { | 1458 for (; charcode < 256; charcode ++, nGlyph ++) { |
1459 m_GlyphIndex[charcode] = nGlyph; | 1459 m_GlyphIndex[charcode] = nGlyph; |
1460 } | 1460 } |
1461 return; | 1461 return; |
1462 } | 1462 } |
1463 FX_BOOL bMSUnicode = FT_UseTTCharmap(m_Font.m_Face, 3, 1); | 1463 bool bMSUnicode = FT_UseTTCharmap(m_Font.m_Face, 3, 1); |
1464 FX_BOOL bMacRoman = FALSE, bMSSymbol = FALSE; | 1464 bool bMacRoman = false, bMSSymbol = false; |
1465 if (!bMSUnicode) { | 1465 if (!bMSUnicode) { |
1466 if (m_Flags & PDFFONT_NONSYMBOLIC) { | 1466 if (m_Flags & PDFFONT_NONSYMBOLIC) { |
1467 bMacRoman = FT_UseTTCharmap(m_Font.m_Face, 1, 0); | 1467 bMacRoman = FT_UseTTCharmap(m_Font.m_Face, 1, 0); |
1468 bMSSymbol = !bMacRoman && FT_UseTTCharmap(m_Font.m_Face, 3, 0); | 1468 bMSSymbol = !bMacRoman && FT_UseTTCharmap(m_Font.m_Face, 3, 0); |
1469 } else { | 1469 } else { |
1470 bMSSymbol = FT_UseTTCharmap(m_Font.m_Face, 3, 0); | 1470 bMSSymbol = FT_UseTTCharmap(m_Font.m_Face, 3, 0); |
1471 bMacRoman = !bMSSymbol && FT_UseTTCharmap(m_Font.m_Face, 1, 0); | 1471 bMacRoman = !bMSSymbol && FT_UseTTCharmap(m_Font.m_Face, 1, 0); |
1472 } | 1472 } |
1473 } | 1473 } |
1474 FX_BOOL bToUnicode = m_pFontDict->KeyExist(FX_BSTRC("ToUnicode")); | 1474 bool bToUnicode = m_pFontDict->KeyExist(FX_BSTRC("ToUnicode")); |
1475 for (int charcode = 0; charcode < 256; charcode ++) { | 1475 for (int charcode = 0; charcode < 256; charcode ++) { |
1476 const FX_CHAR* name = GetAdobeCharName(baseEncoding, m_pCharNames, c
harcode); | 1476 const FX_CHAR* name = GetAdobeCharName(baseEncoding, m_pCharNames, c
harcode); |
1477 if (name == NULL) { | 1477 if (name == NULL) { |
1478 m_GlyphIndex[charcode] = m_pFontFile ? FXFT_Get_Char_Index(m_Fon
t.m_Face, charcode) : -1; | 1478 m_GlyphIndex[charcode] = m_pFontFile ? FXFT_Get_Char_Index(m_Fon
t.m_Face, charcode) : -1; |
1479 continue; | 1479 continue; |
1480 } | 1480 } |
1481 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); | 1481 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); |
1482 if (bMSSymbol) { | 1482 if (bMSSymbol) { |
1483 const uint8_t prefix[4] = {0x00, 0xf0, 0xf1, 0xf2}; | 1483 const uint8_t prefix[4] = {0x00, 0xf0, 0xf1, 0xf2}; |
1484 for (int j = 0; j < 4; j ++) { | 1484 for (int j = 0; j < 4; j ++) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1517 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.
m_Face, charcode); | 1517 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.
m_Face, charcode); |
1518 } | 1518 } |
1519 } | 1519 } |
1520 } | 1520 } |
1521 } | 1521 } |
1522 } | 1522 } |
1523 return; | 1523 return; |
1524 } | 1524 } |
1525 if (FT_UseTTCharmap(m_Font.m_Face, 3, 0)) { | 1525 if (FT_UseTTCharmap(m_Font.m_Face, 3, 0)) { |
1526 const uint8_t prefix[4] = {0x00, 0xf0, 0xf1, 0xf2}; | 1526 const uint8_t prefix[4] = {0x00, 0xf0, 0xf1, 0xf2}; |
1527 FX_BOOL bGotOne = FALSE; | 1527 bool bGotOne = false; |
1528 for (int charcode = 0; charcode < 256; charcode ++) { | 1528 for (int charcode = 0; charcode < 256; charcode ++) { |
1529 for (int j = 0; j < 4; j ++) { | 1529 for (int j = 0; j < 4; j ++) { |
1530 FX_WORD unicode = prefix[j] * 256 + charcode; | 1530 FX_WORD unicode = prefix[j] * 256 + charcode; |
1531 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face, unic
ode); | 1531 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face, unic
ode); |
1532 if (m_GlyphIndex[charcode]) { | 1532 if (m_GlyphIndex[charcode]) { |
1533 bGotOne = TRUE; | 1533 bGotOne = true; |
1534 break; | 1534 break; |
1535 } | 1535 } |
1536 } | 1536 } |
1537 } | 1537 } |
1538 if (bGotOne) { | 1538 if (bGotOne) { |
1539 if (baseEncoding != PDFFONT_ENCODING_BUILTIN) { | 1539 if (baseEncoding != PDFFONT_ENCODING_BUILTIN) { |
1540 for (int charcode = 0; charcode < 256; charcode ++) { | 1540 for (int charcode = 0; charcode < 256; charcode ++) { |
1541 const FX_CHAR* name = GetAdobeCharName(baseEncoding, m_pChar
Names, charcode); | 1541 const FX_CHAR* name = GetAdobeCharName(baseEncoding, m_pChar
Names, charcode); |
1542 if (name == NULL) { | 1542 if (name == NULL) { |
1543 continue; | 1543 continue; |
1544 } | 1544 } |
1545 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(n
ame); | 1545 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(n
ame); |
1546 } | 1546 } |
1547 } else if (FT_UseTTCharmap(m_Font.m_Face, 1, 0)) { | 1547 } else if (FT_UseTTCharmap(m_Font.m_Face, 1, 0)) { |
1548 for (int charcode = 0; charcode < 256; charcode ++) { | 1548 for (int charcode = 0; charcode < 256; charcode ++) { |
1549 m_Encoding.m_Unicodes[charcode] = FT_UnicodeFromCharCode(FXF
T_ENCODING_APPLE_ROMAN, charcode); | 1549 m_Encoding.m_Unicodes[charcode] = FT_UnicodeFromCharCode(FXF
T_ENCODING_APPLE_ROMAN, charcode); |
1550 } | 1550 } |
1551 } | 1551 } |
1552 return; | 1552 return; |
1553 } | 1553 } |
1554 } | 1554 } |
1555 if (FT_UseTTCharmap(m_Font.m_Face, 1, 0)) { | 1555 if (FT_UseTTCharmap(m_Font.m_Face, 1, 0)) { |
1556 FX_BOOL bGotOne = FALSE; | 1556 bool bGotOne = false; |
1557 for (int charcode = 0; charcode < 256; charcode ++) { | 1557 for (int charcode = 0; charcode < 256; charcode ++) { |
1558 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face, charcode
); | 1558 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face, charcode
); |
1559 m_Encoding.m_Unicodes[charcode] = FT_UnicodeFromCharCode(FXFT_ENCODI
NG_APPLE_ROMAN, charcode); | 1559 m_Encoding.m_Unicodes[charcode] = FT_UnicodeFromCharCode(FXFT_ENCODI
NG_APPLE_ROMAN, charcode); |
1560 if (m_GlyphIndex[charcode]) { | 1560 if (m_GlyphIndex[charcode]) { |
1561 bGotOne = TRUE; | 1561 bGotOne = true; |
1562 } | 1562 } |
1563 } | 1563 } |
1564 if (m_pFontFile || bGotOne) { | 1564 if (m_pFontFile || bGotOne) { |
1565 return; | 1565 return; |
1566 } | 1566 } |
1567 } | 1567 } |
1568 if (FXFT_Select_Charmap(m_Font.m_Face, FXFT_ENCODING_UNICODE) == 0) { | 1568 if (FXFT_Select_Charmap(m_Font.m_Face, FXFT_ENCODING_UNICODE) == 0) { |
1569 FX_BOOL bGotOne = FALSE; | 1569 bool bGotOne = false; |
1570 const FX_WORD* pUnicodes = PDF_UnicodesForPredefinedCharSet(baseEncoding
); | 1570 const FX_WORD* pUnicodes = PDF_UnicodesForPredefinedCharSet(baseEncoding
); |
1571 for (int charcode = 0; charcode < 256; charcode ++) { | 1571 for (int charcode = 0; charcode < 256; charcode ++) { |
1572 if (m_pFontFile == NULL) { | 1572 if (m_pFontFile == NULL) { |
1573 const FX_CHAR* name = GetAdobeCharName(0, m_pCharNames, charcode
); | 1573 const FX_CHAR* name = GetAdobeCharName(0, m_pCharNames, charcode
); |
1574 if (name != NULL) { | 1574 if (name != NULL) { |
1575 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(n
ame); | 1575 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(n
ame); |
1576 } else if (pUnicodes) { | 1576 } else if (pUnicodes) { |
1577 m_Encoding.m_Unicodes[charcode] = pUnicodes[charcode]; | 1577 m_Encoding.m_Unicodes[charcode] = pUnicodes[charcode]; |
1578 } | 1578 } |
1579 } else { | 1579 } else { |
1580 m_Encoding.m_Unicodes[charcode] = charcode; | 1580 m_Encoding.m_Unicodes[charcode] = charcode; |
1581 } | 1581 } |
1582 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face, m_Encodi
ng.m_Unicodes[charcode]); | 1582 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face, m_Encodi
ng.m_Unicodes[charcode]); |
1583 if (m_GlyphIndex[charcode]) { | 1583 if (m_GlyphIndex[charcode]) { |
1584 bGotOne = TRUE; | 1584 bGotOne = true; |
1585 } | 1585 } |
1586 } | 1586 } |
1587 if (bGotOne) { | 1587 if (bGotOne) { |
1588 return; | 1588 return; |
1589 } | 1589 } |
1590 } | 1590 } |
1591 for (int charcode = 0; charcode < 256; charcode ++) { | 1591 for (int charcode = 0; charcode < 256; charcode ++) { |
1592 m_GlyphIndex[charcode] = charcode; | 1592 m_GlyphIndex[charcode] = charcode; |
1593 } | 1593 } |
1594 } | 1594 } |
(...skipping 13 matching lines...) Expand all Loading... |
1608 } | 1608 } |
1609 m_CacheMap.RemoveAll(); | 1609 m_CacheMap.RemoveAll(); |
1610 pos = m_DeletedMap.GetStartPosition(); | 1610 pos = m_DeletedMap.GetStartPosition(); |
1611 while (pos) { | 1611 while (pos) { |
1612 void* key; | 1612 void* key; |
1613 void* value; | 1613 void* value; |
1614 m_DeletedMap.GetNextAssoc(pos, key, value); | 1614 m_DeletedMap.GetNextAssoc(pos, key, value); |
1615 delete (CPDF_Type3Char*)key; | 1615 delete (CPDF_Type3Char*)key; |
1616 } | 1616 } |
1617 } | 1617 } |
1618 FX_BOOL CPDF_Type3Font::_Load() | 1618 bool CPDF_Type3Font::_Load() |
1619 { | 1619 { |
1620 m_pFontResources = m_pFontDict->GetDict(FX_BSTRC("Resources")); | 1620 m_pFontResources = m_pFontDict->GetDict(FX_BSTRC("Resources")); |
1621 CPDF_Array* pMatrix = m_pFontDict->GetArray(FX_BSTRC("FontMatrix")); | 1621 CPDF_Array* pMatrix = m_pFontDict->GetArray(FX_BSTRC("FontMatrix")); |
1622 FX_FLOAT xscale = 1.0f, yscale = 1.0f; | 1622 FX_FLOAT xscale = 1.0f, yscale = 1.0f; |
1623 if (pMatrix) { | 1623 if (pMatrix) { |
1624 m_FontMatrix = pMatrix->GetMatrix(); | 1624 m_FontMatrix = pMatrix->GetMatrix(); |
1625 xscale = m_FontMatrix.a; | 1625 xscale = m_FontMatrix.a; |
1626 yscale = m_FontMatrix.d; | 1626 yscale = m_FontMatrix.d; |
1627 } | 1627 } |
1628 CPDF_Array* pBBox = m_pFontDict->GetArray(FX_BSTRC("FontBBox")); | 1628 CPDF_Array* pBBox = m_pFontDict->GetArray(FX_BSTRC("FontBBox")); |
(...skipping 13 matching lines...) Expand all Loading... |
1642 if (StartChar + count > 256) { | 1642 if (StartChar + count > 256) { |
1643 count = 256 - StartChar; | 1643 count = 256 - StartChar; |
1644 } | 1644 } |
1645 for (FX_DWORD i = 0; i < count; i ++) { | 1645 for (FX_DWORD i = 0; i < count; i ++) { |
1646 m_CharWidthL[StartChar + i] = FXSYS_round(FXSYS_Mul(pWidthArray->Get
Number(i), xscale) * 1000); | 1646 m_CharWidthL[StartChar + i] = FXSYS_round(FXSYS_Mul(pWidthArray->Get
Number(i), xscale) * 1000); |
1647 } | 1647 } |
1648 } | 1648 } |
1649 m_pCharProcs = m_pFontDict->GetDict(FX_BSTRC("CharProcs")); | 1649 m_pCharProcs = m_pFontDict->GetDict(FX_BSTRC("CharProcs")); |
1650 CPDF_Object* pEncoding = m_pFontDict->GetElementValue(FX_BSTRC("Encoding")); | 1650 CPDF_Object* pEncoding = m_pFontDict->GetElementValue(FX_BSTRC("Encoding")); |
1651 if (pEncoding) { | 1651 if (pEncoding) { |
1652 LoadPDFEncoding(pEncoding, m_BaseEncoding, m_pCharNames, FALSE, FALSE); | 1652 LoadPDFEncoding(pEncoding, m_BaseEncoding, m_pCharNames, false, false); |
1653 if (m_pCharNames) { | 1653 if (m_pCharNames) { |
1654 for (int i = 0; i < 256; i ++) { | 1654 for (int i = 0; i < 256; i ++) { |
1655 m_Encoding.m_Unicodes[i] = PDF_UnicodeFromAdobeName(m_pCharNames
[i]); | 1655 m_Encoding.m_Unicodes[i] = PDF_UnicodeFromAdobeName(m_pCharNames
[i]); |
1656 if (m_Encoding.m_Unicodes[i] == 0) { | 1656 if (m_Encoding.m_Unicodes[i] == 0) { |
1657 m_Encoding.m_Unicodes[i] = i; | 1657 m_Encoding.m_Unicodes[i] = i; |
1658 } | 1658 } |
1659 } | 1659 } |
1660 } | 1660 } |
1661 } | 1661 } |
1662 return TRUE; | 1662 return true; |
1663 } | 1663 } |
1664 void CPDF_Type3Font::CheckType3FontMetrics() | 1664 void CPDF_Type3Font::CheckType3FontMetrics() |
1665 { | 1665 { |
1666 CheckFontMetrics(); | 1666 CheckFontMetrics(); |
1667 } | 1667 } |
1668 CPDF_Type3Char* CPDF_Type3Font::LoadChar(FX_DWORD charcode, int level) | 1668 CPDF_Type3Char* CPDF_Type3Font::LoadChar(FX_DWORD charcode, int level) |
1669 { | 1669 { |
1670 if (level >= _FPDF_MAX_TYPE3_FORM_LEVEL_) { | 1670 if (level >= _FPDF_MAX_TYPE3_FORM_LEVEL_) { |
1671 return NULL; | 1671 return NULL; |
1672 } | 1672 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1730 if (pChar == NULL) { | 1730 if (pChar == NULL) { |
1731 rect.left = rect.right = rect.top = rect.bottom = 0; | 1731 rect.left = rect.right = rect.top = rect.bottom = 0; |
1732 return; | 1732 return; |
1733 } | 1733 } |
1734 rect = pChar->m_BBox; | 1734 rect = pChar->m_BBox; |
1735 } | 1735 } |
1736 CPDF_Type3Char::CPDF_Type3Char() | 1736 CPDF_Type3Char::CPDF_Type3Char() |
1737 { | 1737 { |
1738 m_pForm = NULL; | 1738 m_pForm = NULL; |
1739 m_pBitmap = NULL; | 1739 m_pBitmap = NULL; |
1740 m_bPageRequired = FALSE; | 1740 m_bPageRequired = false; |
1741 m_bColored = FALSE; | 1741 m_bColored = false; |
1742 } | 1742 } |
1743 CPDF_Type3Char::~CPDF_Type3Char() | 1743 CPDF_Type3Char::~CPDF_Type3Char() |
1744 { | 1744 { |
1745 delete m_pForm; | 1745 delete m_pForm; |
1746 delete m_pBitmap; | 1746 delete m_pBitmap; |
1747 } | 1747 } |
OLD | NEW |