OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 } | 63 } |
64 const WebFallbackFont& fallbackFont() const { return m_fallbackFont; } | 64 const WebFallbackFont& fallbackFont() const { return m_fallbackFont; } |
65 bool hasGlyphForCharacter(WebUChar32 c) | 65 bool hasGlyphForCharacter(WebUChar32 c) |
66 { | 66 { |
67 return m_supportedCharacters && FcCharSetHasChar(m_supportedCharacters, c); | 67 return m_supportedCharacters && FcCharSetHasChar(m_supportedCharacters, c); |
68 } | 68 } |
69 | 69 |
70 private: | 70 private: |
71 static WebCString fontName(FcPattern* pattern) | 71 static WebCString fontName(FcPattern* pattern) |
72 { | 72 { |
73 FcChar8* familyName; | 73 FcChar8* familyName = nullptr; |
74 if (FcPatternGetString(pattern, FC_FAMILY, 0, &familyName) != FcResultMa tch) | 74 if (FcPatternGetString(pattern, FC_FAMILY, 0, &familyName) != FcResultMa tch) |
75 return WebCString(); | 75 return WebCString(); |
76 | 76 |
77 // FCChar8 is unsigned char, so we cast to char for WebCString. | 77 // FCChar8 is unsigned char, so we cast to char for WebCString. |
78 const char* charFamily = reinterpret_cast<char*>(familyName); | 78 const char* charFamily = reinterpret_cast<char*>(familyName); |
79 return WebCString(charFamily, strlen(charFamily)); | 79 return WebCString(charFamily, strlen(charFamily)); |
80 } | 80 } |
81 | 81 |
82 static WebCString fontFilename(FcPattern* pattern) | 82 static WebCString fontFilename(FcPattern* pattern) |
83 { | 83 { |
84 FcChar8* cFilename; | 84 FcChar8* cFilename = nullptr; |
85 if (FcPatternGetString(pattern, FC_FILE, 0, &cFilename) != FcResultMatch ) | 85 if (FcPatternGetString(pattern, FC_FILE, 0, &cFilename) != FcResultMatch ) |
86 return WebCString(); | 86 return WebCString(); |
87 const char* fontFilename = reinterpret_cast<char*>(cFilename); | 87 const char* fontFilename = reinterpret_cast<char*>(cFilename); |
88 return WebCString(fontFilename, strlen(fontFilename)); | 88 return WebCString(fontFilename, strlen(fontFilename)); |
89 } | 89 } |
90 | 90 |
91 static int fontTtcIndex(FcPattern* pattern) | 91 static int fontTtcIndex(FcPattern* pattern) |
92 { | 92 { |
93 int ttcIndex; | 93 int ttcIndex = 0; |
Daniel Erat
2014/08/15 22:40:54
nit: initialize to -1, i.e. an invalid value per t
| |
94 if (FcPatternGetInteger(pattern, FC_INDEX, 0, &ttcIndex) != FcResultMatc h && ttcIndex < 0) | 94 if (FcPatternGetInteger(pattern, FC_INDEX, 0, &ttcIndex) != FcResultMatc h || ttcIndex < 0) |
95 return 0; | 95 return 0; |
96 return ttcIndex; | 96 return ttcIndex; |
97 } | 97 } |
98 | 98 |
99 static bool fontIsBold(FcPattern* pattern) | 99 static bool fontIsBold(FcPattern* pattern) |
100 { | 100 { |
101 int weight; | 101 int weight = 0; |
102 if (FcPatternGetInteger(pattern, FC_WEIGHT, 0, &weight) != FcResultMatch ) | 102 if (FcPatternGetInteger(pattern, FC_WEIGHT, 0, &weight) != FcResultMatch ) |
103 return false; | 103 return false; |
104 return weight >= FC_WEIGHT_BOLD; | 104 return weight >= FC_WEIGHT_BOLD; |
105 } | 105 } |
106 | 106 |
107 static bool fontIsItalic(FcPattern* pattern) | 107 static bool fontIsItalic(FcPattern* pattern) |
108 { | 108 { |
109 int slant; | 109 int slant = 0; |
110 if (FcPatternGetInteger(pattern, FC_SLANT, 0, &slant) != FcResultMatch) | 110 if (FcPatternGetInteger(pattern, FC_SLANT, 0, &slant) != FcResultMatch) |
111 return false; | 111 return false; |
112 return slant != FC_SLANT_ROMAN; | 112 return slant != FC_SLANT_ROMAN; |
113 } | 113 } |
114 | 114 |
115 WebFallbackFont m_fallbackFont; | 115 WebFallbackFont m_fallbackFont; |
116 // m_supportedCharaters is owned by the parent | 116 // m_supportedCharaters is owned by the parent |
117 // FcFontSet and should never be freed. | 117 // FcFontSet and should never be freed. |
118 FcCharSet* m_supportedCharacters; | 118 FcCharSet* m_supportedCharacters; |
119 }; | 119 }; |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
258 typedef HashMap<AtomicString, OwnPtr<CachedFontSet> > LocaleToCachedFont; | 258 typedef HashMap<AtomicString, OwnPtr<CachedFontSet> > LocaleToCachedFont; |
259 LocaleToCachedFont m_setsByLocale; | 259 LocaleToCachedFont m_setsByLocale; |
260 }; | 260 }; |
261 | 261 |
262 void WebFontInfo::fallbackFontForChar(WebUChar32 c, const char* locale, WebFallb ackFont* fallbackFont) | 262 void WebFontInfo::fallbackFontForChar(WebUChar32 c, const char* locale, WebFallb ackFont* fallbackFont) |
263 { | 263 { |
264 *fallbackFont = FontSetCache::shared().fallbackFontForCharInLocale(c, locale ); | 264 *fallbackFont = FontSetCache::shared().fallbackFontForCharInLocale(c, locale ); |
265 } | 265 } |
266 | 266 |
267 } // namespace blink | 267 } // namespace blink |
OLD | NEW |