OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/gfx/platform_font_win.h" | 5 #include "ui/gfx/platform_font_win.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <dwrite.h> | 8 #include <dwrite.h> |
9 #include <math.h> | 9 #include <math.h> |
10 #include <windows.h> | 10 #include <windows.h> |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 return GetFontName(); | 315 return GetFontName(); |
316 return base::SysWideToUTF8(localized_font_name); | 316 return base::SysWideToUTF8(localized_font_name); |
317 } | 317 } |
318 | 318 |
319 int PlatformFontWin::GetFontSize() const { | 319 int PlatformFontWin::GetFontSize() const { |
320 return font_ref_->font_size(); | 320 return font_ref_->font_size(); |
321 } | 321 } |
322 | 322 |
323 const FontRenderParams& PlatformFontWin::GetFontRenderParams() { | 323 const FontRenderParams& PlatformFontWin::GetFontRenderParams() { |
324 CR_DEFINE_STATIC_LOCAL(const gfx::FontRenderParams, params, | 324 CR_DEFINE_STATIC_LOCAL(const gfx::FontRenderParams, params, |
325 (gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(false), NULL))); | 325 (gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(), NULL))); |
326 return params; | 326 return params; |
327 } | 327 } |
328 | 328 |
329 NativeFont PlatformFontWin::GetNativeFont() const { | 329 NativeFont PlatformFontWin::GetNativeFont() const { |
330 return font_ref_->hfont(); | 330 return font_ref_->hfont(); |
331 } | 331 } |
332 | 332 |
333 // static | 333 // static |
334 void PlatformFontWin::SetDirectWriteFactory(IDWriteFactory* factory) { | 334 void PlatformFontWin::SetDirectWriteFactory(IDWriteFactory* factory) { |
335 // We grab a reference on the DirectWrite factory. This reference is | 335 // We grab a reference on the DirectWrite factory. This reference is |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 | 482 |
483 DWRITE_FONT_METRICS dwrite_font_metrics = {0}; | 483 DWRITE_FONT_METRICS dwrite_font_metrics = {0}; |
484 dwrite_font->GetMetrics(&dwrite_font_metrics); | 484 dwrite_font->GetMetrics(&dwrite_font_metrics); |
485 | 485 |
486 skia::RefPtr<SkTypeface> skia_face = skia::AdoptRef( | 486 skia::RefPtr<SkTypeface> skia_face = skia::AdoptRef( |
487 SkTypeface::CreateFromName( | 487 SkTypeface::CreateFromName( |
488 base::SysWideToUTF8(font_info.lfFaceName).c_str(), | 488 base::SysWideToUTF8(font_info.lfFaceName).c_str(), |
489 static_cast<SkTypeface::Style>(skia_style))); | 489 static_cast<SkTypeface::Style>(skia_style))); |
490 | 490 |
491 gfx::FontRenderParams font_params = | 491 gfx::FontRenderParams font_params = |
492 gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(false), nullptr); | 492 gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(), nullptr); |
493 SkFontHost::SetSubpixelOrder( | 493 SkFontHost::SetSubpixelOrder( |
494 gfx::FontRenderParams::SubpixelRenderingToSkiaLCDOrder( | 494 gfx::FontRenderParams::SubpixelRenderingToSkiaLCDOrder( |
495 font_params.subpixel_rendering)); | 495 font_params.subpixel_rendering)); |
496 SkFontHost::SetSubpixelOrientation( | 496 SkFontHost::SetSubpixelOrientation( |
497 gfx::FontRenderParams::SubpixelRenderingToSkiaLCDOrientation( | 497 gfx::FontRenderParams::SubpixelRenderingToSkiaLCDOrientation( |
498 font_params.subpixel_rendering)); | 498 font_params.subpixel_rendering)); |
499 | 499 |
500 SkPaint paint; | 500 SkPaint paint; |
501 paint.setAntiAlias(font_params.antialiasing); | 501 paint.setAntiAlias(font_params.antialiasing); |
502 paint.setTypeface(skia_face.get()); | 502 paint.setTypeface(skia_face.get()); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 return new PlatformFontWin(native_font); | 616 return new PlatformFontWin(native_font); |
617 } | 617 } |
618 | 618 |
619 // static | 619 // static |
620 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, | 620 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, |
621 int font_size) { | 621 int font_size) { |
622 return new PlatformFontWin(font_name, font_size); | 622 return new PlatformFontWin(font_name, font_size); |
623 } | 623 } |
624 | 624 |
625 } // namespace gfx | 625 } // namespace gfx |
OLD | NEW |