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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/linux/FontCacheLinux.cpp

Issue 1685053002: blink fonts: Load Android SkFontMgr on Linux. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@windows_change
Patch Set: Rebase. Created 4 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 16 matching lines...) Expand all
27 #include "platform/fonts/FontPlatformData.h" 27 #include "platform/fonts/FontPlatformData.h"
28 #include "platform/fonts/SimpleFontData.h" 28 #include "platform/fonts/SimpleFontData.h"
29 #include "public/platform/linux/WebFallbackFont.h" 29 #include "public/platform/linux/WebFallbackFont.h"
30 #include "public/platform/linux/WebFontInfo.h" 30 #include "public/platform/linux/WebFontInfo.h"
31 #include "public/platform/linux/WebSandboxSupport.h" 31 #include "public/platform/linux/WebSandboxSupport.h"
32 #include "public/platform/Platform.h" 32 #include "public/platform/Platform.h"
33 #include "wtf/text/CString.h" 33 #include "wtf/text/CString.h"
34 34
35 namespace blink { 35 namespace blink {
36 36
37 FontCache::FontCache()
38 : m_purgePreventCount(0)
39 {
40 if (s_fontManager) {
41 adopted(s_fontManager);
42 m_fontManager = s_fontManager;
43 } else {
44 m_fontManager = nullptr;
45 }
46 }
47
37 void FontCache::getFontForCharacter(UChar32 c, const char* preferredLocale, Font Cache::PlatformFallbackFont* fallbackFont) 48 void FontCache::getFontForCharacter(UChar32 c, const char* preferredLocale, Font Cache::PlatformFallbackFont* fallbackFont)
38 { 49 {
39 WebFallbackFont webFallbackFont; 50 WebFallbackFont webFallbackFont;
40 if (Platform::current()->sandboxSupport()) 51 if (Platform::current()->sandboxSupport())
41 Platform::current()->sandboxSupport()->getFallbackFontForCharacter(c, pr eferredLocale, &webFallbackFont); 52 Platform::current()->sandboxSupport()->getFallbackFontForCharacter(c, pr eferredLocale, &webFallbackFont);
42 else 53 else
43 WebFontInfo::fallbackFontForChar(c, preferredLocale, &webFallbackFont); 54 WebFontInfo::fallbackFontForChar(c, preferredLocale, &webFallbackFont);
44 fallbackFont->name = String::fromUTF8(CString(webFallbackFont.name)); 55 fallbackFont->name = String::fromUTF8(CString(webFallbackFont.name));
45 fallbackFont->filename = webFallbackFont.filename; 56 fallbackFont->filename = webFallbackFont.filename;
46 fallbackFont->fontconfigInterfaceId = webFallbackFont.fontconfigInterfaceId; 57 fallbackFont->fontconfigInterfaceId = webFallbackFont.fontconfigInterfaceId;
47 fallbackFont->ttcIndex = webFallbackFont.ttcIndex; 58 fallbackFont->ttcIndex = webFallbackFont.ttcIndex;
48 fallbackFont->isBold = webFallbackFont.isBold; 59 fallbackFont->isBold = webFallbackFont.isBold;
49 fallbackFont->isItalic = webFallbackFont.isItalic; 60 fallbackFont->isItalic = webFallbackFont.isItalic;
50 } 61 }
51 62
52 #if !OS(ANDROID) 63 #if !OS(ANDROID)
53 PassRefPtr<SimpleFontData> FontCache::fallbackFontForCharacter( 64 PassRefPtr<SimpleFontData> FontCache::fallbackFontForCharacter(
54 const FontDescription& fontDescription, 65 const FontDescription& fontDescription,
55 UChar32 c, 66 UChar32 c,
56 const SimpleFontData*, 67 const SimpleFontData*,
57 FontFallbackPriority fallbackPriority) 68 FontFallbackPriority fallbackPriority)
58 { 69 {
70 // The m_fontManager is set only if it was provided by the embedder with Web FontRendering::setSkiaFontManager. This is
71 // used to emulate android fonts on linux so we always request the family fr om the font manager and if none is found, we return
72 // the LastResort fallback font and avoid using FontCache::getFontForCharact er which would use sandbox support to
73 // query the underlying system for the font family.
74 if (m_fontManager) {
75 AtomicString familyName = getFamilyNameForCharacter(m_fontManager.get(), c, fontDescription, fallbackPriority);
76 if (familyName.isEmpty())
77 return getLastResortFallbackFont(fontDescription, DoNotRetain);
78 return fontDataFromFontPlatformData(getFontPlatformData(fontDescription, FontFaceCreationParams(familyName)), DoNotRetain);
79 }
80
59 if (fallbackPriority == FontFallbackPriority::EmojiEmoji) { 81 if (fallbackPriority == FontFallbackPriority::EmojiEmoji) {
60 // FIXME crbug.com/591346: We're overriding the fallback character here 82 // FIXME crbug.com/591346: We're overriding the fallback character here
61 // with the FAMILY emoji in the hope to find a suitable emoji font. 83 // with the FAMILY emoji in the hope to find a suitable emoji font.
62 // This should be improved by supporting fallback for character 84 // This should be improved by supporting fallback for character
63 // sequences like DIGIT ONE + COMBINING keycap etc. 85 // sequences like DIGIT ONE + COMBINING keycap etc.
64 c = familyCharacter; 86 c = familyCharacter;
65 } 87 }
66 88
67 // First try the specified font with standard style & weight. 89 // First try the specified font with standard style & weight.
68 if (fallbackPriority != FontFallbackPriority::EmojiEmoji 90 if (fallbackPriority != FontFallbackPriority::EmojiEmoji
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 return nullptr; 128 return nullptr;
107 FontPlatformData platformData = FontPlatformData(*substitutePlatformData); 129 FontPlatformData platformData = FontPlatformData(*substitutePlatformData);
108 platformData.setSyntheticBold(shouldSetSyntheticBold); 130 platformData.setSyntheticBold(shouldSetSyntheticBold);
109 platformData.setSyntheticItalic(shouldSetSyntheticItalic); 131 platformData.setSyntheticItalic(shouldSetSyntheticItalic);
110 return fontDataFromFontPlatformData(&platformData, DoNotRetain); 132 return fontDataFromFontPlatformData(&platformData, DoNotRetain);
111 } 133 }
112 134
113 #endif // !OS(ANDROID) 135 #endif // !OS(ANDROID)
114 136
115 } // namespace blink 137 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698