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

Unified Diff: ui/gfx/render_text_linux.cc

Issue 18848002: Shows Japanese and English mixed queries correctly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adds a unit test. Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
« ui/gfx/render_text.cc ('K') | « ui/gfx/render_text.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/render_text_linux.cc
diff --git a/ui/gfx/render_text_linux.cc b/ui/gfx/render_text_linux.cc
index e6a1ab725e4cda13a895e29a6fd1decb587d60aa..188b6a711125acd824318e7082bc064ccd2ed504 100644
--- a/ui/gfx/render_text_linux.cc
+++ b/ui/gfx/render_text_linux.cc
@@ -83,12 +83,25 @@ Size RenderTextLinux::GetStringSize() {
EnsureLayout();
int width = 0, height = 0;
pango_layout_get_pixel_size(layout_, &width, &height);
- return Size(width, height);
+ // pango_layout_get_pixel_size() returns the minimal size to render the given
msw 2013/07/11 22:47:29 DCHECK that |height| is smaller, and just return G
Yuki 2013/07/12 08:25:53 I'm not sure if it's guaranteed that the pango val
msw 2013/07/12 09:36:04 Fair enough; I thought FontLists might track fallb
+ // text, and the height can be smaller than the font height. This means the
+ // baseline may change as the content text changes. Since we'd like to keep
+ // the same baseline as much as possible, we respect the height determined by
+ // the font list, unless the actual height is higher than the height of the
+ // font list.
+ return Size(width, std::max(height, GetFontListHeight()));
}
int RenderTextLinux::GetBaseline() {
EnsureLayout();
- return PANGO_PIXELS(pango_layout_get_baseline(layout_));
+ // pango_layout_get_baseline() returns the baseline based on the minimal size
+ // to render the given text, and the baseline can be smaller than the font
+ // baseline. This means the baseline may change as the content text changes.
+ // Since we'd like to keep the same baseline as much as possible, we respect
+ // the baseline determined by the font list, unless the actual baseline is
+ // greater than the baseline of the font list.
+ return std::max(PANGO_PIXELS(pango_layout_get_baseline(layout_)),
msw 2013/07/11 22:47:29 DCHECK that the pango value is smaller, and just r
Yuki 2013/07/12 08:25:53 Ditto.
+ GetFontListBaseline());
}
SelectionModel RenderTextLinux::FindCursorPosition(const Point& point) {
@@ -364,8 +377,7 @@ void RenderTextLinux::DrawVisualText(Canvas* canvas) {
DCHECK(layout_);
// Skia will draw glyphs with respect to the baseline.
- Vector2d offset(GetTextOffset() +
- Vector2d(0, PANGO_PIXELS(pango_layout_get_baseline(layout_))));
+ Vector2d offset(GetTextOffset() + Vector2d(0, GetBaseline()));
SkScalar x = SkIntToScalar(offset.x());
SkScalar y = SkIntToScalar(offset.y());
« ui/gfx/render_text.cc ('K') | « ui/gfx/render_text.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698