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

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

Issue 1258093002: FX Bool considered harmful, part 3 (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 4 months 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
« no previous file with comments | « core/src/fpdfapi/fpdf_font/font_int.h ('k') | core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
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
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
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
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
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
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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 return result; 616 return result;
617 } 617 }
618 if (buf[0] == '(') { 618 if (buf[0] == '(') {
619 } 619 }
620 return result; 620 return result;
621 } 621 }
622 void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) 622 void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream)
623 { 623 {
624 int CIDSet = 0; 624 int CIDSet = 0;
625 CPDF_StreamAcc stream; 625 CPDF_StreamAcc stream;
626 stream.LoadAllData(pStream, FALSE); 626 stream.LoadAllData(pStream, false);
627 CPDF_SimpleParser parser(stream.GetData(), stream.GetSize()); 627 CPDF_SimpleParser parser(stream.GetData(), stream.GetSize());
628 m_Map.EstimateSize(stream.GetSize() / 8, 1024); 628 m_Map.EstimateSize(stream.GetSize() / 8, 1024);
629 while (1) { 629 while (1) {
630 CFX_ByteStringC word = parser.GetWord(); 630 CFX_ByteStringC word = parser.GetWord();
631 if (word.IsEmpty()) { 631 if (word.IsEmpty()) {
632 break; 632 break;
633 } 633 }
634 if (word == FX_BSTRC("beginbfchar")) { 634 if (word == FX_BSTRC("beginbfchar")) {
635 while (1) { 635 while (1) {
636 word = parser.GetWord(); 636 word = parser.GetWord();
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 CIDSet = CIDSET_KOREA1; 712 CIDSet = CIDSET_KOREA1;
713 } else if (word == FX_BSTRC("/Adobe-Japan1-UCS2")) { 713 } else if (word == FX_BSTRC("/Adobe-Japan1-UCS2")) {
714 CIDSet = CIDSET_JAPAN1; 714 CIDSet = CIDSET_JAPAN1;
715 } else if (word == FX_BSTRC("/Adobe-CNS1-UCS2")) { 715 } else if (word == FX_BSTRC("/Adobe-CNS1-UCS2")) {
716 CIDSet = CIDSET_CNS1; 716 CIDSet = CIDSET_CNS1;
717 } else if (word == FX_BSTRC("/Adobe-GB1-UCS2")) { 717 } else if (word == FX_BSTRC("/Adobe-GB1-UCS2")) {
718 CIDSet = CIDSET_GB1; 718 CIDSet = CIDSET_GB1;
719 } 719 }
720 } 720 }
721 if (CIDSet) { 721 if (CIDSet) {
722 m_pBaseMap = CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals()->m _CMapManager.GetCID2UnicodeMap(CIDSet, FALSE); 722 m_pBaseMap = CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals()->m _CMapManager.GetCID2UnicodeMap(CIDSet, false);
723 } else { 723 } else {
724 m_pBaseMap = NULL; 724 m_pBaseMap = NULL;
725 } 725 }
726 } 726 }
727 static FX_BOOL GetPredefinedEncoding(int& basemap, const CFX_ByteString& value) 727 static bool GetPredefinedEncoding(int& basemap, const CFX_ByteString& value)
728 { 728 {
729 if (value == FX_BSTRC("WinAnsiEncoding")) { 729 if (value == FX_BSTRC("WinAnsiEncoding")) {
730 basemap = PDFFONT_ENCODING_WINANSI; 730 basemap = PDFFONT_ENCODING_WINANSI;
731 } else if (value == FX_BSTRC("MacRomanEncoding")) { 731 } else if (value == FX_BSTRC("MacRomanEncoding")) {
732 basemap = PDFFONT_ENCODING_MACROMAN; 732 basemap = PDFFONT_ENCODING_MACROMAN;
733 } else if (value == FX_BSTRC("MacExpertEncoding")) { 733 } else if (value == FX_BSTRC("MacExpertEncoding")) {
734 basemap = PDFFONT_ENCODING_MACEXPERT; 734 basemap = PDFFONT_ENCODING_MACEXPERT;
735 } else if (value == FX_BSTRC("PDFDocEncoding")) { 735 } else if (value == FX_BSTRC("PDFDocEncoding")) {
736 basemap = PDFFONT_ENCODING_PDFDOC; 736 basemap = PDFFONT_ENCODING_PDFDOC;
737 } else { 737 } else {
738 return FALSE; 738 return false;
739 } 739 }
740 return TRUE; 740 return true;
741 } 741 }
742 void CPDF_Font::LoadPDFEncoding(CPDF_Object* pEncoding, int& iBaseEncoding, CFX_ ByteString*& pCharNames, 742 void CPDF_Font::LoadPDFEncoding(CPDF_Object* pEncoding, int& iBaseEncoding, CFX_ ByteString*& pCharNames,
743 FX_BOOL bEmbedded, FX_BOOL bTrueType) 743 bool bEmbedded, bool bTrueType)
744 { 744 {
745 if (pEncoding == NULL) { 745 if (pEncoding == NULL) {
746 if (m_BaseFont == FX_BSTRC("Symbol")) { 746 if (m_BaseFont == FX_BSTRC("Symbol")) {
747 iBaseEncoding = bTrueType ? PDFFONT_ENCODING_MS_SYMBOL : PDFFONT_ENC ODING_ADOBE_SYMBOL; 747 iBaseEncoding = bTrueType ? PDFFONT_ENCODING_MS_SYMBOL : PDFFONT_ENC ODING_ADOBE_SYMBOL;
748 } else if (!bEmbedded && iBaseEncoding == PDFFONT_ENCODING_BUILTIN) { 748 } else if (!bEmbedded && iBaseEncoding == PDFFONT_ENCODING_BUILTIN) {
749 iBaseEncoding = PDFFONT_ENCODING_WINANSI; 749 iBaseEncoding = PDFFONT_ENCODING_WINANSI;
750 } 750 }
751 return; 751 return;
752 } 752 }
753 if (pEncoding->GetType() == PDFOBJ_NAME) { 753 if (pEncoding->GetType() == PDFOBJ_NAME) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 if (pElement->GetType() == PDFOBJ_NAME) { 795 if (pElement->GetType() == PDFOBJ_NAME) {
796 if (cur_code < 256) { 796 if (cur_code < 256) {
797 pCharNames[cur_code] = ((CPDF_Name*)pElement)->GetString(); 797 pCharNames[cur_code] = ((CPDF_Name*)pElement)->GetString();
798 } 798 }
799 cur_code ++; 799 cur_code ++;
800 } else { 800 } else {
801 cur_code = pElement->GetInteger(); 801 cur_code = pElement->GetInteger();
802 } 802 }
803 } 803 }
804 } 804 }
805 FX_BOOL CPDF_Font::IsStandardFont() const 805 bool CPDF_Font::IsStandardFont() const
806 { 806 {
807 if (m_FontType != PDFFONT_TYPE1) { 807 if (m_FontType != PDFFONT_TYPE1) {
808 return FALSE; 808 return false;
809 } 809 }
810 if (m_pFontFile != NULL) { 810 if (m_pFontFile != NULL) {
811 return FALSE; 811 return false;
812 } 812 }
813 if (((CPDF_Type1Font*)this)->GetBase14Font() < 0) { 813 if (((CPDF_Type1Font*)this)->GetBase14Font() < 0) {
814 return FALSE; 814 return false;
815 } 815 }
816 return TRUE; 816 return true;
817 } 817 }
818 CPDF_SimpleFont::CPDF_SimpleFont(int fonttype) : CPDF_Font(fonttype) 818 CPDF_SimpleFont::CPDF_SimpleFont(int fonttype) : CPDF_Font(fonttype)
819 { 819 {
820 FXSYS_memset(m_CharBBox, 0xff, sizeof m_CharBBox); 820 FXSYS_memset(m_CharBBox, 0xff, sizeof m_CharBBox);
821 FXSYS_memset(m_CharWidth, 0xff, sizeof m_CharWidth); 821 FXSYS_memset(m_CharWidth, 0xff, sizeof m_CharWidth);
822 FXSYS_memset(m_GlyphIndex, 0xff, sizeof m_GlyphIndex); 822 FXSYS_memset(m_GlyphIndex, 0xff, sizeof m_GlyphIndex);
823 FXSYS_memset(m_ExtGID, 0xff, sizeof m_ExtGID); 823 FXSYS_memset(m_ExtGID, 0xff, sizeof m_ExtGID);
824 m_pCharNames = NULL; 824 m_pCharNames = NULL;
825 m_BaseEncoding = PDFFONT_ENCODING_BUILTIN; 825 m_BaseEncoding = PDFFONT_ENCODING_BUILTIN;
826 } 826 }
827 CPDF_SimpleFont::~CPDF_SimpleFont() 827 CPDF_SimpleFont::~CPDF_SimpleFont()
828 { 828 {
829 delete[] m_pCharNames; 829 delete[] m_pCharNames;
830 } 830 }
831 int CPDF_SimpleFont::GlyphFromCharCode(FX_DWORD charcode, FX_BOOL *pVertGlyph) 831 int CPDF_SimpleFont::GlyphFromCharCode(FX_DWORD charcode, bool *pVertGlyph)
832 { 832 {
833 if (pVertGlyph) { 833 if (pVertGlyph) {
834 *pVertGlyph = FALSE; 834 *pVertGlyph = false;
835 } 835 }
836 if (charcode > 0xff) { 836 if (charcode > 0xff) {
837 return -1; 837 return -1;
838 } 838 }
839 int index = m_GlyphIndex[(uint8_t)charcode]; 839 int index = m_GlyphIndex[(uint8_t)charcode];
840 if (index == 0xffff) { 840 if (index == 0xffff) {
841 return -1; 841 return -1;
842 } 842 }
843 return index; 843 return index;
844 } 844 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 name = pCharNames[charcode]; 916 name = pCharNames[charcode];
917 } 917 }
918 if ((name == NULL || name[0] == 0) && iBaseEncoding) { 918 if ((name == NULL || name[0] == 0) && iBaseEncoding) {
919 name = PDF_CharNameFromPredefinedCharSet(iBaseEncoding, charcode); 919 name = PDF_CharNameFromPredefinedCharSet(iBaseEncoding, charcode);
920 } 920 }
921 if (name == NULL || name[0] == 0) { 921 if (name == NULL || name[0] == 0) {
922 return NULL; 922 return NULL;
923 } 923 }
924 return name; 924 return name;
925 } 925 }
926 FX_BOOL CPDF_SimpleFont::LoadCommon() 926 bool CPDF_SimpleFont::LoadCommon()
927 { 927 {
928 CPDF_Dictionary* pFontDesc = m_pFontDict->GetDict(FX_BSTRC("FontDescriptor") ); 928 CPDF_Dictionary* pFontDesc = m_pFontDict->GetDict(FX_BSTRC("FontDescriptor") );
929 if (pFontDesc) { 929 if (pFontDesc) {
930 LoadFontDescriptor(pFontDesc); 930 LoadFontDescriptor(pFontDesc);
931 } 931 }
932 CPDF_Array* pWidthArray = m_pFontDict->GetArray(FX_BSTRC("Widths")); 932 CPDF_Array* pWidthArray = m_pFontDict->GetArray(FX_BSTRC("Widths"));
933 int width_start = 0, width_end = -1; 933 int width_start = 0, width_end = -1;
934 m_bUseFontWidth = TRUE; 934 m_bUseFontWidth = true;
935 if (pWidthArray) { 935 if (pWidthArray) {
936 m_bUseFontWidth = FALSE; 936 m_bUseFontWidth = false;
937 if (pFontDesc && pFontDesc->KeyExist(FX_BSTRC("MissingWidth"))) { 937 if (pFontDesc && pFontDesc->KeyExist(FX_BSTRC("MissingWidth"))) {
938 int MissingWidth = pFontDesc->GetInteger(FX_BSTRC("MissingWidth")); 938 int MissingWidth = pFontDesc->GetInteger(FX_BSTRC("MissingWidth"));
939 for (int i = 0; i < 256; i ++) { 939 for (int i = 0; i < 256; i ++) {
940 m_CharWidth[i] = MissingWidth; 940 m_CharWidth[i] = MissingWidth;
941 } 941 }
942 } 942 }
943 width_start = m_pFontDict->GetInteger(FX_BSTRC("FirstChar"), 0); 943 width_start = m_pFontDict->GetInteger(FX_BSTRC("FirstChar"), 0);
944 width_end = m_pFontDict->GetInteger(FX_BSTRC("LastChar"), 0); 944 width_end = m_pFontDict->GetInteger(FX_BSTRC("LastChar"), 0);
945 if (width_start >= 0 && width_start <= 255) { 945 if (width_start >= 0 && width_start <= 255) {
946 if (width_end <= 0 || width_end >= width_start + (int)pWidthArray->G etCount()) { 946 if (width_end <= 0 || width_end >= width_start + (int)pWidthArray->G etCount()) {
(...skipping 16 matching lines...) Expand all
963 } 963 }
964 if (!(m_Flags & PDFFONT_SYMBOLIC)) { 964 if (!(m_Flags & PDFFONT_SYMBOLIC)) {
965 m_BaseEncoding = PDFFONT_ENCODING_STANDARD; 965 m_BaseEncoding = PDFFONT_ENCODING_STANDARD;
966 } 966 }
967 CPDF_Object* pEncoding = m_pFontDict->GetElementValue(FX_BSTRC("Encoding")); 967 CPDF_Object* pEncoding = m_pFontDict->GetElementValue(FX_BSTRC("Encoding"));
968 LoadPDFEncoding(pEncoding, m_BaseEncoding, m_pCharNames, m_pFontFile != NULL , m_Font.IsTTFont()); 968 LoadPDFEncoding(pEncoding, m_BaseEncoding, m_pCharNames, m_pFontFile != NULL , m_Font.IsTTFont());
969 LoadGlyphMap(); 969 LoadGlyphMap();
970 delete[] m_pCharNames; 970 delete[] m_pCharNames;
971 m_pCharNames = NULL; 971 m_pCharNames = NULL;
972 if (m_Font.m_Face == NULL) { 972 if (m_Font.m_Face == NULL) {
973 return TRUE; 973 return true;
974 } 974 }
975 if (m_Flags & PDFFONT_ALLCAP) { 975 if (m_Flags & PDFFONT_ALLCAP) {
976 unsigned char lowercases[] = {'a', 'z', 0xe0, 0xf6, 0xf8, 0xfd}; 976 unsigned char lowercases[] = {'a', 'z', 0xe0, 0xf6, 0xf8, 0xfd};
977 for (size_t range = 0; range < sizeof lowercases / 2; range ++) { 977 for (size_t range = 0; range < sizeof lowercases / 2; range ++) {
978 for (int i = lowercases[range * 2]; i <= lowercases[range * 2 + 1]; i ++) { 978 for (int i = lowercases[range * 2]; i <= lowercases[range * 2 + 1]; i ++) {
979 if (m_GlyphIndex[i] != 0xffff && m_pFontFile != NULL) { 979 if (m_GlyphIndex[i] != 0xffff && m_pFontFile != NULL) {
980 continue; 980 continue;
981 } 981 }
982 m_GlyphIndex[i] = m_GlyphIndex[i - 32]; 982 m_GlyphIndex[i] = m_GlyphIndex[i - 32];
983 if (m_CharWidth[i - 32]) { 983 if (m_CharWidth[i - 32]) {
984 m_CharWidth[i] = m_CharWidth[i - 32]; 984 m_CharWidth[i] = m_CharWidth[i - 32];
985 m_CharBBox[i] = m_CharBBox[i - 32]; 985 m_CharBBox[i] = m_CharBBox[i - 32];
986 } 986 }
987 } 987 }
988 } 988 }
989 } 989 }
990 CheckFontMetrics(); 990 CheckFontMetrics();
991 return TRUE; 991 return true;
992 } 992 }
993 void CPDF_SimpleFont::LoadSubstFont() 993 void CPDF_SimpleFont::LoadSubstFont()
994 { 994 {
995 if (!m_bUseFontWidth && !(m_Flags & PDFFONT_FIXEDPITCH)) { 995 if (!m_bUseFontWidth && !(m_Flags & PDFFONT_FIXEDPITCH)) {
996 int width = 0, i; 996 int width = 0, i;
997 for (i = 0; i < 256; i ++) { 997 for (i = 0; i < 256; i ++) {
998 if (m_CharWidth[i] == 0 || m_CharWidth[i] == 0xffff) { 998 if (m_CharWidth[i] == 0 || m_CharWidth[i] == 0xffff) {
999 continue; 999 continue;
1000 } 1000 }
1001 if (width == 0) { 1001 if (width == 0) {
1002 width = m_CharWidth[i]; 1002 width = m_CharWidth[i];
1003 } else if (width != m_CharWidth[i]) { 1003 } else if (width != m_CharWidth[i]) {
1004 break; 1004 break;
1005 } 1005 }
1006 } 1006 }
1007 if (i == 256 && width) { 1007 if (i == 256 && width) {
1008 m_Flags |= PDFFONT_FIXEDPITCH; 1008 m_Flags |= PDFFONT_FIXEDPITCH;
1009 } 1009 }
1010 } 1010 }
1011 int weight = m_StemV < 140 ? m_StemV * 5 : (m_StemV * 4 + 140); 1011 int weight = m_StemV < 140 ? m_StemV * 5 : (m_StemV * 4 + 140);
1012 m_Font.LoadSubst(m_BaseFont, IsFontType(PDFFONT_TRUETYPE), m_Flags, weight, m_ItalicAngle, 0); 1012 m_Font.LoadSubst(m_BaseFont, IsFontType(PDFFONT_TRUETYPE), m_Flags, weight, m_ItalicAngle, 0);
1013 if (m_Font.m_pSubstFont->m_SubstFlags & FXFONT_SUBST_NONSYMBOL) { 1013 if (m_Font.m_pSubstFont->m_SubstFlags & FXFONT_SUBST_NONSYMBOL) {
1014 } 1014 }
1015 } 1015 }
1016 FX_BOOL CPDF_SimpleFont::IsUnicodeCompatible() const 1016 bool CPDF_SimpleFont::IsUnicodeCompatible() const
1017 { 1017 {
1018 return m_BaseEncoding != PDFFONT_ENCODING_BUILTIN && m_BaseEncoding != PDFFO NT_ENCODING_ADOBE_SYMBOL && 1018 return m_BaseEncoding != PDFFONT_ENCODING_BUILTIN && m_BaseEncoding != PDFFO NT_ENCODING_ADOBE_SYMBOL &&
1019 m_BaseEncoding != PDFFONT_ENCODING_ZAPFDINGBATS; 1019 m_BaseEncoding != PDFFONT_ENCODING_ZAPFDINGBATS;
1020 } 1020 }
1021 CPDF_Type1Font::CPDF_Type1Font() : CPDF_SimpleFont(PDFFONT_TYPE1) 1021 CPDF_Type1Font::CPDF_Type1Font() : CPDF_SimpleFont(PDFFONT_TYPE1)
1022 { 1022 {
1023 m_Base14Font = -1; 1023 m_Base14Font = -1;
1024 } 1024 }
1025 FX_BOOL CPDF_Type1Font::_Load() 1025 bool CPDF_Type1Font::_Load()
1026 { 1026 {
1027 m_Base14Font = _PDF_GetStandardFontName(m_BaseFont); 1027 m_Base14Font = _PDF_GetStandardFontName(m_BaseFont);
1028 if (m_Base14Font >= 0) { 1028 if (m_Base14Font >= 0) {
1029 CPDF_Dictionary* pFontDesc = m_pFontDict->GetDict(FX_BSTRC("FontDescript or")); 1029 CPDF_Dictionary* pFontDesc = m_pFontDict->GetDict(FX_BSTRC("FontDescript or"));
1030 if (pFontDesc && pFontDesc->KeyExist(FX_BSTRC("Flags"))) { 1030 if (pFontDesc && pFontDesc->KeyExist(FX_BSTRC("Flags"))) {
1031 m_Flags = pFontDesc->GetInteger(FX_BSTRC("Flags")); 1031 m_Flags = pFontDesc->GetInteger(FX_BSTRC("Flags"));
1032 } else { 1032 } else {
1033 m_Flags = m_Base14Font >= 12 ? PDFFONT_SYMBOLIC : PDFFONT_NONSYMBOLI C; 1033 m_Flags = m_Base14Font >= 12 ? PDFFONT_SYMBOLIC : PDFFONT_NONSYMBOLI C;
1034 } 1034 }
1035 if (m_Base14Font < 4) 1035 if (m_Base14Font < 4)
1036 for (int i = 0; i < 256; i ++) { 1036 for (int i = 0; i < 256; i ++) {
1037 m_CharWidth[i] = 600; 1037 m_CharWidth[i] = 600;
1038 } 1038 }
1039 if (m_Base14Font == 12) { 1039 if (m_Base14Font == 12) {
1040 m_BaseEncoding = PDFFONT_ENCODING_ADOBE_SYMBOL; 1040 m_BaseEncoding = PDFFONT_ENCODING_ADOBE_SYMBOL;
1041 } else if (m_Base14Font == 13) { 1041 } else if (m_Base14Font == 13) {
1042 m_BaseEncoding = PDFFONT_ENCODING_ZAPFDINGBATS; 1042 m_BaseEncoding = PDFFONT_ENCODING_ZAPFDINGBATS;
1043 } else if (m_Flags & PDFFONT_NONSYMBOLIC) { 1043 } else if (m_Flags & PDFFONT_NONSYMBOLIC) {
1044 m_BaseEncoding = PDFFONT_ENCODING_STANDARD; 1044 m_BaseEncoding = PDFFONT_ENCODING_STANDARD;
1045 } 1045 }
1046 } 1046 }
1047 return LoadCommon(); 1047 return LoadCommon();
1048 } 1048 }
1049 static FX_BOOL FT_UseType1Charmap(FXFT_Face face) 1049 static bool FT_UseType1Charmap(FXFT_Face face)
1050 { 1050 {
1051 if (FXFT_Get_Face_CharmapCount(face) == 0) { 1051 if (FXFT_Get_Face_CharmapCount(face) == 0) {
1052 return FALSE; 1052 return false;
1053 } 1053 }
1054 if (FXFT_Get_Face_CharmapCount(face) == 1 && 1054 if (FXFT_Get_Face_CharmapCount(face) == 1 &&
1055 FXFT_Get_Charmap_Encoding(FXFT_Get_Face_Charmaps(face)[0]) == FXFT_E NCODING_UNICODE) { 1055 FXFT_Get_Charmap_Encoding(FXFT_Get_Face_Charmaps(face)[0]) == FXFT_E NCODING_UNICODE) {
1056 return FALSE; 1056 return false;
1057 } 1057 }
1058 if (FXFT_Get_Charmap_Encoding(FXFT_Get_Face_Charmaps(face)[0]) == FXFT_ENCOD ING_UNICODE) { 1058 if (FXFT_Get_Charmap_Encoding(FXFT_Get_Face_Charmaps(face)[0]) == FXFT_ENCOD ING_UNICODE) {
1059 FXFT_Set_Charmap(face, FXFT_Get_Face_Charmaps(face)[1]); 1059 FXFT_Set_Charmap(face, FXFT_Get_Face_Charmaps(face)[1]);
1060 } else { 1060 } else {
1061 FXFT_Set_Charmap(face, FXFT_Get_Face_Charmaps(face)[0]); 1061 FXFT_Set_Charmap(face, FXFT_Get_Face_Charmaps(face)[0]);
1062 } 1062 }
1063 return TRUE; 1063 return true;
1064 } 1064 }
1065 extern FX_WCHAR FT_UnicodeFromCharCode(int encoding, FX_DWORD charcode); 1065 extern FX_WCHAR FT_UnicodeFromCharCode(int encoding, FX_DWORD charcode);
1066 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 1066 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
1067 #include "../../fxge/apple/apple_int.h" 1067 #include "../../fxge/apple/apple_int.h"
1068 #endif 1068 #endif
1069 int CPDF_Type1Font::GlyphFromCharCodeExt(FX_DWORD charcode) 1069 int CPDF_Type1Font::GlyphFromCharCodeExt(FX_DWORD charcode)
1070 { 1070 {
1071 if (charcode > 0xff) { 1071 if (charcode > 0xff) {
1072 return -1; 1072 return -1;
1073 } 1073 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 } 1105 }
1106 return NULL; 1106 return NULL;
1107 } 1107 }
1108 #endif 1108 #endif
1109 void CPDF_Type1Font::LoadGlyphMap() 1109 void CPDF_Type1Font::LoadGlyphMap()
1110 { 1110 {
1111 if (m_Font.m_Face == NULL) { 1111 if (m_Font.m_Face == NULL) {
1112 return; 1112 return;
1113 } 1113 }
1114 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 1114 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
1115 FX_BOOL bCoreText = TRUE; 1115 bool bCoreText = true;
1116 CQuartz2D & quartz2d = ((CApplePlatform *) CFX_GEModule::Get()->GetPlatformD ata())->_quartz2d; 1116 CQuartz2D & quartz2d = ((CApplePlatform *) CFX_GEModule::Get()->GetPlatformD ata())->_quartz2d;
1117 if (!m_Font.m_pPlatformFont) { 1117 if (!m_Font.m_pPlatformFont) {
1118 if (m_Font.GetPsName() == CFX_WideString::FromLocal("DFHeiStd-W5")) { 1118 if (m_Font.GetPsName() == CFX_WideString::FromLocal("DFHeiStd-W5")) {
1119 bCoreText = FALSE; 1119 bCoreText = false;
1120 } 1120 }
1121 m_Font.m_pPlatformFont = quartz2d.CreateFont(m_Font.m_pFontData, m_Font. m_dwSize); 1121 m_Font.m_pPlatformFont = quartz2d.CreateFont(m_Font.m_pFontData, m_Font. m_dwSize);
1122 if (NULL == m_Font.m_pPlatformFont) { 1122 if (NULL == m_Font.m_pPlatformFont) {
1123 bCoreText = FALSE; 1123 bCoreText = false;
1124 } 1124 }
1125 } 1125 }
1126 #endif 1126 #endif
1127 if (!IsEmbedded() && (m_Base14Font < 12) && m_Font.IsTTFont()) { 1127 if (!IsEmbedded() && (m_Base14Font < 12) && m_Font.IsTTFont()) {
1128 if (FT_UseTTCharmap(m_Font.m_Face, 3, 0)) { 1128 if (FT_UseTTCharmap(m_Font.m_Face, 3, 0)) {
1129 FX_BOOL bGotOne = FALSE; 1129 bool bGotOne = false;
1130 for (int charcode = 0; charcode < 256; charcode ++) { 1130 for (int charcode = 0; charcode < 256; charcode ++) {
1131 const uint8_t prefix[4] = {0x00, 0xf0, 0xf1, 0xf2}; 1131 const uint8_t prefix[4] = {0x00, 0xf0, 0xf1, 0xf2};
1132 for (int j = 0; j < 4; j ++) { 1132 for (int j = 0; j < 4; j ++) {
1133 FX_WORD unicode = prefix[j] * 256 + charcode; 1133 FX_WORD unicode = prefix[j] * 256 + charcode;
1134 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face, unicode); 1134 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face, unicode);
1135 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 1135 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
1136 FX_CHAR name_glyph[256]; 1136 FX_CHAR name_glyph[256];
1137 FXFT_Get_Glyph_Name(m_Font.m_Face, m_GlyphIndex[charcode], n ame_glyph, 256); 1137 FXFT_Get_Glyph_Name(m_Font.m_Face, m_GlyphIndex[charcode], n ame_glyph, 256);
1138 name_glyph[255] = 0; 1138 name_glyph[255] = 0;
1139 CFStringRef name_ct = CFStringCreateWithCStringNoCopy(kCFAll ocatorDefault, name_glyph, kCFStringEncodingASCII, kCFAllocatorNull); 1139 CFStringRef name_ct = CFStringCreateWithCStringNoCopy(kCFAll ocatorDefault, name_glyph, kCFStringEncodingASCII, kCFAllocatorNull);
1140 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName((CGFontRef) m_Font.m_pPlatformFont, name_ct); 1140 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName((CGFontRef) m_Font.m_pPlatformFont, name_ct);
1141 if (name_ct) { 1141 if (name_ct) {
1142 CFRelease(name_ct); 1142 CFRelease(name_ct);
1143 } 1143 }
1144 #endif 1144 #endif
1145 if (m_GlyphIndex[charcode]) { 1145 if (m_GlyphIndex[charcode]) {
1146 bGotOne = TRUE; 1146 bGotOne = true;
1147 break; 1147 break;
1148 } 1148 }
1149 } 1149 }
1150 } 1150 }
1151 if (bGotOne) { 1151 if (bGotOne) {
1152 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 1152 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
1153 if (!bCoreText) { 1153 if (!bCoreText) {
1154 FXSYS_memcpy(m_ExtGID, m_GlyphIndex, 256); 1154 FXSYS_memcpy(m_ExtGID, m_GlyphIndex, 256);
1155 } 1155 }
1156 #endif 1156 #endif
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1230 m_Encoding.m_Unicodes[charcode] = unicode; 1230 m_Encoding.m_Unicodes[charcode] = unicode;
1231 CFStringRef name_ct = CFStringCreateWithCStringNoCopy(kCFAll ocatorDefault, name_glyph, kCFStringEncodingASCII, kCFAllocatorNull); 1231 CFStringRef name_ct = CFStringCreateWithCStringNoCopy(kCFAll ocatorDefault, name_glyph, kCFStringEncodingASCII, kCFAllocatorNull);
1232 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName((CGFontRef) m_Font.m_pPlatformFont, name_ct); 1232 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName((CGFontRef) m_Font.m_pPlatformFont, name_ct);
1233 if (name_ct) { 1233 if (name_ct) {
1234 CFRelease(name_ct); 1234 CFRelease(name_ct);
1235 } 1235 }
1236 } 1236 }
1237 } 1237 }
1238 return; 1238 return;
1239 } 1239 }
1240 FX_BOOL bUnicode = FALSE; 1240 bool bUnicode = false;
1241 if (0 == FXFT_Select_Charmap(m_Font.m_Face, FXFT_ENCODING_UNICODE)) { 1241 if (0 == FXFT_Select_Charmap(m_Font.m_Face, FXFT_ENCODING_UNICODE)) {
1242 bUnicode = TRUE; 1242 bUnicode = true;
1243 } 1243 }
1244 for (int charcode = 0; charcode < 256; charcode ++) { 1244 for (int charcode = 0; charcode < 256; charcode ++) {
1245 const FX_CHAR* name = GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); 1245 const FX_CHAR* name = GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode);
1246 if (name == NULL) { 1246 if (name == NULL) {
1247 continue; 1247 continue;
1248 } 1248 }
1249 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); 1249 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name);
1250 const FX_CHAR* pStrUnicode = _GlyphNameRemap(name); 1250 const FX_CHAR* pStrUnicode = _GlyphNameRemap(name);
1251 if (pStrUnicode && 0 == FXFT_Get_Name_Index(m_Font.m_Face, (char*)na me)) { 1251 if (pStrUnicode && 0 == FXFT_Get_Name_Index(m_Font.m_Face, (char*)na me)) {
1252 name = pStrUnicode; 1252 name = pStrUnicode;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1308 } 1308 }
1309 } 1309 }
1310 } 1310 }
1311 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 1311 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
1312 if (!bCoreText) { 1312 if (!bCoreText) {
1313 FXSYS_memcpy(m_ExtGID, m_GlyphIndex, 256); 1313 FXSYS_memcpy(m_ExtGID, m_GlyphIndex, 256);
1314 } 1314 }
1315 #endif 1315 #endif
1316 return; 1316 return;
1317 } 1317 }
1318 FX_BOOL bUnicode = FALSE; 1318 bool bUnicode = false;
1319 if (0 == FXFT_Select_Charmap(m_Font.m_Face, FXFT_ENCODING_UNICODE)) { 1319 if (0 == FXFT_Select_Charmap(m_Font.m_Face, FXFT_ENCODING_UNICODE)) {
1320 bUnicode = TRUE; 1320 bUnicode = true;
1321 } 1321 }
1322 for (int charcode = 0; charcode < 256; charcode ++) { 1322 for (int charcode = 0; charcode < 256; charcode ++) {
1323 const FX_CHAR* name = GetAdobeCharName(m_BaseEncoding, m_pCharNames, cha rcode); 1323 const FX_CHAR* name = GetAdobeCharName(m_BaseEncoding, m_pCharNames, cha rcode);
1324 if (name == NULL) { 1324 if (name == NULL) {
1325 continue; 1325 continue;
1326 } 1326 }
1327 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); 1327 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name);
1328 m_GlyphIndex[charcode] = FXFT_Get_Name_Index(m_Font.m_Face, (char*)name) ; 1328 m_GlyphIndex[charcode] = FXFT_Get_Name_Index(m_Font.m_Face, (char*)name) ;
1329 if (m_GlyphIndex[charcode] == 0) { 1329 if (m_GlyphIndex[charcode] == 0) {
1330 if (FXSYS_strcmp(name, ".notdef") != 0 && FXSYS_strcmp(name, "space" ) != 0) { 1330 if (FXSYS_strcmp(name, ".notdef") != 0 && FXSYS_strcmp(name, "space" ) != 0) {
(...skipping 25 matching lines...) Expand all
1356 CPDF_FontEncoding::CPDF_FontEncoding(int PredefinedEncoding) 1356 CPDF_FontEncoding::CPDF_FontEncoding(int PredefinedEncoding)
1357 { 1357 {
1358 const FX_WORD* pSrc = PDF_UnicodesForPredefinedCharSet(PredefinedEncoding); 1358 const FX_WORD* pSrc = PDF_UnicodesForPredefinedCharSet(PredefinedEncoding);
1359 if (!pSrc) { 1359 if (!pSrc) {
1360 FXSYS_memset(m_Unicodes, 0, sizeof(m_Unicodes)); 1360 FXSYS_memset(m_Unicodes, 0, sizeof(m_Unicodes));
1361 } else 1361 } else
1362 for (int i = 0; i < 256; i++) { 1362 for (int i = 0; i < 256; i++) {
1363 m_Unicodes[i] = pSrc[i]; 1363 m_Unicodes[i] = pSrc[i];
1364 } 1364 }
1365 } 1365 }
1366 FX_BOOL CPDF_FontEncoding::IsIdentical(CPDF_FontEncoding* pAnother) const 1366 bool CPDF_FontEncoding::IsIdentical(CPDF_FontEncoding* pAnother) const
1367 { 1367 {
1368 return FXSYS_memcmp(m_Unicodes, pAnother->m_Unicodes, sizeof(m_Unicodes)) == 0; 1368 return FXSYS_memcmp(m_Unicodes, pAnother->m_Unicodes, sizeof(m_Unicodes)) == 0;
1369 } 1369 }
1370 CPDF_Object* CPDF_FontEncoding::Realize() 1370 CPDF_Object* CPDF_FontEncoding::Realize()
1371 { 1371 {
1372 int predefined = 0; 1372 int predefined = 0;
1373 for (int cs = PDFFONT_ENCODING_WINANSI; cs < PDFFONT_ENCODING_ZAPFDINGBATS; cs ++) { 1373 for (int cs = PDFFONT_ENCODING_WINANSI; cs < PDFFONT_ENCODING_ZAPFDINGBATS; cs ++) {
1374 const FX_WORD* pSrc = PDF_UnicodesForPredefinedCharSet(cs); 1374 const FX_WORD* pSrc = PDF_UnicodesForPredefinedCharSet(cs);
1375 FX_BOOL match = TRUE; 1375 bool match = true;
1376 for (int i = 0; i < 256; ++i) { 1376 for (int i = 0; i < 256; ++i) {
1377 if (m_Unicodes[i] != pSrc[i]) { 1377 if (m_Unicodes[i] != pSrc[i]) {
1378 match = FALSE; 1378 match = false;
1379 break; 1379 break;
1380 } 1380 }
1381 } 1381 }
1382 if (match) { 1382 if (match) {
1383 predefined = cs; 1383 predefined = cs;
1384 break; 1384 break;
1385 } 1385 }
1386 } 1386 }
1387 if (predefined) { 1387 if (predefined) {
1388 if (predefined == PDFFONT_ENCODING_WINANSI) { 1388 if (predefined == PDFFONT_ENCODING_WINANSI) {
(...skipping 17 matching lines...) Expand all
1406 } 1406 }
1407 pDiff->Add(CPDF_Number::Create(i)); 1407 pDiff->Add(CPDF_Number::Create(i));
1408 pDiff->Add(CPDF_Name::Create(PDF_AdobeNameFromUnicode(m_Unicodes[i]))); 1408 pDiff->Add(CPDF_Name::Create(PDF_AdobeNameFromUnicode(m_Unicodes[i])));
1409 } 1409 }
1410 pDict->SetAt(FX_BSTRC("Differences"), pDiff); 1410 pDict->SetAt(FX_BSTRC("Differences"), pDiff);
1411 return pDict; 1411 return pDict;
1412 } 1412 }
1413 CPDF_TrueTypeFont::CPDF_TrueTypeFont() : CPDF_SimpleFont(PDFFONT_TRUETYPE) 1413 CPDF_TrueTypeFont::CPDF_TrueTypeFont() : CPDF_SimpleFont(PDFFONT_TRUETYPE)
1414 { 1414 {
1415 } 1415 }
1416 FX_BOOL CPDF_TrueTypeFont::_Load() 1416 bool CPDF_TrueTypeFont::_Load()
1417 { 1417 {
1418 return LoadCommon(); 1418 return LoadCommon();
1419 } 1419 }
1420 void CPDF_TrueTypeFont::LoadGlyphMap() 1420 void CPDF_TrueTypeFont::LoadGlyphMap()
1421 { 1421 {
1422 if (m_Font.m_Face == NULL) { 1422 if (m_Font.m_Face == NULL) {
1423 return; 1423 return;
1424 } 1424 }
1425 int baseEncoding = m_BaseEncoding; 1425 int baseEncoding = m_BaseEncoding;
1426 if (m_pFontFile && m_Font.m_Face->num_charmaps > 0 1426 if (m_pFontFile && m_Font.m_Face->num_charmaps > 0
1427 && (baseEncoding == PDFFONT_ENCODING_MACROMAN || baseEncoding == PDF FONT_ENCODING_WINANSI) 1427 && (baseEncoding == PDFFONT_ENCODING_MACROMAN || baseEncoding == PDF FONT_ENCODING_WINANSI)
1428 && (m_Flags & PDFFONT_SYMBOLIC)) { 1428 && (m_Flags & PDFFONT_SYMBOLIC)) {
1429 FX_BOOL bSupportWin = FALSE; 1429 bool bSupportWin = false;
1430 FX_BOOL bSupportMac = FALSE; 1430 bool bSupportMac = false;
1431 for (int i = 0; i < FXFT_Get_Face_CharmapCount(m_Font.m_Face); i++) { 1431 for (int i = 0; i < FXFT_Get_Face_CharmapCount(m_Font.m_Face); i++) {
1432 int platform_id = FXFT_Get_Charmap_PlatformID(FXFT_Get_Face_Charmaps (m_Font.m_Face)[i]); 1432 int platform_id = FXFT_Get_Charmap_PlatformID(FXFT_Get_Face_Charmaps (m_Font.m_Face)[i]);
1433 if (platform_id == 0 || platform_id == 3) { 1433 if (platform_id == 0 || platform_id == 3) {
1434 bSupportWin = TRUE; 1434 bSupportWin = true;
1435 } else if (platform_id == 0 || platform_id == 1) { 1435 } else if (platform_id == 0 || platform_id == 1) {
1436 bSupportMac = TRUE; 1436 bSupportMac = true;
1437 } 1437 }
1438 } 1438 }
1439 if (baseEncoding == PDFFONT_ENCODING_WINANSI && !bSupportWin) { 1439 if (baseEncoding == PDFFONT_ENCODING_WINANSI && !bSupportWin) {
1440 baseEncoding = bSupportMac ? PDFFONT_ENCODING_MACROMAN : PDFFONT_ENC ODING_BUILTIN; 1440 baseEncoding = bSupportMac ? PDFFONT_ENCODING_MACROMAN : PDFFONT_ENC ODING_BUILTIN;
1441 } else if (baseEncoding == PDFFONT_ENCODING_MACROMAN && !bSupportMac) { 1441 } else if (baseEncoding == PDFFONT_ENCODING_MACROMAN && !bSupportMac) {
1442 baseEncoding = bSupportWin ? PDFFONT_ENCODING_WINANSI : PDFFONT_ENCO DING_BUILTIN; 1442 baseEncoding = bSupportWin ? PDFFONT_ENCODING_WINANSI : PDFFONT_ENCO DING_BUILTIN;
1443 } 1443 }
1444 } 1444 }
1445 if (((baseEncoding == PDFFONT_ENCODING_MACROMAN || baseEncoding == PDFFONT_E NCODING_WINANSI) 1445 if (((baseEncoding == PDFFONT_ENCODING_MACROMAN || baseEncoding == PDFFONT_E NCODING_WINANSI)
1446 && m_pCharNames == NULL) || (m_Flags & PDFFONT_NONSYMBOLIC)) { 1446 && m_pCharNames == NULL) || (m_Flags & PDFFONT_NONSYMBOLIC)) {
1447 if (!FXFT_Has_Glyph_Names(m_Font.m_Face) && (!m_Font.m_Face->num_charmap s || !m_Font.m_Face->charmaps)) { 1447 if (!FXFT_Has_Glyph_Names(m_Font.m_Face) && (!m_Font.m_Face->num_charmap s || !m_Font.m_Face->charmaps)) {
1448 int nStartChar = m_pFontDict->GetInteger(FX_BSTRC("FirstChar")); 1448 int nStartChar = m_pFontDict->GetInteger(FX_BSTRC("FirstChar"));
1449 if(nStartChar < 0 || nStartChar > 255) 1449 if(nStartChar < 0 || nStartChar > 255)
1450 return; 1450 return;
1451 1451
1452 int charcode = 0; 1452 int charcode = 0;
1453 for (; charcode < nStartChar; charcode ++) { 1453 for (; charcode < nStartChar; charcode ++) {
1454 m_GlyphIndex[charcode] = 0; 1454 m_GlyphIndex[charcode] = 0;
1455 } 1455 }
1456 FX_WORD nGlyph = charcode - nStartChar + 3; 1456 FX_WORD nGlyph = charcode - nStartChar + 3;
1457 for (; charcode < 256; charcode ++, nGlyph ++) { 1457 for (; charcode < 256; charcode ++, nGlyph ++) {
1458 m_GlyphIndex[charcode] = nGlyph; 1458 m_GlyphIndex[charcode] = nGlyph;
1459 } 1459 }
1460 return; 1460 return;
1461 } 1461 }
1462 FX_BOOL bMSUnicode = FT_UseTTCharmap(m_Font.m_Face, 3, 1); 1462 bool bMSUnicode = FT_UseTTCharmap(m_Font.m_Face, 3, 1);
1463 FX_BOOL bMacRoman = FALSE, bMSSymbol = FALSE; 1463 bool bMacRoman = false, bMSSymbol = false;
1464 if (!bMSUnicode) { 1464 if (!bMSUnicode) {
1465 if (m_Flags & PDFFONT_NONSYMBOLIC) { 1465 if (m_Flags & PDFFONT_NONSYMBOLIC) {
1466 bMacRoman = FT_UseTTCharmap(m_Font.m_Face, 1, 0); 1466 bMacRoman = FT_UseTTCharmap(m_Font.m_Face, 1, 0);
1467 bMSSymbol = !bMacRoman && FT_UseTTCharmap(m_Font.m_Face, 3, 0); 1467 bMSSymbol = !bMacRoman && FT_UseTTCharmap(m_Font.m_Face, 3, 0);
1468 } else { 1468 } else {
1469 bMSSymbol = FT_UseTTCharmap(m_Font.m_Face, 3, 0); 1469 bMSSymbol = FT_UseTTCharmap(m_Font.m_Face, 3, 0);
1470 bMacRoman = !bMSSymbol && FT_UseTTCharmap(m_Font.m_Face, 1, 0); 1470 bMacRoman = !bMSSymbol && FT_UseTTCharmap(m_Font.m_Face, 1, 0);
1471 } 1471 }
1472 } 1472 }
1473 FX_BOOL bToUnicode = m_pFontDict->KeyExist(FX_BSTRC("ToUnicode")); 1473 bool bToUnicode = m_pFontDict->KeyExist(FX_BSTRC("ToUnicode"));
1474 for (int charcode = 0; charcode < 256; charcode ++) { 1474 for (int charcode = 0; charcode < 256; charcode ++) {
1475 const FX_CHAR* name = GetAdobeCharName(baseEncoding, m_pCharNames, c harcode); 1475 const FX_CHAR* name = GetAdobeCharName(baseEncoding, m_pCharNames, c harcode);
1476 if (name == NULL) { 1476 if (name == NULL) {
1477 m_GlyphIndex[charcode] = m_pFontFile ? FXFT_Get_Char_Index(m_Fon t.m_Face, charcode) : -1; 1477 m_GlyphIndex[charcode] = m_pFontFile ? FXFT_Get_Char_Index(m_Fon t.m_Face, charcode) : -1;
1478 continue; 1478 continue;
1479 } 1479 }
1480 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); 1480 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name);
1481 if (bMSSymbol) { 1481 if (bMSSymbol) {
1482 const uint8_t prefix[4] = {0x00, 0xf0, 0xf1, 0xf2}; 1482 const uint8_t prefix[4] = {0x00, 0xf0, 0xf1, 0xf2};
1483 for (int j = 0; j < 4; j ++) { 1483 for (int j = 0; j < 4; j ++) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1516 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font. m_Face, charcode); 1516 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font. m_Face, charcode);
1517 } 1517 }
1518 } 1518 }
1519 } 1519 }
1520 } 1520 }
1521 } 1521 }
1522 return; 1522 return;
1523 } 1523 }
1524 if (FT_UseTTCharmap(m_Font.m_Face, 3, 0)) { 1524 if (FT_UseTTCharmap(m_Font.m_Face, 3, 0)) {
1525 const uint8_t prefix[4] = {0x00, 0xf0, 0xf1, 0xf2}; 1525 const uint8_t prefix[4] = {0x00, 0xf0, 0xf1, 0xf2};
1526 FX_BOOL bGotOne = FALSE; 1526 bool bGotOne = false;
1527 for (int charcode = 0; charcode < 256; charcode ++) { 1527 for (int charcode = 0; charcode < 256; charcode ++) {
1528 for (int j = 0; j < 4; j ++) { 1528 for (int j = 0; j < 4; j ++) {
1529 FX_WORD unicode = prefix[j] * 256 + charcode; 1529 FX_WORD unicode = prefix[j] * 256 + charcode;
1530 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face, unic ode); 1530 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face, unic ode);
1531 if (m_GlyphIndex[charcode]) { 1531 if (m_GlyphIndex[charcode]) {
1532 bGotOne = TRUE; 1532 bGotOne = true;
1533 break; 1533 break;
1534 } 1534 }
1535 } 1535 }
1536 } 1536 }
1537 if (bGotOne) { 1537 if (bGotOne) {
1538 if (baseEncoding != PDFFONT_ENCODING_BUILTIN) { 1538 if (baseEncoding != PDFFONT_ENCODING_BUILTIN) {
1539 for (int charcode = 0; charcode < 256; charcode ++) { 1539 for (int charcode = 0; charcode < 256; charcode ++) {
1540 const FX_CHAR* name = GetAdobeCharName(baseEncoding, m_pChar Names, charcode); 1540 const FX_CHAR* name = GetAdobeCharName(baseEncoding, m_pChar Names, charcode);
1541 if (name == NULL) { 1541 if (name == NULL) {
1542 continue; 1542 continue;
1543 } 1543 }
1544 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(n ame); 1544 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(n ame);
1545 } 1545 }
1546 } else if (FT_UseTTCharmap(m_Font.m_Face, 1, 0)) { 1546 } else if (FT_UseTTCharmap(m_Font.m_Face, 1, 0)) {
1547 for (int charcode = 0; charcode < 256; charcode ++) { 1547 for (int charcode = 0; charcode < 256; charcode ++) {
1548 m_Encoding.m_Unicodes[charcode] = FT_UnicodeFromCharCode(FXF T_ENCODING_APPLE_ROMAN, charcode); 1548 m_Encoding.m_Unicodes[charcode] = FT_UnicodeFromCharCode(FXF T_ENCODING_APPLE_ROMAN, charcode);
1549 } 1549 }
1550 } 1550 }
1551 return; 1551 return;
1552 } 1552 }
1553 } 1553 }
1554 if (FT_UseTTCharmap(m_Font.m_Face, 1, 0)) { 1554 if (FT_UseTTCharmap(m_Font.m_Face, 1, 0)) {
1555 FX_BOOL bGotOne = FALSE; 1555 bool bGotOne = false;
1556 for (int charcode = 0; charcode < 256; charcode ++) { 1556 for (int charcode = 0; charcode < 256; charcode ++) {
1557 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face, charcode ); 1557 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face, charcode );
1558 m_Encoding.m_Unicodes[charcode] = FT_UnicodeFromCharCode(FXFT_ENCODI NG_APPLE_ROMAN, charcode); 1558 m_Encoding.m_Unicodes[charcode] = FT_UnicodeFromCharCode(FXFT_ENCODI NG_APPLE_ROMAN, charcode);
1559 if (m_GlyphIndex[charcode]) { 1559 if (m_GlyphIndex[charcode]) {
1560 bGotOne = TRUE; 1560 bGotOne = true;
1561 } 1561 }
1562 } 1562 }
1563 if (m_pFontFile || bGotOne) { 1563 if (m_pFontFile || bGotOne) {
1564 return; 1564 return;
1565 } 1565 }
1566 } 1566 }
1567 if (FXFT_Select_Charmap(m_Font.m_Face, FXFT_ENCODING_UNICODE) == 0) { 1567 if (FXFT_Select_Charmap(m_Font.m_Face, FXFT_ENCODING_UNICODE) == 0) {
1568 FX_BOOL bGotOne = FALSE; 1568 bool bGotOne = false;
1569 const FX_WORD* pUnicodes = PDF_UnicodesForPredefinedCharSet(baseEncoding ); 1569 const FX_WORD* pUnicodes = PDF_UnicodesForPredefinedCharSet(baseEncoding );
1570 for (int charcode = 0; charcode < 256; charcode ++) { 1570 for (int charcode = 0; charcode < 256; charcode ++) {
1571 if (m_pFontFile == NULL) { 1571 if (m_pFontFile == NULL) {
1572 const FX_CHAR* name = GetAdobeCharName(0, m_pCharNames, charcode ); 1572 const FX_CHAR* name = GetAdobeCharName(0, m_pCharNames, charcode );
1573 if (name != NULL) { 1573 if (name != NULL) {
1574 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(n ame); 1574 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(n ame);
1575 } else if (pUnicodes) { 1575 } else if (pUnicodes) {
1576 m_Encoding.m_Unicodes[charcode] = pUnicodes[charcode]; 1576 m_Encoding.m_Unicodes[charcode] = pUnicodes[charcode];
1577 } 1577 }
1578 } else { 1578 } else {
1579 m_Encoding.m_Unicodes[charcode] = charcode; 1579 m_Encoding.m_Unicodes[charcode] = charcode;
1580 } 1580 }
1581 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face, m_Encodi ng.m_Unicodes[charcode]); 1581 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.m_Face, m_Encodi ng.m_Unicodes[charcode]);
1582 if (m_GlyphIndex[charcode]) { 1582 if (m_GlyphIndex[charcode]) {
1583 bGotOne = TRUE; 1583 bGotOne = true;
1584 } 1584 }
1585 } 1585 }
1586 if (bGotOne) { 1586 if (bGotOne) {
1587 return; 1587 return;
1588 } 1588 }
1589 } 1589 }
1590 for (int charcode = 0; charcode < 256; charcode ++) { 1590 for (int charcode = 0; charcode < 256; charcode ++) {
1591 m_GlyphIndex[charcode] = charcode; 1591 m_GlyphIndex[charcode] = charcode;
1592 } 1592 }
1593 } 1593 }
(...skipping 13 matching lines...) Expand all
1607 } 1607 }
1608 m_CacheMap.RemoveAll(); 1608 m_CacheMap.RemoveAll();
1609 pos = m_DeletedMap.GetStartPosition(); 1609 pos = m_DeletedMap.GetStartPosition();
1610 while (pos) { 1610 while (pos) {
1611 void* key; 1611 void* key;
1612 void* value; 1612 void* value;
1613 m_DeletedMap.GetNextAssoc(pos, key, value); 1613 m_DeletedMap.GetNextAssoc(pos, key, value);
1614 delete (CPDF_Type3Char*)key; 1614 delete (CPDF_Type3Char*)key;
1615 } 1615 }
1616 } 1616 }
1617 FX_BOOL CPDF_Type3Font::_Load() 1617 bool CPDF_Type3Font::_Load()
1618 { 1618 {
1619 m_pFontResources = m_pFontDict->GetDict(FX_BSTRC("Resources")); 1619 m_pFontResources = m_pFontDict->GetDict(FX_BSTRC("Resources"));
1620 CPDF_Array* pMatrix = m_pFontDict->GetArray(FX_BSTRC("FontMatrix")); 1620 CPDF_Array* pMatrix = m_pFontDict->GetArray(FX_BSTRC("FontMatrix"));
1621 FX_FLOAT xscale = 1.0f, yscale = 1.0f; 1621 FX_FLOAT xscale = 1.0f, yscale = 1.0f;
1622 if (pMatrix) { 1622 if (pMatrix) {
1623 m_FontMatrix = pMatrix->GetMatrix(); 1623 m_FontMatrix = pMatrix->GetMatrix();
1624 xscale = m_FontMatrix.a; 1624 xscale = m_FontMatrix.a;
1625 yscale = m_FontMatrix.d; 1625 yscale = m_FontMatrix.d;
1626 } 1626 }
1627 CPDF_Array* pBBox = m_pFontDict->GetArray(FX_BSTRC("FontBBox")); 1627 CPDF_Array* pBBox = m_pFontDict->GetArray(FX_BSTRC("FontBBox"));
(...skipping 13 matching lines...) Expand all
1641 if (StartChar + count > 256) { 1641 if (StartChar + count > 256) {
1642 count = 256 - StartChar; 1642 count = 256 - StartChar;
1643 } 1643 }
1644 for (FX_DWORD i = 0; i < count; i ++) { 1644 for (FX_DWORD i = 0; i < count; i ++) {
1645 m_CharWidthL[StartChar + i] = FXSYS_round(FXSYS_Mul(pWidthArray->Get Number(i), xscale) * 1000); 1645 m_CharWidthL[StartChar + i] = FXSYS_round(FXSYS_Mul(pWidthArray->Get Number(i), xscale) * 1000);
1646 } 1646 }
1647 } 1647 }
1648 m_pCharProcs = m_pFontDict->GetDict(FX_BSTRC("CharProcs")); 1648 m_pCharProcs = m_pFontDict->GetDict(FX_BSTRC("CharProcs"));
1649 CPDF_Object* pEncoding = m_pFontDict->GetElementValue(FX_BSTRC("Encoding")); 1649 CPDF_Object* pEncoding = m_pFontDict->GetElementValue(FX_BSTRC("Encoding"));
1650 if (pEncoding) { 1650 if (pEncoding) {
1651 LoadPDFEncoding(pEncoding, m_BaseEncoding, m_pCharNames, FALSE, FALSE); 1651 LoadPDFEncoding(pEncoding, m_BaseEncoding, m_pCharNames, false, false);
1652 if (m_pCharNames) { 1652 if (m_pCharNames) {
1653 for (int i = 0; i < 256; i ++) { 1653 for (int i = 0; i < 256; i ++) {
1654 m_Encoding.m_Unicodes[i] = PDF_UnicodeFromAdobeName(m_pCharNames [i]); 1654 m_Encoding.m_Unicodes[i] = PDF_UnicodeFromAdobeName(m_pCharNames [i]);
1655 if (m_Encoding.m_Unicodes[i] == 0) { 1655 if (m_Encoding.m_Unicodes[i] == 0) {
1656 m_Encoding.m_Unicodes[i] = i; 1656 m_Encoding.m_Unicodes[i] = i;
1657 } 1657 }
1658 } 1658 }
1659 } 1659 }
1660 } 1660 }
1661 return TRUE; 1661 return true;
1662 } 1662 }
1663 void CPDF_Type3Font::CheckType3FontMetrics() 1663 void CPDF_Type3Font::CheckType3FontMetrics()
1664 { 1664 {
1665 CheckFontMetrics(); 1665 CheckFontMetrics();
1666 } 1666 }
1667 CPDF_Type3Char* CPDF_Type3Font::LoadChar(FX_DWORD charcode, int level) 1667 CPDF_Type3Char* CPDF_Type3Font::LoadChar(FX_DWORD charcode, int level)
1668 { 1668 {
1669 if (level >= _FPDF_MAX_TYPE3_FORM_LEVEL_) { 1669 if (level >= _FPDF_MAX_TYPE3_FORM_LEVEL_) {
1670 return NULL; 1670 return NULL;
1671 } 1671 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1729 if (pChar == NULL) { 1729 if (pChar == NULL) {
1730 rect.left = rect.right = rect.top = rect.bottom = 0; 1730 rect.left = rect.right = rect.top = rect.bottom = 0;
1731 return; 1731 return;
1732 } 1732 }
1733 rect = pChar->m_BBox; 1733 rect = pChar->m_BBox;
1734 } 1734 }
1735 CPDF_Type3Char::CPDF_Type3Char() 1735 CPDF_Type3Char::CPDF_Type3Char()
1736 { 1736 {
1737 m_pForm = NULL; 1737 m_pForm = NULL;
1738 m_pBitmap = NULL; 1738 m_pBitmap = NULL;
1739 m_bPageRequired = FALSE; 1739 m_bPageRequired = false;
1740 m_bColored = FALSE; 1740 m_bColored = false;
1741 } 1741 }
1742 CPDF_Type3Char::~CPDF_Type3Char() 1742 CPDF_Type3Char::~CPDF_Type3Char()
1743 { 1743 {
1744 delete m_pForm; 1744 delete m_pForm;
1745 delete m_pBitmap; 1745 delete m_pBitmap;
1746 } 1746 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_font/font_int.h ('k') | core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698