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

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

Issue 2101723002: Fix a regression from commit f3e6851. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Address comments Created 4 years, 5 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 | « no previous file | no next file » | 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 "core/fxcrt/include/fx_system.h" 7 #include "core/fxcrt/include/fx_system.h"
8 8
9 #if _FX_OS_ == _FX_ANDROID_ 9 #if _FX_OS_ == _FX_ANDROID_
10 10
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 if (m_bLoaded) { 241 if (m_bLoaded) {
242 return; 242 return;
243 } 243 }
244 ScanPath("/system/fonts"); 244 ScanPath("/system/fonts");
245 OutputSystemFonts(); 245 OutputSystemFonts();
246 m_bLoaded = TRUE; 246 m_bLoaded = TRUE;
247 } 247 }
248 void CFPF_SkiaFontMgr::LoadPrivateFont(IFX_FileRead* pFontFile) {} 248 void CFPF_SkiaFontMgr::LoadPrivateFont(IFX_FileRead* pFontFile) {}
249 void CFPF_SkiaFontMgr::LoadPrivateFont(const CFX_ByteStringC& bsFileName) {} 249 void CFPF_SkiaFontMgr::LoadPrivateFont(const CFX_ByteStringC& bsFileName) {}
250 void CFPF_SkiaFontMgr::LoadPrivateFont(void* pBuffer, size_t szBuffer) {} 250 void CFPF_SkiaFontMgr::LoadPrivateFont(void* pBuffer, size_t szBuffer) {}
251
251 CFPF_SkiaFont* CFPF_SkiaFontMgr::CreateFont(const CFX_ByteStringC& bsFamilyname, 252 CFPF_SkiaFont* CFPF_SkiaFontMgr::CreateFont(const CFX_ByteStringC& bsFamilyname,
252 uint8_t uCharset, 253 uint8_t uCharset,
253 uint32_t dwStyle, 254 uint32_t dwStyle,
254 uint32_t dwMatch) { 255 uint32_t dwMatch) {
255 uint32_t dwHash = FPF_SKIAGetFamilyHash(bsFamilyname, dwStyle, uCharset); 256 uint32_t dwHash = FPF_SKIAGetFamilyHash(bsFamilyname, dwStyle, uCharset);
256 auto it = m_FamilyFonts.find(dwHash); 257 auto it = m_FamilyFonts.find(dwHash);
257 if (it != m_FamilyFonts.end() && it->second) 258 if (it != m_FamilyFonts.end() && it->second)
258 return it->second->Retain(); 259 return it->second->Retain();
259 260
260 uint32_t dwFaceName = FPF_SKIANormalizeFontName(bsFamilyname); 261 uint32_t dwFaceName = FPF_SKIANormalizeFontName(bsFamilyname);
261 uint32_t dwSubst = FPF_SkiaGetSubstFont(dwFaceName); 262 uint32_t dwSubst = FPF_SkiaGetSubstFont(dwFaceName);
262 uint32_t dwSubstSans = FPF_SkiaGetSansFont(dwFaceName); 263 uint32_t dwSubstSans = FPF_SkiaGetSansFont(dwFaceName);
263 FX_BOOL bMaybeSymbol = FPF_SkiaMaybeSymbol(bsFamilyname); 264 FX_BOOL bMaybeSymbol = FPF_SkiaMaybeSymbol(bsFamilyname);
264 if (uCharset != FXFONT_ARABIC_CHARSET && FPF_SkiaMaybeArabic(bsFamilyname)) { 265 if (uCharset != FXFONT_ARABIC_CHARSET && FPF_SkiaMaybeArabic(bsFamilyname)) {
265 uCharset = FXFONT_ARABIC_CHARSET; 266 uCharset = FXFONT_ARABIC_CHARSET;
266 } else if (uCharset == FXFONT_ANSI_CHARSET && 267 } else if (uCharset == FXFONT_ANSI_CHARSET &&
267 (dwMatch & FPF_MATCHFONT_REPLACEANSI)) { 268 (dwMatch & FPF_MATCHFONT_REPLACEANSI)) {
268 uCharset = FXFONT_DEFAULT_CHARSET; 269 uCharset = FXFONT_DEFAULT_CHARSET;
269 } 270 }
270 int32_t nExpectVal = FPF_SKIAMATCHWEIGHT_NAME1 + FPF_SKIAMATCHWEIGHT_1 * 3 + 271 int32_t nExpectVal = FPF_SKIAMATCHWEIGHT_NAME1 + FPF_SKIAMATCHWEIGHT_1 * 3 +
271 FPF_SKIAMATCHWEIGHT_2 * 2; 272 FPF_SKIAMATCHWEIGHT_2 * 2;
272 int32_t nItem = -1; 273 CFPF_SkiaFontDescriptor* pBestFontDes = nullptr;
273 int32_t nMax = -1; 274 int32_t nMax = -1;
274 int32_t nGlyphNum = 0; 275 int32_t nGlyphNum = 0;
275 for (auto it = m_FontFaces.rbegin(); it != m_FontFaces.rend(); ++it) { 276 for (auto it = m_FontFaces.rbegin(); it != m_FontFaces.rend(); ++it) {
276 CFPF_SkiaPathFont* pFontDes = static_cast<CFPF_SkiaPathFont*>(*it); 277 CFPF_SkiaPathFont* pFontDes = static_cast<CFPF_SkiaPathFont*>(*it);
277 if (!(pFontDes->m_dwCharsets & FPF_SkiaGetCharset(uCharset))) { 278 if (!(pFontDes->m_dwCharsets & FPF_SkiaGetCharset(uCharset))) {
278 continue; 279 continue;
279 } 280 }
280 int32_t nFind = 0; 281 int32_t nFind = 0;
281 uint32_t dwSysFontName = FPF_SKIANormalizeFontName(pFontDes->m_pFamily); 282 uint32_t dwSysFontName = FPF_SKIANormalizeFontName(pFontDes->m_pFamily);
282 if (dwFaceName == dwSysFontName) { 283 if (dwFaceName == dwSysFontName) {
(...skipping 16 matching lines...) Expand all
299 if ((dwStyle & FXFONT_SCRIPT) == (pFontDes->m_dwStyle & FXFONT_SCRIPT)) { 300 if ((dwStyle & FXFONT_SCRIPT) == (pFontDes->m_dwStyle & FXFONT_SCRIPT)) {
300 nFind += FPF_SKIAMATCHWEIGHT_2; 301 nFind += FPF_SKIAMATCHWEIGHT_2;
301 } 302 }
302 if (dwSubst == dwSysFontName || dwSubstSans == dwSysFontName) { 303 if (dwSubst == dwSysFontName || dwSubstSans == dwSysFontName) {
303 nFind += FPF_SKIAMATCHWEIGHT_NAME2; 304 nFind += FPF_SKIAMATCHWEIGHT_NAME2;
304 bMatchedName = true; 305 bMatchedName = true;
305 } 306 }
306 if (uCharset == FXFONT_DEFAULT_CHARSET || bMaybeSymbol) { 307 if (uCharset == FXFONT_DEFAULT_CHARSET || bMaybeSymbol) {
307 if (nFind > nMax && bMatchedName) { 308 if (nFind > nMax && bMatchedName) {
308 nMax = nFind; 309 nMax = nFind;
309 nItem = it - m_FontFaces.rbegin(); 310 pBestFontDes = *it;
310 } 311 }
311 } else if (FPF_SkiaIsCJK(uCharset)) { 312 } else if (FPF_SkiaIsCJK(uCharset)) {
312 if (bMatchedName || pFontDes->m_iGlyphNum > nGlyphNum) { 313 if (bMatchedName || pFontDes->m_iGlyphNum > nGlyphNum) {
313 nItem = it - m_FontFaces.rbegin(); 314 pBestFontDes = *it;
314 nGlyphNum = pFontDes->m_iGlyphNum; 315 nGlyphNum = pFontDes->m_iGlyphNum;
315 } 316 }
316 } else if (nFind > nMax) { 317 } else if (nFind > nMax) {
317 nMax = nFind; 318 nMax = nFind;
318 nItem = it - m_FontFaces.rbegin(); 319 pBestFontDes = *it;
319 } 320 }
320 if (nExpectVal <= nFind) { 321 if (nExpectVal <= nFind) {
321 nItem = it - m_FontFaces.rbegin(); 322 pBestFontDes = *it;
322 break; 323 break;
323 } 324 }
324 } 325 }
325 if (nItem > -1) { 326 if (pBestFontDes) {
326 CFPF_SkiaFontDescriptor* pFontDes = m_FontFaces[nItem];
327 CFPF_SkiaFont* pFont = new CFPF_SkiaFont; 327 CFPF_SkiaFont* pFont = new CFPF_SkiaFont;
328 if (pFont->InitFont(this, pFontDes, bsFamilyname, dwStyle, uCharset)) { 328 if (pFont->InitFont(this, pBestFontDes, bsFamilyname, dwStyle, uCharset)) {
329 m_FamilyFonts[dwHash] = pFont; 329 m_FamilyFonts[dwHash] = pFont;
330 return pFont->Retain(); 330 return pFont->Retain();
331 } 331 }
332 pFont->Release(); 332 pFont->Release();
333 } 333 }
334 return nullptr; 334 return nullptr;
335 } 335 }
336
336 FXFT_Face CFPF_SkiaFontMgr::GetFontFace(IFX_FileRead* pFileRead, 337 FXFT_Face CFPF_SkiaFontMgr::GetFontFace(IFX_FileRead* pFileRead,
337 int32_t iFaceIndex) { 338 int32_t iFaceIndex) {
338 if (!pFileRead) { 339 if (!pFileRead) {
339 return nullptr; 340 return nullptr;
340 } 341 }
341 if (pFileRead->GetSize() == 0) { 342 if (pFileRead->GetSize() == 0) {
342 return nullptr; 343 return nullptr;
343 } 344 }
344 if (iFaceIndex < 0) { 345 if (iFaceIndex < 0) {
345 return nullptr; 346 return nullptr;
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 } 514 }
514 if (pOS2 && (pOS2->ulCodePageRange1 & (1 << 31))) { 515 if (pOS2 && (pOS2->ulCodePageRange1 & (1 << 31))) {
515 pFontDesc->m_dwStyle |= FXFONT_SYMBOLIC; 516 pFontDesc->m_dwStyle |= FXFONT_SYMBOLIC;
516 } 517 }
517 pFontDesc->m_dwCharsets = FPF_SkiaGetFaceCharset(pOS2); 518 pFontDesc->m_dwCharsets = FPF_SkiaGetFaceCharset(pOS2);
518 pFontDesc->m_iFaceIndex = face->face_index; 519 pFontDesc->m_iFaceIndex = face->face_index;
519 pFontDesc->m_iGlyphNum = face->num_glyphs; 520 pFontDesc->m_iGlyphNum = face->num_glyphs;
520 } 521 }
521 void CFPF_SkiaFontMgr::OutputSystemFonts() {} 522 void CFPF_SkiaFontMgr::OutputSystemFonts() {}
522 #endif 523 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698