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

Side by Side Diff: core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp

Issue 1644633003: Member function name refactoring (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 11 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/src/fpdfapi/fpdf_font/fpdf_font.cpp ('k') | core/src/fpdfapi/fpdf_page/fpdf_page.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 "font_int.h" 7 #include "font_int.h"
8 8
9 #include "core/include/fpdfapi/fpdf_module.h" 9 #include "core/include/fpdfapi/fpdf_module.h"
10 #include "core/include/fpdfapi/fpdf_page.h" 10 #include "core/include/fpdfapi/fpdf_page.h"
(...skipping 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 #else 1146 #else
1147 if (m_pCMap->m_pEmbedMap) { 1147 if (m_pCMap->m_pEmbedMap) {
1148 return EmbeddedCharcodeFromUnicode(m_pCMap->m_pEmbedMap, m_pCMap->m_Charset, 1148 return EmbeddedCharcodeFromUnicode(m_pCMap->m_pEmbedMap, m_pCMap->m_Charset,
1149 unicode); 1149 unicode);
1150 } 1150 }
1151 #endif 1151 #endif
1152 return 0; 1152 return 0;
1153 } 1153 }
1154 1154
1155 FX_BOOL CPDF_CIDFont::_Load() { 1155 FX_BOOL CPDF_CIDFont::_Load() {
1156 if (m_pFontDict->GetString("Subtype") == "TrueType") { 1156 if (m_pFontDict->GetStringBy("Subtype") == "TrueType") {
1157 return LoadGB2312(); 1157 return LoadGB2312();
1158 } 1158 }
1159 CPDF_Array* pFonts = m_pFontDict->GetArray("DescendantFonts"); 1159 CPDF_Array* pFonts = m_pFontDict->GetArrayBy("DescendantFonts");
1160 if (!pFonts) { 1160 if (!pFonts) {
1161 return FALSE; 1161 return FALSE;
1162 } 1162 }
1163 if (pFonts->GetCount() != 1) { 1163 if (pFonts->GetCount() != 1) {
1164 return FALSE; 1164 return FALSE;
1165 } 1165 }
1166 CPDF_Dictionary* pCIDFontDict = pFonts->GetDict(0); 1166 CPDF_Dictionary* pCIDFontDict = pFonts->GetDictAt(0);
1167 if (!pCIDFontDict) { 1167 if (!pCIDFontDict) {
1168 return FALSE; 1168 return FALSE;
1169 } 1169 }
1170 m_BaseFont = pCIDFontDict->GetString("BaseFont"); 1170 m_BaseFont = pCIDFontDict->GetStringBy("BaseFont");
1171 if ((m_BaseFont.Compare("CourierStd") == 0 || 1171 if ((m_BaseFont.Compare("CourierStd") == 0 ||
1172 m_BaseFont.Compare("CourierStd-Bold") == 0 || 1172 m_BaseFont.Compare("CourierStd-Bold") == 0 ||
1173 m_BaseFont.Compare("CourierStd-BoldOblique") == 0 || 1173 m_BaseFont.Compare("CourierStd-BoldOblique") == 0 ||
1174 m_BaseFont.Compare("CourierStd-Oblique") == 0) && 1174 m_BaseFont.Compare("CourierStd-Oblique") == 0) &&
1175 !IsEmbedded()) { 1175 !IsEmbedded()) {
1176 m_bAdobeCourierStd = TRUE; 1176 m_bAdobeCourierStd = TRUE;
1177 } 1177 }
1178 CPDF_Dictionary* pFontDesc = pCIDFontDict->GetDict("FontDescriptor"); 1178 CPDF_Dictionary* pFontDesc = pCIDFontDict->GetDictBy("FontDescriptor");
1179 if (pFontDesc) { 1179 if (pFontDesc) {
1180 LoadFontDescriptor(pFontDesc); 1180 LoadFontDescriptor(pFontDesc);
1181 } 1181 }
1182 CPDF_Object* pEncoding = m_pFontDict->GetElementValue("Encoding"); 1182 CPDF_Object* pEncoding = m_pFontDict->GetElementValue("Encoding");
1183 if (!pEncoding) { 1183 if (!pEncoding) {
1184 return FALSE; 1184 return FALSE;
1185 } 1185 }
1186 CFX_ByteString subtype = pCIDFontDict->GetString("Subtype"); 1186 CFX_ByteString subtype = pCIDFontDict->GetStringBy("Subtype");
1187 m_bType1 = (subtype == "CIDFontType0"); 1187 m_bType1 = (subtype == "CIDFontType0");
1188 1188
1189 if (pEncoding->IsName()) { 1189 if (pEncoding->IsName()) {
1190 CFX_ByteString cmap = pEncoding->GetString(); 1190 CFX_ByteString cmap = pEncoding->GetString();
1191 m_pCMap = 1191 m_pCMap =
1192 CPDF_ModuleMgr::Get() 1192 CPDF_ModuleMgr::Get()
1193 ->GetPageModule() 1193 ->GetPageModule()
1194 ->GetFontGlobals() 1194 ->GetFontGlobals()
1195 ->m_CMapManager.GetPredefinedCMap(cmap, m_pFontFile && m_bType1); 1195 ->m_CMapManager.GetPredefinedCMap(cmap, m_pFontFile && m_bType1);
1196 } else if (CPDF_Stream* pStream = pEncoding->AsStream()) { 1196 } else if (CPDF_Stream* pStream = pEncoding->AsStream()) {
1197 m_pAllocatedCMap = m_pCMap = new CPDF_CMap; 1197 m_pAllocatedCMap = m_pCMap = new CPDF_CMap;
1198 CPDF_StreamAcc acc; 1198 CPDF_StreamAcc acc;
1199 acc.LoadAllData(pStream, FALSE); 1199 acc.LoadAllData(pStream, FALSE);
1200 m_pCMap->LoadEmbedded(acc.GetData(), acc.GetSize()); 1200 m_pCMap->LoadEmbedded(acc.GetData(), acc.GetSize());
1201 } else { 1201 } else {
1202 return FALSE; 1202 return FALSE;
1203 } 1203 }
1204 if (!m_pCMap) { 1204 if (!m_pCMap) {
1205 return FALSE; 1205 return FALSE;
1206 } 1206 }
1207 m_Charset = m_pCMap->m_Charset; 1207 m_Charset = m_pCMap->m_Charset;
1208 if (m_Charset == CIDSET_UNKNOWN) { 1208 if (m_Charset == CIDSET_UNKNOWN) {
1209 CPDF_Dictionary* pCIDInfo = pCIDFontDict->GetDict("CIDSystemInfo"); 1209 CPDF_Dictionary* pCIDInfo = pCIDFontDict->GetDictBy("CIDSystemInfo");
1210 if (pCIDInfo) { 1210 if (pCIDInfo) {
1211 m_Charset = CharsetFromOrdering(pCIDInfo->GetString("Ordering")); 1211 m_Charset = CharsetFromOrdering(pCIDInfo->GetStringBy("Ordering"));
1212 } 1212 }
1213 } 1213 }
1214 if (m_Charset != CIDSET_UNKNOWN) 1214 if (m_Charset != CIDSET_UNKNOWN)
1215 m_pCID2UnicodeMap = 1215 m_pCID2UnicodeMap =
1216 CPDF_ModuleMgr::Get() 1216 CPDF_ModuleMgr::Get()
1217 ->GetPageModule() 1217 ->GetPageModule()
1218 ->GetFontGlobals() 1218 ->GetFontGlobals()
1219 ->m_CMapManager.GetCID2UnicodeMap( 1219 ->m_CMapManager.GetCID2UnicodeMap(
1220 m_Charset, 1220 m_Charset,
1221 !m_pFontFile && (m_pCMap->m_Coding == CIDCODING_CID || 1221 !m_pFontFile && (m_pCMap->m_Coding == CIDCODING_CID ||
1222 pCIDFontDict->KeyExist("W"))); 1222 pCIDFontDict->KeyExist("W")));
1223 if (m_Font.GetFace()) { 1223 if (m_Font.GetFace()) {
1224 if (m_bType1) { 1224 if (m_bType1) {
1225 FXFT_Select_Charmap(m_Font.GetFace(), FXFT_ENCODING_UNICODE); 1225 FXFT_Select_Charmap(m_Font.GetFace(), FXFT_ENCODING_UNICODE);
1226 } else { 1226 } else {
1227 FT_UseCIDCharmap(m_Font.GetFace(), m_pCMap->m_Coding); 1227 FT_UseCIDCharmap(m_Font.GetFace(), m_pCMap->m_Coding);
1228 } 1228 }
1229 } 1229 }
1230 m_DefaultWidth = pCIDFontDict->GetInteger("DW", 1000); 1230 m_DefaultWidth = pCIDFontDict->GetIntegerBy("DW", 1000);
1231 CPDF_Array* pWidthArray = pCIDFontDict->GetArray("W"); 1231 CPDF_Array* pWidthArray = pCIDFontDict->GetArrayBy("W");
1232 if (pWidthArray) { 1232 if (pWidthArray) {
1233 LoadMetricsArray(pWidthArray, m_WidthList, 1); 1233 LoadMetricsArray(pWidthArray, m_WidthList, 1);
1234 } 1234 }
1235 if (!IsEmbedded()) { 1235 if (!IsEmbedded()) {
1236 LoadSubstFont(); 1236 LoadSubstFont();
1237 } 1237 }
1238 if (1) { 1238 if (1) {
1239 if (m_pFontFile || (GetSubstFont()->m_SubstFlags & FXFONT_SUBST_EXACT)) { 1239 if (m_pFontFile || (GetSubstFont()->m_SubstFlags & FXFONT_SUBST_EXACT)) {
1240 CPDF_Object* pmap = pCIDFontDict->GetElementValue("CIDToGIDMap"); 1240 CPDF_Object* pmap = pCIDFontDict->GetElementValue("CIDToGIDMap");
1241 if (pmap) { 1241 if (pmap) {
1242 if (CPDF_Stream* pStream = pmap->AsStream()) { 1242 if (CPDF_Stream* pStream = pmap->AsStream()) {
1243 m_pCIDToGIDMap = new CPDF_StreamAcc; 1243 m_pCIDToGIDMap = new CPDF_StreamAcc;
1244 m_pCIDToGIDMap->LoadAllData(pStream, FALSE); 1244 m_pCIDToGIDMap->LoadAllData(pStream, FALSE);
1245 } else if (pmap->GetString() == "Identity") { 1245 } else if (pmap->GetString() == "Identity") {
1246 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 1246 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
1247 if (m_pFontFile) { 1247 if (m_pFontFile) {
1248 m_bCIDIsGID = TRUE; 1248 m_bCIDIsGID = TRUE;
1249 } 1249 }
1250 #else 1250 #else
1251 m_bCIDIsGID = TRUE; 1251 m_bCIDIsGID = TRUE;
1252 #endif 1252 #endif
1253 } 1253 }
1254 } 1254 }
1255 } 1255 }
1256 } 1256 }
1257 CheckFontMetrics(); 1257 CheckFontMetrics();
1258 if (IsVertWriting()) { 1258 if (IsVertWriting()) {
1259 pWidthArray = pCIDFontDict->GetArray("W2"); 1259 pWidthArray = pCIDFontDict->GetArrayBy("W2");
1260 if (pWidthArray) { 1260 if (pWidthArray) {
1261 LoadMetricsArray(pWidthArray, m_VertMetrics, 3); 1261 LoadMetricsArray(pWidthArray, m_VertMetrics, 3);
1262 } 1262 }
1263 CPDF_Array* pDefaultArray = pCIDFontDict->GetArray("DW2"); 1263 CPDF_Array* pDefaultArray = pCIDFontDict->GetArrayBy("DW2");
1264 if (pDefaultArray) { 1264 if (pDefaultArray) {
1265 m_DefaultVY = pDefaultArray->GetInteger(0); 1265 m_DefaultVY = pDefaultArray->GetIntegerAt(0);
1266 m_DefaultW1 = pDefaultArray->GetInteger(1); 1266 m_DefaultW1 = pDefaultArray->GetIntegerAt(1);
1267 } else { 1267 } else {
1268 m_DefaultVY = 880; 1268 m_DefaultVY = 880;
1269 m_DefaultW1 = -1000; 1269 m_DefaultW1 = -1000;
1270 } 1270 }
1271 } 1271 }
1272 return TRUE; 1272 return TRUE;
1273 } 1273 }
1274 1274
1275 void CPDF_CIDFont::GetCharBBox(FX_DWORD charcode, FX_RECT& rect, int level) { 1275 void CPDF_CIDFont::GetCharBBox(FX_DWORD charcode, FX_RECT& rect, int level) {
1276 if (charcode < 256 && m_CharBBox[charcode].Right != -1) { 1276 if (charcode < 256 && m_CharBBox[charcode].Right != -1) {
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
1643 1643
1644 if (CPDF_Array* pArray = pObj->AsArray()) { 1644 if (CPDF_Array* pArray = pObj->AsArray()) {
1645 if (width_status != 1) 1645 if (width_status != 1)
1646 return; 1646 return;
1647 1647
1648 FX_DWORD count = pArray->GetCount(); 1648 FX_DWORD count = pArray->GetCount();
1649 for (FX_DWORD j = 0; j < count; j += nElements) { 1649 for (FX_DWORD j = 0; j < count; j += nElements) {
1650 result.Add(first_code); 1650 result.Add(first_code);
1651 result.Add(first_code); 1651 result.Add(first_code);
1652 for (int k = 0; k < nElements; k++) { 1652 for (int k = 0; k < nElements; k++) {
1653 result.Add(pArray->GetInteger(j + k)); 1653 result.Add(pArray->GetIntegerAt(j + k));
1654 } 1654 }
1655 first_code++; 1655 first_code++;
1656 } 1656 }
1657 width_status = 0; 1657 width_status = 0;
1658 } else { 1658 } else {
1659 if (width_status == 0) { 1659 if (width_status == 0) {
1660 first_code = pObj->GetInteger(); 1660 first_code = pObj->GetInteger();
1661 width_status = 1; 1661 width_status = 1;
1662 } else if (width_status == 1) { 1662 } else if (width_status == 1) {
1663 last_code = pObj->GetInteger(); 1663 last_code = pObj->GetInteger();
(...skipping 16 matching lines...) Expand all
1680 1680
1681 // static 1681 // static
1682 FX_FLOAT CPDF_CIDFont::CIDTransformToFloat(uint8_t ch) { 1682 FX_FLOAT CPDF_CIDFont::CIDTransformToFloat(uint8_t ch) {
1683 if (ch < 128) { 1683 if (ch < 128) {
1684 return ch * 1.0f / 127; 1684 return ch * 1.0f / 127;
1685 } 1685 }
1686 return (-255 + ch) * 1.0f / 127; 1686 return (-255 + ch) * 1.0f / 127;
1687 } 1687 }
1688 1688
1689 FX_BOOL CPDF_CIDFont::LoadGB2312() { 1689 FX_BOOL CPDF_CIDFont::LoadGB2312() {
1690 m_BaseFont = m_pFontDict->GetString("BaseFont"); 1690 m_BaseFont = m_pFontDict->GetStringBy("BaseFont");
1691 CPDF_Dictionary* pFontDesc = m_pFontDict->GetDict("FontDescriptor"); 1691 CPDF_Dictionary* pFontDesc = m_pFontDict->GetDictBy("FontDescriptor");
1692 if (pFontDesc) { 1692 if (pFontDesc) {
1693 LoadFontDescriptor(pFontDesc); 1693 LoadFontDescriptor(pFontDesc);
1694 } 1694 }
1695 m_Charset = CIDSET_GB1; 1695 m_Charset = CIDSET_GB1;
1696 m_bType1 = FALSE; 1696 m_bType1 = FALSE;
1697 m_pCMap = CPDF_ModuleMgr::Get() 1697 m_pCMap = CPDF_ModuleMgr::Get()
1698 ->GetPageModule() 1698 ->GetPageModule()
1699 ->GetFontGlobals() 1699 ->GetFontGlobals()
1700 ->m_CMapManager.GetPredefinedCMap("GBK-EUC-H", FALSE); 1700 ->m_CMapManager.GetPredefinedCMap("GBK-EUC-H", FALSE);
1701 m_pCID2UnicodeMap = CPDF_ModuleMgr::Get() 1701 m_pCID2UnicodeMap = CPDF_ModuleMgr::Get()
(...skipping 14 matching lines...) Expand all
1716 1716
1717 const uint8_t* CPDF_CIDFont::GetCIDTransform(FX_WORD CID) const { 1717 const uint8_t* CPDF_CIDFont::GetCIDTransform(FX_WORD CID) const {
1718 if (m_Charset != CIDSET_JAPAN1 || m_pFontFile) 1718 if (m_Charset != CIDSET_JAPAN1 || m_pFontFile)
1719 return nullptr; 1719 return nullptr;
1720 1720
1721 const struct CIDTransform* found = (const struct CIDTransform*)FXSYS_bsearch( 1721 const struct CIDTransform* found = (const struct CIDTransform*)FXSYS_bsearch(
1722 &CID, g_Japan1_VertCIDs, FX_ArraySize(g_Japan1_VertCIDs), 1722 &CID, g_Japan1_VertCIDs, FX_ArraySize(g_Japan1_VertCIDs),
1723 sizeof(g_Japan1_VertCIDs[0]), CompareCIDTransform); 1723 sizeof(g_Japan1_VertCIDs[0]), CompareCIDTransform);
1724 return found ? &found->a : nullptr; 1724 return found ? &found->a : nullptr;
1725 } 1725 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_font/fpdf_font.cpp ('k') | core/src/fpdfapi/fpdf_page/fpdf_page.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698