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

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

Issue 923973003: Fix the x-offset calculation when drawing the text. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 | « no previous file | 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/render_text_harfbuzz.h" 5 #include "ui/gfx/render_text_harfbuzz.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/i18n/bidi_line_iterator.h" 9 #include "base/i18n/bidi_line_iterator.h"
10 #include "base/i18n/break_iterator.h" 10 #include "base/i18n/break_iterator.h"
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 const Vector2d origin = GetLineOffset(i) + Vector2d(0, line.baseline); 953 const Vector2d origin = GetLineOffset(i) + Vector2d(0, line.baseline);
954 SkScalar preceding_segment_widths = 0; 954 SkScalar preceding_segment_widths = 0;
955 for (const internal::LineSegment& segment : line.segments) { 955 for (const internal::LineSegment& segment : line.segments) {
956 const internal::TextRunHarfBuzz& run = *runs_[segment.run]; 956 const internal::TextRunHarfBuzz& run = *runs_[segment.run];
957 renderer.SetTypeface(run.skia_face.get()); 957 renderer.SetTypeface(run.skia_face.get());
958 renderer.SetTextSize(SkIntToScalar(run.font_size)); 958 renderer.SetTextSize(SkIntToScalar(run.font_size));
959 renderer.SetFontRenderParams(run.render_params, 959 renderer.SetFontRenderParams(run.render_params,
960 background_is_transparent()); 960 background_is_transparent());
961 Range glyphs_range = run.CharRangeToGlyphRange(segment.char_range); 961 Range glyphs_range = run.CharRangeToGlyphRange(segment.char_range);
962 scoped_ptr<SkPoint[]> positions(new SkPoint[glyphs_range.length()]); 962 scoped_ptr<SkPoint[]> positions(new SkPoint[glyphs_range.length()]);
963 SkScalar offset_x = 963 SkScalar offset_x = preceding_segment_widths -
msw 2015/02/14 04:22:34 Hmm, I wonder if this is actually correct, or if r
Jun Mukai 2015/02/17 21:24:21 Thanks, you are right. My intension was: - if a se
964 preceding_segment_widths - run.positions[glyphs_range.start()].x(); 964 run.positions[glyphs_range.start()].x() +
965 run.positions[0].x();
965 for (size_t j = 0; j < glyphs_range.length(); ++j) { 966 for (size_t j = 0; j < glyphs_range.length(); ++j) {
966 positions[j] = run.positions[(glyphs_range.is_reversed()) ? 967 positions[j] = run.positions[(glyphs_range.is_reversed()) ?
967 (glyphs_range.start() - j) : 968 (glyphs_range.start() - j) :
968 (glyphs_range.start() + j)]; 969 (glyphs_range.start() + j)];
969 positions[j].offset(SkIntToScalar(origin.x()) + offset_x, 970 positions[j].offset(SkIntToScalar(origin.x()) + offset_x,
970 SkIntToScalar(origin.y())); 971 SkIntToScalar(origin.y()));
971 } 972 }
972 for (BreakList<SkColor>::const_iterator it = 973 for (BreakList<SkColor>::const_iterator it =
973 colors().GetBreak(segment.char_range.start()); 974 colors().GetBreak(segment.char_range.start());
974 it != colors().breaks().end() && 975 it != colors().breaks().end() &&
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
1324 if (!run->render_params.subpixel_positioning) 1325 if (!run->render_params.subpixel_positioning)
1325 run->width = std::floor(run->width + 0.5f); 1326 run->width = std::floor(run->width + 0.5f);
1326 } 1327 }
1327 1328
1328 hb_buffer_destroy(buffer); 1329 hb_buffer_destroy(buffer);
1329 hb_font_destroy(harfbuzz_font); 1330 hb_font_destroy(harfbuzz_font);
1330 return true; 1331 return true;
1331 } 1332 }
1332 1333
1333 } // namespace gfx 1334 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698