OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2006, 2007, 2008, 2009, 2010, 2012 Google Inc. All rights reser
ved. | 2 * Copyright (c) 2006, 2007, 2008, 2009, 2010, 2012 Google Inc. All rights reser
ved. |
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 13 matching lines...) Expand all Loading... |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "platform/fonts/win/FontFallbackWin.h" | 32 #include "platform/fonts/win/FontFallbackWin.h" |
33 | 33 |
| 34 #include "platform/fonts/FontCache.h" |
34 #include "SkFontMgr.h" | 35 #include "SkFontMgr.h" |
35 #include "SkTypeface.h" | 36 #include "SkTypeface.h" |
36 #include "wtf/HashMap.h" | 37 #include "wtf/HashMap.h" |
37 #include "wtf/text/StringHash.h" | 38 #include "wtf/text/StringHash.h" |
38 #include "wtf/text/WTFString.h" | 39 #include "wtf/text/WTFString.h" |
39 #include <limits> | 40 #include <limits> |
40 #include <unicode/locid.h> | 41 #include <unicode/locid.h> |
41 #include <unicode/uchar.h> | 42 #include <unicode/uchar.h> |
42 | 43 |
43 namespace blink { | 44 namespace blink { |
44 | 45 |
45 namespace { | 46 namespace { |
46 | 47 |
47 static inline bool isFontPresent(const UChar* fontName, SkFontMgr* fontManager) | 48 static inline bool isFontPresent(const UChar* fontName, SkFontMgr* fontManager) |
48 { | 49 { |
49 String family = fontName; | 50 String family = fontName; |
50 RefPtr<SkTypeface> tf = adoptRef(fontManager->legacyCreateTypeface(family.ut
f8().data(), SkTypeface::kNormal)); | 51 SkTypeface* typeface; |
51 if (!tf) | 52 if (FontCache::useDirectWrite()) |
| 53 typeface = fontManager->matchFamilyStyle(family.utf8().data(), SkFontSty
le()); |
| 54 else |
| 55 typeface = fontManager->legacyCreateTypeface(family.utf8().data(), SkTyp
eface::kNormal); |
| 56 |
| 57 if (!typeface) |
52 return false; | 58 return false; |
53 | 59 |
| 60 RefPtr<SkTypeface> tf = adoptRef(typeface); |
54 SkTypeface::LocalizedStrings* actualFamilies = tf->createFamilyNameIterator(
); | 61 SkTypeface::LocalizedStrings* actualFamilies = tf->createFamilyNameIterator(
); |
55 bool matchesRequestedFamily = false; | 62 bool matchesRequestedFamily = false; |
56 SkTypeface::LocalizedString actualFamily; | 63 SkTypeface::LocalizedString actualFamily; |
57 while (actualFamilies->next(&actualFamily)) { | 64 while (actualFamilies->next(&actualFamily)) { |
58 if (equalIgnoringCase(family, AtomicString::fromUTF8(actualFamily.fStrin
g.c_str()))) { | 65 if (equalIgnoringCase(family, AtomicString::fromUTF8(actualFamily.fStrin
g.c_str()))) { |
59 matchesRequestedFamily = true; | 66 matchesRequestedFamily = true; |
60 break; | 67 break; |
61 } | 68 } |
62 } | 69 } |
63 actualFamilies->unref(); | 70 actualFamilies->unref(); |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 family = L"lucida sans unicode"; | 349 family = L"lucida sans unicode"; |
343 } | 350 } |
344 } | 351 } |
345 | 352 |
346 if (scriptChecked) | 353 if (scriptChecked) |
347 *scriptChecked = script; | 354 *scriptChecked = script; |
348 return family; | 355 return family; |
349 } | 356 } |
350 | 357 |
351 } // namespace blink | 358 } // namespace blink |
OLD | NEW |