Skip to content

Commit

Permalink
Fixed: Linux compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
TheNicker committed Aug 20, 2023
1 parent 96c0bb5 commit 92c0746
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 30 deletions.
2 changes: 1 addition & 1 deletion FreeTypeWrapper/Source/FreeTypeConnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ namespace FreeType
if (out_glyphMapping != nullptr)
{
out_glyphMapping->push_back(LLUtils::RectI32{ { penX, penY } ,
{penX + advance, penY + static_cast<int32_t>(rowHeight)} });
{penX + static_cast<int32_t>(advance), penY + static_cast<int32_t>(rowHeight)} });
}

penX += slot->advance.x >> 6;
Expand Down
59 changes: 30 additions & 29 deletions Test/Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ SOFTWARE.
#include <LLUtils/Exception.h>
#include "xxh3.h"

std::filesystem::path folderToSaveFiles = "d:/testImages/";
bool shouldSaveToFile = false;
std::filesystem::path folderToSaveFiles = "./testImages/";
std::filesystem::path fontPathSegoeib = L"/media/lior/System/Windows/Fonts/segoeuib.ttf";
std::filesystem::path fontPathConsola = L"/media/lior/System/Windows/Fonts/consola.ttf";
bool shouldSaveToFile = true;

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

if (hash != testParams.expectedHash)
throw std::exception("test failed");
throw std::runtime_error("test failed");

}

Expand All @@ -84,15 +86,15 @@ int runtests()

params.DPIx = 120;
params.DPIy = 120;
params.fontPath = L"C:/Windows/Fonts/segoeuib.ttf";
params.fontPath = fontPathSegoeib.wstring();
params.text = L"ijkjojujrjaj";
params.textColor = LLUtils::Colors::Black;
params.backgroundColor = LLUtils::Colors::White;
params.fontSize = 44;
params.renderMode = FreeType::RenderMode::Antialiased;
params.outlineWidth = 0;

testParams.fileName = folderToSaveFiles / "test10.bmp";
testParams.fileName = (folderToSaveFiles / "test10.bmp").wstring();
testParams.expectedHash = 7683707409401849002;

runTest(params, testParams);
Expand All @@ -103,7 +105,7 @@ int runtests()

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

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

testParams.fileName = folderToSaveFiles / "test.bmp";
testParams.expectedHash = 16738229490926515141;
testParams.fileName = (folderToSaveFiles / "test.bmp").wstring();
testParams.expectedHash = 16738229490926515141u;

runTest(params, testParams);

Expand All @@ -125,7 +127,7 @@ int runtests()

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

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

testParams.fileName = folderToSaveFiles / "test1.bmp";
testParams.expectedHash = 16558562707942498804;
testParams.fileName = (folderToSaveFiles / "test1.bmp").wstring();
testParams.expectedHash = 16558562707942498804u;

runTest(params, testParams);

Expand All @@ -152,55 +154,55 @@ int runtests()

//params.text = L"3000 X 1712 X 32 BPP | loaded in 92.7 ms";
params.text = L"Texel: 1218.3 X 584.6";
params.fontPath = L"C:/Windows/Fonts/consola.ttf";
params.fontPath = fontPathConsola.wstring();
params.renderMode = FreeType::RenderMode::SubpixelAntiAliased;
params.fontSize = 11;
params.backgroundColor = { 255, 255, 255, 192 };
params.DPIx = 120;
params.DPIy = 120;
//params.padding = 1;
testParams.fileName = folderToSaveFiles / "test2.bmp";
testParams.expectedHash = 11320992707252375232;
testParams.fileName = (folderToSaveFiles / "test2.bmp").wstring();
testParams.expectedHash = 11320992707252375232u;
runTest(params, testParams);




params.text = L"<textcolor=#ff8930>windowed";
params.fontPath = L"C:/Windows/Fonts/segoeuib.ttf";
params.fontPath = fontPathSegoeib.wstring();
params.renderMode = FreeType::RenderMode::SubpixelAntiAliased;
params.fontSize = 11;
params.backgroundColor = { 255, 255, 255, 192 };
params.DPIx = 120;
params.DPIy = 120;
params.padding = 0;

testParams.fileName = folderToSaveFiles / "test3.bmp";
testParams.expectedHash = 9753445643566658639;
testParams.fileName = (folderToSaveFiles / "test3.bmp").wstring();
testParams.expectedHash = 9753445643566658639u;
runTest(params, testParams);



//Test Fixed width font

params.text = L"<textcolor=#ff8930>444";
params.fontPath = L"C:/Windows/Fonts/consola.ttf";
params.fontPath = fontPathConsola.wstring();
params.renderMode = FreeType::RenderMode::Antialiased;
params.fontSize = 11;
params.backgroundColor = { 255, 255, 255, 192 };
params.DPIx = 120;
params.DPIy = 120;
params.padding = 0;

testParams.fileName = folderToSaveFiles / "test4_1.bmp";
testParams.expectedHash = 11631623323771771341;
testParams.fileName = (folderToSaveFiles / "test4_1.bmp").wstring();
testParams.expectedHash = 11631623323771771341u;
runTest(params, testParams);


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

testParams.fileName = folderToSaveFiles / "test4_2.bmp";
testParams.expectedHash = 17162733075979477580;
testParams.fileName = (folderToSaveFiles / "test4_2.bmp").wstring();
testParams.expectedHash = 17162733075979477580u;
runTest(params, testParams);


Expand All @@ -211,7 +213,7 @@ int runtests()

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

testParams.fileName = folderToSaveFiles / "test5.bmp";
testParams.expectedHash = 4822496049661565882;
testParams.fileName = (folderToSaveFiles / "test5.bmp").wstring();
testParams.expectedHash = 4822496049661565882u;
runTest(params, testParams);


//Lower dpi mode
params.text = L"abcdefg.tif";
params.fontPath = L"C:/Windows/Fonts/segoeuib.ttf";
params.fontPath = fontPathSegoeib.wstring();
params.renderMode = FreeType::RenderMode::Antialiased;
params.fontSize = 12;
params.backgroundColor = { 255, 255, 255, 192 };
Expand All @@ -236,8 +237,8 @@ int runtests()
params.padding = 0;
params.outlineWidth = 2;

testParams.fileName = folderToSaveFiles / "test6.bmp";
testParams.expectedHash = 3439216908320477038;
testParams.fileName = (folderToSaveFiles / L"test6.bmp").wstring();
testParams.expectedHash = 3439216908320477038u;
runTest(params, testParams);

return 0;
Expand Down

0 comments on commit 92c0746

Please sign in to comment.