OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include <hb-ot.h> | 8 #include <hb-ot.h> |
9 | 9 |
10 #include "SkShaper.h" | 10 #include "SkShaper.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 hb_shape(fImpl->fHarfBuzzFont.get(), buffer, nullptr, 0); | 98 hb_shape(fImpl->fHarfBuzzFont.get(), buffer, nullptr, 0); |
99 unsigned len = hb_buffer_get_length(buffer); | 99 unsigned len = hb_buffer_get_length(buffer); |
100 if (len == 0) { | 100 if (len == 0) { |
101 hb_buffer_clear_contents(buffer); | 101 hb_buffer_clear_contents(buffer); |
102 return 0; | 102 return 0; |
103 } | 103 } |
104 | 104 |
105 hb_glyph_info_t* info = hb_buffer_get_glyph_infos(buffer, NULL); | 105 hb_glyph_info_t* info = hb_buffer_get_glyph_infos(buffer, NULL); |
106 hb_glyph_position_t* pos = | 106 hb_glyph_position_t* pos = |
107 hb_buffer_get_glyph_positions(buffer, NULL); | 107 hb_buffer_get_glyph_positions(buffer, NULL); |
108 auto runBuffer = builder->allocRunPos(paint, len); | 108 auto runBuffer = builder->allocRunTextPos( |
| 109 paint, SkToInt(len), SkToInt(textBytes), SkString()); |
| 110 memcpy(runBuffer.utf8text, utf8text, textBytes); |
109 | 111 |
110 double x = point.x(); | 112 double x = point.x(); |
111 double y = point.y(); | 113 double y = point.y(); |
112 | 114 |
113 double textSizeY = paint.getTextSize() / (double)FONT_SIZE_SCALE; | 115 double textSizeY = paint.getTextSize() / (double)FONT_SIZE_SCALE; |
114 double textSizeX = textSizeY * paint.getTextScaleX(); | 116 double textSizeX = textSizeY * paint.getTextScaleX(); |
115 | 117 |
116 for (unsigned i = 0; i < len; i++) { | 118 for (unsigned i = 0; i < len; i++) { |
117 runBuffer.glyphs[i] = info[i].codepoint; | 119 runBuffer.glyphs[i] = info[i].codepoint; |
| 120 runBuffer.clusters[i] = info[i].cluster; |
118 reinterpret_cast<SkPoint*>(runBuffer.pos)[i] = | 121 reinterpret_cast<SkPoint*>(runBuffer.pos)[i] = |
119 SkPoint::Make(SkDoubleToScalar(x + pos[i].x_offset * textSizeX), | 122 SkPoint::Make(SkDoubleToScalar(x + pos[i].x_offset * textSizeX), |
120 SkDoubleToScalar(y - pos[i].y_offset * textSizeY))
; | 123 SkDoubleToScalar(y - pos[i].y_offset * textSizeY))
; |
121 x += pos[i].x_advance * textSizeX; | 124 x += pos[i].x_advance * textSizeX; |
122 y += pos[i].y_advance * textSizeY; | 125 y += pos[i].y_advance * textSizeY; |
123 } | 126 } |
| 127 |
124 hb_buffer_clear_contents(buffer); | 128 hb_buffer_clear_contents(buffer); |
125 return (SkScalar)x; | 129 return (SkScalar)x; |
126 } | 130 } |
OLD | NEW |