Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Unified Diff: Source/platform/fonts/win/FontFallbackWin.cpp

Issue 182383002: Reland "Change FontFallbackWin to use FamilyNameIterator" (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/fonts/win/FontFallbackWin.cpp
diff --git a/Source/platform/fonts/win/FontFallbackWin.cpp b/Source/platform/fonts/win/FontFallbackWin.cpp
index 6f4d91d6eb5e6f2cae573401e79ea54ecb10f611..f170dcaf274543c575c46e3c5acb22634737c36b 100644
--- a/Source/platform/fonts/win/FontFallbackWin.cpp
+++ b/Source/platform/fonts/win/FontFallbackWin.cpp
@@ -31,7 +31,7 @@
#include "config.h"
#include "platform/fonts/win/FontFallbackWin.h"
-#include "platform/win/HWndDC.h"
+#include "SkTypeface.h"
#include "wtf/HashMap.h"
#include "wtf/text/StringHash.h"
#include "wtf/text/WTFString.h"
@@ -43,22 +43,25 @@ namespace WebCore {
namespace {
-bool isFontPresent(const UChar* fontName)
+static inline bool isFontPresent(const UChar* fontName)
{
- HFONT hfont = CreateFont(12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, fontName);
- if (!hfont)
+ String family = fontName;
+ RefPtr<SkTypeface> tf = adoptRef(SkTypeface::CreateFromName(family.utf8().data(), SkTypeface::kNormal));
+ if (!tf)
return false;
- HWndDC dc(0);
- HGDIOBJ oldFont = static_cast<HFONT>(SelectObject(dc, hfont));
- WCHAR actualFontName[LF_FACESIZE];
- GetTextFace(dc, LF_FACESIZE, actualFontName);
- actualFontName[LF_FACESIZE - 1] = 0;
- SelectObject(dc, oldFont);
- DeleteObject(hfont);
- // We don't have to worry about East Asian fonts with locale-dependent
- // names here for now.
- // FIXME: Why not?
- return !wcscmp(fontName, actualFontName);
+
+ SkTypeface::LocalizedStrings* actualFamilies = tf->createFamilyNameIterator();
+ bool matchesRequestedFamily = false;
+ SkTypeface::LocalizedString actualFamily;
+ while (actualFamilies->next(&actualFamily)) {
+ if (equalIgnoringCase(family, AtomicString::fromUTF8(actualFamily.fString.c_str()))) {
+ matchesRequestedFamily = true;
+ break;
+ }
+ }
+ actualFamilies->unref();
+
+ return matchesRequestedFamily;
}
// A simple mapping from UScriptCode to family name. This is a sparse array,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698