forked from TheCherno/Hazel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added msdf-atlas-gen submodule + basic example in Font.cpp
- Loading branch information
Showing
8 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include "hzpch.h" | ||
#include "Font.h" | ||
|
||
#undef INFINITE | ||
#include "msdf-atlas-gen.h" | ||
|
||
namespace Hazel { | ||
|
||
Font::Font(const std::filesystem::path& filepath) | ||
{ | ||
msdfgen::FreetypeHandle* ft = msdfgen::initializeFreetype(); | ||
if (ft) | ||
{ | ||
std::string fileString = filepath.string(); | ||
msdfgen::FontHandle* font = msdfgen::loadFont(ft, fileString.c_str()); | ||
if (font) | ||
{ | ||
msdfgen::Shape shape; | ||
if (msdfgen::loadGlyph(shape, font, 'C')) | ||
{ | ||
shape.normalize(); | ||
// max. angle | ||
msdfgen::edgeColoringSimple(shape, 3.0); | ||
// image width, height | ||
msdfgen::Bitmap<float, 3> msdf(32, 32); | ||
// range, scale, translation | ||
msdfgen::generateMSDF(msdf, shape, 4.0, 1.0, msdfgen::Vector2(4.0, 4.0)); | ||
msdfgen::savePng(msdf, "output.png"); | ||
} | ||
msdfgen::destroyFont(font); | ||
} | ||
msdfgen::deinitializeFreetype(ft); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#pragma once | ||
|
||
namespace Hazel { | ||
|
||
class Font | ||
{ | ||
public: | ||
Font(const std::filesystem::path& font); | ||
|
||
|
||
}; | ||
|
||
} |
Submodule msdf-atlas-gen
added at
b50e10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters