Skip to content

Commit 92c0746

Browse files
committed
Fixed: Linux compilation
1 parent 96c0bb5 commit 92c0746

File tree

2 files changed

+31
-30
lines changed

2 files changed

+31
-30
lines changed

FreeTypeWrapper/Source/FreeTypeConnector.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ namespace FreeType
366366
if (out_glyphMapping != nullptr)
367367
{
368368
out_glyphMapping->push_back(LLUtils::RectI32{ { penX, penY } ,
369-
{penX + advance, penY + static_cast<int32_t>(rowHeight)} });
369+
{penX + static_cast<int32_t>(advance), penY + static_cast<int32_t>(rowHeight)} });
370370
}
371371

372372
penX += slot->advance.x >> 6;

Test/Test.cpp

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ SOFTWARE.
2929
#include <LLUtils/Exception.h>
3030
#include "xxh3.h"
3131

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;
3436

3537
void SaveToFile(const FreeType::FreeTypeConnector::Bitmap& textBitmap, const std::wstring& filePath)
3638
{
@@ -69,7 +71,7 @@ void runTest(FreeType::TextCreateParams freetypeParams, TestParams testParams)
6971
SaveToFile(textBitmap, testParams.fileName);
7072

7173
if (hash != testParams.expectedHash)
72-
throw std::exception("test failed");
74+
throw std::runtime_error("test failed");
7375

7476
}
7577

@@ -84,15 +86,15 @@ int runtests()
8486

8587
params.DPIx = 120;
8688
params.DPIy = 120;
87-
params.fontPath = L"C:/Windows/Fonts/segoeuib.ttf";
89+
params.fontPath = fontPathSegoeib.wstring();
8890
params.text = L"ijkjojujrjaj";
8991
params.textColor = LLUtils::Colors::Black;
9092
params.backgroundColor = LLUtils::Colors::White;
9193
params.fontSize = 44;
9294
params.renderMode = FreeType::RenderMode::Antialiased;
9395
params.outlineWidth = 0;
9496

95-
testParams.fileName = folderToSaveFiles / "test10.bmp";
97+
testParams.fileName = (folderToSaveFiles / "test10.bmp").wstring();
9698
testParams.expectedHash = 7683707409401849002;
9799

98100
runTest(params, testParams);
@@ -103,7 +105,7 @@ int runtests()
103105

104106
params.DPIx = 120;
105107
params.DPIy = 120;
106-
params.fontPath = L"C:/Windows/Fonts/segoeui.ttf";
108+
params.fontPath = fontPathSegoeib.wstring();
107109
params.text = L"<textcolor=#000000ff>|This| is זה משהו\n באמת משהו\nabcdefghijklmnopqrstuvwwxyz\nABCDEFGHIJKLMNOPQVWXYZ\n|!#_+";
108110

109111
params.backgroundColor = LLUtils::Colors::White;
@@ -114,8 +116,8 @@ int runtests()
114116
params.flags = FreeType::TextCreateFlags::UseMetaText |
115117
FreeType::TextCreateFlags::Bidirectional;
116118

117-
testParams.fileName = folderToSaveFiles / "test.bmp";
118-
testParams.expectedHash = 16738229490926515141;
119+
testParams.fileName = (folderToSaveFiles / "test.bmp").wstring();
120+
testParams.expectedHash = 16738229490926515141u;
119121

120122
runTest(params, testParams);
121123

@@ -125,7 +127,7 @@ int runtests()
125127

126128
params.DPIx = 120;
127129
params.DPIy = 120;
128-
params.fontPath = L"C:/Windows/Fonts/segoeuib.ttf";
130+
params.fontPath = fontPathSegoeib.wstring();
129131
params.text = L"<textcolor=#00ff00ff>|This| is זה משהו\n באמת משהו\nabcdefghijklmnopqrstuvwwxyz\nABCDEFGHIJKLMNOPQVWXYZ\n|!#_+";
130132

131133
params.text = L"<textcolor=#4a80e2>Welcome to <textcolor=#dd0f1d>OIV\n"\
@@ -141,8 +143,8 @@ int runtests()
141143
params.flags = FreeType::TextCreateFlags::UseMetaText |
142144
FreeType::TextCreateFlags::Bidirectional;
143145

144-
testParams.fileName = folderToSaveFiles / "test1.bmp";
145-
testParams.expectedHash = 16558562707942498804;
146+
testParams.fileName = (folderToSaveFiles / "test1.bmp").wstring();
147+
testParams.expectedHash = 16558562707942498804u;
146148

147149
runTest(params, testParams);
148150

@@ -152,55 +154,55 @@ int runtests()
152154

