| 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 "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 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 break; | 772 break; |
| 773 case FXFONT_GB2312_CHARSET: | 773 case FXFONT_GB2312_CHARSET: |
| 774 cmap = bVert ? "GBK-EUC-V" : "GBK-EUC-H"; | 774 cmap = bVert ? "GBK-EUC-V" : "GBK-EUC-H"; |
| 775 ordering = "GB1"; | 775 ordering = "GB1"; |
| 776 supplement = 2; | 776 supplement = 2; |
| 777 pWidthArray->AddInteger(7716); | 777 pWidthArray->AddInteger(7716); |
| 778 Insert(0x20, 0x20, pWidthArray); | 778 Insert(0x20, 0x20, pWidthArray); |
| 779 pWidthArray->AddInteger(814); | 779 pWidthArray->AddInteger(814); |
| 780 Insert(0x21, 0x7e, pWidthArray); | 780 Insert(0x21, 0x7e, pWidthArray); |
| 781 break; | 781 break; |
| 782 case FXFONT_HANGEUL_CHARSET: | 782 case FXFONT_HANGUL_CHARSET: |
| 783 cmap = bVert ? "KSCms-UHC-V" : "KSCms-UHC-H"; | 783 cmap = bVert ? "KSCms-UHC-V" : "KSCms-UHC-H"; |
| 784 ordering = "Korea1"; | 784 ordering = "Korea1"; |
| 785 supplement = 2; | 785 supplement = 2; |
| 786 pWidthArray->AddInteger(1); | 786 pWidthArray->AddInteger(1); |
| 787 Insert(0x20, 0x7e, pWidthArray); | 787 Insert(0x20, 0x7e, pWidthArray); |
| 788 break; | 788 break; |
| 789 case FXFONT_SHIFTJIS_CHARSET: | 789 case FXFONT_SHIFTJIS_CHARSET: |
| 790 cmap = bVert ? "90ms-RKSJ-V" : "90ms-RKSJ-H"; | 790 cmap = bVert ? "90ms-RKSJ-V" : "90ms-RKSJ-H"; |
| 791 ordering = "Japan1"; | 791 ordering = "Japan1"; |
| 792 supplement = 5; | 792 supplement = 5; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 818 pArray->AddReference(this, pFontDict); | 818 pArray->AddReference(this, pFontDict); |
| 819 return pFontDict; | 819 return pFontDict; |
| 820 } | 820 } |
| 821 | 821 |
| 822 CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert) { | 822 CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert) { |
| 823 if (!pFont) | 823 if (!pFont) |
| 824 return nullptr; | 824 return nullptr; |
| 825 | 825 |
| 826 bool bCJK = charset == FXFONT_CHINESEBIG5_CHARSET || | 826 bool bCJK = charset == FXFONT_CHINESEBIG5_CHARSET || |
| 827 charset == FXFONT_GB2312_CHARSET || | 827 charset == FXFONT_GB2312_CHARSET || |
| 828 charset == FXFONT_HANGEUL_CHARSET || | 828 charset == FXFONT_HANGUL_CHARSET || |
| 829 charset == FXFONT_SHIFTJIS_CHARSET; | 829 charset == FXFONT_SHIFTJIS_CHARSET; |
| 830 CFX_ByteString basefont = pFont->GetFamilyName(); | 830 CFX_ByteString basefont = pFont->GetFamilyName(); |
| 831 basefont.Replace(" ", ""); | 831 basefont.Replace(" ", ""); |
| 832 int flags = | 832 int flags = |
| 833 CalculateFlags(pFont->IsBold(), pFont->IsItalic(), pFont->IsFixedWidth(), | 833 CalculateFlags(pFont->IsBold(), pFont->IsItalic(), pFont->IsFixedWidth(), |
| 834 false, false, charset == FXFONT_SYMBOL_CHARSET); | 834 false, false, charset == FXFONT_SYMBOL_CHARSET); |
| 835 | 835 |
| 836 CPDF_Dictionary* pBaseDict = new CPDF_Dictionary; | 836 CPDF_Dictionary* pBaseDict = new CPDF_Dictionary; |
| 837 pBaseDict->SetNameFor("Type", "Font"); | 837 pBaseDict->SetNameFor("Type", "Font"); |
| 838 std::unique_ptr<CFX_UnicodeEncoding> pEncoding( | 838 std::unique_ptr<CFX_UnicodeEncoding> pEncoding( |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 937 return nullptr; | 937 return nullptr; |
| 938 } | 938 } |
| 939 | 939 |
| 940 LPBYTE tm_buf = FX_Alloc(BYTE, tm_size); | 940 LPBYTE tm_buf = FX_Alloc(BYTE, tm_size); |
| 941 OUTLINETEXTMETRIC* ptm = reinterpret_cast<OUTLINETEXTMETRIC*>(tm_buf); | 941 OUTLINETEXTMETRIC* ptm = reinterpret_cast<OUTLINETEXTMETRIC*>(tm_buf); |
| 942 GetOutlineTextMetrics(hDC, tm_size, ptm); | 942 GetOutlineTextMetrics(hDC, tm_size, ptm); |
| 943 int flags = CalculateFlags(false, pLogFont->lfItalic != 0, | 943 int flags = CalculateFlags(false, pLogFont->lfItalic != 0, |
| 944 (pLogFont->lfPitchAndFamily & 3) == FIXED_PITCH, | 944 (pLogFont->lfPitchAndFamily & 3) == FIXED_PITCH, |
| 945 (pLogFont->lfPitchAndFamily & 0xf8) == FF_ROMAN, | 945 (pLogFont->lfPitchAndFamily & 0xf8) == FF_ROMAN, |
| 946 (pLogFont->lfPitchAndFamily & 0xf8) == FF_SCRIPT, | 946 (pLogFont->lfPitchAndFamily & 0xf8) == FF_SCRIPT, |
| 947 pLogFont->lfCharSet == SYMBOL_CHARSET); | 947 pLogFont->lfCharSet == FXFONT_SYMBOL_CHARSET); |
| 948 | 948 |
| 949 bool bCJK = pLogFont->lfCharSet == CHINESEBIG5_CHARSET || | 949 bool bCJK = pLogFont->lfCharSet == FXFONT_CHINESEBIG5_CHARSET || |
| 950 pLogFont->lfCharSet == GB2312_CHARSET || | 950 pLogFont->lfCharSet == FXFONT_GB2312_CHARSET || |
| 951 pLogFont->lfCharSet == HANGEUL_CHARSET || | 951 pLogFont->lfCharSet == FXFONT_HANGUL_CHARSET || |
| 952 pLogFont->lfCharSet == SHIFTJIS_CHARSET; | 952 pLogFont->lfCharSet == FXFONT_SHIFTJIS_CHARSET; |
| 953 CFX_ByteString basefont; | 953 CFX_ByteString basefont; |
| 954 if (bTranslateName && bCJK) | 954 if (bTranslateName && bCJK) |
| 955 basefont = FPDF_GetPSNameFromTT(hDC); | 955 basefont = FPDF_GetPSNameFromTT(hDC); |
| 956 | 956 |
| 957 if (basefont.IsEmpty()) | 957 if (basefont.IsEmpty()) |
| 958 basefont = pLogFont->lfFaceName; | 958 basefont = pLogFont->lfFaceName; |
| 959 | 959 |
| 960 int italicangle = ptm->otmItalicAngle / 10; | 960 int italicangle = ptm->otmItalicAngle / 10; |
| 961 int ascend = ptm->otmrcFontBox.top; | 961 int ascend = ptm->otmrcFontBox.top; |
| 962 int descend = ptm->otmrcFontBox.bottom; | 962 int descend = ptm->otmrcFontBox.bottom; |
| 963 int capheight = ptm->otmsCapEmHeight; | 963 int capheight = ptm->otmsCapEmHeight; |
| 964 int bbox[4] = {ptm->otmrcFontBox.left, ptm->otmrcFontBox.bottom, | 964 int bbox[4] = {ptm->otmrcFontBox.left, ptm->otmrcFontBox.bottom, |
| 965 ptm->otmrcFontBox.right, ptm->otmrcFontBox.top}; | 965 ptm->otmrcFontBox.right, ptm->otmrcFontBox.top}; |
| 966 FX_Free(tm_buf); | 966 FX_Free(tm_buf); |
| 967 basefont.Replace(" ", ""); | 967 basefont.Replace(" ", ""); |
| 968 CPDF_Dictionary* pBaseDict = new CPDF_Dictionary; | 968 CPDF_Dictionary* pBaseDict = new CPDF_Dictionary; |
| 969 pBaseDict->SetNameFor("Type", "Font"); | 969 pBaseDict->SetNameFor("Type", "Font"); |
| 970 CPDF_Dictionary* pFontDict = pBaseDict; | 970 CPDF_Dictionary* pFontDict = pBaseDict; |
| 971 if (!bCJK) { | 971 if (!bCJK) { |
| 972 if (pLogFont->lfCharSet == ANSI_CHARSET || | 972 if (pLogFont->lfCharSet == FXFONT_ANSI_CHARSET || |
| 973 pLogFont->lfCharSet == DEFAULT_CHARSET || | 973 pLogFont->lfCharSet == FXFONT_DEFAULT_CHARSET || |
| 974 pLogFont->lfCharSet == SYMBOL_CHARSET) { | 974 pLogFont->lfCharSet == FXFONT_SYMBOL_CHARSET) { |
| 975 pBaseDict->SetNameFor("Encoding", "WinAnsiEncoding"); | 975 pBaseDict->SetNameFor("Encoding", "WinAnsiEncoding"); |
| 976 } else { | 976 } else { |
| 977 CalculateEncodingDict(pLogFont->lfCharSet, pBaseDict); | 977 CalculateEncodingDict(pLogFont->lfCharSet, pBaseDict); |
| 978 } | 978 } |
| 979 int char_widths[224]; | 979 int char_widths[224]; |
| 980 GetCharWidth(hDC, 32, 255, char_widths); | 980 GetCharWidth(hDC, 32, 255, char_widths); |
| 981 CPDF_Array* pWidths = new CPDF_Array; | 981 CPDF_Array* pWidths = new CPDF_Array; |
| 982 for (size_t i = 0; i < 224; i++) | 982 for (size_t i = 0; i < 224; i++) |
| 983 pWidths->AddInteger(char_widths[i]); | 983 pWidths->AddInteger(char_widths[i]); |
| 984 ProcessNonbCJK(pBaseDict, pLogFont->lfWeight > FW_MEDIUM, | 984 ProcessNonbCJK(pBaseDict, pLogFont->lfWeight > FW_MEDIUM, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 999 pLogFont->lfWeight / 5); | 999 pLogFont->lfWeight / 5); |
| 1000 pFontDesc->SetIntegerFor("CapHeight", capheight); | 1000 pFontDesc->SetIntegerFor("CapHeight", capheight); |
| 1001 AddIndirectObject(pFontDesc); | 1001 AddIndirectObject(pFontDesc); |
| 1002 pFontDict->SetReferenceFor("FontDescriptor", this, pFontDesc); | 1002 pFontDict->SetReferenceFor("FontDescriptor", this, pFontDesc); |
| 1003 hFont = SelectObject(hDC, hFont); | 1003 hFont = SelectObject(hDC, hFont); |
| 1004 DeleteObject(hFont); | 1004 DeleteObject(hFont); |
| 1005 DeleteDC(hDC); | 1005 DeleteDC(hDC); |
| 1006 return LoadFont(pBaseDict); | 1006 return LoadFont(pBaseDict); |
| 1007 } | 1007 } |
| 1008 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 1008 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| OLD | NEW |