summaryrefslogtreecommitdiffstats
path: root/ui/gfx/font_list.h
Commit message (Collapse)AuthorAgeFilesLines
* Make FontList description-parsing public.derat2015-02-101-14/+23
| | | | | | | | | | | | | | | | Move FontListImpl's description-string-parsing code into a static FontList::ParseDescription() method that PlatformFontPango will be able to call to parse descriptions on Chrome OS. Also make parsing stricter, add tests, and delete unused SetUpPangoLayout() and GetFontDescriptionString(). BUG=398885,393067 Review URL: https://codereview.chromium.org/903423002 Cr-Commit-Position: refs/heads/master@{#315559}
* [Win, Linux] Always display the avatar button text at the same size.noms2014-08-291-0/+25
| | | | | | | | | | | | | | | | | | | | The problem is that some locales (Hindi) or platforms (Linux) have a bigger base font size for the default font (crbug.com/405994). If this is the case, we should decrease the font size to the one we expect, so that the font fits in the button correctly. Just adjusting the baseline is not always enough, as the new avatar button has a fixed size, and the text might not fit correctly regardless of the baseline adjustments. Screenshots: https://drive.google.com/folderview?id=0B1B1Up4p2NRMRHc5WTBxZWNrRm8&usp=sharing BUG=403466 TEST=Start Chrome with --enable-new-avatar-menu on Linux, or with --enable-new-avatar-menu and --lang-hi on Windows. The avatar button text should fit nicely in the button. Review URL: https://codereview.chromium.org/470053004 Cr-Commit-Position: refs/heads/master@{#292715}
* Makes FontList light-weighted introducing FontListImpl.yukishiino@chromium.org2014-02-091-49/+24
| | | | | | | | | | | | | | | | | Like Font class has scoped_refptr<PlatformFont>, makes FontList have scoped_refptr<FontListImpl>. FontListImpl is almost the same as the old FontList and implements all functionalities. There are two major benefits with this CL. 1. Copying a FontList to another FontList is very quick. It just copies a scoped_refptr. 2. Calculated font metrics are shared among all FontList instances which refer to the same FontListImpl. In addition, this CL may fix Issue 340396. I don't fully understand the cause yet, but it seems that copying the object in a ctor is causing the issue (It's a little tricky, but I thought it should be okay). This CL doesn't copy the object. So I think this CL may fix the issue. BUG=340396 TEST=Run ui_unittests, views_unittests and unit_tests. Review URL: https://codereview.chromium.org/148773007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@249976 0039d316-1c4b-4281-b951-d872f2087c98
* Renames gfx::FontList::Derive* family.yukishiino@chromium.org2014-01-311-11/+13
| | | | | | | | | | | | | | | | | | | 1. Removes obsolete methods. - DeriveFontList(font_style) # The method name and argument are not clear compared to other versions. Use DeriveWithStyle(style) below instead. - DeriveFontListWithSize(absolute_size) # Don't specify the absolute size. 2. Renames very long named methods. - DeriveFontListWithSizeDeltaAndStyle => Derive - DeriveFontListWithSizeDelta => DeriveWithSizeDelta - new method => DeriveWithStyle Since DeriveFontListWithSizeDeltaAndStyle is used more often than DeriveFontListWithSizeDelta, so give the former a shorter name. Review URL: https://codereview.chromium.org/142523003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@248131 0039d316-1c4b-4281-b951-d872f2087c98
* Clean-up: Removes gfx::FontList::GetStringWidth(text).yukishiino@chromium.org2014-01-231-3/+0
| | | | | | | | | | gfx::GetStringWidth(text, font_list) in ui/gfx/text_utils.h is recommended and gfx::FontList::GetStringWidth(text) is obsolete. Remove the method. TEST=none Review URL: https://codereview.chromium.org/144183005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@246548 0039d316-1c4b-4281-b951-d872f2087c98
* Makes the default ctor of gfx::FontList copy the pre-calculated metrics.yukishiino@chromium.org2014-01-121-1/+2
| | | | | | | | | | | Every instance of default-constructed FontList has been calling CacheCommonFontHeightAndBaseline() and CacheFontStyleAndSize(), and it's inefficient. This CL creates an instance of FontList which holds pre-calculated metrics, and copy the pre-calculated metrics in the default ctor. This change improves the performance very much. BUG=330975 TEST=Run unit_tests, views_unittests, ui_unittests. Review URL: https://codereview.chromium.org/124693003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@244446 0039d316-1c4b-4281-b951-d872f2087c98
* Default ctor of FontList initializes with IDS_UI_FONT_FAMILY_CROS.yukishiino@chromium.org2013-11-201-0/+10
| | | | | | | | | | | | | This CL makes the default constructor of gfx::FontList initialize its font list from the default font description, set by gfx::FontList::SetDefaultFontDescription(). This CL is a preparation of http://crrev.com/32153002 , etc. BUG=265485 TEST=none Review URL: https://codereview.chromium.org/61933002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@236187 0039d316-1c4b-4281-b951-d872f2087c98
* Supports cap height in gfx::Font and gfx::FontList.yukishiino@chromium.org2013-10-011-0/+4
| | | | | | | | | | | | | | | | | | | This CL is a preparation of http://crrev.com/23601006 . Cap height will be used to determine the fixed baseline of text, especially for Omnibox but not limited to. Omnibox wants to show Latin characters vertically center, i.e. ABC look just center. Omnibox also wants to resize the font list so text is small enough to fit in Omnibox. The baseline is determined from these two restrictions. All the texts are rendered based on this baseline regardless its height. Any characters within the height of the font list must fit in Omnibox. For text controls other than Omnibox, the height of text box may be determined from the height of the font list and the cap height may not be used. If the height of text box is smaller than the height of the font list, then the text control determines the baseline based on cap height so it shows ABC vertically center. BUG=146236,264436 TEST=Ran ui_unittests. Review URL: https://codereview.chromium.org/24240013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@226202 0039d316-1c4b-4281-b951-d872f2087c98
* Remove last dependencies on ui/base from ui/gfxben@chromium.org2013-09-271-1/+1
| | | | | | | | | BUG=103304 R=sky@chromium.org Review URL: https://codereview.chromium.org/23498059 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@225722 0039d316-1c4b-4281-b951-d872f2087c98
* Adds a gfx_export.h to ui/gfx and converts all code in ui/gfx toben@chromium.org2013-09-051-1/+1
| | | | | | | | | | | include it rather than ui_export.h TBR=sky@chromium.org http://crbug.com/285385 Review URL: https://codereview.chromium.org/23486010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221506 0039d316-1c4b-4281-b951-d872f2087c98
* Supports FontList::DeriveFontListWithSizeDeltaAndStyle, etc.yukishiino@chromium.org2013-08-091-0/+35
| | | | | | | | | | | | | | | This CL improves FontList so the class has useful methods for replacing Font class. Also improves the performance of GetFontStyle() and GetFontSize(). This CL also adds GetAverageCharacterWidth(), GetStringWidth(), and GetExpectedTextWidth(). These methods are supported by Font class, and FontList should implement them for replacing Font. Just FYI, I'm now working on http://crrev.com/21736002 , and these new methods are used there. BUG=265485 TEST=Included in the unittests as ui_unittests. Review URL: https://chromiumcodereview.appspot.com/21868004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@216563 0039d316-1c4b-4281-b951-d872f2087c98
* Supports FontList in Textfield.yukishiino@chromium.org2013-08-011-0/+6
| | | | | | | | | | | | | | | | | | | The current interface of Textfield does not support FontList while RenderText supports FontList. This CL supports FontList in Textfield. The direct cause of crbug.com/263169 was that RenderText always uses the IDS_UI_FONT_FAMILY_CROS font set ignoring what font is specified for Textfield on ChromeOS. (See https://code.google.com/p/chromium/codesearch#chromium/src/ui/views/controls/textfield/native_textfield_views.cc&q=IDS_UI_FONT_FAMILY_CROS&sq=package:chromium&type=cs&l=88 ) The Omnibox font size is carefully calculated, but the font is ignored right now. This CL changes the following: - Supports FontList in Textfield so Omnibox layer can specify the font set, such as IDS_UI_FONT_FAMILY_CROS, for the underlying Textfield. - Makes NativeTextfieldViews follow the specified font set via Textfield on ChromeOS. BUG=263169,263196 TEST=Test manually. Review URL: https://chromiumcodereview.appspot.com/19666006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@215055 0039d316-1c4b-4281-b951-d872f2087c98
* Fixes vertical alignment of RenderText.yukishiino@chromium.org2013-07-201-0/+12
| | | | | | | | | | | | | | | (was: Issue 18848002: Shows Japanese and English mixed queries correctly.) The CL 18848002 was reverted because the new unit test, which I added, depended on the specific fonts and didn't run well on some of platforms. I've carefully chosen another font for the unit test, which is available on all platforms. BUG=244323 TEST=Test manually. Review URL: https://chromiumcodereview.appspot.com/19352002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@212792 0039d316-1c4b-4281-b951-d872f2087c98
* This caused failures in ui_unittests FontListTest.Fonts_GetHeight_GetBaselinemark@chromium.org2013-07-151-15/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | http://build.chromium.org/p/chromium.mac/buildstatus?builder=Mac%2010.6%20Tests%20%28dbg%29%284%29&number=30356 http://build.chromium.org/p/chromium.mac/buildstatus?builder=Mac%2010.7%20Tests%20%28dbg%29%284%29&number=13543 Revert 211664 "Shows Japanese and English mixed queries correctly." > Shows Japanese and English mixed queries correctly. > > This CL respects the common height and baseline of the fonts in the given font list, and draw text according to the baseline. > > The cause of vertically-misaligned queries was that > 1. ASCII characters have 23 pixels in height > 2. Japanese characters have 17 pixels in height > > pango_layout_get_pixel_size(), which is called in RenderTextLinux::GetStringSize(), returns the above size. > > Also see: > https://docs.google.com/a/chromium.org/document/d/1e2n9lEM_usn37Pld8tMeo_qpfLRQQjkx-O1hTHi3sPo/edit?usp=sharing > > BUG=244323 > TEST=Test manually. > > Review URL: https://chromiumcodereview.appspot.com/18848002 TBR=yukishiino@chromium.org Review URL: https://codereview.chromium.org/19270002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@211669 0039d316-1c4b-4281-b951-d872f2087c98
* Shows Japanese and English mixed queries correctly.yukishiino@chromium.org2013-07-151-0/+15
| | | | | | | | | | | | | | | | | | | | This CL respects the common height and baseline of the fonts in the given font list, and draw text according to the baseline. The cause of vertically-misaligned queries was that 1. ASCII characters have 23 pixels in height 2. Japanese characters have 17 pixels in height pango_layout_get_pixel_size(), which is called in RenderTextLinux::GetStringSize(), returns the above size. Also see: https://docs.google.com/a/chromium.org/document/d/1e2n9lEM_usn37Pld8tMeo_qpfLRQQjkx-O1hTHi3sPo/edit?usp=sharing BUG=244323 TEST=Test manually. Review URL: https://chromiumcodereview.appspot.com/18848002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@211664 0039d316-1c4b-4281-b951-d872f2087c98
* Remove the rest of #pragma once in one big CL.ajwong@chromium.org2012-07-111-1/+0
| | | | | | | | | For context see this thread: https://groups.google.com/a/chromium.org/forum/?fromgroups#!topic/chromium-dev/RMcVNGjB4II TBR=thakis,pkasting,jam git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146163 0039d316-1c4b-4281-b951-d872f2087c98
* ui/gfx: Remove an unnecessary include from font_list.htfarina@chromium.org2012-03-061-1/+0
| | | | | | | | R=asvitkine@chromium.org Review URL: https://chromiumcodereview.appspot.com/9595005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@125078 0039d316-1c4b-4281-b951-d872f2087c98
* Aura: apply UI font list to cros.xji@chromium.org2012-01-241-0/+4
| | | | | | | | | | | | | | | | | | - change IDS_UI_FONT_FAMILY_CROS back to 12px in default. - GetDefaultFont() in platform_font_pango.cc returns IDS_UI_FONT_FAMILY_CROS for Aura Chrome OS. - views::NativeTextfieldViews::UpdateFont() applies the size from the passed-in font on Chrome OS - OmniboxViewViews requests a larger font size. - Correspondingly, decrease OmniboxViewViews's vertical margin so that the display area has greater height to accommodate larger font size. BUG=103860, 109961 TEST=visual on omnibox and popup, bookmark bubble, findbar, and omnibox in popup. Review URL: http://codereview.chromium.org/9192018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118802 0039d316-1c4b-4281-b951-d872f2087c98
* Enable bold and italic text styles in RenderText*.asvitkine@chromium.org2012-01-101-0/+6
| | | | | | | | | | | | | | | | To do this, the following changes were made: Added functions GetStyle() and DeriveFontList(style) to FontList. Changed font list to use strings "Bold" and "Italic" instead of PANGO_STYLE_ITALIC and PANGO_WEIGHT_BOLD - where were actually compile constants for setting attributes and weren't recognized by Pango in a font string. (Whereas "Bold" and "Italic" are recognized). Add RenderText test that checks that the width of a bold string > the width of a non-bold string. Add FontList tests for the new functions. BUG=107893 TEST=Run views_examples_exe "Text Styles" examples and try bold and italic styles (this depends on an unreleased CL). Also, new tests in FontListTest and RenderTextTest. Review URL: http://codereview.chromium.org/8963027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117034 0039d316-1c4b-4281-b951-d872f2087c98
* Revert 116945 - Enable bold and italic text styles in RenderText*.binji@chromium.org2012-01-091-6/+0
| | | | | | | | | | | | | | | | | | | To do this, the following changes were made: Added functions GetStyle() and DeriveFontList(style) to FontList. Changed font list to use strings "Bold" and "Italic" instead of PANGO_STYLE_ITALIC and PANGO_WEIGHT_BOLD - where were actually compile constants for setting attributes and weren't recognized by Pango in a font string. (Whereas "Bold" and "Italic" are recognized). Add RenderText test that checks that the width of a bold string > the width of a non-bold string. Add FontList tests for the new functions. BUG=107893 TEST=Run views_examples_exe "Text Styles" examples and try bold and italic styles (this depends on an unreleased CL). Also, new tests in FontListTest and RenderTextTest. Review URL: http://codereview.chromium.org/8963027 TBR=asvitkine@chromium.org Review URL: http://codereview.chromium.org/9147016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116948 0039d316-1c4b-4281-b951-d872f2087c98
* Enable bold and italic text styles in RenderText*.asvitkine@chromium.org2012-01-091-0/+6
| | | | | | | | | | | | | | | | To do this, the following changes were made: Added functions GetStyle() and DeriveFontList(style) to FontList. Changed font list to use strings "Bold" and "Italic" instead of PANGO_STYLE_ITALIC and PANGO_WEIGHT_BOLD - where were actually compile constants for setting attributes and weren't recognized by Pango in a font string. (Whereas "Bold" and "Italic" are recognized). Add RenderText test that checks that the width of a bold string > the width of a non-bold string. Add FontList tests for the new functions. BUG=107893 TEST=Run views_examples_exe "Text Styles" examples and try bold and italic styles (this depends on an unreleased CL). Also, new tests in FontListTest and RenderTextTest. Review URL: http://codereview.chromium.org/8963027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116945 0039d316-1c4b-4281-b951-d872f2087c98
* specify locale-dependent font list for UI on ChromeOS, so that those fonts ↵xji@chromium.org2012-01-041-0/+80
| | | | | | | | | | | | | have higher priority over the fallback fonts Pango picks up. BUG=103860 TEST=build aura, start chromium in 'ar' locale. type in Arabic and check the Arabic text's shapes. remove IDS_UI_FONT_FAMILY_CROS from 'ar' resource file, build aura again, start chromium in 'ar', type in Arabic and the Arabic text's shapes should be different. Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=114953 Review URL: http://codereview.chromium.org/8770034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116359 0039d316-1c4b-4281-b951-d872f2087c98
* Revert 114953 (breaks cros font sizes, etc.) - specify locale-dependent font ↵msw@chromium.org2011-12-201-79/+0
| | | | | | | | | | | | | | list for UI on ChromeOS, so that those fonts have higher priority over the fallback fonts Pango picks up. BUG=103860 TEST=build aura, start chromium in 'ar' locale. type in Arabic and check the Arabic text's shapes. remove IDS_UI_FONT_FAMILY_CROS from 'ar' resource file, build aura again, start chromium in 'ar', type in Arabic and the Arabic text's shapes should be different. Review URL: http://codereview.chromium.org/8770034 TBR=xji@chromium.org Review URL: http://codereview.chromium.org/9007028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115179 0039d316-1c4b-4281-b951-d872f2087c98
* specify locale-dependent font list for UI on ChromeOS, so that those fonts ↵xji@chromium.org2011-12-191-0/+79
have higher priority over the fallback fonts Pango picks up. BUG=103860 TEST=build aura, start chromium in 'ar' locale. type in Arabic and check the Arabic text's shapes. remove IDS_UI_FONT_FAMILY_CROS from 'ar' resource file, build aura again, start chromium in 'ar', type in Arabic and the Arabic text's shapes should be different. Review URL: http://codereview.chromium.org/8770034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114953 0039d316-1c4b-4281-b951-d872f2087c98