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

Side by Side Diff: core/fpdfapi/fpdf_parser/cpdf_document.cpp

Issue 2345063002: Use string pools in some dictionaries (Closed)
Patch Set: windows compile Created 4 years, 2 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
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 "core/fpdfapi/fpdf_parser/include/cpdf_document.h" 7 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
8 8
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 basefont += ",Bold"; 376 basefont += ",Bold";
377 else if (italic) 377 else if (italic)
378 basefont += ",Italic"; 378 basefont += ",Italic";
379 pBaseDict->SetNameFor("Subtype", "TrueType"); 379 pBaseDict->SetNameFor("Subtype", "TrueType");
380 pBaseDict->SetNameFor("BaseFont", basefont); 380 pBaseDict->SetNameFor("BaseFont", basefont);
381 pBaseDict->SetNumberFor("FirstChar", 32); 381 pBaseDict->SetNumberFor("FirstChar", 32);
382 pBaseDict->SetNumberFor("LastChar", 255); 382 pBaseDict->SetNumberFor("LastChar", 255);
383 pBaseDict->SetFor("Widths", pWidths); 383 pBaseDict->SetFor("Widths", pWidths);
384 } 384 }
385 385
386 CPDF_Dictionary* CalculateFontDesc(CFX_ByteString basefont, 386 CPDF_Dictionary* CalculateFontDesc(CPDF_Document* pDoc,
387 CFX_ByteString basefont,
387 int flags, 388 int flags,
388 int italicangle, 389 int italicangle,
389 int ascend, 390 int ascend,
390 int descend, 391 int descend,
391 CPDF_Array* bbox, 392 CPDF_Array* bbox,
392 int32_t stemV) { 393 int32_t stemV) {
393 CPDF_Dictionary* pFontDesc = new CPDF_Dictionary; 394 CPDF_Dictionary* pFontDesc = new CPDF_Dictionary(pDoc->GetByteStringPool());
394 pFontDesc->SetNameFor("Type", "FontDescriptor"); 395 pFontDesc->SetNameFor("Type", "FontDescriptor");
395 pFontDesc->SetNameFor("FontName", basefont); 396 pFontDesc->SetNameFor("FontName", basefont);
396 pFontDesc->SetIntegerFor("Flags", flags); 397 pFontDesc->SetIntegerFor("Flags", flags);
397 pFontDesc->SetFor("FontBBox", bbox); 398 pFontDesc->SetFor("FontBBox", bbox);
398 pFontDesc->SetIntegerFor("ItalicAngle", italicangle); 399 pFontDesc->SetIntegerFor("ItalicAngle", italicangle);
399 pFontDesc->SetIntegerFor("Ascent", ascend); 400 pFontDesc->SetIntegerFor("Ascent", ascend);
400 pFontDesc->SetIntegerFor("Descent", descend); 401 pFontDesc->SetIntegerFor("Descent", descend);
401 pFontDesc->SetIntegerFor("StemV", stemV); 402 pFontDesc->SetIntegerFor("StemV", stemV);
402 return pFontDesc; 403 return pFontDesc;
403 } 404 }
404 405
405 } // namespace 406 } // namespace
406 407
407 CPDF_Document::CPDF_Document(std::unique_ptr<CPDF_Parser> pParser) 408 CPDF_Document::CPDF_Document(std::unique_ptr<CPDF_Parser> pParser)
408 : CPDF_IndirectObjectHolder(), 409 : CPDF_IndirectObjectHolder(),
409 m_pParser(std::move(pParser)), 410 m_pParser(std::move(pParser)),
410 m_pRootDict(nullptr), 411 m_pRootDict(nullptr),
411 m_pInfoDict(nullptr), 412 m_pInfoDict(nullptr),
412 m_bLinearized(false), 413 m_bLinearized(false),
413 m_iFirstPageNo(0), 414 m_iFirstPageNo(0),
414 m_dwFirstPageObjNum(0), 415 m_dwFirstPageObjNum(0),
415 m_pDocPage(new CPDF_DocPageData(this)), 416 m_pDocPage(new CPDF_DocPageData(this)),
416 m_pDocRender(new CPDF_DocRenderData(this)) { 417 m_pDocRender(new CPDF_DocRenderData(this)),
418 m_pByteStringPool(WrapUnique(new CFX_ByteStringPool)) {
417 if (pParser) 419 if (pParser)
418 SetLastObjNum(m_pParser->GetLastObjNum()); 420 SetLastObjNum(m_pParser->GetLastObjNum());
419 } 421 }
420 422
421 CPDF_Document::~CPDF_Document() { 423 CPDF_Document::~CPDF_Document() {
422 delete m_pDocPage; 424 delete m_pDocPage;
423 CPDF_ModuleMgr::Get()->GetPageModule()->ClearStockFont(this); 425 CPDF_ModuleMgr::Get()->GetPageModule()->ClearStockFont(this);
426 m_pByteStringPool.Clear(); // Make weak.
424 } 427 }
425 428
426 CPDF_Object* CPDF_Document::ParseIndirectObject(uint32_t objnum) { 429 CPDF_Object* CPDF_Document::ParseIndirectObject(uint32_t objnum) {
427 return m_pParser ? m_pParser->ParseIndirectObject(this, objnum) : nullptr; 430 return m_pParser ? m_pParser->ParseIndirectObject(this, objnum) : nullptr;
428 } 431 }
429 432
430 void CPDF_Document::LoadDocInternal() { 433 void CPDF_Document::LoadDocInternal() {
431 SetLastObjNum(m_pParser->GetLastObjNum()); 434 SetLastObjNum(m_pParser->GetLastObjNum());
432 435
433 CPDF_Object* pRootObj = GetOrParseIndirectObject(m_pParser->GetRootObjNum()); 436 CPDF_Object* pRootObj = GetOrParseIndirectObject(m_pParser->GetRootObjNum());
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 CPDF_Image* CPDF_Document::LoadImageF(CPDF_Object* pObj) { 683 CPDF_Image* CPDF_Document::LoadImageF(CPDF_Object* pObj) {
681 if (!pObj) 684 if (!pObj)
682 return nullptr; 685 return nullptr;
683 686
684 ASSERT(pObj->GetObjNum()); 687 ASSERT(pObj->GetObjNum());
685 return m_pDocPage->GetImage(pObj); 688 return m_pDocPage->GetImage(pObj);
686 } 689 }
687 690
688 void CPDF_Document::CreateNewDoc() { 691 void CPDF_Document::CreateNewDoc() {
689 ASSERT(!m_pRootDict && !m_pInfoDict); 692 ASSERT(!m_pRootDict && !m_pInfoDict);
690 m_pRootDict = new CPDF_Dictionary; 693 m_pRootDict = new CPDF_Dictionary(m_pByteStringPool);
691 m_pRootDict->SetNameFor("Type", "Catalog"); 694 m_pRootDict->SetNameFor("Type", "Catalog");
692 AddIndirectObject(m_pRootDict); 695 AddIndirectObject(m_pRootDict);
693 CPDF_Dictionary* pPages = new CPDF_Dictionary; 696
697 CPDF_Dictionary* pPages = new CPDF_Dictionary(m_pByteStringPool);
694 pPages->SetNameFor("Type", "Pages"); 698 pPages->SetNameFor("Type", "Pages");
695 pPages->SetNumberFor("Count", 0); 699 pPages->SetNumberFor("Count", 0);
696 pPages->SetFor("Kids", new CPDF_Array); 700 pPages->SetFor("Kids", new CPDF_Array);
697 m_pRootDict->SetReferenceFor("Pages", this, AddIndirectObject(pPages)); 701 m_pRootDict->SetReferenceFor("Pages", this, AddIndirectObject(pPages));
698 m_pInfoDict = new CPDF_Dictionary; 702 m_pInfoDict = new CPDF_Dictionary(m_pByteStringPool);
699 AddIndirectObject(m_pInfoDict); 703 AddIndirectObject(m_pInfoDict);
700 } 704 }
701 705
702 CPDF_Dictionary* CPDF_Document::CreateNewPage(int iPage) { 706 CPDF_Dictionary* CPDF_Document::CreateNewPage(int iPage) {
703 CPDF_Dictionary* pDict = new CPDF_Dictionary; 707 CPDF_Dictionary* pDict = new CPDF_Dictionary(m_pByteStringPool);
704 pDict->SetNameFor("Type", "Page"); 708 pDict->SetNameFor("Type", "Page");
705 uint32_t dwObjNum = AddIndirectObject(pDict); 709 uint32_t dwObjNum = AddIndirectObject(pDict);
706 if (InsertNewPage(this, iPage, pDict, m_PageList) < 0) { 710 if (InsertNewPage(this, iPage, pDict, m_PageList) < 0) {
707 ReleaseIndirectObject(dwObjNum); 711 ReleaseIndirectObject(dwObjNum);
708 return nullptr; 712 return nullptr;
709 } 713 }
710 return pDict; 714 return pDict;
711 } 715 }
712 716
713 void CPDF_Document::DeletePage(int iPage) { 717 void CPDF_Document::DeletePage(int iPage) {
(...skipping 22 matching lines...) Expand all
736 740
737 size_t CPDF_Document::CalculateEncodingDict(int charset, 741 size_t CPDF_Document::CalculateEncodingDict(int charset,
738 CPDF_Dictionary* pBaseDict) { 742 CPDF_Dictionary* pBaseDict) {
739 size_t i; 743 size_t i;
740 for (i = 0; i < FX_ArraySize(g_FX_CharsetUnicodes); ++i) { 744 for (i = 0; i < FX_ArraySize(g_FX_CharsetUnicodes); ++i) {
741 if (g_FX_CharsetUnicodes[i].m_Charset == charset) 745 if (g_FX_CharsetUnicodes[i].m_Charset == charset)
742 break; 746 break;
743 } 747 }
744 if (i == FX_ArraySize(g_FX_CharsetUnicodes)) 748 if (i == FX_ArraySize(g_FX_CharsetUnicodes))
745 return i; 749 return i;
746 CPDF_Dictionary* pEncodingDict = new CPDF_Dictionary; 750 CPDF_Dictionary* pEncodingDict = new CPDF_Dictionary(m_pByteStringPool);
747 pEncodingDict->SetNameFor("BaseEncoding", "WinAnsiEncoding"); 751 pEncodingDict->SetNameFor("BaseEncoding", "WinAnsiEncoding");
748 CPDF_Array* pArray = new CPDF_Array; 752 CPDF_Array* pArray = new CPDF_Array;
749 pArray->AddInteger(128); 753 pArray->AddInteger(128);
750 const uint16_t* pUnicodes = g_FX_CharsetUnicodes[i].m_pUnicodes; 754 const uint16_t* pUnicodes = g_FX_CharsetUnicodes[i].m_pUnicodes;
751 for (int j = 0; j < 128; j++) { 755 for (int j = 0; j < 128; j++) {
752 CFX_ByteString name = PDF_AdobeNameFromUnicode(pUnicodes[j]); 756 CFX_ByteString name = PDF_AdobeNameFromUnicode(pUnicodes[j]);
753 pArray->AddName(name.IsEmpty() ? ".notdef" : name); 757 pArray->AddName(name.IsEmpty() ? ".notdef" : name);
754 } 758 }
755 pEncodingDict->SetFor("Differences", pArray); 759 pEncodingDict->SetFor("Differences", pArray);
756 pBaseDict->SetReferenceFor("Encoding", this, 760 pBaseDict->SetReferenceFor("Encoding", this,
757 AddIndirectObject(pEncodingDict)); 761 AddIndirectObject(pEncodingDict));
758 762
759 return i; 763 return i;
760 } 764 }
761 765
762 CPDF_Dictionary* CPDF_Document::ProcessbCJK( 766 CPDF_Dictionary* CPDF_Document::ProcessbCJK(
763 CPDF_Dictionary* pBaseDict, 767 CPDF_Dictionary* pBaseDict,
764 int charset, 768 int charset,
765 FX_BOOL bVert, 769 FX_BOOL bVert,
766 CFX_ByteString basefont, 770 CFX_ByteString basefont,
767 std::function<void(FX_WCHAR, FX_WCHAR, CPDF_Array*)> Insert) { 771 std::function<void(FX_WCHAR, FX_WCHAR, CPDF_Array*)> Insert) {
768 CPDF_Dictionary* pFontDict = new CPDF_Dictionary; 772 CPDF_Dictionary* pFontDict = new CPDF_Dictionary(m_pByteStringPool);
769 CFX_ByteString cmap; 773 CFX_ByteString cmap;
770 CFX_ByteString ordering; 774 CFX_ByteString ordering;
771 int supplement = 0; 775 int supplement = 0;
772 CPDF_Array* pWidthArray = new CPDF_Array; 776 CPDF_Array* pWidthArray = new CPDF_Array;
773 switch (charset) { 777 switch (charset) {
774 case FXFONT_CHINESEBIG5_CHARSET: 778 case FXFONT_CHINESEBIG5_CHARSET:
775 cmap = bVert ? "ETenms-B5-V" : "ETenms-B5-H"; 779 cmap = bVert ? "ETenms-B5-V" : "ETenms-B5-H";
776 ordering = "CNS1"; 780 ordering = "CNS1";
777 supplement = 4; 781 supplement = 4;
778 pWidthArray->AddInteger(1); 782 pWidthArray->AddInteger(1);
(...skipping 29 matching lines...) Expand all
808 Insert(0x7e, 0x7e, pWidthArray); 812 Insert(0x7e, 0x7e, pWidthArray);
809 break; 813 break;
810 } 814 }
811 pBaseDict->SetNameFor("Subtype", "Type0"); 815 pBaseDict->SetNameFor("Subtype", "Type0");
812 pBaseDict->SetNameFor("BaseFont", basefont); 816 pBaseDict->SetNameFor("BaseFont", basefont);
813 pBaseDict->SetNameFor("Encoding", cmap); 817 pBaseDict->SetNameFor("Encoding", cmap);
814 pFontDict->SetFor("W", pWidthArray); 818 pFontDict->SetFor("W", pWidthArray);
815 pFontDict->SetNameFor("Type", "Font"); 819 pFontDict->SetNameFor("Type", "Font");
816 pFontDict->SetNameFor("Subtype", "CIDFontType2"); 820 pFontDict->SetNameFor("Subtype", "CIDFontType2");
817 pFontDict->SetNameFor("BaseFont", basefont); 821 pFontDict->SetNameFor("BaseFont", basefont);
818 CPDF_Dictionary* pCIDSysInfo = new CPDF_Dictionary; 822 CPDF_Dictionary* pCIDSysInfo = new CPDF_Dictionary(m_pByteStringPool);
819 pCIDSysInfo->SetStringFor("Registry", "Adobe"); 823 pCIDSysInfo->SetStringFor("Registry", "Adobe");
820 pCIDSysInfo->SetStringFor("Ordering", ordering); 824 pCIDSysInfo->SetStringFor("Ordering", ordering);
821 pCIDSysInfo->SetIntegerFor("Supplement", supplement); 825 pCIDSysInfo->SetIntegerFor("Supplement", supplement);
822 pFontDict->SetFor("CIDSystemInfo", pCIDSysInfo); 826 pFontDict->SetFor("CIDSystemInfo", pCIDSysInfo);
823 CPDF_Array* pArray = new CPDF_Array; 827 CPDF_Array* pArray = new CPDF_Array;
824 pBaseDict->SetFor("DescendantFonts", pArray); 828 pBaseDict->SetFor("DescendantFonts", pArray);
825 pArray->AddReference(this, AddIndirectObject(pFontDict)); 829 pArray->AddReference(this, AddIndirectObject(pFontDict));
826 return pFontDict; 830 return pFontDict;
827 } 831 }
828 832
829 CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert) { 833 CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert) {
830 if (!pFont) 834 if (!pFont)
831 return nullptr; 835 return nullptr;
832 836
833 bool bCJK = charset == FXFONT_CHINESEBIG5_CHARSET || 837 bool bCJK = charset == FXFONT_CHINESEBIG5_CHARSET ||
834 charset == FXFONT_GB2312_CHARSET || 838 charset == FXFONT_GB2312_CHARSET ||
835 charset == FXFONT_HANGUL_CHARSET || 839 charset == FXFONT_HANGUL_CHARSET ||
836 charset == FXFONT_SHIFTJIS_CHARSET; 840 charset == FXFONT_SHIFTJIS_CHARSET;
837 CFX_ByteString basefont = pFont->GetFamilyName(); 841 CFX_ByteString basefont = pFont->GetFamilyName();
838 basefont.Replace(" ", ""); 842 basefont.Replace(" ", "");
839 int flags = 843 int flags =
840 CalculateFlags(pFont->IsBold(), pFont->IsItalic(), pFont->IsFixedWidth(), 844 CalculateFlags(pFont->IsBold(), pFont->IsItalic(), pFont->IsFixedWidth(),
841 false, false, charset == FXFONT_SYMBOL_CHARSET); 845 false, false, charset == FXFONT_SYMBOL_CHARSET);
842 846
843 CPDF_Dictionary* pBaseDict = new CPDF_Dictionary; 847 CPDF_Dictionary* pBaseDict = new CPDF_Dictionary(m_pByteStringPool);
844 pBaseDict->SetNameFor("Type", "Font"); 848 pBaseDict->SetNameFor("Type", "Font");
845 std::unique_ptr<CFX_UnicodeEncoding> pEncoding( 849 std::unique_ptr<CFX_UnicodeEncoding> pEncoding(
846 new CFX_UnicodeEncoding(pFont)); 850 new CFX_UnicodeEncoding(pFont));
847 CPDF_Dictionary* pFontDict = pBaseDict; 851 CPDF_Dictionary* pFontDict = pBaseDict;
848 if (!bCJK) { 852 if (!bCJK) {
849 CPDF_Array* pWidths = new CPDF_Array; 853 CPDF_Array* pWidths = new CPDF_Array;
850 for (int charcode = 32; charcode < 128; charcode++) { 854 for (int charcode = 32; charcode < 128; charcode++) {
851 int glyph_index = pEncoding->GlyphFromCharCode(charcode); 855 int glyph_index = pEncoding->GlyphFromCharCode(charcode);
852 int char_width = pFont->GetGlyphWidth(glyph_index); 856 int char_width = pFont->GetGlyphWidth(glyph_index);
853 pWidths->AddInteger(char_width); 857 pWidths->AddInteger(char_width);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 uint32_t glyph = pEncoding->GlyphFromCharCode(stem_chars[0]); 904 uint32_t glyph = pEncoding->GlyphFromCharCode(stem_chars[0]);
901 nStemV = pFont->GetGlyphWidth(glyph); 905 nStemV = pFont->GetGlyphWidth(glyph);
902 for (size_t i = 1; i < count; i++) { 906 for (size_t i = 1; i < count; i++) {
903 glyph = pEncoding->GlyphFromCharCode(stem_chars[i]); 907 glyph = pEncoding->GlyphFromCharCode(stem_chars[i]);
904 int width = pFont->GetGlyphWidth(glyph); 908 int width = pFont->GetGlyphWidth(glyph);
905 if (width > 0 && width < nStemV) 909 if (width > 0 && width < nStemV)
906 nStemV = width; 910 nStemV = width;
907 } 911 }
908 } 912 }
909 CPDF_Dictionary* pFontDesc = 913 CPDF_Dictionary* pFontDesc =
910 CalculateFontDesc(basefont, flags, italicangle, pFont->GetAscent(), 914 CalculateFontDesc(this, basefont, flags, italicangle, pFont->GetAscent(),
911 pFont->GetDescent(), pBBox, nStemV); 915 pFont->GetDescent(), pBBox, nStemV);
912 pFontDict->SetReferenceFor("FontDescriptor", this, 916 pFontDict->SetReferenceFor("FontDescriptor", this,
913 AddIndirectObject(pFontDesc)); 917 AddIndirectObject(pFontDesc));
914 return LoadFont(pBaseDict); 918 return LoadFont(pBaseDict);
915 } 919 }
916 920
917 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 921 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
918 CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTW* pLogFont, 922 CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTW* pLogFont,
919 FX_BOOL bVert, 923 FX_BOOL bVert,
920 FX_BOOL bTranslateName) { 924 FX_BOOL bTranslateName) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 basefont = pLogFont->lfFaceName; 969 basefont = pLogFont->lfFaceName;
966 970
967 int italicangle = ptm->otmItalicAngle / 10; 971 int italicangle = ptm->otmItalicAngle / 10;
968 int ascend = ptm->otmrcFontBox.top; 972 int ascend = ptm->otmrcFontBox.top;
969 int descend = ptm->otmrcFontBox.bottom; 973 int descend = ptm->otmrcFontBox.bottom;
970 int capheight = ptm->otmsCapEmHeight; 974 int capheight = ptm->otmsCapEmHeight;
971 int bbox[4] = {ptm->otmrcFontBox.left, ptm->otmrcFontBox.bottom, 975 int bbox[4] = {ptm->otmrcFontBox.left, ptm->otmrcFontBox.bottom,
972 ptm->otmrcFontBox.right, ptm->otmrcFontBox.top}; 976 ptm->otmrcFontBox.right, ptm->otmrcFontBox.top};
973 FX_Free(tm_buf); 977 FX_Free(tm_buf);
974 basefont.Replace(" ", ""); 978 basefont.Replace(" ", "");
975 CPDF_Dictionary* pBaseDict = new CPDF_Dictionary; 979 CPDF_Dictionary* pBaseDict = new CPDF_Dictionary(m_pByteStringPool);
976 pBaseDict->SetNameFor("Type", "Font"); 980 pBaseDict->SetNameFor("Type", "Font");
977 CPDF_Dictionary* pFontDict = pBaseDict; 981 CPDF_Dictionary* pFontDict = pBaseDict;
978 if (!bCJK) { 982 if (!bCJK) {
979 if (pLogFont->lfCharSet == FXFONT_ANSI_CHARSET || 983 if (pLogFont->lfCharSet == FXFONT_ANSI_CHARSET ||
980 pLogFont->lfCharSet == FXFONT_DEFAULT_CHARSET || 984 pLogFont->lfCharSet == FXFONT_DEFAULT_CHARSET ||
981 pLogFont->lfCharSet == FXFONT_SYMBOL_CHARSET) { 985 pLogFont->lfCharSet == FXFONT_SYMBOL_CHARSET) {
982 pBaseDict->SetNameFor("Encoding", "WinAnsiEncoding"); 986 pBaseDict->SetNameFor("Encoding", "WinAnsiEncoding");
983 } else { 987 } else {
984 CalculateEncodingDict(pLogFont->lfCharSet, pBaseDict); 988 CalculateEncodingDict(pLogFont->lfCharSet, pBaseDict);
985 } 989 }
986 int char_widths[224]; 990 int char_widths[224];
987 GetCharWidth(hDC, 32, 255, char_widths); 991 GetCharWidth(hDC, 32, 255, char_widths);
988 CPDF_Array* pWidths = new CPDF_Array; 992 CPDF_Array* pWidths = new CPDF_Array;
989 for (size_t i = 0; i < 224; i++) 993 for (size_t i = 0; i < 224; i++)
990 pWidths->AddInteger(char_widths[i]); 994 pWidths->AddInteger(char_widths[i]);
991 ProcessNonbCJK(pBaseDict, pLogFont->lfWeight > FW_MEDIUM, 995 ProcessNonbCJK(pBaseDict, pLogFont->lfWeight > FW_MEDIUM,
992 pLogFont->lfItalic != 0, basefont, pWidths); 996 pLogFont->lfItalic != 0, basefont, pWidths);
993 } else { 997 } else {
994 pFontDict = 998 pFontDict =
995 ProcessbCJK(pBaseDict, pLogFont->lfCharSet, bVert, basefont, 999 ProcessbCJK(pBaseDict, pLogFont->lfCharSet, bVert, basefont,
996 [&hDC](FX_WCHAR start, FX_WCHAR end, CPDF_Array* widthArr) { 1000 [&hDC](FX_WCHAR start, FX_WCHAR end, CPDF_Array* widthArr) {
997 InsertWidthArray(hDC, start, end, widthArr); 1001 InsertWidthArray(hDC, start, end, widthArr);
998 }); 1002 });
999 } 1003 }
1000 AddIndirectObject(pBaseDict); 1004 AddIndirectObject(pBaseDict);
1001 CPDF_Array* pBBox = new CPDF_Array; 1005 CPDF_Array* pBBox = new CPDF_Array;
1002 for (int i = 0; i < 4; i++) 1006 for (int i = 0; i < 4; i++)
1003 pBBox->AddInteger(bbox[i]); 1007 pBBox->AddInteger(bbox[i]);
1004 CPDF_Dictionary* pFontDesc = 1008 CPDF_Dictionary* pFontDesc =
1005 CalculateFontDesc(basefont, flags, italicangle, ascend, descend, pBBox, 1009 CalculateFontDesc(this, basefont, flags, italicangle, ascend, descend,
1006 pLogFont->lfWeight / 5); 1010 pBBox, pLogFont->lfWeight / 5);
1007 pFontDesc->SetIntegerFor("CapHeight", capheight); 1011 pFontDesc->SetIntegerFor("CapHeight", capheight);
1008 pFontDict->SetReferenceFor("FontDescriptor", this, 1012 pFontDict->SetReferenceFor("FontDescriptor", this,
1009 AddIndirectObject(pFontDesc)); 1013 AddIndirectObject(pFontDesc));
1010 hFont = SelectObject(hDC, hFont); 1014 hFont = SelectObject(hDC, hFont);
1011 DeleteObject(hFont); 1015 DeleteObject(hFont);
1012 DeleteDC(hDC); 1016 DeleteDC(hDC);
1013 return LoadFont(pBaseDict); 1017 return LoadFont(pBaseDict);
1014 } 1018 }
1015 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 1019 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp ('k') | core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698