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

Side by Side Diff: core/src/fxge/android/fpf_skiafontmgr.cpp

Issue 1172793002: Merge to XFA: Use stdint.h types throughout PDFium. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 6 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/fxge/android/fpf_skiafontmgr.h ('k') | core/src/fxge/apple/apple_int.h » ('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 "fx_fpf.h" 7 #include "fx_fpf.h"
8 #if _FX_OS_ == _FX_ANDROID_ 8 #if _FX_OS_ == _FX_ANDROID_
9 #define FPF_SKIAMATCHWEIGHT_NAME1 62 9 #define FPF_SKIAMATCHWEIGHT_NAME1 62
10 #define FPF_SKIAMATCHWEIGHT_NAME2 60 10 #define FPF_SKIAMATCHWEIGHT_NAME2 60
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 {0xbf85ff26, 0xe1633081}, 57 {0xbf85ff26, 0xe1633081},
58 {0xc04fe601, 0xbbeeec72}, 58 {0xc04fe601, 0xbbeeec72},
59 {0xca3812d5, 0x59b9f8f1}, 59 {0xca3812d5, 0x59b9f8f1},
60 {0xca383e15, 0x59b9f8f1}, 60 {0xca383e15, 0x59b9f8f1},
61 {0xcad5eaf6, 0x59b9f8f1}, 61 {0xcad5eaf6, 0x59b9f8f1},
62 {0xcb7a04c8, 0xc8d2e345}, 62 {0xcb7a04c8, 0xc8d2e345},
63 {0xfb4ce0de, 0xe1633081}, 63 {0xfb4ce0de, 0xe1633081},
64 }; 64 };
65 FX_DWORD FPF_SkiaGetSubstFont(FX_DWORD dwHash) 65 FX_DWORD FPF_SkiaGetSubstFont(FX_DWORD dwHash)
66 { 66 {
67 FX_INT32 iStart = 0; 67 int32_t iStart = 0;
68 FX_INT32 iEnd = sizeof(g_SkiaFontmap) / sizeof(FPF_SKIAFONTMAP); 68 int32_t iEnd = sizeof(g_SkiaFontmap) / sizeof(FPF_SKIAFONTMAP);
69 while (iStart <= iEnd) { 69 while (iStart <= iEnd) {
70 FX_INT32 iMid = (iStart + iEnd) / 2; 70 int32_t iMid = (iStart + iEnd) / 2;
71 FPF_LPCSKIAFONTMAP pItem = &g_SkiaFontmap[iMid]; 71 FPF_LPCSKIAFONTMAP pItem = &g_SkiaFontmap[iMid];
72 if (dwHash < pItem->dwFamily) { 72 if (dwHash < pItem->dwFamily) {
73 iEnd = iMid - 1; 73 iEnd = iMid - 1;
74 } else if (dwHash > pItem->dwFamily) { 74 } else if (dwHash > pItem->dwFamily) {
75 iStart = iMid + 1; 75 iStart = iMid + 1;
76 } else { 76 } else {
77 return pItem->dwSubSt; 77 return pItem->dwSubSt;
78 } 78 }
79 } 79 }
80 return 0; 80 return 0;
81 } 81 }
82 static const FPF_SKIAFONTMAP g_SkiaSansFontMap[] = { 82 static const FPF_SKIAFONTMAP g_SkiaSansFontMap[] = {
83 {0x58c5083, 0xd5b8d10f}, 83 {0x58c5083, 0xd5b8d10f},
84 {0x14ee2d13, 0xd5b8d10f}, 84 {0x14ee2d13, 0xd5b8d10f},
85 {0x779ce19d, 0xd5b8d10f}, 85 {0x779ce19d, 0xd5b8d10f},
86 {0xcb7a04c8, 0xd5b8d10f}, 86 {0xcb7a04c8, 0xd5b8d10f},
87 {0xfb4ce0de, 0xd5b8d10f}, 87 {0xfb4ce0de, 0xd5b8d10f},
88 }; 88 };
89 FX_DWORD FPF_SkiaGetSansFont(FX_DWORD dwHash) 89 FX_DWORD FPF_SkiaGetSansFont(FX_DWORD dwHash)
90 { 90 {
91 FX_INT32 iStart = 0; 91 int32_t iStart = 0;
92 FX_INT32 iEnd = sizeof(g_SkiaSansFontMap) / sizeof(FPF_SKIAFONTMAP); 92 int32_t iEnd = sizeof(g_SkiaSansFontMap) / sizeof(FPF_SKIAFONTMAP);
93 while (iStart <= iEnd) { 93 while (iStart <= iEnd) {
94 FX_INT32 iMid = (iStart + iEnd) / 2; 94 int32_t iMid = (iStart + iEnd) / 2;
95 FPF_LPCSKIAFONTMAP pItem = &g_SkiaSansFontMap[iMid]; 95 FPF_LPCSKIAFONTMAP pItem = &g_SkiaSansFontMap[iMid];
96 if (dwHash < pItem->dwFamily) { 96 if (dwHash < pItem->dwFamily) {
97 iEnd = iMid - 1; 97 iEnd = iMid - 1;
98 } else if (dwHash > pItem->dwFamily) { 98 } else if (dwHash > pItem->dwFamily) {
99 iStart = iMid + 1; 99 iStart = iMid + 1;
100 } else { 100 } else {
101 return pItem->dwSubSt; 101 return pItem->dwSubSt;
102 } 102 }
103 } 103 }
104 return 0; 104 return 0;
105 } 105 }
106 static FX_UINT32 FPF_GetHashCode_StringA(FX_LPCSTR pStr, FX_INT32 iLength, FX_BO OL bIgnoreCase = FALSE) 106 static uint32_t FPF_GetHashCode_StringA(FX_LPCSTR pStr, int32_t iLength, FX_BOOL bIgnoreCase = FALSE)
107 { 107 {
108 if (!pStr) { 108 if (!pStr) {
109 return 0; 109 return 0;
110 } 110 }
111 if (iLength < 0) { 111 if (iLength < 0) {
112 iLength = FXSYS_strlen(pStr); 112 iLength = FXSYS_strlen(pStr);
113 } 113 }
114 FX_LPCSTR pStrEnd = pStr + iLength; 114 FX_LPCSTR pStrEnd = pStr + iLength;
115 FX_UINT32 uHashCode = 0; 115 uint32_t uHashCode = 0;
116 if (bIgnoreCase) { 116 if (bIgnoreCase) {
117 while (pStr < pStrEnd) { 117 while (pStr < pStrEnd) {
118 uHashCode = 31 * uHashCode + FXSYS_tolower(*pStr++); 118 uHashCode = 31 * uHashCode + FXSYS_tolower(*pStr++);
119 } 119 }
120 } else { 120 } else {
121 while (pStr < pStrEnd) { 121 while (pStr < pStrEnd) {
122 uHashCode = 31 * uHashCode + *pStr ++; 122 uHashCode = 31 * uHashCode + *pStr ++;
123 } 123 }
124 } 124 }
125 return uHashCode; 125 return uHashCode;
(...skipping 12 matching lines...) Expand all
138 FPF_SKIACHARSET_Vietnamese = 1 << 10, 138 FPF_SKIACHARSET_Vietnamese = 1 << 10,
139 FPF_SKIACHARSET_Hebrew = 1 << 11, 139 FPF_SKIACHARSET_Hebrew = 1 << 11,
140 FPF_SKIACHARSET_Arabic = 1 << 12, 140 FPF_SKIACHARSET_Arabic = 1 << 12,
141 FPF_SKIACHARSET_Baltic = 1 << 13, 141 FPF_SKIACHARSET_Baltic = 1 << 13,
142 FPF_SKIACHARSET_Cyrillic = 1 << 14, 142 FPF_SKIACHARSET_Cyrillic = 1 << 14,
143 FPF_SKIACHARSET_Thai = 1 << 15, 143 FPF_SKIACHARSET_Thai = 1 << 15,
144 FPF_SKIACHARSET_EeasternEuropean = 1 << 16, 144 FPF_SKIACHARSET_EeasternEuropean = 1 << 16,
145 FPF_SKIACHARSET_PC = 1 << 17, 145 FPF_SKIACHARSET_PC = 1 << 17,
146 FPF_SKIACHARSET_OEM = 1 << 18, 146 FPF_SKIACHARSET_OEM = 1 << 18,
147 }; 147 };
148 static FX_DWORD FPF_SkiaGetCharset(FX_BYTE uCharset) 148 static FX_DWORD FPF_SkiaGetCharset(uint8_t uCharset)
149 { 149 {
150 switch (uCharset) { 150 switch (uCharset) {
151 case FXFONT_ANSI_CHARSET: 151 case FXFONT_ANSI_CHARSET:
152 return FPF_SKIACHARSET_Ansi; 152 return FPF_SKIACHARSET_Ansi;
153 case FXFONT_DEFAULT_CHARSET: 153 case FXFONT_DEFAULT_CHARSET:
154 return FPF_SKIACHARSET_Default; 154 return FPF_SKIACHARSET_Default;
155 case FXFONT_SYMBOL_CHARSET: 155 case FXFONT_SYMBOL_CHARSET:
156 return FPF_SKIACHARSET_Symbol; 156 return FPF_SKIACHARSET_Symbol;
157 case FXFONT_SHIFTJIS_CHARSET: 157 case FXFONT_SHIFTJIS_CHARSET:
158 return FPF_SKIACHARSET_ShiftJIS; 158 return FPF_SKIACHARSET_ShiftJIS;
(...skipping 18 matching lines...) Expand all
177 case FXFONT_THAI_CHARSET: 177 case FXFONT_THAI_CHARSET:
178 return FPF_SKIACHARSET_Thai; 178 return FPF_SKIACHARSET_Thai;
179 case FXFONT_EASTEUROPE_CHARSET: 179 case FXFONT_EASTEUROPE_CHARSET:
180 return FPF_SKIACHARSET_EeasternEuropean; 180 return FPF_SKIACHARSET_EeasternEuropean;
181 } 181 }
182 return FPF_SKIACHARSET_Default; 182 return FPF_SKIACHARSET_Default;
183 } 183 }
184 static FX_DWORD FPF_SKIANormalizeFontName(FX_BSTR bsfamily) 184 static FX_DWORD FPF_SKIANormalizeFontName(FX_BSTR bsfamily)
185 { 185 {
186 FX_DWORD dwHash = 0; 186 FX_DWORD dwHash = 0;
187 FX_INT32 iLength = bsfamily.GetLength(); 187 int32_t iLength = bsfamily.GetLength();
188 FX_LPCSTR pBuffer = bsfamily.GetCStr(); 188 FX_LPCSTR pBuffer = bsfamily.GetCStr();
189 for (FX_INT32 i = 0; i < iLength; i++) { 189 for (int32_t i = 0; i < iLength; i++) {
190 FX_CHAR ch = pBuffer[i]; 190 FX_CHAR ch = pBuffer[i];
191 if (ch == ' ' || ch == '-' || ch == ',') { 191 if (ch == ' ' || ch == '-' || ch == ',') {
192 continue; 192 continue;
193 } 193 }
194 dwHash = 31 * dwHash + FXSYS_tolower(ch); 194 dwHash = 31 * dwHash + FXSYS_tolower(ch);
195 } 195 }
196 return dwHash; 196 return dwHash;
197 } 197 }
198 static FX_DWORD»FPF_SKIAGetFamilyHash(FX_BSTR bsFamily, FX_DWORD dwStyle, FX_BYT E uCharset) 198 static FX_DWORD»FPF_SKIAGetFamilyHash(FX_BSTR bsFamily, FX_DWORD dwStyle, uint8_ t uCharset)
199 { 199 {
200 CFX_ByteString bsFont(bsFamily); 200 CFX_ByteString bsFont(bsFamily);
201 if (dwStyle & FXFONT_BOLD) { 201 if (dwStyle & FXFONT_BOLD) {
202 bsFont += "Bold"; 202 bsFont += "Bold";
203 } 203 }
204 if (dwStyle & FXFONT_ITALIC) { 204 if (dwStyle & FXFONT_ITALIC) {
205 bsFont += "Italic"; 205 bsFont += "Italic";
206 } 206 }
207 if (dwStyle & FXFONT_SERIF) { 207 if (dwStyle & FXFONT_SERIF) {
208 bsFont += "Serif"; 208 bsFont += "Serif";
209 } 209 }
210 bsFont += uCharset; 210 bsFont += uCharset;
211 return FPF_GetHashCode_StringA(bsFont.c_str(), bsFont.GetLength(), TRUE); 211 return FPF_GetHashCode_StringA(bsFont.c_str(), bsFont.GetLength(), TRUE);
212 } 212 }
213 static FX_BOOL FPF_SkiaIsCJK(FX_BYTE uCharset) 213 static FX_BOOL FPF_SkiaIsCJK(uint8_t uCharset)
214 { 214 {
215 return (uCharset == FXFONT_GB2312_CHARSET) || (uCharset == FXFONT_CHINESEBIG 5_CHARSET) 215 return (uCharset == FXFONT_GB2312_CHARSET) || (uCharset == FXFONT_CHINESEBIG 5_CHARSET)
216 || (uCharset == FXFONT_HANGEUL_CHARSET) || (uCharset == FXFONT_SHIFTJ IS_CHARSET); 216 || (uCharset == FXFONT_HANGEUL_CHARSET) || (uCharset == FXFONT_SHIFTJ IS_CHARSET);
217 } 217 }
218 static FX_BOOL FPF_SkiaMaybeSymbol(FX_BSTR bsFacename) 218 static FX_BOOL FPF_SkiaMaybeSymbol(FX_BSTR bsFacename)
219 { 219 {
220 CFX_ByteString bsName = bsFacename; 220 CFX_ByteString bsName = bsFacename;
221 bsName.MakeLower(); 221 bsName.MakeLower();
222 return bsName.Find("symbol") > -1; 222 return bsName.Find("symbol") > -1;
223 } 223 }
(...skipping 12 matching lines...) Expand all
236 void *pkey = NULL; 236 void *pkey = NULL;
237 CFPF_SkiaFont *pValue = NULL; 237 CFPF_SkiaFont *pValue = NULL;
238 FX_POSITION pos = m_FamilyFonts.GetStartPosition(); 238 FX_POSITION pos = m_FamilyFonts.GetStartPosition();
239 while (pos) { 239 while (pos) {
240 m_FamilyFonts.GetNextAssoc(pos, pkey, (void*&)pValue); 240 m_FamilyFonts.GetNextAssoc(pos, pkey, (void*&)pValue);
241 if (pValue) { 241 if (pValue) {
242 pValue->Release(); 242 pValue->Release();
243 } 243 }
244 } 244 }
245 m_FamilyFonts.RemoveAll(); 245 m_FamilyFonts.RemoveAll();
246 for (FX_INT32 i = m_FontFaces.GetUpperBound(); i >= 0; i--) { 246 for (int32_t i = m_FontFaces.GetUpperBound(); i >= 0; i--) {
247 CFPF_SkiaFontDescriptor *pFont = (CFPF_SkiaFontDescriptor*)m_FontFaces.E lementAt(i); 247 CFPF_SkiaFontDescriptor *pFont = (CFPF_SkiaFontDescriptor*)m_FontFaces.E lementAt(i);
248 if (pFont) { 248 if (pFont) {
249 delete pFont; 249 delete pFont;
250 } 250 }
251 } 251 }
252 m_FontFaces.RemoveAll(); 252 m_FontFaces.RemoveAll();
253 if (m_FTLibrary) { 253 if (m_FTLibrary) {
254 FXFT_Done_FreeType(m_FTLibrary); 254 FXFT_Done_FreeType(m_FTLibrary);
255 } 255 }
256 } 256 }
(...skipping 15 matching lines...) Expand all
272 } 272 }
273 void CFPF_SkiaFontMgr::LoadPrivateFont(IFX_FileRead* pFontFile) 273 void CFPF_SkiaFontMgr::LoadPrivateFont(IFX_FileRead* pFontFile)
274 { 274 {
275 } 275 }
276 void CFPF_SkiaFontMgr::LoadPrivateFont(FX_BSTR bsFileName) 276 void CFPF_SkiaFontMgr::LoadPrivateFont(FX_BSTR bsFileName)
277 { 277 {
278 } 278 }
279 void CFPF_SkiaFontMgr::LoadPrivateFont(FX_LPVOID pBuffer, size_t szBuffer) 279 void CFPF_SkiaFontMgr::LoadPrivateFont(FX_LPVOID pBuffer, size_t szBuffer)
280 { 280 {
281 } 281 }
282 IFPF_Font* CFPF_SkiaFontMgr::CreateFont(FX_BSTR bsFamilyname, FX_BYTE uCharset, FX_DWORD dwStyle, FX_DWORD dwMatch) 282 IFPF_Font* CFPF_SkiaFontMgr::CreateFont(FX_BSTR bsFamilyname, uint8_t uCharset, FX_DWORD dwStyle, FX_DWORD dwMatch)
283 { 283 {
284 FX_DWORD dwHash = FPF_SKIAGetFamilyHash(bsFamilyname, dwStyle, uCharset); 284 FX_DWORD dwHash = FPF_SKIAGetFamilyHash(bsFamilyname, dwStyle, uCharset);
285 IFPF_Font *pFont = NULL; 285 IFPF_Font *pFont = NULL;
286 if (m_FamilyFonts.Lookup((void*)(FX_UINTPTR)dwHash, (void*&)pFont)) { 286 if (m_FamilyFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) {
287 if (pFont) { 287 if (pFont) {
288 return pFont->Retain(); 288 return pFont->Retain();
289 } 289 }
290 } 290 }
291 FX_DWORD dwFaceName = FPF_SKIANormalizeFontName(bsFamilyname); 291 FX_DWORD dwFaceName = FPF_SKIANormalizeFontName(bsFamilyname);
292 FX_DWORD dwSubst = FPF_SkiaGetSubstFont(dwFaceName); 292 FX_DWORD dwSubst = FPF_SkiaGetSubstFont(dwFaceName);
293 FX_DWORD dwSubstSans = FPF_SkiaGetSansFont(dwFaceName); 293 FX_DWORD dwSubstSans = FPF_SkiaGetSansFont(dwFaceName);
294 FX_BOOL bMaybeSymbol = FPF_SkiaMaybeSymbol(bsFamilyname); 294 FX_BOOL bMaybeSymbol = FPF_SkiaMaybeSymbol(bsFamilyname);
295 if (uCharset != FXFONT_ARABIC_CHARSET && FPF_SkiaMaybeArabic(bsFamilyname)) { 295 if (uCharset != FXFONT_ARABIC_CHARSET && FPF_SkiaMaybeArabic(bsFamilyname)) {
296 uCharset = FXFONT_ARABIC_CHARSET; 296 uCharset = FXFONT_ARABIC_CHARSET;
297 } else if (uCharset == FXFONT_ANSI_CHARSET && (dwMatch & FPF_MATCHFONT_REPLA CEANSI)) { 297 } else if (uCharset == FXFONT_ANSI_CHARSET && (dwMatch & FPF_MATCHFONT_REPLA CEANSI)) {
298 uCharset = FXFONT_DEFAULT_CHARSET; 298 uCharset = FXFONT_DEFAULT_CHARSET;
299 } 299 }
300 FX_INT32 nExpectVal = FPF_SKIAMATCHWEIGHT_NAME1 + FPF_SKIAMATCHWEIGHT_1 * 3 + FPF_SKIAMATCHWEIGHT_2 * 2; 300 int32_t nExpectVal = FPF_SKIAMATCHWEIGHT_NAME1 + FPF_SKIAMATCHWEIGHT_1 * 3 + FPF_SKIAMATCHWEIGHT_2 * 2;
301 FX_INT32 nItem = -1; 301 int32_t nItem = -1;
302 FX_INT32 nMax = -1; 302 int32_t nMax = -1;
303 FX_INT32 nGlyphNum = 0; 303 int32_t nGlyphNum = 0;
304 for (FX_INT32 i = m_FontFaces.GetUpperBound(); i >= 0; i--) { 304 for (int32_t i = m_FontFaces.GetUpperBound(); i >= 0; i--) {
305 CFPF_SkiaPathFont *pFontDes = (CFPF_SkiaPathFont*)m_FontFaces.ElementAt( i); 305 CFPF_SkiaPathFont *pFontDes = (CFPF_SkiaPathFont*)m_FontFaces.ElementAt( i);
306 if(!(pFontDes->m_dwCharsets & FPF_SkiaGetCharset(uCharset))) { 306 if(!(pFontDes->m_dwCharsets & FPF_SkiaGetCharset(uCharset))) {
307 continue; 307 continue;
308 } 308 }
309 FX_INT32 nFind = 0; 309 int32_t nFind = 0;
310 FX_DWORD dwSysFontName = FPF_SKIANormalizeFontName(pFontDes->m_pFamily); 310 FX_DWORD dwSysFontName = FPF_SKIANormalizeFontName(pFontDes->m_pFamily);
311 if (dwFaceName == dwSysFontName) { 311 if (dwFaceName == dwSysFontName) {
312 nFind += FPF_SKIAMATCHWEIGHT_NAME1; 312 nFind += FPF_SKIAMATCHWEIGHT_NAME1;
313 } 313 }
314 FX_BOOL bMatchedName = (nFind == FPF_SKIAMATCHWEIGHT_NAME1); 314 FX_BOOL bMatchedName = (nFind == FPF_SKIAMATCHWEIGHT_NAME1);
315 if ((dwStyle & FXFONT_BOLD) == (pFontDes->m_dwStyle & FXFONT_BOLD)) { 315 if ((dwStyle & FXFONT_BOLD) == (pFontDes->m_dwStyle & FXFONT_BOLD)) {
316 nFind += FPF_SKIAMATCHWEIGHT_1; 316 nFind += FPF_SKIAMATCHWEIGHT_1;
317 } 317 }
318 if ((dwStyle & FXFONT_ITALIC) == (pFontDes->m_dwStyle & FXFONT_ITALIC)) { 318 if ((dwStyle & FXFONT_ITALIC) == (pFontDes->m_dwStyle & FXFONT_ITALIC)) {
319 nFind += FPF_SKIAMATCHWEIGHT_1; 319 nFind += FPF_SKIAMATCHWEIGHT_1;
(...skipping 25 matching lines...) Expand all
345 nMax = nFind; 345 nMax = nFind;
346 nItem = i; 346 nItem = i;
347 } 347 }
348 if (nExpectVal <= nFind) { 348 if (nExpectVal <= nFind) {
349 nItem = i; 349 nItem = i;
350 break; 350 break;
351 } 351 }
352 } 352 }
353 if (nItem > -1) { 353 if (nItem > -1) {
354 CFPF_SkiaFontDescriptor *pFontDes = (CFPF_SkiaFontDescriptor*)m_FontFace s.ElementAt(nItem); 354 CFPF_SkiaFontDescriptor *pFontDes = (CFPF_SkiaFontDescriptor*)m_FontFace s.ElementAt(nItem);
355 <<<<<<< HEAD
355 CFPF_SkiaFont *pFont = FX_NEW CFPF_SkiaFont; 356 CFPF_SkiaFont *pFont = FX_NEW CFPF_SkiaFont;
356 if (pFont) { 357 if (pFont) {
357 if (pFont->InitFont(this, pFontDes, bsFamilyname, dwStyle, uCharset) ) { 358 if (pFont->InitFont(this, pFontDes, bsFamilyname, dwStyle, uCharset) ) {
358 m_FamilyFonts.SetAt((void*)(FX_UINTPTR)dwHash, (void*)pFont); 359 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont);
359 return pFont->Retain(); 360 return pFont->Retain();
360 } 361 }
361 pFont->Release(); 362 pFont->Release();
362 pFont = NULL; 363 pFont = NULL;
364 =======
365 CFPF_SkiaFont *pFont = new CFPF_SkiaFont;
366 if (pFont->InitFont(this, pFontDes, bsFamilyname, dwStyle, uCharset)) {
367 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont);
368 return pFont->Retain();
369 >>>>>>> bb17868... Use stdint.h types throughout PDFium.
363 } 370 }
364 return pFont; 371 return pFont;
365 } 372 }
366 return NULL; 373 return NULL;
367 } 374 }
368 FXFT_Face CFPF_SkiaFontMgr::GetFontFace(IFX_FileRead *pFileRead, FX_INT32 iFaceI ndex) 375 FXFT_Face CFPF_SkiaFontMgr::GetFontFace(IFX_FileRead *pFileRead, int32_t iFaceIn dex)
369 { 376 {
370 if (!pFileRead) { 377 if (!pFileRead) {
371 return NULL; 378 return NULL;
372 } 379 }
373 if (pFileRead->GetSize() == 0) { 380 if (pFileRead->GetSize() == 0) {
374 return NULL; 381 return NULL;
375 } 382 }
376 if (iFaceIndex < 0) { 383 if (iFaceIndex < 0) {
377 return NULL; 384 return NULL;
378 } 385 }
379 FXFT_StreamRec streamRec; 386 FXFT_StreamRec streamRec;
380 FXSYS_memset32(&streamRec, 0, sizeof(FXFT_StreamRec)); 387 FXSYS_memset32(&streamRec, 0, sizeof(FXFT_StreamRec));
381 streamRec.size = pFileRead->GetSize(); 388 streamRec.size = pFileRead->GetSize();
382 streamRec.descriptor.pointer = pFileRead; 389 streamRec.descriptor.pointer = pFileRead;
383 streamRec.read = FPF_SkiaStream_Read; 390 streamRec.read = FPF_SkiaStream_Read;
384 streamRec.close = FPF_SkiaStream_Close; 391 streamRec.close = FPF_SkiaStream_Close;
385 FXFT_Open_Args args; 392 FXFT_Open_Args args;
386 args.flags = FT_OPEN_STREAM; 393 args.flags = FT_OPEN_STREAM;
387 args.stream = &streamRec; 394 args.stream = &streamRec;
388 FXFT_Face face; 395 FXFT_Face face;
389 if (FXFT_Open_Face(m_FTLibrary, &args, iFaceIndex, &face)) { 396 if (FXFT_Open_Face(m_FTLibrary, &args, iFaceIndex, &face)) {
390 return NULL; 397 return NULL;
391 } 398 }
392 FXFT_Set_Pixel_Sizes(face, 0, 64); 399 FXFT_Set_Pixel_Sizes(face, 0, 64);
393 return face; 400 return face;
394 } 401 }
395 FXFT_Face CFPF_SkiaFontMgr::GetFontFace(FX_BSTR bsFile, FX_INT32 iFaceIndex ) 402 FXFT_Face CFPF_SkiaFontMgr::GetFontFace(FX_BSTR bsFile, int32_t iFaceIndex )
396 { 403 {
397 if (bsFile.IsEmpty()) { 404 if (bsFile.IsEmpty()) {
398 return NULL; 405 return NULL;
399 } 406 }
400 if (iFaceIndex < 0) { 407 if (iFaceIndex < 0) {
401 return NULL; 408 return NULL;
402 } 409 }
403 FXFT_Open_Args args; 410 FXFT_Open_Args args;
404 args.flags = FT_OPEN_PATHNAME; 411 args.flags = FT_OPEN_PATHNAME;
405 args.pathname = (FT_String*)bsFile.GetCStr(); 412 args.pathname = (FT_String*)bsFile.GetCStr();
406 FXFT_Face face; 413 FXFT_Face face;
407 if (FXFT_Open_Face(m_FTLibrary, &args, iFaceIndex, &face)) { 414 if (FXFT_Open_Face(m_FTLibrary, &args, iFaceIndex, &face)) {
408 return FALSE; 415 return FALSE;
409 } 416 }
410 FXFT_Set_Pixel_Sizes(face, 0, 64); 417 FXFT_Set_Pixel_Sizes(face, 0, 64);
411 return face; 418 return face;
412 } 419 }
413 FXFT_Face CFPF_SkiaFontMgr::GetFontFace(FX_LPCBYTE pBuffer, size_t szBuffer, FX_ INT32 iFaceIndex ) 420 FXFT_Face CFPF_SkiaFontMgr::GetFontFace(FX_LPCBYTE pBuffer, size_t szBuffer, int 32_t iFaceIndex )
414 { 421 {
415 if (!pBuffer || szBuffer < 1) { 422 if (!pBuffer || szBuffer < 1) {
416 return NULL; 423 return NULL;
417 } 424 }
418 if (iFaceIndex < 0) { 425 if (iFaceIndex < 0) {
419 return NULL; 426 return NULL;
420 } 427 }
421 FXFT_Open_Args args; 428 FXFT_Open_Args args;
422 args.flags = FT_OPEN_MEMORY; 429 args.flags = FT_OPEN_MEMORY;
423 args.memory_base = pBuffer; 430 args.memory_base = pBuffer;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 0, 512 0,
506 0, 513 0,
507 0, 514 0,
508 FPF_SKIACHARSET_OEM, 515 FPF_SKIACHARSET_OEM,
509 FPF_SKIACHARSET_Symbol, 516 FPF_SKIACHARSET_Symbol,
510 }; 517 };
511 static FX_DWORD FPF_SkiaGetFaceCharset(TT_OS2 *pOS2) 518 static FX_DWORD FPF_SkiaGetFaceCharset(TT_OS2 *pOS2)
512 { 519 {
513 FX_DWORD dwCharset = 0; 520 FX_DWORD dwCharset = 0;
514 if (pOS2) { 521 if (pOS2) {
515 for (FX_INT32 i = 0; i < 32; i++) { 522 for (int32_t i = 0; i < 32; i++) {
516 if (pOS2->ulCodePageRange1 & (1 << i)) { 523 if (pOS2->ulCodePageRange1 & (1 << i)) {
517 dwCharset |= g_FPFSkiaFontCharsets[i]; 524 dwCharset |= g_FPFSkiaFontCharsets[i];
518 } 525 }
519 } 526 }
520 } 527 }
521 dwCharset |= FPF_SKIACHARSET_Default; 528 dwCharset |= FPF_SKIACHARSET_Default;
522 return dwCharset; 529 return dwCharset;
523 } 530 }
524 void CFPF_SkiaFontMgr::ReportFace(FXFT_Face face, CFPF_SkiaFontDescriptor *pFont Desc) 531 void CFPF_SkiaFontMgr::ReportFace(FXFT_Face face, CFPF_SkiaFontDescriptor *pFont Desc)
525 { 532 {
526 if (!face || !pFontDesc) { 533 if (!face || !pFontDesc) {
527 return; 534 return;
528 } 535 }
529 pFontDesc->SetFamily(FXFT_Get_Face_Family_Name(face)); 536 pFontDesc->SetFamily(FXFT_Get_Face_Family_Name(face));
530 if (FXFT_Is_Face_Bold(face)) { 537 if (FXFT_Is_Face_Bold(face)) {
531 pFontDesc->m_dwStyle |= FXFONT_BOLD; 538 pFontDesc->m_dwStyle |= FXFONT_BOLD;
532 } 539 }
533 if (FXFT_Is_Face_Italic(face)) { 540 if (FXFT_Is_Face_Italic(face)) {
534 pFontDesc->m_dwStyle |= FXFONT_ITALIC; 541 pFontDesc->m_dwStyle |= FXFONT_ITALIC;
535 } 542 }
536 if (FT_IS_FIXED_WIDTH(face)) { 543 if (FT_IS_FIXED_WIDTH(face)) {
537 pFontDesc->m_dwStyle |= FXFONT_FIXED_PITCH; 544 pFontDesc->m_dwStyle |= FXFONT_FIXED_PITCH;
538 } 545 }
539 TT_OS2 *pOS2 = (TT_OS2*)FT_Get_Sfnt_Table(face, ft_sfnt_os2); 546 TT_OS2 *pOS2 = (TT_OS2*)FT_Get_Sfnt_Table(face, ft_sfnt_os2);
540 if (pOS2) { 547 if (pOS2) {
541 if (pOS2->ulCodePageRange1 & (1 << 31)) { 548 if (pOS2->ulCodePageRange1 & (1 << 31)) {
542 pFontDesc->m_dwStyle |= FXFONT_SYMBOLIC; 549 pFontDesc->m_dwStyle |= FXFONT_SYMBOLIC;
543 } 550 }
544 if (pOS2->panose[0] == 2) { 551 if (pOS2->panose[0] == 2) {
545 FX_BYTE uSerif = pOS2->panose[1]; 552 uint8_t uSerif = pOS2->panose[1];
546 if ((uSerif > 1 && uSerif < 10) || uSerif > 13) { 553 if ((uSerif > 1 && uSerif < 10) || uSerif > 13) {
547 pFontDesc->m_dwStyle |= FXFONT_SERIF; 554 pFontDesc->m_dwStyle |= FXFONT_SERIF;
548 } 555 }
549 } 556 }
550 } 557 }
551 if (pOS2 && (pOS2->ulCodePageRange1 & (1 << 31))) { 558 if (pOS2 && (pOS2->ulCodePageRange1 & (1 << 31))) {
552 pFontDesc->m_dwStyle |= FXFONT_SYMBOLIC; 559 pFontDesc->m_dwStyle |= FXFONT_SYMBOLIC;
553 } 560 }
554 pFontDesc->m_dwCharsets = FPF_SkiaGetFaceCharset(pOS2); 561 pFontDesc->m_dwCharsets = FPF_SkiaGetFaceCharset(pOS2);
555 pFontDesc->m_iFaceIndex = face->face_index; 562 pFontDesc->m_iFaceIndex = face->face_index;
556 pFontDesc->m_iGlyphNum = face->num_glyphs; 563 pFontDesc->m_iGlyphNum = face->num_glyphs;
557 } 564 }
558 void CFPF_SkiaFontMgr::OutputSystemFonts() 565 void CFPF_SkiaFontMgr::OutputSystemFonts()
559 { 566 {
560 } 567 }
561 #endif 568 #endif
OLDNEW
« no previous file with comments | « core/src/fxge/android/fpf_skiafontmgr.h ('k') | core/src/fxge/apple/apple_int.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698