OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/harfbuzz_font_skia.h" | 5 #include "ui/gfx/harfbuzz_font_skia.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <limits> | 10 #include <limits> |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 SkTypeface* typeface = font_data->paint_.getTypeface(); | 125 SkTypeface* typeface = font_data->paint_.getTypeface(); |
126 const uint16_t glyphs[2] = { static_cast<uint16_t>(first_glyph), | 126 const uint16_t glyphs[2] = { static_cast<uint16_t>(first_glyph), |
127 static_cast<uint16_t>(second_glyph) }; | 127 static_cast<uint16_t>(second_glyph) }; |
128 int32_t kerning_adjustments[1] = { 0 }; | 128 int32_t kerning_adjustments[1] = { 0 }; |
129 | 129 |
130 if (!typeface->getKerningPairAdjustments(glyphs, 2, kerning_adjustments)) | 130 if (!typeface->getKerningPairAdjustments(glyphs, 2, kerning_adjustments)) |
131 return 0; | 131 return 0; |
132 | 132 |
133 SkScalar upm = SkIntToScalar(typeface->getUnitsPerEm()); | 133 SkScalar upm = SkIntToScalar(typeface->getUnitsPerEm()); |
134 SkScalar size = font_data->paint_.getTextSize(); | 134 SkScalar size = font_data->paint_.getTextSize(); |
135 return SkiaScalarToHarfBuzzUnits( | 135 return SkiaScalarToHarfBuzzUnits(SkIntToScalar(kerning_adjustments[0]) * |
136 SkScalarMulDiv(SkIntToScalar(kerning_adjustments[0]), size, upm)); | 136 size / upm); |
137 } | 137 } |
138 | 138 |
139 hb_position_t GetGlyphHorizontalKerning(hb_font_t* font, | 139 hb_position_t GetGlyphHorizontalKerning(hb_font_t* font, |
140 void* data, | 140 void* data, |
141 hb_codepoint_t left_glyph, | 141 hb_codepoint_t left_glyph, |
142 hb_codepoint_t right_glyph, | 142 hb_codepoint_t right_glyph, |
143 void* user_data) { | 143 void* user_data) { |
144 FontData* font_data = reinterpret_cast<FontData*>(data); | 144 FontData* font_data = reinterpret_cast<FontData*>(data); |
145 if (font_data->paint_.isVerticalText()) { | 145 if (font_data->paint_.isVerticalText()) { |
146 // We don't support cross-stream kerning. | 146 // We don't support cross-stream kerning. |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 // TODO(ckocagil): Do we need to update these params later? | 279 // TODO(ckocagil): Do we need to update these params later? |
280 internal::ApplyRenderParams(params, subpixel_rendering_suppressed, | 280 internal::ApplyRenderParams(params, subpixel_rendering_suppressed, |
281 &hb_font_data->paint_); | 281 &hb_font_data->paint_); |
282 hb_font_set_funcs(harfbuzz_font, g_font_funcs.Get().get(), hb_font_data, | 282 hb_font_set_funcs(harfbuzz_font, g_font_funcs.Get().get(), hb_font_data, |
283 DeleteByType<FontData>); | 283 DeleteByType<FontData>); |
284 hb_font_make_immutable(harfbuzz_font); | 284 hb_font_make_immutable(harfbuzz_font); |
285 return harfbuzz_font; | 285 return harfbuzz_font; |
286 } | 286 } |
287 | 287 |
288 } // namespace gfx | 288 } // namespace gfx |
OLD | NEW |