| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "../../../include/fpdfapi/fpdf_page.h" | 7 #include "../../../include/fpdfapi/fpdf_page.h" |
| 8 #include "../../../include/fpdfapi/fpdf_module.h" | 8 #include "../../../include/fpdfapi/fpdf_module.h" |
| 9 #include "../fpdf_page/pageint.h" | 9 #include "../fpdf_page/pageint.h" |
| 10 #include <limits.h> | 10 #include <limits.h> |
| (...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 969 AddIndirectObject(pFontDict); | 969 AddIndirectObject(pFontDict); |
| 970 pArray->AddReference(this, pFontDict); | 970 pArray->AddReference(this, pFontDict); |
| 971 } | 971 } |
| 972 AddIndirectObject(pBaseDict); | 972 AddIndirectObject(pBaseDict); |
| 973 CPDF_Dictionary* pFontDesc = new CPDF_Dictionary; | 973 CPDF_Dictionary* pFontDesc = new CPDF_Dictionary; |
| 974 pFontDesc->SetAtName("Type", "FontDescriptor"); | 974 pFontDesc->SetAtName("Type", "FontDescriptor"); |
| 975 pFontDesc->SetAtName("FontName", basefont); | 975 pFontDesc->SetAtName("FontName", basefont); |
| 976 pFontDesc->SetAtInteger("Flags", flags); | 976 pFontDesc->SetAtInteger("Flags", flags); |
| 977 pFontDesc->SetAtInteger( | 977 pFontDesc->SetAtInteger( |
| 978 "ItalicAngle", | 978 "ItalicAngle", |
| 979 pFont->m_pSubstFont ? pFont->m_pSubstFont->m_ItalicAngle : 0); | 979 pFont->GetSubstFont() ? pFont->GetSubstFont()->m_ItalicAngle : 0); |
| 980 pFontDesc->SetAtInteger("Ascent", pFont->GetAscent()); | 980 pFontDesc->SetAtInteger("Ascent", pFont->GetAscent()); |
| 981 pFontDesc->SetAtInteger("Descent", pFont->GetDescent()); | 981 pFontDesc->SetAtInteger("Descent", pFont->GetDescent()); |
| 982 FX_RECT bbox; | 982 FX_RECT bbox; |
| 983 pFont->GetBBox(bbox); | 983 pFont->GetBBox(bbox); |
| 984 CPDF_Array* pBBox = new CPDF_Array; | 984 CPDF_Array* pBBox = new CPDF_Array; |
| 985 pBBox->AddInteger(bbox.left); | 985 pBBox->AddInteger(bbox.left); |
| 986 pBBox->AddInteger(bbox.bottom); | 986 pBBox->AddInteger(bbox.bottom); |
| 987 pBBox->AddInteger(bbox.right); | 987 pBBox->AddInteger(bbox.right); |
| 988 pBBox->AddInteger(bbox.top); | 988 pBBox->AddInteger(bbox.top); |
| 989 pFontDesc->SetAt("FontBBox", pBBox); | 989 pFontDesc->SetAt("FontBBox", pBBox); |
| 990 int32_t nStemV = 0; | 990 int32_t nStemV = 0; |
| 991 if (pFont->m_pSubstFont) { | 991 if (pFont->GetSubstFont()) { |
| 992 nStemV = pFont->m_pSubstFont->m_Weight / 5; | 992 nStemV = pFont->GetSubstFont()->m_Weight / 5; |
| 993 } else { | 993 } else { |
| 994 static const FX_CHAR stem_chars[] = {'i', 'I', '!', '1'}; | 994 static const FX_CHAR stem_chars[] = {'i', 'I', '!', '1'}; |
| 995 const size_t count = sizeof(stem_chars) / sizeof(stem_chars[0]); | 995 const size_t count = sizeof(stem_chars) / sizeof(stem_chars[0]); |
| 996 FX_DWORD glyph = pEncoding->GlyphFromCharCode(stem_chars[0]); | 996 FX_DWORD glyph = pEncoding->GlyphFromCharCode(stem_chars[0]); |
| 997 nStemV = pFont->GetGlyphWidth(glyph); | 997 nStemV = pFont->GetGlyphWidth(glyph); |
| 998 for (size_t i = 1; i < count; i++) { | 998 for (size_t i = 1; i < count; i++) { |
| 999 glyph = pEncoding->GlyphFromCharCode(stem_chars[i]); | 999 glyph = pEncoding->GlyphFromCharCode(stem_chars[i]); |
| 1000 int width = pFont->GetGlyphWidth(glyph); | 1000 int width = pFont->GetGlyphWidth(glyph); |
| 1001 if (width > 0 && width < nStemV) { | 1001 if (width > 0 && width < nStemV) { |
| 1002 nStemV = width; | 1002 nStemV = width; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 void FPDFAPI_FlatPageAttr(CPDF_Dictionary* pPageDict, | 1138 void FPDFAPI_FlatPageAttr(CPDF_Dictionary* pPageDict, |
| 1139 const CFX_ByteStringC& name) { | 1139 const CFX_ByteStringC& name) { |
| 1140 if (pPageDict->KeyExist(name)) { | 1140 if (pPageDict->KeyExist(name)) { |
| 1141 return; | 1141 return; |
| 1142 } | 1142 } |
| 1143 CPDF_Object* pObj = FPDFAPI_GetPageAttr(pPageDict, name); | 1143 CPDF_Object* pObj = FPDFAPI_GetPageAttr(pPageDict, name); |
| 1144 if (pObj) { | 1144 if (pObj) { |
| 1145 pPageDict->SetAt(name, pObj->Clone()); | 1145 pPageDict->SetAt(name, pObj->Clone()); |
| 1146 } | 1146 } |
| 1147 } | 1147 } |
| OLD | NEW |