OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2006 Apple Computer, 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 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 if (m_fontList[i]->isCustomFont() && m_fontList[i]->isLoading()) { | 101 if (m_fontList[i]->isCustomFont() && m_fontList[i]->isLoading()) { |
102 m_loadingCustomFonts = true; | 102 m_loadingCustomFonts = true; |
103 return true; | 103 return true; |
104 } | 104 } |
105 } | 105 } |
106 return false; | 106 return false; |
107 } | 107 } |
108 | 108 |
109 const FontData* FontFallbackList::primaryFontData(const FontDescription& fontDes
cription) const | 109 const FontData* FontFallbackList::primaryFontData(const FontDescription& fontDes
cription) const |
110 { | 110 { |
| 111 bool shouldLoadCustomFont = true; |
| 112 |
111 for (unsigned fontIndex = 0; ; ++fontIndex) { | 113 for (unsigned fontIndex = 0; ; ++fontIndex) { |
112 const FontData* fontData = fontDataAt(fontDescription, fontIndex); | 114 const FontData* fontData = fontDataAt(fontDescription, fontIndex); |
113 if (!fontData) { | 115 if (!fontData) { |
114 // All fonts are custom fonts and are loading. Return the first Font
Data. | 116 // All fonts are custom fonts and are loading. Return the first Font
Data. |
115 // FIXME: Correct fallback to the default font. | 117 // FIXME: Correct fallback to the default font. |
116 return fontDataAt(fontDescription, 0); | 118 return fontDataAt(fontDescription, 0); |
117 } | 119 } |
118 | 120 |
| 121 if (fontData->isSegmented() && !toSegmentedFontData(fontData)->containsC
haracter(' ')) |
| 122 continue; |
| 123 |
119 // When a custom font is loading, we should use the correct fallback fon
t to layout the text. | 124 // When a custom font is loading, we should use the correct fallback fon
t to layout the text. |
120 // Here skip the temporary font for the loading custom font which may no
t act as the correct fallback font. | 125 // Here skip the temporary font for the loading custom font which may no
t act as the correct fallback font. |
121 if (!fontData->isLoadingFallback()) | 126 if (!fontData->isLoadingFallback()) |
122 return fontData; | 127 return fontData; |
123 | 128 |
124 // Begin to load the first custom font if needed. | 129 // Begin to load the first custom font if needed. |
125 if (!fontIndex) { | 130 if (shouldLoadCustomFont) { |
| 131 shouldLoadCustomFont = false; |
126 const SimpleFontData* simpleFontData = fontData->fontDataForCharacte
r(' '); | 132 const SimpleFontData* simpleFontData = fontData->fontDataForCharacte
r(' '); |
127 if (simpleFontData && simpleFontData->customFontData()) | 133 if (simpleFontData && simpleFontData->customFontData()) |
128 simpleFontData->customFontData()->beginLoadIfNeeded(); | 134 simpleFontData->customFontData()->beginLoadIfNeeded(); |
129 } | 135 } |
130 } | 136 } |
131 } | 137 } |
132 | 138 |
133 PassRefPtr<FontData> FontFallbackList::getFontData(const FontDescription& fontDe
scription, int& familyIndex) const | 139 PassRefPtr<FontData> FontFallbackList::getFontData(const FontDescription& fontDe
scription, int& familyIndex) const |
134 { | 140 { |
135 RefPtr<FontData> result; | 141 RefPtr<FontData> result; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 RefPtr<FontData> result = getFontData(fontDescription, m_familyIndex); | 196 RefPtr<FontData> result = getFontData(fontDescription, m_familyIndex); |
191 if (result) { | 197 if (result) { |
192 m_fontList.append(result); | 198 m_fontList.append(result); |
193 if (result->isLoading()) | 199 if (result->isLoading()) |
194 m_loadingCustomFonts = true; | 200 m_loadingCustomFonts = true; |
195 } | 201 } |
196 return result.get(); | 202 return result.get(); |
197 } | 203 } |
198 | 204 |
199 } | 205 } |
OLD | NEW |