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

Side by Side Diff: chrome/browser/ui/libgtk2ui/gtk2_ui.cc

Issue 1819753003: Allow various font weights in gfx. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Further Mac and Linux fixes. Created 4 years, 9 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
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 "chrome/browser/ui/libgtk2ui/gtk2_ui.h" 5 #include "chrome/browser/ui/libgtk2ui/gtk2_ui.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <pango/pango.h> 8 #include <pango/pango.h>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 default: 466 default:
467 return views::LinuxUI::MIDDLE_CLICK_ACTION_LOWER; 467 return views::LinuxUI::MIDDLE_CLICK_ACTION_LOWER;
468 } 468 }
469 } 469 }
470 470
471 } // namespace 471 } // namespace
472 472
473 Gtk2UI::Gtk2UI() 473 Gtk2UI::Gtk2UI()
474 : default_font_size_pixels_(0), 474 : default_font_size_pixels_(0),
475 default_font_style_(gfx::Font::NORMAL), 475 default_font_style_(gfx::Font::NORMAL),
476 default_font_weight_(gfx::Font::Weight::NORMAL),
476 middle_click_action_(GetDefaultMiddleClickAction()), 477 middle_click_action_(GetDefaultMiddleClickAction()),
477 device_scale_factor_(1.0) { 478 device_scale_factor_(1.0) {
478 GtkInitFromCommandLine(*base::CommandLine::ForCurrentProcess()); 479 GtkInitFromCommandLine(*base::CommandLine::ForCurrentProcess());
479 } 480 }
480 481
481 482
482 483
483 void OnThemeChanged(GObject* obj, GParamSpec* param, Gtk2UI* gtkui) { 484 void OnThemeChanged(GObject* obj, GParamSpec* param, Gtk2UI* gtkui) {
484 gtkui->ResetStyle(); 485 gtkui->ResetStyle();
485 } 486 }
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 } 814 }
814 815
815 gfx::FontRenderParams Gtk2UI::GetDefaultFontRenderParams() const { 816 gfx::FontRenderParams Gtk2UI::GetDefaultFontRenderParams() const {
816 static gfx::FontRenderParams params = GetGtkFontRenderParams(); 817 static gfx::FontRenderParams params = GetGtkFontRenderParams();
817 return params; 818 return params;
818 } 819 }
819 820
820 void Gtk2UI::GetDefaultFontDescription( 821 void Gtk2UI::GetDefaultFontDescription(
821 std::string* family_out, 822 std::string* family_out,
822 int* size_pixels_out, 823 int* size_pixels_out,
823 int* style_out, 824 bool* italic_out,
825 gfx::Font::Weight* weight_out,
824 gfx::FontRenderParams* params_out) const { 826 gfx::FontRenderParams* params_out) const {
825 *family_out = default_font_family_; 827 *family_out = default_font_family_;
826 *size_pixels_out = default_font_size_pixels_; 828 *size_pixels_out = default_font_size_pixels_;
827 *style_out = default_font_style_; 829 *italic_out = default_font_style_ == gfx::Font::ITALIC;
msw 2016/03/25 01:33:09 nit: check (default_font_style_ & gfx::Font::ITALI
Mikus 2016/03/25 11:49:00 Done.
830 *weight_out = default_font_weight_;
828 *params_out = default_font_render_params_; 831 *params_out = default_font_render_params_;
829 } 832 }
830 833
831 ui::SelectFileDialog* Gtk2UI::CreateSelectFileDialog( 834 ui::SelectFileDialog* Gtk2UI::CreateSelectFileDialog(
832 ui::SelectFileDialog::Listener* listener, 835 ui::SelectFileDialog::Listener* listener,
833 ui::SelectFilePolicy* policy) const { 836 ui::SelectFilePolicy* policy) const {
834 return SelectFileDialogImpl::Create(listener, policy); 837 return SelectFileDialogImpl::Create(listener, policy);
835 } 838 }
836 839
837 bool Gtk2UI::UnityIsRunning() { 840 bool Gtk2UI::UnityIsRunning() {
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 // Non-absolute sizes are in points (again scaled by PANGO_SIZE). 1342 // Non-absolute sizes are in points (again scaled by PANGO_SIZE).
1340 // Round the value when converting to pixels to match GTK's logic. 1343 // Round the value when converting to pixels to match GTK's logic.
1341 const double size_points = pango_font_description_get_size(desc) / 1344 const double size_points = pango_font_description_get_size(desc) /
1342 static_cast<double>(PANGO_SCALE); 1345 static_cast<double>(PANGO_SCALE);
1343 default_font_size_pixels_ = static_cast<int>( 1346 default_font_size_pixels_ = static_cast<int>(
1344 GetPixelsInPoint(device_scale_factor_) * size_points + 0.5); 1347 GetPixelsInPoint(device_scale_factor_) * size_points + 0.5);
1345 query.point_size = static_cast<int>(size_points); 1348 query.point_size = static_cast<int>(size_points);
1346 } 1349 }
1347 1350
1348 query.style = gfx::Font::NORMAL; 1351 query.style = gfx::Font::NORMAL;
1352 query.weight = gfx::Font::Weight::NORMAL;
1349 // TODO(davemoore): Support weights other than bold? 1353 // TODO(davemoore): Support weights other than bold?
msw 2016/03/25 01:33:09 It'll be much easier to address this TODO now! (in
Mikus 2016/03/25 11:49:00 Acknowledged. Todo changed.
1350 if (pango_font_description_get_weight(desc) == PANGO_WEIGHT_BOLD) 1354 if (pango_font_description_get_weight(desc) == PANGO_WEIGHT_BOLD)
1351 query.style |= gfx::Font::BOLD; 1355 query.weight = gfx::Font::Weight::BOLD;
1352 // TODO(davemoore): What about PANGO_STYLE_OBLIQUE? 1356 // TODO(davemoore): What about PANGO_STYLE_OBLIQUE?
1353 if (pango_font_description_get_style(desc) == PANGO_STYLE_ITALIC) 1357 if (pango_font_description_get_style(desc) == PANGO_STYLE_ITALIC)
1354 query.style |= gfx::Font::ITALIC; 1358 query.style |= gfx::Font::ITALIC;
1355 1359
1356 default_font_render_params_ = 1360 default_font_render_params_ =
1357 gfx::GetFontRenderParams(query, &default_font_family_); 1361 gfx::GetFontRenderParams(query, &default_font_family_);
1358 default_font_style_ = query.style; 1362 default_font_style_ = query.style;
1359 } 1363 }
1360 1364
1361 void Gtk2UI::ResetStyle() { 1365 void Gtk2UI::ResetStyle() {
(...skipping 16 matching lines...) Expand all
1378 // Blacklist scaling factors <130% (crbug.com/484400) and round 1382 // Blacklist scaling factors <130% (crbug.com/484400) and round
1379 // to 1 decimal to prevent rendering problems (crbug.com/485183). 1383 // to 1 decimal to prevent rendering problems (crbug.com/485183).
1380 return scale < 1.3f ? 1.0f : roundf(scale * 10) / 10; 1384 return scale < 1.3f ? 1.0f : roundf(scale * 10) / 10;
1381 } 1385 }
1382 1386
1383 } // namespace libgtk2ui 1387 } // namespace libgtk2ui
1384 1388
1385 views::LinuxUI* BuildGtk2UI() { 1389 views::LinuxUI* BuildGtk2UI() {
1386 return new libgtk2ui::Gtk2UI; 1390 return new libgtk2ui::Gtk2UI;
1387 } 1391 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698