@@ -31,13 +31,11 @@ SOFTWARE.
31
31
32
32
std::filesystem::path folderToSaveFiles = " ./testImages/" ;
33
33
#if LLUTILS_PLATFORM == LLUTILS_PLATFORM_WIN32
34
- std::filesystem::path fontPathSegoei = L" c:/Windows/Fonts/segoeui.ttf" ;
35
- std::filesystem::path fontPathSegoeib = L" c:/Windows/Fonts/segoeuib.ttf" ;
36
- std::filesystem::path fontPathConsola = L" c:/Windows/Fonts/consola.ttf" ;
34
+ std::filesystem::path fontPathSegoei = L" c:/Windows/Fonts/segoeui.ttf" ;
35
+ std::filesystem::path fontPathSegoeib = L" c:/Windows/Fonts/segoeuib.ttf" ;
36
+ std::filesystem::path fontPathFixed = L" c:/Windows/Fonts/consola.ttf" ;
37
37
#elif LLUTILS_PLATFORM == LLUTILS_PLATFORM_LINUX
38
- std::filesystem::path fontPathSegoei = L" c:/Windows/Fonts/segoeui.ttf" ;
39
- std::filesystem::path fontPathSegoeib = L" c:/Windows/Fonts/segoeuib.ttf" ;
40
- std::filesystem::path fontPathConsola = L" c:/Windows/Fonts/consola.ttf" ;
38
+ std::filesystem::path fontPathFixed = L" ./CascadiaCode.ttf" ;
41
39
#else
42
40
#pragma error "Non-compatible platform detected."
43
41
#endif
@@ -78,7 +76,7 @@ void runTest(FreeType::FreeTypeConnector& freeType, FreeType::TextCreateParams f
78
76
FreeTypeConnector::Bitmap textBitmap;
79
77
freeType.CreateBitmap (freetypeParams, textBitmap, nullptr );
80
78
81
- auto hash = XXH3_64bits (static_cast <const void *>(textBitmap.buffer .data ()), textBitmap.height * textBitmap.rowPitch );
79
+ [[maybe_unused]] auto hash = XXH3_64bits (static_cast <const void *>(textBitmap.buffer .data ()), textBitmap.height * textBitmap.rowPitch );
82
80
83
81
if (testParams.saveToFile )
84
82
SaveToFile (textBitmap, testParams.fileName );
@@ -97,10 +95,12 @@ int runtests()
97
95
TestParams testParams{};
98
96
testParams.saveToFile = shouldSaveToFile;
99
97
// Several test cases, for now mostly checks for out of bounds errors, if there's no exceptions test is considered passed.
100
-
101
98
params.DPIx = 120 ;
102
99
params.DPIy = 120 ;
103
- params.fontPath = fontPathSegoeib.wstring ();
100
+
101
+ #if LLUTILS_PLATFORM == LLUTILS_PLATFORM_WIN32
102
+ params.fontPath = fontPathSegoeib.wstring ();
103
+
104
104
params.text = L" ijkjojujrjaj" ;
105
105
params.textColor = LLUtils::Colors::Black;
106
106
params.outlineColor = { 0 ,0 ,0 ,255 };
@@ -121,6 +121,8 @@ int runtests()
121
121
params.DPIx = 120 ;
122
122
params.DPIy = 120 ;
123
123
params.fontPath = fontPathSegoei.wstring ();
124
+
125
+
124
126
params.text = L" <textcolor=#000000ff>|This| is זה משהו\n באמת משהו\n abcdefghijklmnopqrstuvwwxyz\n ABCDEFGHIJKLMNOPQVWXYZ\n |!#_+" ;
125
127
126
128
params.backgroundColor = LLUtils::Colors::White;
@@ -136,8 +138,6 @@ int runtests()
136
138
137
139
runTest (freeType, params, testParams);
138
140
139
-
140
-
141
141
// Several test cases, for now mostly checks for out of bounds errors, if there's no exceptions test is considered passed.
142
142
143
143
params.DPIx = 120 ;
@@ -164,45 +164,56 @@ int runtests()
164
164
runTest (freeType, params, testParams);
165
165
166
166
167
-
168
-
169
-
170
- // params.text = L"3000 X 1712 X 32 BPP | loaded in 92.7 ms";
171
- params.text = L" Texel: 1218.3 X 584.6" ;
172
- params.textColor = Colors::Lava;
173
- params.fontPath = fontPathConsola.wstring ();
167
+ params.text = L" <textcolor=#ff8930>windowed" ;
168
+ params.fontPath = fontPathSegoeib.wstring ();
174
169
params.renderMode = FreeType::RenderMode::SubpixelAntiAliased;
175
170
params.fontSize = 11 ;
176
171
params.backgroundColor = { 255 , 255 , 255 , 192 };
177
172
params.DPIx = 120 ;
178
173
params.DPIy = 120 ;
179
- // params.padding = 1;
180
- testParams.fileName = (folderToSaveFiles / " test2.bmp" ).wstring ();
181
- testParams.expectedHash = 11320992707252375232u ;
174
+ params.padding = 0 ;
175
+
176
+ testParams.fileName = (folderToSaveFiles / " test3.bmp" ).wstring ();
177
+ testParams.expectedHash = 9753445643566658639u ;
182
178
runTest (freeType, params, testParams);
183
179
184
180
181
+ // Lower dpi mode
182
+ params.text = L" abcdefg.tif" ;
183
+ params.fontPath = fontPathSegoeib.wstring ();
184
+ params.renderMode = FreeType::RenderMode::Antialiased;
185
+ params.fontSize = 12 ;
186
+ params.backgroundColor = { 255 , 255 , 255 , 192 };
187
+ params.DPIx = 96 ;
188
+ params.DPIy = 96 ;
189
+ params.padding = 0 ;
190
+ params.outlineWidth = 2 ;
191
+
192
+ testParams.fileName = (folderToSaveFiles / L" test6.bmp" ).wstring ();
193
+ testParams.expectedHash = 3439216908320477038u ;
194
+ runTest (freeType, params, testParams);
185
195
186
196
197
+ // Test very thick outline
187
198
params.text = L" <textcolor=#ff8930>windowed" ;
188
199
params.fontPath = fontPathSegoeib.wstring ();
189
- params.renderMode = FreeType::RenderMode::SubpixelAntiAliased ;
200
+ params.renderMode = FreeType::RenderMode::Antialiased ;
190
201
params.fontSize = 11 ;
191
202
params.backgroundColor = { 255 , 255 , 255 , 192 };
192
203
params.DPIx = 120 ;
193
204
params.DPIy = 120 ;
194
205
params.padding = 0 ;
206
+ params.outlineWidth = 20 ;
195
207
196
- testParams.fileName = (folderToSaveFiles / " test3 .bmp" ).wstring ();
197
- testParams.expectedHash = 9753445643566658639u ;
208
+ testParams.fileName = (folderToSaveFiles / " test5 .bmp" ).wstring ();
209
+ testParams.expectedHash = 4822496049661565882u ;
198
210
runTest (freeType, params, testParams);
199
211
200
-
212
+ # endif
201
213
202
214
// Test Fixed width font
203
-
204
215
params.text = L" <textcolor=#ff8930>444" ;
205
- params.fontPath = fontPathConsola .wstring ();
216
+ params.fontPath = fontPathFixed .wstring ();
206
217
params.renderMode = FreeType::RenderMode::Antialiased;
207
218
params.fontSize = 11 ;
208
219
params.backgroundColor = { 255 , 255 , 255 , 192 };
@@ -227,40 +238,14 @@ int runtests()
227
238
LL_EXCEPTION(LLUtils::Exception::ErrorCode::InvalidState, "mismatch size");*/
228
239
229
240
230
- // test very thick outline
231
- params.text = L" <textcolor=#ff8930>windowed" ;
232
- params.fontPath = fontPathSegoeib.wstring ();
233
- params.renderMode = FreeType::RenderMode::Antialiased;
234
- params.fontSize = 11 ;
235
- params.backgroundColor = { 255 , 255 , 255 , 192 };
236
- params.DPIx = 120 ;
237
- params.DPIy = 120 ;
238
- params.padding = 0 ;
239
- params.outlineWidth = 20 ;
240
241
241
- testParams.fileName = (folderToSaveFiles / " test5.bmp" ).wstring ();
242
- testParams.expectedHash = 4822496049661565882u ;
243
- runTest (freeType, params, testParams);
244
242
245
- // Lower dpi mode
246
- params.text = L" abcdefg.tif" ;
247
- params.fontPath = fontPathSegoeib.wstring ();
248
- params.renderMode = FreeType::RenderMode::Antialiased;
249
- params.fontSize = 12 ;
250
- params.backgroundColor = { 255 , 255 , 255 , 192 };
251
- params.DPIx = 96 ;
252
- params.DPIy = 96 ;
253
- params.padding = 0 ;
254
- params.outlineWidth = 2 ;
255
243
256
- testParams.fileName = (folderToSaveFiles / L" test6.bmp" ).wstring ();
257
- testParams.expectedHash = 3439216908320477038u ;
258
- runTest (freeType, params, testParams);
259
244
260
245
261
246
// Test aliased text
262
247
params.text = L" <textcolor=#ff8930>aliased text" ;
263
- params.fontPath = fontPathConsola .wstring ();
248
+ params.fontPath = fontPathFixed .wstring ();
264
249
params.outlineColor = { 0 , 0 , 0 , 255 };
265
250
params.outlineWidth = 0 ;
266
251
params.renderMode = FreeType::RenderMode::Aliased;
@@ -274,6 +259,20 @@ int runtests()
274
259
testParams.expectedHash = 11631623323771771341u ;
275
260
runTest (freeType, params, testParams);
276
261
262
+ // params.text = L"3000 X 1712 X 32 BPP | loaded in 92.7 ms";
263
+ params.text = L" Texel: 1218.3 X 584.6" ;
264
+ params.textColor = Colors::Lava;
265
+ params.fontPath = fontPathFixed.wstring ();
266
+ params.renderMode = FreeType::RenderMode::SubpixelAntiAliased;
267
+ params.fontSize = 11 ;
268
+ params.backgroundColor = { 255 , 255 , 255 , 192 };
269
+ params.DPIx = 120 ;
270
+ params.DPIy = 120 ;
271
+ // params.padding = 1;
272
+ testParams.fileName = (folderToSaveFiles / " test2.bmp" ).wstring ();
273
+ testParams.expectedHash = 11320992707252375232u ;
274
+ runTest (freeType, params, testParams);
275
+
277
276
278
277
return 0 ;
279
278
}
@@ -283,11 +282,8 @@ int main()
283
282
284
283
try
285
284
{
286
- #if LLUTILS_PLATFORM == LLUTILS_PLATFORM_WIN32
287
-
288
285
if (runtests () == 0 )
289
286
std::cout << " All tests passed successfully." ;
290
- #endif
291
287
292
288
}
293
289
catch (...)
0 commit comments