| OLD | NEW | 
|    1 /* |    1 /* | 
|    2  * Copyright (C) 2006, 2007 Apple Computer, Inc. |    2  * Copyright (C) 2006, 2007 Apple Computer, Inc. | 
|    3  * Copyright (c) 2006, 2007, 2008, 2009, 2012 Google Inc. All rights reserved. |    3  * Copyright (c) 2006, 2007, 2008, 2009, 2012 Google Inc. All rights reserved. | 
|    4  * |    4  * | 
|    5  * Redistribution and use in source and binary forms, with or without |    5  * Redistribution and use in source and binary forms, with or without | 
|    6  * modification, are permitted provided that the following conditions are |    6  * modification, are permitted provided that the following conditions are | 
|    7  * met: |    7  * met: | 
|    8  * |    8  * | 
|    9  *     * Redistributions of source code must retain the above copyright |    9  *     * Redistributions of source code must retain the above copyright | 
|   10  * notice, this list of conditions and the following disclaimer. |   10  * notice, this list of conditions and the following disclaimer. | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
|   38 #include "platform/fonts/FontDescription.h" |   38 #include "platform/fonts/FontDescription.h" | 
|   39 #include "platform/fonts/FontFaceCreationParams.h" |   39 #include "platform/fonts/FontFaceCreationParams.h" | 
|   40 #include "platform/fonts/FontPlatformData.h" |   40 #include "platform/fonts/FontPlatformData.h" | 
|   41 #include "platform/fonts/SimpleFontData.h" |   41 #include "platform/fonts/SimpleFontData.h" | 
|   42 #include "platform/fonts/win/FontFallbackWin.h" |   42 #include "platform/fonts/win/FontFallbackWin.h" | 
|   43 #include "wtf/PtrUtil.h" |   43 #include "wtf/PtrUtil.h" | 
|   44 #include <memory> |   44 #include <memory> | 
|   45  |   45  | 
|   46 namespace blink { |   46 namespace blink { | 
|   47  |   47  | 
|   48 HashMap<String, sk_sp<SkTypeface>>* FontCache::s_sideloadedFonts = 0; |   48 HashMap<String, sk_sp<SkTypeface>>* FontCache::s_sideloadedFonts = nullptr; | 
|   49  |   49  | 
|   50 // Cached system font metrics. |   50 // Cached system font metrics. | 
|   51 AtomicString* FontCache::s_menuFontFamilyName = 0; |   51 AtomicString* FontCache::s_menuFontFamilyName = nullptr; | 
|   52 int32_t FontCache::s_menuFontHeight = 0; |   52 int32_t FontCache::s_menuFontHeight = 0; | 
|   53 AtomicString* FontCache::s_smallCaptionFontFamilyName = 0; |   53 AtomicString* FontCache::s_smallCaptionFontFamilyName = nullptr; | 
|   54 int32_t FontCache::s_smallCaptionFontHeight = 0; |   54 int32_t FontCache::s_smallCaptionFontHeight = 0; | 
|   55 AtomicString* FontCache::s_statusFontFamilyName = 0; |   55 AtomicString* FontCache::s_statusFontFamilyName = nullptr; | 
|   56 int32_t FontCache::s_statusFontHeight = 0; |   56 int32_t FontCache::s_statusFontHeight = 0; | 
|   57  |   57  | 
|   58 namespace { |   58 namespace { | 
|   59  |   59  | 
|   60 int32_t ensureMinimumFontHeightIfNeeded(int32_t fontHeight) { |   60 int32_t ensureMinimumFontHeightIfNeeded(int32_t fontHeight) { | 
|   61   // Adjustment for codepage 936 to make the fonts more legible in Simplified |   61   // Adjustment for codepage 936 to make the fonts more legible in Simplified | 
|   62   // Chinese.  Please refer to LayoutThemeFontProviderWin.cpp for more |   62   // Chinese.  Please refer to LayoutThemeFontProviderWin.cpp for more | 
|   63   // information. |   63   // information. | 
|   64   return (fontHeight < 12.0f) && (GetACP() == 936) ? 12.0f : fontHeight; |   64   return (fontHeight < 12.0f) && (GetACP() == 936) ? 12.0f : fontHeight; | 
|   65 } |   65 } | 
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  122     RefPtr<SimpleFontData> fontData = |  122     RefPtr<SimpleFontData> fontData = | 
|  123         fallbackOnStandardFontStyle(fontDescription, character); |  123         fallbackOnStandardFontStyle(fontDescription, character); | 
|  124     if (fontData) |  124     if (fontData) | 
|  125       return fontData; |  125       return fontData; | 
|  126   } |  126   } | 
|  127  |  127  | 
|  128   UScriptCode script; |  128   UScriptCode script; | 
|  129   const wchar_t* family = getFallbackFamily( |  129   const wchar_t* family = getFallbackFamily( | 
|  130       character, fontDescription.genericFamily(), fontDescription.locale(), |  130       character, fontDescription.genericFamily(), fontDescription.locale(), | 
|  131       &script, fallbackPriority, m_fontManager.get()); |  131       &script, fallbackPriority, m_fontManager.get()); | 
|  132   FontPlatformData* data = 0; |  132   FontPlatformData* data = nullptr; | 
|  133   if (family) { |  133   if (family) { | 
|  134     FontFaceCreationParams createByFamily(AtomicString(family, wcslen(family))); |  134     FontFaceCreationParams createByFamily(AtomicString(family, wcslen(family))); | 
|  135     data = getFontPlatformData(fontDescription, createByFamily); |  135     data = getFontPlatformData(fontDescription, createByFamily); | 
|  136   } |  136   } | 
|  137  |  137  | 
|  138   if ((!data || !data->fontContainsCharacter(character)) && |  138   if ((!data || !data->fontContainsCharacter(character)) && | 
|  139       s_useSkiaFontFallback) { |  139       s_useSkiaFontFallback) { | 
|  140     const char* bcp47Locale = nullptr; |  140     const char* bcp47Locale = nullptr; | 
|  141     int localeCount = 0; |  141     int localeCount = 0; | 
|  142     // If the font description has a locale, use that. Otherwise, Skia will |  142     // If the font description has a locale, use that. Otherwise, Skia will | 
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  179  |  179  | 
|  180   const static wchar_t* const commonFonts[] = { |  180   const static wchar_t* const commonFonts[] = { | 
|  181       L"tahoma", L"arial unicode ms", L"lucida sans unicode", |  181       L"tahoma", L"arial unicode ms", L"lucida sans unicode", | 
|  182       L"microsoft sans serif", L"palatino linotype", |  182       L"microsoft sans serif", L"palatino linotype", | 
|  183       // Six fonts below (and code2000 at the end) are not from MS, but |  183       // Six fonts below (and code2000 at the end) are not from MS, but | 
|  184       // once installed, cover a very wide range of characters. |  184       // once installed, cover a very wide range of characters. | 
|  185       L"dejavu serif", L"dejavu sasns", L"freeserif", L"freesans", L"gentium", |  185       L"dejavu serif", L"dejavu sasns", L"freeserif", L"freesans", L"gentium", | 
|  186       L"gentiumalt", L"ms pgothic", L"simsun", L"gulim", L"pmingliu", |  186       L"gentiumalt", L"ms pgothic", L"simsun", L"gulim", L"pmingliu", | 
|  187       L"code2000"}; |  187       L"code2000"}; | 
|  188  |  188  | 
|  189   const wchar_t* const* panUniFonts = 0; |  189   const wchar_t* const* panUniFonts = nullptr; | 
|  190   int numFonts = 0; |  190   int numFonts = 0; | 
|  191   if (script == USCRIPT_HAN) { |  191   if (script == USCRIPT_HAN) { | 
|  192     panUniFonts = cjkFonts; |  192     panUniFonts = cjkFonts; | 
|  193     numFonts = WTF_ARRAY_LENGTH(cjkFonts); |  193     numFonts = WTF_ARRAY_LENGTH(cjkFonts); | 
|  194   } else { |  194   } else { | 
|  195     panUniFonts = commonFonts; |  195     panUniFonts = commonFonts; | 
|  196     numFonts = WTF_ARRAY_LENGTH(commonFonts); |  196     numFonts = WTF_ARRAY_LENGTH(commonFonts); | 
|  197   } |  197   } | 
|  198   // Font returned from getFallbackFamily may not cover |character| |  198   // Font returned from getFallbackFamily may not cover |character| | 
|  199   // because it's based on script to font mapping. This problem is |  199   // because it's based on script to font mapping. This problem is | 
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  413     if (typefacesMatchesFamily(tf.get(), family)) { |  413     if (typefacesMatchesFamily(tf.get(), family)) { | 
|  414       result->setMinSizeForSubpixel(minSizeForSubpixelForFont); |  414       result->setMinSizeForSubpixel(minSizeForSubpixelForFont); | 
|  415       break; |  415       break; | 
|  416     } |  416     } | 
|  417   } |  417   } | 
|  418  |  418  | 
|  419   return result; |  419   return result; | 
|  420 } |  420 } | 
|  421  |  421  | 
|  422 }  // namespace blink |  422 }  // namespace blink | 
| OLD | NEW |