153155
//params.text = L"3000 X 1712 X 32 BPP | loaded in 92.7 ms";
154156
params.text = L"Texel: 1218.3 X 584.6";
155-
params.fontPath = L"C:/Windows/Fonts/consola.ttf";
157+
params.fontPath = fontPathConsola.wstring();
156158
params.renderMode = FreeType::RenderMode::SubpixelAntiAliased;
157159
params.fontSize = 11;
158160
params.backgroundColor = { 255, 255, 255, 192 };
159161
params.DPIx = 120;
160162
params.DPIy = 120;
161163
//params.padding = 1;
162-
testParams.fileName = folderToSaveFiles / "test2.bmp";
163-
testParams.expectedHash = 11320992707252375232;
164+
testParams.fileName = (folderToSaveFiles / "test2.bmp").wstring();
165+
testParams.expectedHash = 11320992707252375232u;
164166
runTest(params, testParams);
165167

166168

167169

168170

169171
params.text = L"<textcolor=#ff8930>windowed";
170-
params.fontPath = L"C:/Windows/Fonts/segoeuib.ttf";
172+
params.fontPath = fontPathSegoeib.wstring();
171173
params.renderMode = FreeType::RenderMode::SubpixelAntiAliased;
172174
params.fontSize = 11;
173175
params.backgroundColor = { 255, 255, 255, 192 };
174176
params.DPIx = 120;
175177
params.DPIy = 120;
176178
params.padding = 0;
177179

178-
testParams.fileName = folderToSaveFiles / "test3.bmp";
179-
testParams.expectedHash = 9753445643566658639;
180+
testParams.fileName = (folderToSaveFiles / "test3.bmp").wstring();
181+
testParams.expectedHash = 9753445643566658639u;
180182
runTest(params, testParams);
181183

182184

183185

184186
//Test Fixed width font
185187

186188
params.text = L"<textcolor=#ff8930>444";
187-
params.fontPath = L"C:/Windows/Fonts/consola.ttf";
189+
params.fontPath = fontPathConsola.wstring();
188190
params.renderMode = FreeType::RenderMode::Antialiased;
189191
params.fontSize = 11;
190192
params.backgroundColor = { 255, 255, 255, 192 };
191193
params.DPIx = 120;
192194
params.DPIy = 120;
193195
params.padding = 0;
194196

195-
testParams.fileName = folderToSaveFiles / "test4_1.bmp";
196-
testParams.expectedHash = 11631623323771771341;
197+
testParams.fileName = (folderToSaveFiles / "test4_1.bmp").wstring();
198+
testParams.expectedHash = 11631623323771771341u;
197199
runTest(params, testParams);
198200

199201

200202
params.text = L"<textcolor=#ff8930>555";
201203

202-
testParams.fileName = folderToSaveFiles / "test4_2.bmp";
203-
testParams.expectedHash = 17162733075979477580;
204+
testParams.fileName = (folderToSaveFiles / "test4_2.bmp").wstring();
205+
testParams.expectedHash = 17162733075979477580u;
204206
runTest(params, testParams);
205207

206208

@@ -211,7 +213,7 @@ int runtests()
211213

212214
//test very thick outline
213215
params.text = L"<textcolor=#ff8930>windowed";
214-
params.fontPath = L"C:/Windows/Fonts/segoeuib.ttf";
216+
params.fontPath = fontPathSegoeib.wstring();
215217
params.renderMode = FreeType::RenderMode::Antialiased;
216218
params.fontSize = 11;
217219
params.backgroundColor = { 255, 255, 255, 192 };
@@ -220,14 +222,13 @@ int runtests()
220222
params.padding = 0;
221223
params.outlineWidth = 20;
222224

223-
testParams.fileName = folderToSaveFiles / "test5.bmp";
224-
testParams.expectedHash = 4822496049661565882;
225+
testParams.fileName = (folderToSaveFiles / "test5.bmp").wstring();
226+
testParams.expectedHash = 4822496049661565882u;
225227
runTest(params, testParams);
226228

227-
228229
//Lower dpi mode
229230
params.text = L"abcdefg.tif";
230-
params.fontPath = L"C:/Windows/Fonts/segoeuib.ttf";
231+
params.fontPath = fontPathSegoeib.wstring();
231232
params.renderMode = FreeType::RenderMode::Antialiased;
232233
params.fontSize = 12;
233234
params.backgroundColor = { 255, 255, 255, 192 };
@@ -236,8 +237,8 @@ int runtests()
236237
params.padding = 0;
237238
params.outlineWidth = 2;
238239

239-
testParams.fileName = folderToSaveFiles / "test6.bmp";
240-
testParams.expectedHash = 3439216908320477038;
240+
testParams.fileName = (folderToSaveFiles / L"test6.bmp").wstring();
241+
testParams.expectedHash = 3439216908320477038u;
241242
runTest(params, testParams);
242243

243244
return 0;

0 commit comments

Comments
 (0)