summaryrefslogtreecommitdiffstats
path: root/ui/gfx/font_list.h
diff options
context:
space:
mode:
authornoms <noms@chromium.org>2014-08-29 16:26:07 -0700
committerCommit bot <commit-bot@chromium.org>2014-08-29 23:33:04 +0000
commit899ae44e331661f709f463d6861a1dbceb9194f2 (patch)
tree79fc8adc58955449324ece8cabc7435ff201056d /ui/gfx/font_list.h
parent65a60fcbfcddcd0749659144189b2a26b3de0977 (diff)
downloadchromium_src-899ae44e331661f709f463d6861a1dbceb9194f2.zip
chromium_src-899ae44e331661f709f463d6861a1dbceb9194f2.tar.gz
chromium_src-899ae44e331661f709f463d6861a1dbceb9194f2.tar.bz2
[Win, Linux] Always display the avatar button text at the same size.
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}
Diffstat (limited to 'ui/gfx/font_list.h')
-rw-r--r--ui/gfx/font_list.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/ui/gfx/font_list.h b/ui/gfx/font_list.h
index 1ba8ad1..bc3afc2 100644
--- a/ui/gfx/font_list.h
+++ b/ui/gfx/font_list.h
@@ -83,6 +83,31 @@ class GFX_EXPORT FontList {
// values: Font::BOLD, Font::ITALIC and Font::UNDERLINE.
FontList DeriveWithStyle(int font_style) const;
+ // Shrinks the font size until the font list fits within |height| while
+ // having its cap height vertically centered. Returns a new FontList with
+ // the correct height.
+ //
+ // The expected layout:
+ // +--------+-----------------------------------------------+------------+
+ // | | y offset | space |
+ // | +--------+-------------------+------------------+ above |
+ // | | | | internal leading | cap height |
+ // | box | font | ascent (baseline) +------------------+------------+
+ // | height | height | | cap height |
+ // | | |-------------------+------------------+------------+
+ // | | | descent (height - baseline) | space |
+ // | +--------+--------------------------------------+ below |
+ // | | space at bottom | cap height |
+ // +--------+-----------------------------------------------+------------+
+ // Goal:
+ // center of box height == center of cap height
+ // (i.e. space above cap height == space below cap height)
+ // Restrictions:
+ // y offset >= 0
+ // space at bottom >= 0
+ // (i.e. Entire font must be visible inside the box.)
+ gfx::FontList DeriveWithHeightUpperBound(int height) const;
+
// Returns the height of this font list, which is max(ascent) + max(descent)
// for all the fonts in the font list.
int GetHeight() const;