Index: ui/gfx/platform_font_win.cc |
diff --git a/ui/gfx/platform_font_win.cc b/ui/gfx/platform_font_win.cc |
index df2b874b64b6fbf2b2062142d9ccaa6cac299092..68c7284f55c6d9e3c3877a9dd650920c6dbc68bf 100644 |
--- a/ui/gfx/platform_font_win.cc |
+++ b/ui/gfx/platform_font_win.cc |
@@ -9,6 +9,7 @@ |
#include <math.h> |
#include <windows.h> |
+#include "base/debug/alias.h" |
#include "base/logging.h" |
#include "base/macros.h" |
#include "base/strings/string_util.h" |
@@ -125,10 +126,44 @@ HRESULT GetMatchingDirectWriteFontForTypeface(const wchar_t* face_name, |
DWRITE_FONT_STYLE italic = (font_style & SkTypeface::kItalic) |
? DWRITE_FONT_STYLE_ITALIC |
: DWRITE_FONT_STYLE_NORMAL; |
+ |
+ // The IDWriteFontFamily::GetFirstMatchingFont call fails on certain machines |
+ // for fonts like MS UI Gothic, Segoe UI, etc. It is not clear why these |
+ // fonts could be accessible to GDI and not to DirectWrite. |
+ // The code below adds some debug fields to help track down these failures. |
+ // 1. We get the matching font list for the font attributes passed in. |
+ // 2. We get the font count in the family with a debug alias variable. |
+ // 3. If we fail to get the font via the GetFirstMatchingFont call then we |
+ // try to get the first matching font in the IDWriteFontList. |
+ // 4. If GetFirstMatchingFont and IDWriteFontList both fail then we CHECK as |
+ // before. |
+ // Next step would be to remove the CHECKs in this function and fallback to |
+ // GDI. |
+ // http://crbug.com/434425 |
Shrikant Kelkar
2014/11/19 23:30:47
If you want to look for specific fonts that are ca
ananta
2014/11/19 23:38:58
Will do that in a followup. Dunno what the clean u
|
+ base::win::ScopedComPtr<IDWriteFontList> matching_font_list; |
+ hr = font_family->GetMatchingFonts(weight, stretch, italic, |
+ matching_font_list.Receive()); |
+ uint32 matching_font_count = 0; |
+ if (SUCCEEDED(hr)) |
+ matching_font_count = matching_font_list->GetFontCount(); |
+ |
+ bool fallback_to_matching_font = false; |
+ |
hr = font_family->GetFirstMatchingFont(weight, stretch, italic, |
dwrite_font); |
- if (FAILED(hr)) |
+ if (FAILED(hr)) { |
+ if (matching_font_list) { |
+ hr = matching_font_list->GetFont(0, dwrite_font); |
+ if (SUCCEEDED(hr)) |
+ fallback_to_matching_font = true; |
+ } |
+ } |
+ |
+ if (FAILED(hr)) { |
+ base::debug::Alias(&matching_font_count); |
+ base::debug::Alias(&fallback_to_matching_font); |
Shrikant Kelkar
2014/11/19 23:30:47
fallback_to_matching_font = true if SUCCEEDED(hr)
ananta
2014/11/19 23:38:58
Moved the alias for fallback_to_matching_font abov
|
CHECK(false); |
+ } |
return hr; |
} |