Chromium Code Reviews| 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 <limits.h> | 7 #include <limits.h> |
| 8 | 8 |
| 9 #include <vector> | |
| 10 | |
| 9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" | 11 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" |
| 10 #include "core/fpdfapi/fpdf_font/include/cpdf_fontencoding.h" | 12 #include "core/fpdfapi/fpdf_font/include/cpdf_fontencoding.h" |
| 11 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" | 13 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" |
| 12 #include "core/fpdfapi/fpdf_page/pageint.h" | 14 #include "core/fpdfapi/fpdf_page/pageint.h" |
| 13 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 15 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
| 14 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" | 16 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" |
| 15 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 17 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
| 16 #include "core/fpdfapi/fpdf_parser/include/cpdf_reference.h" | 18 #include "core/fpdfapi/fpdf_parser/include/cpdf_reference.h" |
| 17 #include "core/fpdfapi/include/cpdf_modulemgr.h" | 19 #include "core/fpdfapi/include/cpdf_modulemgr.h" |
| 18 #include "core/fpdfapi/ipdf_rendermodule.h" | 20 #include "core/fpdfapi/ipdf_rendermodule.h" |
| 21 #include "third_party/base/stl_util.h" | |
| 19 | 22 |
| 20 CPDF_Document::CPDF_Document() : CPDF_IndirectObjectHolder(NULL) { | 23 CPDF_Document::CPDF_Document() : CPDF_IndirectObjectHolder(NULL) { |
| 21 m_pRootDict = NULL; | 24 m_pRootDict = NULL; |
| 22 m_pInfoDict = NULL; | 25 m_pInfoDict = NULL; |
| 23 m_bLinearized = FALSE; | 26 m_bLinearized = FALSE; |
| 24 m_dwFirstPageNo = 0; | 27 m_dwFirstPageNo = 0; |
| 25 m_dwFirstPageObjNum = 0; | 28 m_dwFirstPageObjNum = 0; |
| 26 m_pDocPage = CPDF_ModuleMgr::Get()->GetPageModule()->CreateDocData(this); | 29 m_pDocPage = CPDF_ModuleMgr::Get()->GetPageModule()->CreateDocData(this); |
| 27 m_pDocRender = CPDF_ModuleMgr::Get()->GetRenderModule()->CreateDocData(this); | 30 m_pDocRender = CPDF_ModuleMgr::Get()->GetRenderModule()->CreateDocData(this); |
| 28 } | 31 } |
| 29 void CPDF_Document::CreateNewDoc() { | 32 void CPDF_Document::CreateNewDoc() { |
| 30 ASSERT(!m_pRootDict && !m_pInfoDict); | 33 ASSERT(!m_pRootDict && !m_pInfoDict); |
| 31 m_pRootDict = new CPDF_Dictionary; | 34 m_pRootDict = new CPDF_Dictionary; |
| 32 m_pRootDict->SetAtName("Type", "Catalog"); | 35 m_pRootDict->SetAtName("Type", "Catalog"); |
| 33 int objnum = AddIndirectObject(m_pRootDict); | 36 int objnum = AddIndirectObject(m_pRootDict); |
| 34 CPDF_Dictionary* pPages = new CPDF_Dictionary; | 37 CPDF_Dictionary* pPages = new CPDF_Dictionary; |
| 35 pPages->SetAtName("Type", "Pages"); | 38 pPages->SetAtName("Type", "Pages"); |
| 36 pPages->SetAtNumber("Count", 0); | 39 pPages->SetAtNumber("Count", 0); |
| 37 pPages->SetAt("Kids", new CPDF_Array); | 40 pPages->SetAt("Kids", new CPDF_Array); |
| 38 objnum = AddIndirectObject(pPages); | 41 objnum = AddIndirectObject(pPages); |
| 39 m_pRootDict->SetAtReference("Pages", this, objnum); | 42 m_pRootDict->SetAtReference("Pages", this, objnum); |
| 40 m_pInfoDict = new CPDF_Dictionary; | 43 m_pInfoDict = new CPDF_Dictionary; |
| 41 AddIndirectObject(m_pInfoDict); | 44 AddIndirectObject(m_pInfoDict); |
| 42 } | 45 } |
| 43 static const uint16_t g_FX_CP874Unicodes[128] = { | 46 static const uint16_t g_FX_CP874Unicodes[128] = { |
|
Lei Zhang
2016/04/21 22:57:33
BTW, there's a bunch of 128s in the file.
| |
| 44 0x20AC, 0x0000, 0x0000, 0x0000, 0x0000, 0x2026, 0x0000, 0x0000, 0x0000, | 47 0x20AC, 0x0000, 0x0000, 0x0000, 0x0000, 0x2026, 0x0000, 0x0000, 0x0000, |
| 45 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2018, | 48 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2018, |
| 46 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, 0x0000, 0x0000, 0x0000, | 49 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, 0x0000, 0x0000, 0x0000, |
| 47 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00A0, 0x0E01, 0x0E02, 0x0E03, | 50 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00A0, 0x0E01, 0x0E02, 0x0E03, |
| 48 0x0E04, 0x0E05, 0x0E06, 0x0E07, 0x0E08, 0x0E09, 0x0E0A, 0x0E0B, 0x0E0C, | 51 0x0E04, 0x0E05, 0x0E06, 0x0E07, 0x0E08, 0x0E09, 0x0E0A, 0x0E0B, 0x0E0C, |
| 49 0x0E0D, 0x0E0E, 0x0E0F, 0x0E10, 0x0E11, 0x0E12, 0x0E13, 0x0E14, 0x0E15, | 52 0x0E0D, 0x0E0E, 0x0E0F, 0x0E10, 0x0E11, 0x0E12, 0x0E13, 0x0E14, 0x0E15, |
| 50 0x0E16, 0x0E17, 0x0E18, 0x0E19, 0x0E1A, 0x0E1B, 0x0E1C, 0x0E1D, 0x0E1E, | 53 0x0E16, 0x0E17, 0x0E18, 0x0E19, 0x0E1A, 0x0E1B, 0x0E1C, 0x0E1D, 0x0E1E, |
| 51 0x0E1F, 0x0E20, 0x0E21, 0x0E22, 0x0E23, 0x0E24, 0x0E25, 0x0E26, 0x0E27, | 54 0x0E1F, 0x0E20, 0x0E21, 0x0E22, 0x0E23, 0x0E24, 0x0E25, 0x0E26, 0x0E27, |
| 52 0x0E28, 0x0E29, 0x0E2A, 0x0E2B, 0x0E2C, 0x0E2D, 0x0E2E, 0x0E2F, 0x0E30, | 55 0x0E28, 0x0E29, 0x0E2A, 0x0E2B, 0x0E2C, 0x0E2D, 0x0E2E, 0x0E2F, 0x0E30, |
| 53 0x0E31, 0x0E32, 0x0E33, 0x0E34, 0x0E35, 0x0E36, 0x0E37, 0x0E38, 0x0E39, | 56 0x0E31, 0x0E32, 0x0E33, 0x0E34, 0x0E35, 0x0E36, 0x0E37, 0x0E38, 0x0E39, |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 169 0x00B6, 0x00B7, 0x00F8, 0x00B9, 0x0157, 0x00BB, 0x00BC, 0x00BD, 0x00BE, | 172 0x00B6, 0x00B7, 0x00F8, 0x00B9, 0x0157, 0x00BB, 0x00BC, 0x00BD, 0x00BE, |
| 170 0x00E6, 0x0104, 0x012E, 0x0100, 0x0106, 0x00C4, 0x00C5, 0x0118, 0x0112, | 173 0x00E6, 0x0104, 0x012E, 0x0100, 0x0106, 0x00C4, 0x00C5, 0x0118, 0x0112, |
| 171 0x010C, 0x00C9, 0x0179, 0x0116, 0x0122, 0x0136, 0x012A, 0x013B, 0x0160, | 174 0x010C, 0x00C9, 0x0179, 0x0116, 0x0122, 0x0136, 0x012A, 0x013B, 0x0160, |
| 172 0x0143, 0x0145, 0x00D3, 0x014C, 0x00D5, 0x00D6, 0x00D7, 0x0172, 0x0141, | 175 0x0143, 0x0145, 0x00D3, 0x014C, 0x00D5, 0x00D6, 0x00D7, 0x0172, 0x0141, |
| 173 0x015A, 0x016A, 0x00DC, 0x017B, 0x017D, 0x00DF, 0x0105, 0x012F, 0x0101, | 176 0x015A, 0x016A, 0x00DC, 0x017B, 0x017D, 0x00DF, 0x0105, 0x012F, 0x0101, |
| 174 0x0107, 0x00E4, 0x00E5, 0x0119, 0x0113, 0x010D, 0x00E9, 0x017A, 0x0117, | 177 0x0107, 0x00E4, 0x00E5, 0x0119, 0x0113, 0x010D, 0x00E9, 0x017A, 0x0117, |
| 175 0x0123, 0x0137, 0x012B, 0x013C, 0x0161, 0x0144, 0x0146, 0x00F3, 0x014D, | 178 0x0123, 0x0137, 0x012B, 0x013C, 0x0161, 0x0144, 0x0146, 0x00F3, 0x014D, |
| 176 0x00F5, 0x00F6, 0x00F7, 0x0173, 0x0142, 0x015B, 0x016B, 0x00FC, 0x017C, | 179 0x00F5, 0x00F6, 0x00F7, 0x0173, 0x0142, 0x015B, 0x016B, 0x00FC, 0x017C, |
| 177 0x017E, 0x02D9, | 180 0x017E, 0x02D9, |
| 178 }; | 181 }; |
| 179 typedef struct { | 182 |
| 183 struct FX_CharsetUnicodes { | |
| 180 uint8_t m_Charset; | 184 uint8_t m_Charset; |
| 181 const uint16_t* m_pUnicodes; | 185 const uint16_t* m_pUnicodes; |
| 182 } FX_CharsetUnicodes; | 186 }; |
| 187 | |
| 183 const FX_CharsetUnicodes g_FX_CharsetUnicodes[] = { | 188 const FX_CharsetUnicodes g_FX_CharsetUnicodes[] = { |
| 184 {FXFONT_THAI_CHARSET, g_FX_CP874Unicodes}, | 189 {FXFONT_THAI_CHARSET, g_FX_CP874Unicodes}, |
| 185 {FXFONT_EASTEUROPE_CHARSET, g_FX_CP1250Unicodes}, | 190 {FXFONT_EASTEUROPE_CHARSET, g_FX_CP1250Unicodes}, |
| 186 {FXFONT_RUSSIAN_CHARSET, g_FX_CP1251Unicodes}, | 191 {FXFONT_RUSSIAN_CHARSET, g_FX_CP1251Unicodes}, |
| 187 {FXFONT_GREEK_CHARSET, g_FX_CP1253Unicodes}, | 192 {FXFONT_GREEK_CHARSET, g_FX_CP1253Unicodes}, |
| 188 {FXFONT_TURKISH_CHARSET, g_FX_CP1254Unicodes}, | 193 {FXFONT_TURKISH_CHARSET, g_FX_CP1254Unicodes}, |
| 189 {FXFONT_HEBREW_CHARSET, g_FX_CP1255Unicodes}, | 194 {FXFONT_HEBREW_CHARSET, g_FX_CP1255Unicodes}, |
| 190 {FXFONT_ARABIC_CHARSET, g_FX_CP1256Unicodes}, | 195 {FXFONT_ARABIC_CHARSET, g_FX_CP1256Unicodes}, |
| 191 {FXFONT_BALTIC_CHARSET, g_FX_CP1257Unicodes}, | 196 {FXFONT_BALTIC_CHARSET, g_FX_CP1257Unicodes}, |
| 192 }; | 197 }; |
| 198 | |
| 193 #if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_) | 199 #if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_) |
| 194 static void _InsertWidthArray(HDC hDC, | 200 static void _InsertWidthArray(HDC hDC, |
| 195 int start, | 201 int start, |
| 196 int end, | 202 int end, |
| 197 CPDF_Array* pWidthArray) { | 203 CPDF_Array* pWidthArray) { |
| 198 int size = end - start + 1; | 204 int size = end - start + 1; |
| 199 int* widths = FX_Alloc(int, size); | 205 int* widths = FX_Alloc(int, size); |
| 200 GetCharWidth(hDC, start, end, widths); | 206 GetCharWidth(hDC, start, end, widths); |
| 201 int i; | 207 int i; |
| 202 for (i = 1; i < size; i++) | 208 for (i = 1; i < size; i++) |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 493 static void _CFString2CFXByteString(CFStringRef src, CFX_ByteString& dest) { | 499 static void _CFString2CFXByteString(CFStringRef src, CFX_ByteString& dest) { |
| 494 SInt32 len = CFStringGetLength(src); | 500 SInt32 len = CFStringGetLength(src); |
| 495 CFRange range = CFRangeMake(0, len); | 501 CFRange range = CFRangeMake(0, len); |
| 496 CFIndex used = 0; | 502 CFIndex used = 0; |
| 497 UInt8* pBuffer = (UInt8*)calloc(len + 1, sizeof(UInt8)); | 503 UInt8* pBuffer = (UInt8*)calloc(len + 1, sizeof(UInt8)); |
| 498 CFStringGetBytes(src, range, kCFStringEncodingASCII, 0, false, pBuffer, len, | 504 CFStringGetBytes(src, range, kCFStringEncodingASCII, 0, false, pBuffer, len, |
| 499 &used); | 505 &used); |
| 500 dest = (FX_CHAR*)pBuffer; | 506 dest = (FX_CHAR*)pBuffer; |
| 501 free(pBuffer); | 507 free(pBuffer); |
| 502 } | 508 } |
| 503 FX_BOOL IsHasCharSet(CFArrayRef languages, | 509 static bool IsHasCharSet(CFArrayRef languages, |
| 504 const CFX_ArrayTemplate<uint32_t>& charSets) { | 510 const std::vector<uint32_t>& charSets) { |
| 505 int iCount = charSets.GetSize(); | |
| 506 for (int i = 0; i < CFArrayGetCount(languages); ++i) { | 511 for (int i = 0; i < CFArrayGetCount(languages); ++i) { |
| 507 CFStringRef language = (CFStringRef)CFArrayGetValueAtIndex(languages, i); | 512 CFStringRef language = (CFStringRef)CFArrayGetValueAtIndex(languages, i); |
| 508 uint32_t CharSet = FX_GetCharsetFromLang( | 513 uint32_t CharSet = FX_GetCharsetFromLang( |
| 509 CFStringGetCStringPtr(language, kCFStringEncodingMacRoman), -1); | 514 CFStringGetCStringPtr(language, kCFStringEncodingMacRoman), -1); |
| 510 for (int j = 0; j < iCount; ++j) { | 515 if (pdfium::ContainsValue(charSets, CharSet)) |
| 511 if (CharSet == charSets[j]) { | 516 return true; |
| 512 return TRUE; | |
| 513 } | |
| 514 } | |
| 515 } | 517 } |
| 516 return FALSE; | 518 return false; |
| 517 } | 519 } |
| 518 void FX_GetCharWidth(CTFontRef font, UniChar start, UniChar end, int* width) { | 520 void FX_GetCharWidth(CTFontRef font, UniChar start, UniChar end, int* width) { |
| 519 CGFloat size = CTFontGetSize(font); | 521 CGFloat size = CTFontGetSize(font); |
| 520 for (; start <= end; ++start) { | 522 for (; start <= end; ++start) { |
| 521 CGGlyph pGlyph = 0; | 523 CGGlyph pGlyph = 0; |
| 522 CFIndex count = 1; | 524 CFIndex count = 1; |
| 523 CTFontGetGlyphsForCharacters(font, &start, &pGlyph, count); | 525 CTFontGetGlyphsForCharacters(font, &start, &pGlyph, count); |
| 524 CGSize advances; | 526 CGSize advances; |
| 525 CTFontGetAdvancesForGlyphs(font, kCTFontDefaultOrientation, &pGlyph, | 527 CTFontGetAdvancesForGlyphs(font, kCTFontDefaultOrientation, &pGlyph, |
| 526 &advances, 1); | 528 &advances, 1); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 555 } | 557 } |
| 556 CPDF_Font* CPDF_Document::AddMacFont(CTFontRef pFont, | 558 CPDF_Font* CPDF_Document::AddMacFont(CTFontRef pFont, |
| 557 FX_BOOL bVert, | 559 FX_BOOL bVert, |
| 558 FX_BOOL bTranslateName) { | 560 FX_BOOL bTranslateName) { |
| 559 CTFontRef font = (CTFontRef)pFont; | 561 CTFontRef font = (CTFontRef)pFont; |
| 560 CTFontDescriptorRef descriptor = CTFontCopyFontDescriptor(font); | 562 CTFontDescriptorRef descriptor = CTFontCopyFontDescriptor(font); |
| 561 if (!descriptor) { | 563 if (!descriptor) { |
| 562 return NULL; | 564 return NULL; |
| 563 } | 565 } |
| 564 CFX_ByteString basefont; | 566 CFX_ByteString basefont; |
| 565 FX_BOOL bCJK = FALSE; | |
| 566 int flags = 0, italicangle = 0, ascend = 0, descend = 0, capheight = 0, | 567 int flags = 0, italicangle = 0, ascend = 0, descend = 0, capheight = 0, |
| 567 bbox[4]; | 568 bbox[4]; |
| 568 FXSYS_memset(bbox, 0, sizeof(int) * 4); | 569 FXSYS_memset(bbox, 0, sizeof(int) * 4); |
| 569 CFArrayRef languages = (CFArrayRef)CTFontDescriptorCopyAttribute( | 570 CFArrayRef languages = (CFArrayRef)CTFontDescriptorCopyAttribute( |
| 570 descriptor, kCTFontLanguagesAttribute); | 571 descriptor, kCTFontLanguagesAttribute); |
| 571 if (!languages) { | 572 if (!languages) { |
| 572 CFRelease(descriptor); | 573 CFRelease(descriptor); |
| 573 return NULL; | 574 return NULL; |
| 574 } | 575 } |
| 575 CFX_ArrayTemplate<uint32_t> charSets; | 576 |
| 576 charSets.Add(FXFONT_CHINESEBIG5_CHARSET); | 577 bool bCJK = IsHasCharSet(languages, |
| 577 charSets.Add(FXFONT_GB2312_CHARSET); | 578 {FXFONT_CHINESEBIG5_CHARSET, FXFONT_GB2312_CHARSET, |
| 578 charSets.Add(FXFONT_HANGEUL_CHARSET); | 579 FXFONT_HANGEUL_CHARSET, FXFONT_SHIFTJIS_CHARSET}); |
| 579 charSets.Add(FXFONT_SHIFTJIS_CHARSET); | |
| 580 if (IsHasCharSet(languages, charSets)) { | |
| 581 bCJK = TRUE; | |
| 582 } | |
| 583 CFRelease(descriptor); | 580 CFRelease(descriptor); |
| 584 CFDictionaryRef traits = (CFDictionaryRef)CTFontCopyTraits(font); | 581 CFDictionaryRef traits = (CFDictionaryRef)CTFontCopyTraits(font); |
| 585 if (!traits) { | 582 if (!traits) { |
| 586 CFRelease(languages); | 583 CFRelease(languages); |
| 587 return NULL; | 584 return NULL; |
| 588 } | 585 } |
| 589 CFNumberRef sybolicTrait = | 586 CFNumberRef sybolicTrait = |
| 590 (CFNumberRef)CFDictionaryGetValue(traits, kCTFontSymbolicTrait); | 587 (CFNumberRef)CFDictionaryGetValue(traits, kCTFontSymbolicTrait); |
| 591 CTFontSymbolicTraits trait = 0; | 588 CTFontSymbolicTraits trait = 0; |
| 592 CFNumberGetValue(sybolicTrait, kCFNumberSInt32Type, &trait); | 589 CFNumberGetValue(sybolicTrait, kCFNumberSInt32Type, &trait); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 622 } | 619 } |
| 623 if (basefont.IsEmpty()) { | 620 if (basefont.IsEmpty()) { |
| 624 CFStringRef fullName = CTFontCopyFullName(font); | 621 CFStringRef fullName = CTFontCopyFullName(font); |
| 625 _CFString2CFXByteString(fullName, basefont); | 622 _CFString2CFXByteString(fullName, basefont); |
| 626 CFRelease(fullName); | 623 CFRelease(fullName); |
| 627 } | 624 } |
| 628 basefont.Replace(" ", ""); | 625 basefont.Replace(" ", ""); |
| 629 CPDF_Dictionary* pBaseDict = new CPDF_Dictionary; | 626 CPDF_Dictionary* pBaseDict = new CPDF_Dictionary; |
| 630 CPDF_Dictionary* pFontDict = pBaseDict; | 627 CPDF_Dictionary* pFontDict = pBaseDict; |
| 631 if (!bCJK) { | 628 if (!bCJK) { |
| 632 charSets.RemoveAll(); | 629 if (IsHasCharSet(languages, {FXFONT_ANSI_CHARSET, FXFONT_DEFAULT_CHARSET, |
| 633 charSets.Add(FXFONT_ANSI_CHARSET); | 630 FXFONT_SYMBOL_CHARSET})) { |
| 634 charSets.Add(FXFONT_DEFAULT_CHARSET); | 631 if (IsHasCharSet(languages, {FXFONT_SYMBOL_CHARSET})) { |
| 635 charSets.Add(FXFONT_SYMBOL_CHARSET); | |
| 636 if (IsHasCharSet(languages, charSets)) { | |
| 637 charSets.RemoveAll(); | |
| 638 charSets.Add(FXFONT_SYMBOL_CHARSET); | |
| 639 if (IsHasCharSet(languages, charSets)) { | |
| 640 flags |= PDFFONT_SYMBOLIC; | 632 flags |= PDFFONT_SYMBOLIC; |
| 641 } else { | 633 } else { |
| 642 flags |= PDFFONT_NONSYMBOLIC; | 634 flags |= PDFFONT_NONSYMBOLIC; |
| 643 } | 635 } |
| 644 pBaseDict->SetAtName("Encoding", "WinAnsiEncoding"); | 636 pBaseDict->SetAtName("Encoding", "WinAnsiEncoding"); |
| 645 } else { | 637 } else { |
| 646 flags |= PDFFONT_NONSYMBOLIC; | 638 flags |= PDFFONT_NONSYMBOLIC; |
| 647 size_t i; | 639 size_t i; |
| 648 for (i = 0; i < sizeof g_FX_CharsetUnicodes / sizeof(FX_CharsetUnicodes); | 640 for (i = 0; i < FX_ArraySize(g_FX_CharsetUnicodes); ++i) { |
| 649 i++) { | 641 if (IsHasCharSet(languages, {g_FX_CharsetUnicodes[i].m_Charset})) |
| 650 charSets.RemoveAll(); | |
| 651 charSets.Add(g_FX_CharsetUnicodes[i].m_Charset); | |
| 652 if (IsHasCharSet(languages, charSets)) { | |
| 653 break; | 642 break; |
| 654 } | |
| 655 } | 643 } |
| 656 if (i < sizeof g_FX_CharsetUnicodes / sizeof(FX_CharsetUnicodes)) { | 644 if (i < FX_ArraySize(g_FX_CharsetUnicodes)) { |
| 657 CPDF_Dictionary* pEncoding = new CPDF_Dictionary; | 645 CPDF_Dictionary* pEncoding = new CPDF_Dictionary; |
| 658 pEncoding->SetAtName("BaseEncoding", "WinAnsiEncoding"); | 646 pEncoding->SetAtName("BaseEncoding", "WinAnsiEncoding"); |
| 659 CPDF_Array* pArray = new CPDF_Array; | 647 CPDF_Array* pArray = new CPDF_Array; |
| 660 pArray->AddInteger(128); | 648 pArray->AddInteger(128); |
| 661 const uint16_t* pUnicodes = g_FX_CharsetUnicodes[i].m_pUnicodes; | 649 const uint16_t* pUnicodes = g_FX_CharsetUnicodes[i].m_pUnicodes; |
| 662 for (int j = 0; j < 128; j++) { | 650 for (int j = 0; j < 128; j++) { |
| 663 CFX_ByteString name = PDF_AdobeNameFromUnicode(pUnicodes[j]); | 651 CFX_ByteString name = PDF_AdobeNameFromUnicode(pUnicodes[j]); |
| 664 if (name.IsEmpty()) { | 652 if (name.IsEmpty()) { |
| 665 pArray->AddName(".notdef"); | 653 pArray->AddName(".notdef"); |
| 666 } else { | 654 } else { |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 692 pBaseDict->SetAt("Widths", pWidths); | 680 pBaseDict->SetAt("Widths", pWidths); |
| 693 } else { | 681 } else { |
| 694 flags |= PDFFONT_NONSYMBOLIC; | 682 flags |= PDFFONT_NONSYMBOLIC; |
| 695 CPDF_Array* pArray = NULL; | 683 CPDF_Array* pArray = NULL; |
| 696 pFontDict = new CPDF_Dictionary; | 684 pFontDict = new CPDF_Dictionary; |
| 697 CFX_ByteString cmap; | 685 CFX_ByteString cmap; |
| 698 CFX_ByteString ordering; | 686 CFX_ByteString ordering; |
| 699 int supplement; | 687 int supplement; |
| 700 FX_BOOL bFound = FALSE; | 688 FX_BOOL bFound = FALSE; |
| 701 CPDF_Array* pWidthArray = new CPDF_Array; | 689 CPDF_Array* pWidthArray = new CPDF_Array; |
| 702 charSets.RemoveAll(); | 690 if (IsHasCharSet(languages, {FXFONT_CHINESEBIG5_CHARSET})) { |
| 703 charSets.Add(FXFONT_CHINESEBIG5_CHARSET); | |
| 704 if (IsHasCharSet(languages, charSets)) { | |
| 705 cmap = bVert ? "ETenms-B5-V" : "ETenms-B5-H"; | 691 cmap = bVert ? "ETenms-B5-V" : "ETenms-B5-H"; |
| 706 ordering = "CNS1"; | 692 ordering = "CNS1"; |
| 707 supplement = 4; | 693 supplement = 4; |
| 708 pWidthArray->AddInteger(1); | 694 pWidthArray->AddInteger(1); |
| 709 _InsertWidthArray(font, 0x20, 0x7e, pWidthArray); | 695 _InsertWidthArray(font, 0x20, 0x7e, pWidthArray); |
| 710 bFound = TRUE; | 696 bFound = TRUE; |
| 711 } | 697 } |
| 712 charSets.RemoveAll(); | 698 if (!bFound && IsHasCharSet(languages, {FXFONT_GB2312_CHARSET})) { |
| 713 charSets.Add(FXFONT_GB2312_CHARSET); | |
| 714 if (!bFound && IsHasCharSet(languages, charSets)) { | |
| 715 cmap = bVert ? "GBK-EUC-V" : "GBK-EUC-H"; | 699 cmap = bVert ? "GBK-EUC-V" : "GBK-EUC-H"; |
| 716 ordering = "GB1", supplement = 2; | 700 ordering = "GB1", supplement = 2; |
| 717 pWidthArray->AddInteger(7716); | 701 pWidthArray->AddInteger(7716); |
| 718 _InsertWidthArray(font, 0x20, 0x20, pWidthArray); | 702 _InsertWidthArray(font, 0x20, 0x20, pWidthArray); |
| 719 pWidthArray->AddInteger(814); | 703 pWidthArray->AddInteger(814); |
| 720 _InsertWidthArray(font, 0x21, 0x7e, pWidthArray); | 704 _InsertWidthArray(font, 0x21, 0x7e, pWidthArray); |
| 721 bFound = TRUE; | 705 bFound = TRUE; |
| 722 } | 706 } |
| 723 charSets.RemoveAll(); | 707 if (!bFound && IsHasCharSet(languages, {FXFONT_HANGEUL_CHARSET})) { |
| 724 charSets.Add(FXFONT_HANGEUL_CHARSET); | |
| 725 if (!bFound && IsHasCharSet(languages, charSets)) { | |
| 726 cmap = bVert ? "KSCms-UHC-V" : "KSCms-UHC-H"; | 708 cmap = bVert ? "KSCms-UHC-V" : "KSCms-UHC-H"; |
| 727 ordering = "Korea1"; | 709 ordering = "Korea1"; |
| 728 supplement = 2; | 710 supplement = 2; |
| 729 pWidthArray->AddInteger(1); | 711 pWidthArray->AddInteger(1); |
| 730 _InsertWidthArray(font, 0x20, 0x7e, pWidthArray); | 712 _InsertWidthArray(font, 0x20, 0x7e, pWidthArray); |
| 731 bFound = TRUE; | 713 bFound = TRUE; |
| 732 } | 714 } |
| 733 charSets.RemoveAll(); | 715 if (!bFound && IsHasCharSet(languages, {FXFONT_SHIFTJIS_CHARSET})) { |
| 734 charSets.Add(FXFONT_SHIFTJIS_CHARSET); | |
| 735 if (!bFound && IsHasCharSet(languages, charSets)) { | |
| 736 cmap = bVert ? "90ms-RKSJ-V" : "90ms-RKSJ-H"; | 716 cmap = bVert ? "90ms-RKSJ-V" : "90ms-RKSJ-H"; |
| 737 ordering = "Japan1"; | 717 ordering = "Japan1"; |
| 738 supplement = 5; | 718 supplement = 5; |
| 739 pWidthArray->AddInteger(231); | 719 pWidthArray->AddInteger(231); |
| 740 _InsertWidthArray(font, 0x20, 0x7d, pWidthArray); | 720 _InsertWidthArray(font, 0x20, 0x7d, pWidthArray); |
| 741 pWidthArray->AddInteger(326); | 721 pWidthArray->AddInteger(326); |
| 742 _InsertWidthArray(font, 0xa0, 0xa0, pWidthArray); | 722 _InsertWidthArray(font, 0xa0, 0xa0, pWidthArray); |
| 743 pWidthArray->AddInteger(327); | 723 pWidthArray->AddInteger(327); |
| 744 _InsertWidthArray(font, 0xa1, 0xdf, pWidthArray); | 724 _InsertWidthArray(font, 0xa1, 0xdf, pWidthArray); |
| 745 pWidthArray->AddInteger(631); | 725 pWidthArray->AddInteger(631); |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1150 void FPDFAPI_FlatPageAttr(CPDF_Dictionary* pPageDict, | 1130 void FPDFAPI_FlatPageAttr(CPDF_Dictionary* pPageDict, |
| 1151 const CFX_ByteStringC& name) { | 1131 const CFX_ByteStringC& name) { |
| 1152 if (pPageDict->KeyExist(name)) { | 1132 if (pPageDict->KeyExist(name)) { |
| 1153 return; | 1133 return; |
| 1154 } | 1134 } |
| 1155 CPDF_Object* pObj = FPDFAPI_GetPageAttr(pPageDict, name); | 1135 CPDF_Object* pObj = FPDFAPI_GetPageAttr(pPageDict, name); |
| 1156 if (pObj) { | 1136 if (pObj) { |
| 1157 pPageDict->SetAt(name, pObj->Clone()); | 1137 pPageDict->SetAt(name, pObj->Clone()); |
| 1158 } | 1138 } |
| 1159 } | 1139 } |
| OLD | NEW |