mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
test library
This commit is contained in:
parent
0b61a337de
commit
2c81344638
2 changed files with 39 additions and 0 deletions
34
src/coders/vector_fonts.cpp
Normal file
34
src/coders/vector_fonts.cpp
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#include "vector_fonts.hpp"
|
||||
|
||||
#include "io/io.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
static FT_Library library;
|
||||
|
||||
void vector_fonts::initialize() {
|
||||
if (FT_Error error = FT_Init_FreeType(&library)) {
|
||||
throw std::runtime_error(
|
||||
"could not initialize freetype: " +
|
||||
std::string(FT_Error_String(error))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static FT_Face load_ft_face(const io::path& path) {
|
||||
auto bytes = io::read_bytes_buffer(path);
|
||||
|
||||
FT_Face face;
|
||||
|
||||
if (FT_Error error =
|
||||
FT_New_Memory_Face(library, bytes.data(), bytes.size(), 0, &face)) {
|
||||
throw std::runtime_error(
|
||||
"could not load font '" + path.string() +
|
||||
"': " + std::string(FT_Error_String(error))
|
||||
);
|
||||
}
|
||||
|
||||
return face;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue