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

Side by Side Diff: ui/gfx/platform_font_win.cc

Issue 1021643002: Retrieve and pass subpixel lcd geometry on windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review Created 5 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 unified diff | Download patch
« no previous file with comments | « ui/gfx/font_render_params_win.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 } 481 }
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 BOOL antialiasing = TRUE; 491 gfx::FontRenderParams font_params =
492 SystemParametersInfo(SPI_GETFONTSMOOTHING, 0, &antialiasing, 0); 492 gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(false), nullptr);
493 SkFontHost::SetSubpixelOrder(
494 gfx::FontRenderParams::SubpixelRenderingToSkiaLCDOrder(
495 font_params.subpixel_rendering));
496 SkFontHost::SetSubpixelOrientation(
497 gfx::FontRenderParams::SubpixelRenderingToSkiaLCDOrientation(
498 font_params.subpixel_rendering));
493 499
494 SkPaint paint; 500 SkPaint paint;
495 paint.setAntiAlias(!!antialiasing); 501 paint.setAntiAlias(font_params.antialiasing);
496 paint.setTypeface(skia_face.get()); 502 paint.setTypeface(skia_face.get());
497 paint.setTextSize(-font_info.lfHeight); 503 paint.setTextSize(-font_info.lfHeight);
498 SkPaint::FontMetrics skia_metrics; 504 SkPaint::FontMetrics skia_metrics;
499 paint.getFontMetrics(&skia_metrics); 505 paint.getFontMetrics(&skia_metrics);
500 506
501 // The calculations below are similar to those in the CreateHFontRef 507 // The calculations below are similar to those in the CreateHFontRef
502 // function. The height, baseline and cap height are rounded up to ensure 508 // function. The height, baseline and cap height are rounded up to ensure
503 // that they match up closely with GDI. 509 // that they match up closely with GDI.
504 const int height = std::ceil(skia_metrics.fDescent - skia_metrics.fAscent); 510 const int height = std::ceil(skia_metrics.fDescent - skia_metrics.fAscent);
505 const int baseline = std::max<int>(1, std::ceil(-skia_metrics.fAscent)); 511 const int baseline = std::max<int>(1, std::ceil(-skia_metrics.fAscent));
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 return new PlatformFontWin(native_font); 616 return new PlatformFontWin(native_font);
611 } 617 }
612 618
613 // static 619 // static
614 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, 620 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name,
615 int font_size) { 621 int font_size) {
616 return new PlatformFontWin(font_name, font_size); 622 return new PlatformFontWin(font_name, font_size);
617 } 623 }
618 624
619 } // namespace gfx 625 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/font_render_params_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698