From 3a29b9984760af0b3a85e35190e1dede39e13891 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 16 Nov 2021 11:07:49 +0100 Subject: Implement all interfaces to mgl --- src/graphics/Font.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/graphics/Font.cpp') diff --git a/src/graphics/Font.cpp b/src/graphics/Font.cpp index ae87625..b3ef54c 100644 --- a/src/graphics/Font.cpp +++ b/src/graphics/Font.cpp @@ -1,5 +1,6 @@ #include "../../include/mglpp/graphics/Font.hpp" #include "../../include/mglpp/graphics/Texture.hpp" +#include "../../include/mglpp/system/MemoryMappedFile.hpp" #include namespace mgl { @@ -11,32 +12,31 @@ namespace mgl { mgl_font_unload(&font); } - bool Font::load_from_file(const char *filepath, unsigned int character_size) { + bool Font::load_from_file(const MemoryMappedFile &mapped_file, unsigned int character_size) { if(font.texture.id) return false; - return mgl_font_load_from_file(&font, filepath, character_size) == 0; + return mgl_font_load_from_file(&font, mapped_file.internal_mapped_file(), character_size) == 0; } unsigned int Font::get_character_size() const { return font.character_size; } - FontGlyph Font::get_glyph(uint32_t codepoint) const { + FontGlyph Font::get_glyph(uint32_t codepoint) { FontGlyph font_glyph; - if(font.texture.id == 0) - return font_glyph; - mgl_font_get_glyph(&font, codepoint, (mgl_font_glyph*)&font_glyph); return font_glyph; } + int Font::get_kerning(uint32_t prev_codepoint, uint32_t codepoint) { + return mgl_font_get_kerning(&font, prev_codepoint, codepoint); + } + Texture Font::get_texture() const { - if(font.texture.id == 0) - return Texture(); return Texture::reference(font.texture); } mgl_font* Font::internal_font() { return &font; } -} \ No newline at end of file +} -- cgit v1.2.3