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

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

Issue 1297303002: Fix mac build after commit e1ce94e. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: 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/fxge/apple/fx_apple_platform.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_module.h" 7 #include "../../../include/fpdfapi/fpdf_module.h"
8 #include "../../../include/fpdfapi/fpdf_page.h" 8 #include "../../../include/fpdfapi/fpdf_page.h"
9 #include "../../../include/fpdfapi/fpdf_pageobj.h" 9 #include "../../../include/fpdfapi/fpdf_pageobj.h"
10 #include "../../../include/fpdfapi/fpdf_resource.h" 10 #include "../../../include/fpdfapi/fpdf_resource.h"
(...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 } 1083 }
1084 #endif 1084 #endif
1085 void CPDF_Type1Font::LoadGlyphMap() { 1085 void CPDF_Type1Font::LoadGlyphMap() {
1086 if (!m_Font.GetFace()) 1086 if (!m_Font.GetFace())
1087 return; 1087 return;
1088 1088
1089 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 1089 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
1090 FX_BOOL bCoreText = TRUE; 1090 FX_BOOL bCoreText = TRUE;
1091 CQuartz2D& quartz2d = 1091 CQuartz2D& quartz2d =
1092 ((CApplePlatform*)CFX_GEModule::Get()->GetPlatformData())->_quartz2d; 1092 ((CApplePlatform*)CFX_GEModule::Get()->GetPlatformData())->_quartz2d;
1093 if (!m_Font.m_pPlatformFont) { 1093 if (!m_Font.GetPlatformFont()) {
1094 if (m_Font.GetPsName() == CFX_WideString::FromLocal("DFHeiStd-W5")) { 1094 if (m_Font.GetPsName() == CFX_WideString::FromLocal("DFHeiStd-W5")) {
1095 bCoreText = FALSE; 1095 bCoreText = FALSE;
1096 } 1096 }
1097 m_Font.m_pPlatformFont = 1097 m_Font.SetPlatformFont(
1098 quartz2d.CreateFont(m_Font.m_pFontData, m_Font.m_dwSize); 1098 quartz2d.CreateFont(m_Font.GetFontData(), m_Font.GetSize()));
1099 if (NULL == m_Font.m_pPlatformFont) { 1099 if (!m_Font.GetPlatformFont()) {
1100 bCoreText = FALSE; 1100 bCoreText = FALSE;
1101 } 1101 }
1102 } 1102 }
1103 #endif 1103 #endif
1104 if (!IsEmbedded() && (m_Base14Font < 12) && m_Font.IsTTFont()) { 1104 if (!IsEmbedded() && (m_Base14Font < 12) && m_Font.IsTTFont()) {
1105 if (FT_UseTTCharmap(m_Font.GetFace(), 3, 0)) { 1105 if (FT_UseTTCharmap(m_Font.GetFace(), 3, 0)) {
1106 FX_BOOL bGotOne = FALSE; 1106 FX_BOOL bGotOne = FALSE;
1107 for (int charcode = 0; charcode < 256; charcode++) { 1107 for (int charcode = 0; charcode < 256; charcode++) {
1108 const uint8_t prefix[4] = {0x00, 0xf0, 0xf1, 0xf2}; 1108 const uint8_t prefix[4] = {0x00, 0xf0, 0xf1, 0xf2};
1109 for (int j = 0; j < 4; j++) { 1109 for (int j = 0; j < 4; j++) {
1110 FX_WORD unicode = prefix[j] * 256 + charcode; 1110 FX_WORD unicode = prefix[j] * 256 + charcode;
1111 m_GlyphIndex[charcode] = 1111 m_GlyphIndex[charcode] =
1112 FXFT_Get_Char_Index(m_Font.GetFace(), unicode); 1112 FXFT_Get_Char_Index(m_Font.GetFace(), unicode);
1113 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 1113 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
1114 FX_CHAR name_glyph[256]; 1114 FX_CHAR name_glyph[256];
1115 FXFT_Get_Glyph_Name(m_Font.GetFace(), m_GlyphIndex[charcode], 1115 FXFT_Get_Glyph_Name(m_Font.GetFace(), m_GlyphIndex[charcode],
1116 name_glyph, 256); 1116 name_glyph, 256);
1117 name_glyph[255] = 0; 1117 name_glyph[255] = 0;
1118 CFStringRef name_ct = CFStringCreateWithCStringNoCopy( 1118 CFStringRef name_ct = CFStringCreateWithCStringNoCopy(
1119 kCFAllocatorDefault, name_glyph, kCFStringEncodingASCII, 1119 kCFAllocatorDefault, name_glyph, kCFStringEncodingASCII,
1120 kCFAllocatorNull); 1120 kCFAllocatorNull);
1121 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName( 1121 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName(
1122 (CGFontRef)m_Font.m_pPlatformFont, name_ct); 1122 (CGFontRef)m_Font.GetPlatformFont(), name_ct);
1123 if (name_ct) { 1123 if (name_ct) {
1124 CFRelease(name_ct); 1124 CFRelease(name_ct);
1125 } 1125 }
1126 #endif 1126 #endif
1127 if (m_GlyphIndex[charcode]) { 1127 if (m_GlyphIndex[charcode]) {
1128 bGotOne = TRUE; 1128 bGotOne = TRUE;
1129 break; 1129 break;
1130 } 1130 }
1131 } 1131 }
1132 } 1132 }
(...skipping 21 matching lines...) Expand all
1154 m_Font.GetFace(), m_Encoding.m_Unicodes[charcode]); 1154 m_Font.GetFace(), m_Encoding.m_Unicodes[charcode]);
1155 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 1155 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
1156 FX_CHAR name_glyph[256]; 1156 FX_CHAR name_glyph[256];
1157 FXFT_Get_Glyph_Name(m_Font.GetFace(), m_GlyphIndex[charcode], name_glyph, 1157 FXFT_Get_Glyph_Name(m_Font.GetFace(), m_GlyphIndex[charcode], name_glyph,
1158 256); 1158 256);
1159 name_glyph[255] = 0; 1159 name_glyph[255] = 0;
1160 CFStringRef name_ct = CFStringCreateWithCStringNoCopy( 1160 CFStringRef name_ct = CFStringCreateWithCStringNoCopy(
1161 kCFAllocatorDefault, name_glyph, kCFStringEncodingASCII, 1161 kCFAllocatorDefault, name_glyph, kCFStringEncodingASCII,
1162 kCFAllocatorNull); 1162 kCFAllocatorNull);
1163 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName( 1163 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName(
1164 (CGFontRef)m_Font.m_pPlatformFont, name_ct); 1164 (CGFontRef)m_Font.GetPlatformFont(), name_ct);
1165 if (name_ct) { 1165 if (name_ct) {
1166 CFRelease(name_ct); 1166 CFRelease(name_ct);
1167 } 1167 }
1168 #endif 1168 #endif
1169 if (m_GlyphIndex[charcode] == 0 && FXSYS_strcmp(name, ".notdef") == 0) { 1169 if (m_GlyphIndex[charcode] == 0 && FXSYS_strcmp(name, ".notdef") == 0) {
1170 m_Encoding.m_Unicodes[charcode] = 0x20; 1170 m_Encoding.m_Unicodes[charcode] = 0x20;
1171 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.GetFace(), 0x20); 1171 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.GetFace(), 0x20);
1172 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 1172 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
1173 FX_CHAR name_glyph[256]; 1173 FX_CHAR name_glyph[256];
1174 FXFT_Get_Glyph_Name(m_Font.GetFace(), m_GlyphIndex[charcode], 1174 FXFT_Get_Glyph_Name(m_Font.GetFace(), m_GlyphIndex[charcode],
1175 name_glyph, 256); 1175 name_glyph, 256);
1176 name_glyph[255] = 0; 1176 name_glyph[255] = 0;
1177 CFStringRef name_ct = CFStringCreateWithCStringNoCopy( 1177 CFStringRef name_ct = CFStringCreateWithCStringNoCopy(
1178 kCFAllocatorDefault, name_glyph, kCFStringEncodingASCII, 1178 kCFAllocatorDefault, name_glyph, kCFStringEncodingASCII,
1179 kCFAllocatorNull); 1179 kCFAllocatorNull);
1180 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName( 1180 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName(
1181 (CGFontRef)m_Font.m_pPlatformFont, name_ct); 1181 (CGFontRef)m_Font.GetPlatformFont(), name_ct);
1182 if (name_ct) { 1182 if (name_ct) {
1183 CFRelease(name_ct); 1183 CFRelease(name_ct);
1184 } 1184 }
1185 #endif 1185 #endif
1186 } 1186 }
1187 } 1187 }
1188 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 1188 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
1189 if (!bCoreText) { 1189 if (!bCoreText) {
1190 FXSYS_memcpy(m_ExtGID, m_GlyphIndex, 256); 1190 FXSYS_memcpy(m_ExtGID, m_GlyphIndex, 256);
1191 } 1191 }
1192 #endif 1192 #endif
1193 return; 1193 return;
1194 } 1194 }
1195 FT_UseType1Charmap(m_Font.GetFace()); 1195 FT_UseType1Charmap(m_Font.GetFace());
1196 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 1196 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
1197 if (bCoreText) { 1197 if (bCoreText) {
1198 if (m_Flags & PDFFONT_SYMBOLIC) { 1198 if (m_Flags & PDFFONT_SYMBOLIC) {
1199 for (int charcode = 0; charcode < 256; charcode++) { 1199 for (int charcode = 0; charcode < 256; charcode++) {
1200 const FX_CHAR* name = 1200 const FX_CHAR* name =
1201 GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); 1201 GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode);
1202 if (name) { 1202 if (name) {
1203 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); 1203 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name);
1204 m_GlyphIndex[charcode] = 1204 m_GlyphIndex[charcode] =
1205 FXFT_Get_Name_Index(m_Font.GetFace(), (char*)name); 1205 FXFT_Get_Name_Index(m_Font.GetFace(), (char*)name);
1206 CFStringRef name_ct = CFStringCreateWithCStringNoCopy( 1206 CFStringRef name_ct = CFStringCreateWithCStringNoCopy(
1207 kCFAllocatorDefault, name, kCFStringEncodingASCII, 1207 kCFAllocatorDefault, name, kCFStringEncodingASCII,
1208 kCFAllocatorNull); 1208 kCFAllocatorNull);
1209 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName( 1209 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName(
1210 (CGFontRef)m_Font.m_pPlatformFont, name_ct); 1210 (CGFontRef)m_Font.GetPlatformFont(), name_ct);
1211 if (name_ct) { 1211 if (name_ct) {
1212 CFRelease(name_ct); 1212 CFRelease(name_ct);
1213 } 1213 }
1214 } else { 1214 } else {
1215 m_GlyphIndex[charcode] = 1215 m_GlyphIndex[charcode] =
1216 FXFT_Get_Char_Index(m_Font.GetFace(), charcode); 1216 FXFT_Get_Char_Index(m_Font.GetFace(), charcode);
1217 FX_WCHAR unicode = 0; 1217 FX_WCHAR unicode = 0;
1218 if (m_GlyphIndex[charcode]) { 1218 if (m_GlyphIndex[charcode]) {
1219 unicode = 1219 unicode =
1220 FT_UnicodeFromCharCode(PDFFONT_ENCODING_STANDARD, charcode); 1220 FT_UnicodeFromCharCode(PDFFONT_ENCODING_STANDARD, charcode);
1221 } 1221 }
1222 FX_CHAR name_glyph[256]; 1222 FX_CHAR name_glyph[256];
1223 FXSYS_memset(name_glyph, 0, sizeof(name_glyph)); 1223 FXSYS_memset(name_glyph, 0, sizeof(name_glyph));
1224 FXFT_Get_Glyph_Name(m_Font.GetFace(), m_GlyphIndex[charcode], 1224 FXFT_Get_Glyph_Name(m_Font.GetFace(), m_GlyphIndex[charcode],
1225 name_glyph, 256); 1225 name_glyph, 256);
1226 name_glyph[255] = 0; 1226 name_glyph[255] = 0;
1227 if (unicode == 0 && name_glyph[0] != 0) { 1227 if (unicode == 0 && name_glyph[0] != 0) {
1228 unicode = PDF_UnicodeFromAdobeName(name_glyph); 1228 unicode = PDF_UnicodeFromAdobeName(name_glyph);
1229 } 1229 }
1230 m_Encoding.m_Unicodes[charcode] = unicode; 1230 m_Encoding.m_Unicodes[charcode] = unicode;
1231 CFStringRef name_ct = CFStringCreateWithCStringNoCopy( 1231 CFStringRef name_ct = CFStringCreateWithCStringNoCopy(
1232 kCFAllocatorDefault, name_glyph, kCFStringEncodingASCII, 1232 kCFAllocatorDefault, name_glyph, kCFStringEncodingASCII,
1233 kCFAllocatorNull); 1233 kCFAllocatorNull);
1234 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName( 1234 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName(
1235 (CGFontRef)m_Font.m_pPlatformFont, name_ct); 1235 (CGFontRef)m_Font.GetPlatformFont(), name_ct);
1236 if (name_ct) { 1236 if (name_ct) {
1237 CFRelease(name_ct); 1237 CFRelease(name_ct);
1238 } 1238 }
1239 } 1239 }
1240 } 1240 }
1241 return; 1241 return;
1242 } 1242 }
1243 FX_BOOL bUnicode = FALSE; 1243 FX_BOOL bUnicode = FALSE;
1244 if (0 == FXFT_Select_Charmap(m_Font.GetFace(), FXFT_ENCODING_UNICODE)) { 1244 if (0 == FXFT_Select_Charmap(m_Font.GetFace(), FXFT_ENCODING_UNICODE)) {
1245 bUnicode = TRUE; 1245 bUnicode = TRUE;
1246 } 1246 }
1247 for (int charcode = 0; charcode < 256; charcode++) { 1247 for (int charcode = 0; charcode < 256; charcode++) {
1248 const FX_CHAR* name = 1248 const FX_CHAR* name =
1249 GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); 1249 GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode);
1250 if (name == NULL) { 1250 if (name == NULL) {
1251 continue; 1251 continue;
1252 } 1252 }
1253 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); 1253 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name);
1254 const FX_CHAR* pStrUnicode = _GlyphNameRemap(name); 1254 const FX_CHAR* pStrUnicode = _GlyphNameRemap(name);
1255 if (pStrUnicode && 1255 if (pStrUnicode &&
1256 0 == FXFT_Get_Name_Index(m_Font.GetFace(), (char*)name)) { 1256 0 == FXFT_Get_Name_Index(m_Font.GetFace(), (char*)name)) {
1257 name = pStrUnicode; 1257 name = pStrUnicode;
1258 } 1258 }
1259 m_GlyphIndex[charcode] = 1259 m_GlyphIndex[charcode] =
1260 FXFT_Get_Name_Index(m_Font.GetFace(), (char*)name); 1260 FXFT_Get_Name_Index(m_Font.GetFace(), (char*)name);
1261 CFStringRef name_ct = CFStringCreateWithCStringNoCopy( 1261 CFStringRef name_ct = CFStringCreateWithCStringNoCopy(
1262 kCFAllocatorDefault, name, kCFStringEncodingASCII, kCFAllocatorNull); 1262 kCFAllocatorDefault, name, kCFStringEncodingASCII, kCFAllocatorNull);
1263 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName( 1263 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName(
1264 (CGFontRef)m_Font.m_pPlatformFont, name_ct); 1264 (CGFontRef)m_Font.GetPlatformFont(), name_ct);
1265 if (name_ct) { 1265 if (name_ct) {
1266 CFRelease(name_ct); 1266 CFRelease(name_ct);
1267 } 1267 }
1268 if (m_GlyphIndex[charcode] == 0) { 1268 if (m_GlyphIndex[charcode] == 0) {
1269 if (FXSYS_strcmp(name, ".notdef") != 0 && 1269 if (FXSYS_strcmp(name, ".notdef") != 0 &&
1270 FXSYS_strcmp(name, "space") != 0) { 1270 FXSYS_strcmp(name, "space") != 0) {
1271 m_GlyphIndex[charcode] = FXFT_Get_Char_Index( 1271 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(
1272 m_Font.GetFace(), 1272 m_Font.GetFace(),
1273 bUnicode ? m_Encoding.m_Unicodes[charcode] : charcode); 1273 bUnicode ? m_Encoding.m_Unicodes[charcode] : charcode);
1274 FX_CHAR name_glyph[256]; 1274 FX_CHAR name_glyph[256];
1275 FXFT_Get_Glyph_Name(m_Font.GetFace(), m_GlyphIndex[charcode], 1275 FXFT_Get_Glyph_Name(m_Font.GetFace(), m_GlyphIndex[charcode],
1276 name_glyph, 256); 1276 name_glyph, 256);
1277 name_glyph[255] = 0; 1277 name_glyph[255] = 0;
1278 CFStringRef name_ct = CFStringCreateWithCStringNoCopy( 1278 CFStringRef name_ct = CFStringCreateWithCStringNoCopy(
1279 kCFAllocatorDefault, name_glyph, kCFStringEncodingASCII, 1279 kCFAllocatorDefault, name_glyph, kCFStringEncodingASCII,
1280 kCFAllocatorNull); 1280 kCFAllocatorNull);
1281 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName( 1281 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName(
1282 (CGFontRef)m_Font.m_pPlatformFont, name_ct); 1282 (CGFontRef)m_Font.GetPlatformFont(), name_ct);
1283 if (name_ct) { 1283 if (name_ct) {
1284 CFRelease(name_ct); 1284 CFRelease(name_ct);
1285 } 1285 }
1286 } else { 1286 } else {
1287 m_Encoding.m_Unicodes[charcode] = 0x20; 1287 m_Encoding.m_Unicodes[charcode] = 0x20;
1288 m_GlyphIndex[charcode] = 1288 m_GlyphIndex[charcode] =
1289 bUnicode ? FXFT_Get_Char_Index(m_Font.GetFace(), 0x20) : 0xffff; 1289 bUnicode ? FXFT_Get_Char_Index(m_Font.GetFace(), 0x20) : 0xffff;
1290 FX_CHAR name_glyph[256]; 1290 FX_CHAR name_glyph[256];
1291 FXFT_Get_Glyph_Name(m_Font.GetFace(), m_GlyphIndex[charcode], 1291 FXFT_Get_Glyph_Name(m_Font.GetFace(), m_GlyphIndex[charcode],
1292 name_glyph, 256); 1292 name_glyph, 256);
1293 name_glyph[255] = 0; 1293 name_glyph[255] = 0;
1294 CFStringRef name_ct = CFStringCreateWithCStringNoCopy( 1294 CFStringRef name_ct = CFStringCreateWithCStringNoCopy(
1295 kCFAllocatorDefault, name_glyph, kCFStringEncodingASCII, 1295 kCFAllocatorDefault, name_glyph, kCFStringEncodingASCII,
1296 kCFAllocatorNull); 1296 kCFAllocatorNull);
1297 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName( 1297 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName(
1298 (CGFontRef)m_Font.m_pPlatformFont, name_ct); 1298 (CGFontRef)m_Font.GetPlatformFont(), name_ct);
1299 if (name_ct) { 1299 if (name_ct) {
1300 CFRelease(name_ct); 1300 CFRelease(name_ct);
1301 } 1301 }
1302 } 1302 }
1303 } 1303 }
1304 } 1304 }
1305 return; 1305 return;
1306 } 1306 }
1307 #endif 1307 #endif
1308 if (m_Flags & PDFFONT_SYMBOLIC) { 1308 if (m_Flags & PDFFONT_SYMBOLIC) {
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
1781 CPDF_Type3Char::CPDF_Type3Char() { 1781 CPDF_Type3Char::CPDF_Type3Char() {
1782 m_pForm = NULL; 1782 m_pForm = NULL;
1783 m_pBitmap = NULL; 1783 m_pBitmap = NULL;
1784 m_bPageRequired = FALSE; 1784 m_bPageRequired = FALSE;
1785 m_bColored = FALSE; 1785 m_bColored = FALSE;
1786 } 1786 }
1787 CPDF_Type3Char::~CPDF_Type3Char() { 1787 CPDF_Type3Char::~CPDF_Type3Char() {
1788 delete m_pForm; 1788 delete m_pForm;
1789 delete m_pBitmap; 1789 delete m_pBitmap;
1790 } 1790 }
OLDNEW
« no previous file with comments | « core/include/fxge/fx_font.h ('k') | core/src/fxge/apple/fx_apple_platform.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698