OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 bool is_vertical_text = !style.IsHorizontalWritingMode(); | 201 bool is_vertical_text = !style.IsHorizontalWritingMode(); |
202 | 202 |
203 // Calculate absolute length of whole text chunk (starting from text box | 203 // Calculate absolute length of whole text chunk (starting from text box |
204 // 'start', spanning 'length' text boxes). | 204 // 'start', spanning 'length' text boxes). |
205 ChunkLengthAccumulator length_accumulator(is_vertical_text); | 205 ChunkLengthAccumulator length_accumulator(is_vertical_text); |
206 length_accumulator.ProcessRange(box_start, box_end); | 206 length_accumulator.ProcessRange(box_start, box_end); |
207 | 207 |
208 if (process_text_length) { | 208 if (process_text_length) { |
209 float chunk_length = length_accumulator.length(); | 209 float chunk_length = length_accumulator.length(); |
210 if (length_adjust == kSVGLengthAdjustSpacing) { | 210 if (length_adjust == kSVGLengthAdjustSpacing) { |
211 float text_length_shift = (desired_text_length - chunk_length) / | 211 float text_length_shift = 0; |
212 length_accumulator.NumCharacters(); | 212 if (length_accumulator.NumCharacters() > 1) { |
fs
2017/05/10 16:06:10
When I had finished this I remembered/noticed that
| |
213 text_length_shift = desired_text_length - chunk_length; | |
214 text_length_shift /= length_accumulator.NumCharacters() - 1; | |
215 } | |
213 unsigned at_character = 0; | 216 unsigned at_character = 0; |
214 for (auto box_iter = box_start; box_iter != box_end; ++box_iter) { | 217 for (auto box_iter = box_start; box_iter != box_end; ++box_iter) { |
215 Vector<SVGTextFragment>& fragments = (*box_iter)->TextFragments(); | 218 Vector<SVGTextFragment>& fragments = (*box_iter)->TextFragments(); |
216 if (fragments.IsEmpty()) | 219 if (fragments.IsEmpty()) |
217 continue; | 220 continue; |
218 ProcessTextLengthSpacingCorrection(is_vertical_text, text_length_shift, | 221 ProcessTextLengthSpacingCorrection(is_vertical_text, text_length_shift, |
219 fragments, at_character); | 222 fragments, at_character); |
220 } | 223 } |
221 | 224 |
222 // Fragments have been adjusted, we have to recalculate the chunk | 225 // Fragments have been adjusted, we have to recalculate the chunk |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
294 Vector<SVGTextFragment>& fragments) { | 297 Vector<SVGTextFragment>& fragments) { |
295 for (SVGTextFragment& fragment : fragments) { | 298 for (SVGTextFragment& fragment : fragments) { |
296 if (is_vertical_text) | 299 if (is_vertical_text) |
297 fragment.y += text_anchor_shift; | 300 fragment.y += text_anchor_shift; |
298 else | 301 else |
299 fragment.x += text_anchor_shift; | 302 fragment.x += text_anchor_shift; |
300 } | 303 } |
301 } | 304 } |
302 | 305 |
303 } // namespace blink | 306 } // namespace blink |
OLD | NEW |