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

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

Issue 387543002: RenderTextHarfBuzz: Fix glyph offset calculation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
« 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 <map> 7 #include <map>
8 8
9 #include "base/debug/leak_annotations.h" 9 #include "base/debug/leak_annotations.h"
10 #include "base/i18n/bidi_line_iterator.h" 10 #include "base/i18n/bidi_line_iterator.h"
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 260
261 FaceCache* face_cache = &face_caches[skia_face->uniqueID()]; 261 FaceCache* face_cache = &face_caches[skia_face->uniqueID()];
262 if (face_cache->first == 0) { 262 if (face_cache->first == 0) {
263 // These HarfBuzz faces live indefinitely and are intentionally leaked. 263 // These HarfBuzz faces live indefinitely and are intentionally leaked.
264 ANNOTATE_SCOPED_MEMORY_LEAK; 264 ANNOTATE_SCOPED_MEMORY_LEAK;
265 hb_face_t* harfbuzz_face = CreateHarfBuzzFace(skia_face); 265 hb_face_t* harfbuzz_face = CreateHarfBuzzFace(skia_face);
266 *face_cache = FaceCache(harfbuzz_face, GlyphCache()); 266 *face_cache = FaceCache(harfbuzz_face, GlyphCache());
267 } 267 }
268 268
269 hb_font_t* harfbuzz_font = hb_font_create(face_cache->first); 269 hb_font_t* harfbuzz_font = hb_font_create(face_cache->first);
270 // TODO(ckocagil): Investigate whether disabling hinting here has any effect 270
271 // on text quality. 271 const int scale = SkScalarToFixed(text_size);
272 int upem = hb_face_get_upem(face_cache->first); 272 hb_font_set_scale(harfbuzz_font, scale, scale);
273 hb_font_set_scale(harfbuzz_font, upem, upem);
274 FontData* hb_font_data = new FontData(&face_cache->second); 273 FontData* hb_font_data = new FontData(&face_cache->second);
275 hb_font_data->paint_.setTypeface(skia_face); 274 hb_font_data->paint_.setTypeface(skia_face);
276 hb_font_data->paint_.setTextSize(text_size); 275 hb_font_data->paint_.setTextSize(text_size);
277 hb_font_set_funcs(harfbuzz_font, g_font_funcs.Get().get(), hb_font_data, 276 hb_font_set_funcs(harfbuzz_font, g_font_funcs.Get().get(), hb_font_data,
278 DeleteByType<FontData>); 277 DeleteByType<FontData>);
279 hb_font_make_immutable(harfbuzz_font); 278 hb_font_make_immutable(harfbuzz_font);
280 return harfbuzz_font; 279 return harfbuzz_font;
281 } 280 }
282 281
283 // Returns true if characters of |block_code| may trigger font fallback. 282 // Returns true if characters of |block_code| may trigger font fallback.
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 run->glyphs.reset(new uint16[run->glyph_count]); 992 run->glyphs.reset(new uint16[run->glyph_count]);
994 run->glyph_to_char.reset(new uint32[run->glyph_count]); 993 run->glyph_to_char.reset(new uint32[run->glyph_count]);
995 run->positions.reset(new SkPoint[run->glyph_count]); 994 run->positions.reset(new SkPoint[run->glyph_count]);
996 for (size_t i = 0; i < run->glyph_count; ++i) { 995 for (size_t i = 0; i < run->glyph_count; ++i) {
997 run->glyphs[i] = infos[i].codepoint; 996 run->glyphs[i] = infos[i].codepoint;
998 run->glyph_to_char[i] = infos[i].cluster; 997 run->glyph_to_char[i] = infos[i].cluster;
999 const int x_offset = 998 const int x_offset =
1000 SkScalarRoundToInt(SkFixedToScalar(hb_positions[i].x_offset)); 999 SkScalarRoundToInt(SkFixedToScalar(hb_positions[i].x_offset));
1001 const int y_offset = 1000 const int y_offset =
1002 SkScalarRoundToInt(SkFixedToScalar(hb_positions[i].y_offset)); 1001 SkScalarRoundToInt(SkFixedToScalar(hb_positions[i].y_offset));
1003 run->positions[i].set(run->width + x_offset, y_offset); 1002 run->positions[i].set(run->width + x_offset, -y_offset);
1004 run->width += 1003 run->width +=
1005 SkScalarRoundToInt(SkFixedToScalar(hb_positions[i].x_advance)); 1004 SkScalarRoundToInt(SkFixedToScalar(hb_positions[i].x_advance));
1006 } 1005 }
1007 1006
1008 hb_buffer_destroy(buffer); 1007 hb_buffer_destroy(buffer);
1009 hb_font_destroy(harfbuzz_font); 1008 hb_font_destroy(harfbuzz_font);
1010 } 1009 }
1011 1010
1012 } // namespace gfx 1011 } // 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