Skip to content

Commit 885f458

Browse files
committed
Fixed: linux compilation
1 parent 78a6b99 commit 885f458

File tree

3 files changed

+64
-62
lines changed

3 files changed

+64
-62
lines changed

Test/CMakeLists.txt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ set(CMAKE_CXX_STANDARD 20)
99
if(NOT TARGET FreeTypeTest)
1010
include_directories(../External/FreeTypeWrapper/Include)
1111
# Add source to this project's executable.
12-
add_executable (FreeTypeTest "Test.cpp")
12+
set(TargetName FreeTypeTest)
13+
add_executable (${TargetName} "Test.cpp")
1314

1415
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
1516
#enabled warnings flags
@@ -25,9 +26,14 @@ if(NOT TARGET FreeTypeTest)
2526
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
2627
endif()
2728
endif()
28-
endif()
2929

30-
target_include_directories(FreeTypeTest PRIVATE ../FreeTypeWrapper/Include)
31-
target_include_directories(FreeTypeTest PRIVATE ../FreeTypeWrapper/External/LLUtils/Include)
30+
target_include_directories(${TargetName} PRIVATE ../FreeTypeWrapper/Include)
31+
target_include_directories(${TargetName} PRIVATE ../FreeTypeWrapper/External/LLUtils/Include)
32+
target_link_libraries(${TargetName} PRIVATE FreeTypeWrapper)
33+
34+
#Copy font to output dir
35+
add_custom_command(TARGET ${TargetName} POST_BUILD
36+
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/CascadiaCode.ttf ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/)
3237

33-
target_link_libraries(FreeTypeTest PRIVATE FreeTypeWrapper)
38+
endif()
39+

Test/CascadiaCode.ttf

634 KB
Binary file not shown.

Test/Test.cpp

Lines changed: 53 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,11 @@ SOFTWARE.
3131

3232
std::filesystem::path folderToSaveFiles = "./testImages/";
3333
#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";
3737
#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";
4139
#else
4240
#pragma error "Non-compatible platform detected."
4341
#endif
@@ -78,7 +76,7 @@ void runTest(FreeType::FreeTypeConnector& freeType, FreeType::TextCreateParams f
7876
FreeTypeConnector::Bitmap textBitmap;
7977
freeType.CreateBitmap(freetypeParams, textBitmap, nullptr);
8078

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);
8280

8381
if (testParams.saveToFile)
8482
SaveToFile(textBitmap, testParams.fileName);
@@ -97,10 +95,12 @@ int runtests()
9795
TestParams testParams{};
9896
testParams.saveToFile = shouldSaveToFile;
9997
//Several test cases, for now mostly checks for out of bounds errors, if there's no exceptions test is considered passed.
100-
10198
params.DPIx = 120;
10299
params.DPIy = 120;
103-
params.fontPath = fontPathSegoeib.wstring();
100+
101+
#if LLUTILS_PLATFORM == LLUTILS_PLATFORM_WIN32
102+
params.fontPath = fontPathSegoeib.wstring();
103+
104104
params.text = L"ijkjojujrjaj";
105105
params.textColor = LLUtils::Colors::Black;
106106
params.outlineColor = { 0,0,0,255 };
@@ -121,6 +121,8 @@ int runtests()
121121
params.DPIx = 120;
122122
params.DPIy = 120;
123123
params.fontPath = fontPathSegoei.wstring();
124+
125+
124126
params.text = L"<textcolor=#000000ff>|This| is זה משהו\n באמת משהו\nabcdefghijklmnopqrstuvwwxyz\nABCDEFGHIJKLMNOPQVWXYZ\n|!#_+";
125127

126128
params.backgroundColor = LLUtils::Colors::White;
@@ -136,8 +138,6 @@ int runtests()
136138

137139
runTest(freeType, params, testParams);
138140

139-
140-
141141
//Several test cases, for now mostly checks for out of bounds errors, if there's no exceptions test is considered passed.
142142

143143
params.DPIx = 120;
@@ -164,45 +164,56 @@ int runtests()
164164
runTest(freeType, params, testParams);
165165

166166

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();
174169
params.renderMode = FreeType::RenderMode::SubpixelAntiAliased;
175170
params.fontSize = 11;
176171
params.backgroundColor = { 255, 255, 255, 192 };
177172
params.DPIx = 120;
178173
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;
182178
runTest(freeType, params, testParams);
183179

184180

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);
185195

186196

197+
// Test very thick outline
187198
params.text = L"<textcolor=#ff8930>windowed";
188199
params.fontPath = fontPathSegoeib.wstring();
189-
params.renderMode = FreeType::RenderMode::SubpixelAntiAliased;
200+
params.renderMode = FreeType::RenderMode::Antialiased;
190201
params.fontSize = 11;
191202
params.backgroundColor = { 255, 255, 255, 192 };
192203
params.DPIx = 120;
193204
params.DPIy = 120;
194205
params.padding = 0;
206+
params.outlineWidth = 20;
195207

196-
testParams.fileName = (folderToSaveFiles / "test3.bmp").wstring();
197-
testParams.expectedHash = 9753445643566658639u;
208+
testParams.fileName = (folderToSaveFiles / "test5.bmp").wstring();
209+
testParams.expectedHash = 4822496049661565882u;
198210
runTest(freeType, params, testParams);
199211

200-
212+
#endif
201213

202214
//Test Fixed width font
203-
204215
params.text = L"<textcolor=#ff8930>444";
205-
params.fontPath = fontPathConsola.wstring();
216+
params.fontPath = fontPathFixed.wstring();
206217
params.renderMode = FreeType::RenderMode::Antialiased;
207218
params.fontSize = 11;
208219
params.backgroundColor = { 255, 255, 255, 192 };
@@ -227,40 +238,14 @@ int runtests()
227238
LL_EXCEPTION(LLUtils::Exception::ErrorCode::InvalidState, "mismatch size");*/
228239

229240

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

241-
testParams.fileName = (folderToSaveFiles / "test5.bmp").wstring();
242-
testParams.expectedHash = 4822496049661565882u;
243-
runTest(freeType, params, testParams);
244242

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

256-
testParams.fileName = (folderToSaveFiles / L"test6.bmp").wstring();
257-
testParams.expectedHash = 3439216908320477038u;
258-
runTest(freeType, params, testParams);
259244

260245

261246
//Test aliased text
262247
params.text = L"<textcolor=#ff8930>aliased text";
263-
params.fontPath = fontPathConsola.wstring();
248+
params.fontPath = fontPathFixed.wstring();
264249
params.outlineColor = { 0, 0, 0, 255 };
265250
params.outlineWidth = 0;
266251
params.renderMode = FreeType::RenderMode::Aliased;
@@ -274,6 +259,20 @@ int runtests()
274259
testParams.expectedHash = 11631623323771771341u;
275260
runTest(freeType, params, testParams);
276261

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+
277276

278277
return 0;
279278
}
@@ -283,11 +282,8 @@ int main()
283282

284283
try
285284
{
286-
#if LLUTILS_PLATFORM == LLUTILS_PLATFORM_WIN32
287-
288285
if (runtests() == 0)
289286
std::cout << "All tests passed successfully.";
290-
#endif
291287

292288
}
293289
catch (...)

0 commit comments

Comments
 (0)