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

Side by Side Diff: core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp

Issue 1293973002: Cleanup CFX_Font a bit. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: rebase 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/include/fxge/fx_font.h ('k') | core/src/fpdfapi/fpdf_font/fpdf_font.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_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 962 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 AddIndirectObject(pFontDict); 973 AddIndirectObject(pFontDict);
974 pArray->AddReference(this, pFontDict); 974 pArray->AddReference(this, pFontDict);
975 } 975 }
976 AddIndirectObject(pBaseDict); 976 AddIndirectObject(pBaseDict);
977 CPDF_Dictionary* pFontDesc = new CPDF_Dictionary; 977 CPDF_Dictionary* pFontDesc = new CPDF_Dictionary;
978 pFontDesc->SetAtName("Type", "FontDescriptor"); 978 pFontDesc->SetAtName("Type", "FontDescriptor");
979 pFontDesc->SetAtName("FontName", basefont); 979 pFontDesc->SetAtName("FontName", basefont);
980 pFontDesc->SetAtInteger("Flags", flags); 980 pFontDesc->SetAtInteger("Flags", flags);
981 pFontDesc->SetAtInteger( 981 pFontDesc->SetAtInteger(
982 "ItalicAngle", 982 "ItalicAngle",
983 pFont->m_pSubstFont ? pFont->m_pSubstFont->m_ItalicAngle : 0); 983 pFont->GetSubstFont() ? pFont->GetSubstFont()->m_ItalicAngle : 0);
984 pFontDesc->SetAtInteger("Ascent", pFont->GetAscent()); 984 pFontDesc->SetAtInteger("Ascent", pFont->GetAscent());
985 pFontDesc->SetAtInteger("Descent", pFont->GetDescent()); 985 pFontDesc->SetAtInteger("Descent", pFont->GetDescent());
986 FX_RECT bbox; 986 FX_RECT bbox;
987 pFont->GetBBox(bbox); 987 pFont->GetBBox(bbox);
988 CPDF_Array* pBBox = new CPDF_Array; 988 CPDF_Array* pBBox = new CPDF_Array;
989 pBBox->AddInteger(bbox.left); 989 pBBox->AddInteger(bbox.left);
990 pBBox->AddInteger(bbox.bottom); 990 pBBox->AddInteger(bbox.bottom);
991 pBBox->AddInteger(bbox.right); 991 pBBox->AddInteger(bbox.right);
992 pBBox->AddInteger(bbox.top); 992 pBBox->AddInteger(bbox.top);
993 pFontDesc->SetAt("FontBBox", pBBox); 993 pFontDesc->SetAt("FontBBox", pBBox);
994 int32_t nStemV = 0; 994 int32_t nStemV = 0;
995 if (pFont->m_pSubstFont) { 995 if (pFont->GetSubstFont()) {
996 nStemV = pFont->m_pSubstFont->m_Weight / 5; 996 nStemV = pFont->GetSubstFont()->m_Weight / 5;
997 } else { 997 } else {
998 static const FX_CHAR stem_chars[] = {'i', 'I', '!', '1'}; 998 static const FX_CHAR stem_chars[] = {'i', 'I', '!', '1'};
999 const size_t count = sizeof(stem_chars) / sizeof(stem_chars[0]); 999 const size_t count = sizeof(stem_chars) / sizeof(stem_chars[0]);
1000 FX_DWORD glyph = pEncoding->GlyphFromCharCode(stem_chars[0]); 1000 FX_DWORD glyph = pEncoding->GlyphFromCharCode(stem_chars[0]);
1001 nStemV = pFont->GetGlyphWidth(glyph); 1001 nStemV = pFont->GetGlyphWidth(glyph);
1002 for (size_t i = 1; i < count; i++) { 1002 for (size_t i = 1; i < count; i++) {
1003 glyph = pEncoding->GlyphFromCharCode(stem_chars[i]); 1003 glyph = pEncoding->GlyphFromCharCode(stem_chars[i]);
1004 int width = pFont->GetGlyphWidth(glyph); 1004 int width = pFont->GetGlyphWidth(glyph);
1005 if (width > 0 && width < nStemV) { 1005 if (width > 0 && width < nStemV) {
1006 nStemV = width; 1006 nStemV = width;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 void FPDFAPI_FlatPageAttr(CPDF_Dictionary* pPageDict, 1141 void FPDFAPI_FlatPageAttr(CPDF_Dictionary* pPageDict,
1142 const CFX_ByteStringC& name) { 1142 const CFX_ByteStringC& name) {
1143 if (pPageDict->KeyExist(name)) { 1143 if (pPageDict->KeyExist(name)) {
1144 return; 1144 return;
1145 } 1145 }
1146 CPDF_Object* pObj = FPDFAPI_GetPageAttr(pPageDict, name); 1146 CPDF_Object* pObj = FPDFAPI_GetPageAttr(pPageDict, name);
1147 if (pObj) { 1147 if (pObj) {
1148 pPageDict->SetAt(name, pObj->Clone()); 1148 pPageDict->SetAt(name, pObj->Clone());
1149 } 1149 }
1150 } 1150 }
OLDNEW
« no previous file with comments | « core/include/fxge/fx_font.h ('k') | core/src/fpdfapi/fpdf_font/fpdf_font.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698