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

Unified Diff: content/renderer/renderer_main_platform_delegate_win.cc

Issue 231763003: Support sideloaded fonts via command line option for blink layout_tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 8 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
Index: content/renderer/renderer_main_platform_delegate_win.cc
diff --git a/content/renderer/renderer_main_platform_delegate_win.cc b/content/renderer/renderer_main_platform_delegate_win.cc
index 56d81ee47774c580d99c7937e9df6240040c3a35..f02258806025ae20a704274f136f23fef00b988d 100644
--- a/content/renderer/renderer_main_platform_delegate_win.cc
+++ b/content/renderer/renderer_main_platform_delegate_win.cc
@@ -66,6 +66,28 @@ void CreateDirectWriteFactory(IDWriteFactory** factory) {
reinterpret_cast<IUnknown**>(factory))));
}
+void WarmupFontPaint(SkTypeface* typeface) {
+ SkPaint paint_warmup;
+ paint_warmup.setTypeface(typeface);
+ wchar_t glyph = L'S';
+ paint_warmup.measureText(&glyph, 2);
+}
+
+// DirectWrite only has access to %WINDIR%\Fonts by default. For developer
+// side-loading, support kRegisterFontFiles to allow access to additional fonts.
+void RegisterSideloadedTypefaces(SkFontMgr* fontmgr) {
+ std::vector<std::string> files;
+ if (GetSideloadFontFiles(&files)) {
+ for (std::vector<std::string>::const_iterator i(files.begin());
+ i != files.end();
+ ++i) {
+ SkTypeface* typeface = fontmgr->createFromFile(i->c_str());
+ WarmupFontPaint(typeface);
+ blink::WebFontRendering::addSideloadedFontForTesting(typeface);
+ }
+ }
+}
+
void WarmupDirectWrite() {
// The objects used here are intentionally not freed as we want the Skia
// code to use these objects after warmup.
@@ -74,10 +96,11 @@ void WarmupDirectWrite() {
blink::WebFontRendering::setDirectWriteFactory(factory);
SkFontMgr* fontmgr = SkFontMgr_New_DirectWrite(factory);
SkTypeface* typeface = fontmgr->legacyCreateTypeface("Times New Roman", 0);
- SkPaint paint_warmup;
- paint_warmup.setTypeface(typeface);
- wchar_t glyph = L'S';
- paint_warmup.measureText(&glyph, 2);
+ WarmupFontPaint(typeface);
+
+ // Register auxiliary non-system installed fonts. This is primarily for
+ // Blink layout tests.
jam 2014/04/14 05:40:02 since this is only for layout tests, can you do th
scottmg 2014/04/14 15:48:58 It's mostly for Blink but is useful for testing to
jschuh 2014/04/14 15:58:51 I'm inclined to say keep it in Chrome just to make
jam 2014/04/14 16:20:59 note that testing could still be done using conten
+ RegisterSideloadedTypefaces(fontmgr);
}
} // namespace

Powered by Google App Engine
This is Rietveld 408576698