@@ -29,8 +29,10 @@ SOFTWARE.
29
29
#include < LLUtils/Exception.h>
30
30
#include " xxh3.h"
31
31
32
- std::filesystem::path folderToSaveFiles = " d:/testImages/" ;
33
- bool shouldSaveToFile = false ;
32
+ std::filesystem::path folderToSaveFiles = " ./testImages/" ;
33
+ std::filesystem::path fontPathSegoeib = L" /media/lior/System/Windows/Fonts/segoeuib.ttf" ;
34
+ std::filesystem::path fontPathConsola = L" /media/lior/System/Windows/Fonts/consola.ttf" ;
35
+ bool shouldSaveToFile = true ;
34
36
35
37
void SaveToFile (const FreeType::FreeTypeConnector::Bitmap& textBitmap, const std::wstring& filePath)
36
38
{
@@ -69,7 +71,7 @@ void runTest(FreeType::TextCreateParams freetypeParams, TestParams testParams)
69
71
SaveToFile (textBitmap, testParams.fileName );
70
72
71
73
if (hash != testParams.expectedHash )
72
- throw std::exception (" test failed" );
74
+ throw std::runtime_error (" test failed" );
73
75
74
76
}
75
77
@@ -84,15 +86,15 @@ int runtests()
84
86
85
87
params.DPIx = 120 ;
86
88
params.DPIy = 120 ;
87
- params.fontPath = L" C:/Windows/Fonts/segoeuib.ttf " ;
89
+ params.fontPath = fontPathSegoeib. wstring () ;
88
90
params.text = L" ijkjojujrjaj" ;
89
91
params.textColor = LLUtils::Colors::Black;
90
92
params.backgroundColor = LLUtils::Colors::White;
91
93
params.fontSize = 44 ;
92
94
params.renderMode = FreeType::RenderMode::Antialiased;
93
95
params.outlineWidth = 0 ;
94
96
95
- testParams.fileName = folderToSaveFiles / " test10.bmp" ;
97
+ testParams.fileName = ( folderToSaveFiles / " test10.bmp" ). wstring () ;
96
98
testParams.expectedHash = 7683707409401849002 ;
97
99
98
100
runTest (params, testParams);
@@ -103,7 +105,7 @@ int runtests()
103
105
104
106
params.DPIx = 120 ;
105
107
params.DPIy = 120 ;
106
- params.fontPath = L" C:/Windows/Fonts/segoeui.ttf " ;
108
+ params.fontPath = fontPathSegoeib. wstring () ;
107
109
params.text = L" <textcolor=#000000ff>|This| is זה משהו\n באמת משהו\n abcdefghijklmnopqrstuvwwxyz\n ABCDEFGHIJKLMNOPQVWXYZ\n |!#_+" ;
108
110
109
111
params.backgroundColor = LLUtils::Colors::White;
@@ -114,8 +116,8 @@ int runtests()
114
116
params.flags = FreeType::TextCreateFlags::UseMetaText |
115
117
FreeType::TextCreateFlags::Bidirectional;
116
118
117
- testParams.fileName = folderToSaveFiles / " test.bmp" ;
118
- testParams.expectedHash = 16738229490926515141 ;
119
+ testParams.fileName = ( folderToSaveFiles / " test.bmp" ). wstring () ;
120
+ testParams.expectedHash = 16738229490926515141u ;
119
121
120
122
runTest (params, testParams);
121
123
@@ -125,7 +127,7 @@ int runtests()
125
127
126
128
params.DPIx = 120 ;
127
129
params.DPIy = 120 ;
128
- params.fontPath = L" C:/Windows/Fonts/segoeuib.ttf " ;
130
+ params.fontPath = fontPathSegoeib. wstring () ;
129
131
params.text = L" <textcolor=#00ff00ff>|This| is זה משהו\n באמת משהו\n abcdefghijklmnopqrstuvwwxyz\n ABCDEFGHIJKLMNOPQVWXYZ\n |!#_+" ;
130
132
131
133
params.text = L" <textcolor=#4a80e2>Welcome to <textcolor=#dd0f1d>OIV\n " \
@@ -141,8 +143,8 @@ int runtests()
141
143
params.flags = FreeType::TextCreateFlags::UseMetaText |
142
144
FreeType::TextCreateFlags::Bidirectional;
143
145
144
- testParams.fileName = folderToSaveFiles / " test1.bmp" ;
145
- testParams.expectedHash = 16558562707942498804 ;
146
+ testParams.fileName = ( folderToSaveFiles / " test1.bmp" ). wstring () ;
147
+ testParams.expectedHash = 16558562707942498804u ;
146
148
147
149
runTest (params, testParams);
148
150
@@ -152,55 +154,55 @@ int runtests()
152
154
153
155
// params.text = L"3000 X 1712 X 32 BPP | loaded in 92.7 ms";
154
156
params.text = L" Texel: 1218.3 X 584.6" ;
155
- params.fontPath = L" C:/Windows/Fonts/consola.ttf " ;
157
+ params.fontPath = fontPathConsola. wstring () ;
156
158
params.renderMode = FreeType::RenderMode::SubpixelAntiAliased;
157
159
params.fontSize = 11 ;
158
160
params.backgroundColor = { 255 , 255 , 255 , 192 };
159
161
params.DPIx = 120 ;
160
162
params.DPIy = 120 ;
161
163
// params.padding = 1;
162
- testParams.fileName = folderToSaveFiles / " test2.bmp" ;
163
- testParams.expectedHash = 11320992707252375232 ;
164
+ testParams.fileName = ( folderToSaveFiles / " test2.bmp" ). wstring () ;
165
+ testParams.expectedHash = 11320992707252375232u ;
164
166
runTest (params, testParams);
165
167
166
168
167
169
168
170
169
171
params.text = L" <textcolor=#ff8930>windowed" ;
170
- params.fontPath = L" C:/Windows/Fonts/segoeuib.ttf " ;
172
+ params.fontPath = fontPathSegoeib. wstring () ;
171
173
params.renderMode = FreeType::RenderMode::SubpixelAntiAliased;
172
174
params.fontSize = 11 ;
173
175
params.backgroundColor = { 255 , 255 , 255 , 192 };
174
176
params.DPIx = 120 ;
175
177
params.DPIy = 120 ;
176
178
params.padding = 0 ;
177
179
178
- testParams.fileName = folderToSaveFiles / " test3.bmp" ;
179
- testParams.expectedHash = 9753445643566658639 ;
180
+ testParams.fileName = ( folderToSaveFiles / " test3.bmp" ). wstring () ;
181
+ testParams.expectedHash = 9753445643566658639u ;
180
182
runTest (params, testParams);
181
183
182
184
183
185
184
186
// Test Fixed width font
185
187
186
188
params.text = L" <textcolor=#ff8930>444" ;
187
- params.fontPath = L" C:/Windows/Fonts/consola.ttf " ;
189
+ params.fontPath = fontPathConsola. wstring () ;
188
190
params.renderMode = FreeType::RenderMode::Antialiased;
189
191
params.fontSize = 11 ;
190
192
params.backgroundColor = { 255 , 255 , 255 , 192 };
191
193
params.DPIx = 120 ;
192
194
params.DPIy = 120 ;
193
195
params.padding = 0 ;
194
196
195
- testParams.fileName = folderToSaveFiles / " test4_1.bmp" ;
196
- testParams.expectedHash = 11631623323771771341 ;
197
+ testParams.fileName = ( folderToSaveFiles / " test4_1.bmp" ). wstring () ;
198
+ testParams.expectedHash = 11631623323771771341u ;
197
199
runTest (params, testParams);
198
200
199
201
200
202
params.text = L" <textcolor=#ff8930>555" ;
201
203
202
- testParams.fileName = folderToSaveFiles / " test4_2.bmp" ;
203
- testParams.expectedHash = 17162733075979477580 ;
204
+ testParams.fileName = ( folderToSaveFiles / " test4_2.bmp" ). wstring () ;
205
+ testParams.expectedHash = 17162733075979477580u ;
204
206
runTest (params, testParams);
205
207
206
208
@@ -211,7 +213,7 @@ int runtests()
211
213
212
214
// test very thick outline
213
215
params.text = L" <textcolor=#ff8930>windowed" ;
214
- params.fontPath = L" C:/Windows/Fonts/segoeuib.ttf " ;
216
+ params.fontPath = fontPathSegoeib. wstring () ;
215
217
params.renderMode = FreeType::RenderMode::Antialiased;
216
218
params.fontSize = 11 ;
217
219
params.backgroundColor = { 255 , 255 , 255 , 192 };
@@ -220,14 +222,13 @@ int runtests()
220
222
params.padding = 0 ;
221
223
params.outlineWidth = 20 ;
222
224
223
- testParams.fileName = folderToSaveFiles / " test5.bmp" ;
224
- testParams.expectedHash = 4822496049661565882 ;
225
+ testParams.fileName = ( folderToSaveFiles / " test5.bmp" ). wstring () ;
226
+ testParams.expectedHash = 4822496049661565882u ;
225
227
runTest (params, testParams);
226
228
227
-
228
229
// Lower dpi mode
229
230
params.text = L" abcdefg.tif" ;
230
- params.fontPath = L" C:/Windows/Fonts/segoeuib.ttf " ;
231
+ params.fontPath = fontPathSegoeib. wstring () ;
231
232
params.renderMode = FreeType::RenderMode::Antialiased;
232
233
params.fontSize = 12 ;
233
234
params.backgroundColor = { 255 , 255 , 255 , 192 };
@@ -236,8 +237,8 @@ int runtests()
236
237
params.padding = 0 ;
237
238
params.outlineWidth = 2 ;
238
239
239
- testParams.fileName = folderToSaveFiles / " test6.bmp" ;
240
- testParams.expectedHash = 3439216908320477038 ;
240
+ testParams.fileName = ( folderToSaveFiles / L " test6.bmp" ). wstring () ;
241
+ testParams.expectedHash = 3439216908320477038u ;
241
242
runTest (params, testParams);
242
243
243
244
return 0 ;
0 commit comments