1/*
2 * Copyright (C) 2016 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include "config.h"
27
28#if !PLATFORM(WIN)
29
30#include <JavaScriptCore/InitializeThreading.h>
31#include <WebCore/ComplexTextController.h>
32#include <WebCore/FontCascade.h>
33#include <wtf/MainThread.h>
34#include <wtf/RunLoop.h>
35
36using namespace WebCore;
37
38namespace TestWebKitAPI {
39
40class ComplexTextControllerTest : public testing::Test {
41public:
42 virtual void SetUp()
43 {
44 JSC::initializeThreading();
45 RunLoop::initializeMainRunLoop();
46 }
47};
48
49TEST_F(ComplexTextControllerTest, InitialAdvanceWithLeftRunInRTL)
50{
51 FontCascadeDescription description;
52 description.setOneFamily("Times");
53 description.setComputedSize(80);
54 FontCascade font(WTFMove(description));
55 font.update();
56 auto spaceWidth = font.primaryFont().spaceWidth();
57
58 Vector<FloatSize> advances = { FloatSize(), FloatSize(21.640625, 0.0), FloatSize(42.3046875, 0.0), FloatSize(55.8984375, 0.0), FloatSize(22.34375, 0.0) };
59 Vector<FloatPoint> origins = { FloatPoint(-15.15625, 18.046875), FloatPoint(), FloatPoint(), FloatPoint(), FloatPoint() };
60
61 FloatSize initialAdvance = FloatSize(-15.15625, 18.046875);
62
63 UChar characters[] = { 0x644, 0x637, 0x641, 0x627, 0x64b, 0x20 };
64 size_t charactersLength = WTF_ARRAY_LENGTH(characters);
65 TextRun textRun(StringView(characters, charactersLength));
66 auto run1 = ComplexTextController::ComplexTextRun::create({ FloatSize(21.875, 0) }, { FloatPoint() }, { 5 }, { 5 }, FloatSize(), font.primaryFont(), characters, 0, charactersLength, 5, 6, false);
67 auto run2 = ComplexTextController::ComplexTextRun::create(advances, origins, { 193, 377, 447, 431, 458 }, { 4, 3, 2, 1, 0 }, initialAdvance, font.primaryFont(), characters, 0, charactersLength, 0, 5, false);
68 Vector<Ref<ComplexTextController::ComplexTextRun>> runs;
69 runs.append(WTFMove(run1));
70 runs.append(WTFMove(run2));
71 ComplexTextController controller(font, textRun, runs);
72
73 float totalWidth = 0;
74 for (size_t i = 1; i < advances.size(); ++i)
75 totalWidth += advances[i].width();
76 EXPECT_NEAR(controller.totalWidth(), spaceWidth + totalWidth, 0.0001);
77 GlyphBuffer glyphBuffer;
78 EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001);
79 controller.advance(0, &glyphBuffer);
80 EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001);
81 controller.advance(1, &glyphBuffer);
82 EXPECT_NEAR(controller.runWidthSoFar(), advances[4].width(), 0.0001);
83 controller.advance(6, &glyphBuffer);
84 EXPECT_NEAR(controller.runWidthSoFar(), spaceWidth + totalWidth, 0.0001);
85 EXPECT_NEAR(glyphBuffer.initialAdvance().width(), 0, 0.0001);
86 EXPECT_NEAR(glyphBuffer.initialAdvance().height(), 0, 0.0001);
87 EXPECT_EQ(glyphBuffer.size(), 6U);
88 EXPECT_NEAR(glyphBuffer.advanceAt(0).width(), advances[4].width(), 0.0001);
89 EXPECT_NEAR(glyphBuffer.advanceAt(1).width(), advances[3].width(), 0.0001);
90 EXPECT_NEAR(glyphBuffer.advanceAt(2).width(), advances[2].width(), 0.0001);
91 EXPECT_NEAR(glyphBuffer.advanceAt(3).width(), advances[1].width(), 0.0001);
92 EXPECT_NEAR(glyphBuffer.advanceAt(4).width(), -initialAdvance.width(), 0.0001);
93 EXPECT_NEAR(glyphBuffer.advanceAt(5).width(), spaceWidth + initialAdvance.width(), 0.0001);
94}
95
96TEST_F(ComplexTextControllerTest, InitialAdvanceInRTL)
97{
98 FontCascadeDescription description;
99 description.setOneFamily("Times");
100 description.setComputedSize(80);
101 FontCascade font(WTFMove(description));
102 font.update();
103
104 Vector<FloatSize> advances = { FloatSize(), FloatSize(21.640625, 0.0), FloatSize(42.3046875, 0.0), FloatSize(55.8984375, 0.0), FloatSize(22.34375, 0.0) };
105 Vector<FloatPoint> origins = { FloatPoint(-15.15625, 18.046875), FloatPoint(), FloatPoint(), FloatPoint(), FloatPoint() };
106
107 FloatSize initialAdvance = FloatSize(-15.15625, 18.046875);
108
109 UChar characters[] = { 0x644, 0x637, 0x641, 0x627, 0x64b };
110 size_t charactersLength = WTF_ARRAY_LENGTH(characters);
111 TextRun textRun(StringView(characters, charactersLength));
112 auto run = ComplexTextController::ComplexTextRun::create(advances, origins, { 193, 377, 447, 431, 458 }, { 4, 3, 2, 1, 0 }, initialAdvance, font.primaryFont(), characters, 0, charactersLength, 0, 5, false);
113 Vector<Ref<ComplexTextController::ComplexTextRun>> runs;
114 runs.append(WTFMove(run));
115 ComplexTextController controller(font, textRun, runs);
116
117 float totalWidth = 0;
118 for (size_t i = 1; i < advances.size(); ++i)
119 totalWidth += advances[i].width();
120 EXPECT_NEAR(controller.totalWidth(), totalWidth, 0.0001);
121 GlyphBuffer glyphBuffer;
122 EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001);
123 controller.advance(0, &glyphBuffer);
124 EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001);
125 controller.advance(1, &glyphBuffer);
126 EXPECT_NEAR(controller.runWidthSoFar(), advances[4].width(), 0.0001);
127 controller.advance(5, &glyphBuffer);
128 EXPECT_NEAR(controller.runWidthSoFar(), totalWidth, 0.0001);
129 EXPECT_NEAR(glyphBuffer.initialAdvance().width(), initialAdvance.width(), 0.0001);
130 EXPECT_NEAR(glyphBuffer.initialAdvance().height(), initialAdvance.height(), 0.0001);
131 EXPECT_EQ(glyphBuffer.size(), 5U);
132 EXPECT_NEAR(glyphBuffer.advanceAt(0).width(), advances[4].width(), 0.0001);
133 EXPECT_NEAR(glyphBuffer.advanceAt(1).width(), advances[3].width(), 0.0001);
134 EXPECT_NEAR(glyphBuffer.advanceAt(2).width(), advances[2].width(), 0.0001);
135 EXPECT_NEAR(glyphBuffer.advanceAt(3).width(), advances[1].width(), 0.0001);
136 EXPECT_NEAR(glyphBuffer.advanceAt(4).width(), -initialAdvance.width(), 0.0001);
137 EXPECT_NEAR(glyphBuffer.advanceAt(4).height(), initialAdvance.height(), 0.0001);
138}
139
140TEST_F(ComplexTextControllerTest, InitialAdvanceWithLeftRunInLTR)
141{
142 FontCascadeDescription description;
143 description.setOneFamily("LucidaGrande");
144 description.setComputedSize(80);
145 FontCascade font(WTFMove(description));
146 font.update();
147 auto spaceWidth = font.primaryFont().spaceWidth();
148
149 Vector<FloatSize> advances = { FloatSize(76.347656, 0.000000), FloatSize(0.000000, 0.000000) };
150 Vector<FloatPoint> origins = { FloatPoint(), FloatPoint(-23.281250, -8.398438) };
151
152 FloatSize initialAdvance = FloatSize(28.144531, 0);
153
154 UChar characters[] = { 0x20, 0x61, 0x20e3 };
155 size_t charactersLength = WTF_ARRAY_LENGTH(characters);
156 TextRun textRun(StringView(characters, charactersLength));
157 auto run1 = ComplexTextController::ComplexTextRun::create({ FloatSize(spaceWidth, 0) }, { FloatPoint() }, { 5 }, { 0 }, FloatSize(), font.primaryFont(), characters, 0, charactersLength, 0, 1, true);
158 auto run2 = ComplexTextController::ComplexTextRun::create(advances, origins, { 68, 1471 }, { 1, 2 }, initialAdvance, font.primaryFont(), characters, 0, charactersLength, 1, 3, true);
159 Vector<Ref<ComplexTextController::ComplexTextRun>> runs;
160 runs.append(WTFMove(run1));
161 runs.append(WTFMove(run2));
162 ComplexTextController controller(font, textRun, runs);
163
164 EXPECT_NEAR(controller.totalWidth(), spaceWidth + 76.347656 + initialAdvance.width(), 0.0001);
165 GlyphBuffer glyphBuffer;
166 EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001);
167 controller.advance(0, &glyphBuffer);
168 EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001);
169 controller.advance(1, &glyphBuffer);
170 EXPECT_NEAR(controller.runWidthSoFar(), spaceWidth, 0.0001);
171 controller.advance(2, &glyphBuffer);
172 EXPECT_NEAR(controller.runWidthSoFar(), spaceWidth + advances[0].width() + initialAdvance.width(), 0.0001);
173 controller.advance(3, &glyphBuffer);
174 EXPECT_NEAR(controller.runWidthSoFar(), spaceWidth + 76.347656 + initialAdvance.width(), 0.0001);
175 EXPECT_NEAR(glyphBuffer.initialAdvance().width(), 0, 0.0001);
176 EXPECT_NEAR(glyphBuffer.initialAdvance().height(), 0, 0.0001);
177 EXPECT_EQ(glyphBuffer.size(), 3U);
178 EXPECT_NEAR(glyphBuffer.advanceAt(0).width(), spaceWidth + initialAdvance.width(), 0.0001);
179 EXPECT_NEAR(glyphBuffer.advanceAt(1).width(), 53.066406, 0.0001);
180 EXPECT_NEAR(glyphBuffer.advanceAt(2).width(), 23.281250, 0.0001);
181}
182
183TEST_F(ComplexTextControllerTest, InitialAdvanceInLTR)
184{
185 FontCascadeDescription description;
186 description.setOneFamily("LucidaGrande");
187 description.setComputedSize(80);
188 FontCascade font(WTFMove(description));
189 font.update();
190
191 Vector<FloatSize> advances = { FloatSize(76.347656, 0.000000), FloatSize(0.000000, 0.000000) };
192 Vector<FloatPoint> origins = { FloatPoint(), FloatPoint(-23.281250, -8.398438) };
193
194 FloatSize initialAdvance = FloatSize(28.144531, 0);
195
196 UChar characters[] = { 0x61, 0x20e3 };
197 size_t charactersLength = WTF_ARRAY_LENGTH(characters);
198 TextRun textRun(StringView(characters, charactersLength));
199 auto run = ComplexTextController::ComplexTextRun::create(advances, origins, { 68, 1471 }, { 0, 1 }, initialAdvance, font.primaryFont(), characters, 0, charactersLength, 0, 2, true);
200 Vector<Ref<ComplexTextController::ComplexTextRun>> runs;
201 runs.append(WTFMove(run));
202 ComplexTextController controller(font, textRun, runs);
203
204 EXPECT_NEAR(controller.totalWidth(), 76.347656 + initialAdvance.width(), 0.0001);
205 GlyphBuffer glyphBuffer;
206 EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001);
207 controller.advance(0, &glyphBuffer);
208 EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001);
209 controller.advance(1, &glyphBuffer);
210 EXPECT_NEAR(controller.runWidthSoFar(), advances[0].width() + initialAdvance.width(), 0.0001);
211 controller.advance(2, &glyphBuffer);
212 EXPECT_NEAR(controller.runWidthSoFar(), 76.347656 + initialAdvance.width(), 0.0001);
213 EXPECT_NEAR(glyphBuffer.initialAdvance().width(), initialAdvance.width(), 0.0001);
214 EXPECT_NEAR(glyphBuffer.initialAdvance().height(), initialAdvance.height(), 0.0001);
215 EXPECT_EQ(glyphBuffer.size(), 2U);
216 EXPECT_NEAR(glyphBuffer.advanceAt(0).width(), 53.066406, 0.0001);
217 EXPECT_NEAR(glyphBuffer.advanceAt(1).width(), 23.281250, 0.0001);
218}
219
220TEST_F(ComplexTextControllerTest, InitialAdvanceInRTLNoOrigins)
221{
222 FontCascadeDescription description;
223 description.setOneFamily("Times");
224 description.setComputedSize(48);
225 FontCascade font(WTFMove(description));
226 font.update();
227
228 FloatSize initialAdvance = FloatSize(4.33996383363472, 12.368896925859);
229
230 UChar characters[] = { 0x633, 0x20, 0x627, 0x650 };
231 size_t charactersLength = WTF_ARRAY_LENGTH(characters);
232 TextRun textRun(StringView(characters, charactersLength));
233 auto run1 = ComplexTextController::ComplexTextRun::create({ FloatSize(-4.33996383363472, -12.368896925859), FloatSize(14.0397830018083, 0) }, { }, { 884, 240 }, { 3, 2 }, initialAdvance, font.primaryFont(), characters, 0, charactersLength, 2, 4, false);
234 auto run2 = ComplexTextController::ComplexTextRun::create({ FloatSize(12.0, 0) }, { }, { 3 }, { 1 }, FloatSize(), font.primaryFont(), characters, 0, charactersLength, 1, 2, false);
235 auto run3 = ComplexTextController::ComplexTextRun::create({ FloatSize(43.8119349005425, 0) }, { }, { 276 }, { 0 }, FloatSize(), font.primaryFont(), characters, 0, charactersLength, 0, 1, false);
236 Vector<Ref<ComplexTextController::ComplexTextRun>> runs;
237 runs.append(WTFMove(run1));
238 runs.append(WTFMove(run2));
239 runs.append(WTFMove(run3));
240 ComplexTextController controller(font, textRun, runs);
241
242 float totalWidth = 14.0397830018083 + 12.0 + 43.8119349005425;
243 EXPECT_NEAR(controller.totalWidth(), totalWidth, 0.0001);
244 GlyphBuffer glyphBuffer;
245 EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001);
246 controller.advance(0, &glyphBuffer);
247 EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001);
248 controller.advance(1, &glyphBuffer);
249 EXPECT_NEAR(controller.runWidthSoFar(), 43.8119349005425, 0.0001);
250 controller.advance(2, &glyphBuffer);
251 EXPECT_NEAR(controller.runWidthSoFar(), 43.8119349005425 + 12.0, 0.0001);
252 controller.advance(3, &glyphBuffer);
253 EXPECT_NEAR(controller.runWidthSoFar(), totalWidth, 0.0001);
254 controller.advance(4, &glyphBuffer);
255 EXPECT_NEAR(controller.runWidthSoFar(), totalWidth, 0.0001);
256 EXPECT_NEAR(glyphBuffer.initialAdvance().width(), initialAdvance.width(), 0.0001);
257 EXPECT_NEAR(glyphBuffer.initialAdvance().height(), initialAdvance.height(), 0.0001);
258 EXPECT_EQ(glyphBuffer.size(), 4U);
259 EXPECT_NEAR(glyphBuffer.advanceAt(0).width(), 43.8119349005425, 0.0001);
260 EXPECT_NEAR(glyphBuffer.advanceAt(1).width(), 12.0, 0.0001);
261 EXPECT_NEAR(glyphBuffer.advanceAt(2).width(), 14.0397830018083, 0.0001);
262 EXPECT_NEAR(glyphBuffer.advanceAt(3).width(), -4.33996383363472, 0.0001);
263 EXPECT_NEAR(glyphBuffer.advanceAt(3).height(), 12.368896925859, 0.0001);
264}
265
266TEST_F(ComplexTextControllerTest, LeadingExpansion)
267{
268 FontCascadeDescription description;
269 description.setOneFamily("Times");
270 description.setComputedSize(48);
271 FontCascade font(WTFMove(description));
272 font.update();
273
274 UChar characters[] = { 'a' };
275 size_t charactersLength = WTF_ARRAY_LENGTH(characters);
276 TextRun textRun(StringView(characters, charactersLength), 0, 100, ForceLeadingExpansion);
277 auto run = ComplexTextController::ComplexTextRun::create({ FloatSize(24, 0) }, { }, { 16 }, { 0 }, FloatSize(), font.primaryFont(), characters, 0, charactersLength, 0, 1, true);
278 Vector<Ref<ComplexTextController::ComplexTextRun>> runs;
279 runs.append(WTFMove(run));
280 ComplexTextController controller(font, textRun, runs);
281
282 float totalWidth = 100 + 24;
283 EXPECT_NEAR(controller.totalWidth(), totalWidth, 0.0001);
284 GlyphBuffer glyphBuffer;
285 EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001);
286 controller.advance(0, &glyphBuffer);
287 EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001);
288 controller.advance(1, &glyphBuffer);
289 EXPECT_NEAR(controller.runWidthSoFar(), totalWidth, 0.0001);
290 EXPECT_NEAR(glyphBuffer.initialAdvance().width(), 100, 0.0001);
291 EXPECT_NEAR(glyphBuffer.initialAdvance().height(), 0, 0.0001);
292 EXPECT_EQ(glyphBuffer.size(), 1U);
293 EXPECT_NEAR(glyphBuffer.advanceAt(0).width(), 24, 0.0001);
294}
295
296TEST_F(ComplexTextControllerTest, VerticalAdvances)
297{
298 FontCascadeDescription description;
299 description.setOneFamily("Times");
300 description.setComputedSize(48);
301 FontCascade font(WTFMove(description));
302 font.update();
303
304 UChar characters[] = { 'a', 'b', 'c', 'd' };
305 size_t charactersLength = WTF_ARRAY_LENGTH(characters);
306 TextRun textRun(StringView(characters, charactersLength));
307 auto run1 = ComplexTextController::ComplexTextRun::create({ FloatSize(0, 1), FloatSize(0, 2) }, { FloatPoint(0, 4), FloatPoint(0, 8) }, { 16, 17 }, { 0, 1 }, FloatSize(0, 16), font.primaryFont(), characters, 0, charactersLength, 0, 2, true);
308 auto run2 = ComplexTextController::ComplexTextRun::create({ FloatSize(0, 32), FloatSize(0, 64) }, { FloatPoint(0, 128), FloatPoint(0, 256) }, { 18, 19 }, { 2, 3 }, FloatSize(0, 512), font.primaryFont(), characters, 0, charactersLength, 2, 4, true);
309 Vector<Ref<ComplexTextController::ComplexTextRun>> runs;
310 runs.append(WTFMove(run1));
311 runs.append(WTFMove(run2));
312 ComplexTextController controller(font, textRun, runs);
313
314 EXPECT_NEAR(controller.totalWidth(), 0, 0.0001);
315 GlyphBuffer glyphBuffer;
316 EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001);
317 controller.advance(0, &glyphBuffer);
318 EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001);
319 controller.advance(1, &glyphBuffer);
320 EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001);
321 controller.advance(2, &glyphBuffer);
322 EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001);
323 controller.advance(3, &glyphBuffer);
324 EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001);
325 controller.advance(4, &glyphBuffer);
326 EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001);
327 EXPECT_NEAR(glyphBuffer.initialAdvance().width(), 0, 0.0001);
328 EXPECT_NEAR(glyphBuffer.initialAdvance().height(), 16, 0.0001);
329 EXPECT_EQ(glyphBuffer.size(), 4U);
330 EXPECT_NEAR(glyphBuffer.advanceAt(0).width(), 0, 0.0001);
331 EXPECT_NEAR(glyphBuffer.advanceAt(0).height(), 4 - 1 -8, 0.0001);
332 EXPECT_NEAR(glyphBuffer.advanceAt(1).width(), 0, 0.0001);
333 EXPECT_NEAR(glyphBuffer.advanceAt(1).height(), 8 - 2 - 512, 0.0001);
334 EXPECT_NEAR(glyphBuffer.advanceAt(2).width(), 0, 0.0001);
335 EXPECT_NEAR(glyphBuffer.advanceAt(2).height(), 128 - 32 - 256, 0.0001);
336 EXPECT_NEAR(glyphBuffer.advanceAt(3).width(), 0, 0.0001);
337 EXPECT_NEAR(glyphBuffer.advanceAt(3).height(), 256 - 64, 0.0001);
338}
339
340TEST_F(ComplexTextControllerTest, TotalWidthWithJustification)
341{
342 FontCascadeDescription description;
343 description.setOneFamily("Times");
344 description.setComputedSize(80);
345 FontCascade font(WTFMove(description));
346 font.update();
347
348 Vector<FloatSize> advances = { FloatSize(1, 0), FloatSize(2, 0), FloatSize(4, 0), FloatSize(8, 0), FloatSize(16, 0) };
349 Vector<FloatPoint> origins = { FloatPoint(), FloatPoint(), FloatPoint(), FloatPoint(), FloatPoint() };
350
351 FloatSize initialAdvance = FloatSize();
352
353 UChar characters[] = { 0x644, ' ', 0x644, ' ', 0x644 };
354 size_t charactersLength = WTF_ARRAY_LENGTH(characters);
355 TextRun textRun(StringView(characters, charactersLength), 0, 14, DefaultExpansion, TextDirection::RTL);
356 auto run = ComplexTextController::ComplexTextRun::create(advances, origins, { 5, 6, 7, 8, 9 }, { 4, 3, 2, 1, 0 }, initialAdvance, font.primaryFont(), characters, 0, charactersLength, 0, 5, false);
357 Vector<Ref<ComplexTextController::ComplexTextRun>> runs;
358 runs.append(WTFMove(run));
359 ComplexTextController controller(font, textRun, runs);
360
361 EXPECT_NEAR(controller.totalWidth(), 1 + 20 + 7 + 4 + 20 + 7 + 16, 0.0001);
362 GlyphBuffer glyphBuffer;
363 EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001);
364 controller.advance(5, &glyphBuffer);
365 EXPECT_EQ(glyphBuffer.size(), 5U);
366 EXPECT_NEAR(glyphBuffer.advanceAt(0).width() + glyphBuffer.advanceAt(1).width() + glyphBuffer.advanceAt(2).width() + glyphBuffer.advanceAt(3).width() + glyphBuffer.advanceAt(4).width(), controller.totalWidth(), 0.0001);
367}
368
369}
370
371#endif
372