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

Unified Diff: ui/gfx/platform_font_win.h

Issue 692633003: Use the correct font metrics in base PlatformFontWin if DirectWrite is used in the browser for font… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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: ui/gfx/platform_font_win.h
diff --git a/ui/gfx/platform_font_win.h b/ui/gfx/platform_font_win.h
index 90160aa6049ccc3ad8afc7bc046b2c3ca66ef618..27bad4d0b4719b448f904631c7766a1d3f0fc830 100644
--- a/ui/gfx/platform_font_win.h
+++ b/ui/gfx/platform_font_win.h
@@ -5,6 +5,7 @@
#ifndef UI_GFX_PLATFORM_FONT_WIN_H_
#define UI_GFX_PLATFORM_FONT_WIN_H_
+#include <dwrite.h>
#include <string>
#include "base/compiler_specific.h"
@@ -66,6 +67,11 @@ class GFX_EXPORT PlatformFontWin : public PlatformFont {
virtual const FontRenderParams& GetFontRenderParams() const override;
virtual NativeFont GetNativeFont() const override;
+ // Called once during initialization if we are using DirectWrite for fonts.
+ static void set_direct_write_factory(IDWriteFactory* factory) {
+ direct_write_factory_ = factory;
+ }
+
private:
virtual ~PlatformFontWin() {}
@@ -151,6 +157,13 @@ class GFX_EXPORT PlatformFontWin : public PlatformFont {
// |base_font|.
static Font DeriveWithCorrectedSize(HFONT base_font);
+ // Converts the GDI font identified by the |gdi_font| parameter to a
+ // DirectWrite compatible HFONT, i.e with metrics compatible with
+ // DirectWrite.
+ // Returns the HFONT which is created from DirectWrite compatible font
+ // metrics.
+ static HFONT ConvertGDIFontToDirectWriteFont(HFONT gdi_font);
+
// Creates a new PlatformFontWin with the specified HFontRef. Used when
// constructing a Font from a HFONT we don't want to copy.
explicit PlatformFontWin(HFontRef* hfont_ref);
@@ -161,6 +174,10 @@ class GFX_EXPORT PlatformFontWin : public PlatformFont {
// Indirect reference to the HFontRef, which references the underlying HFONT.
scoped_refptr<HFontRef> font_ref_;
+ // Pointer to the global IDWriteFactory interface. This is only set if we are
+ // using DirectWrite for fonts. Defaults to NULL.
+ static IDWriteFactory* direct_write_factory_;
+
DISALLOW_COPY_AND_ASSIGN(PlatformFontWin);
};

Powered by Google App Engine
This is Rietveld 408576698