#include "FontData.hpp" //#include #include #include #include #include #ifdef __EMSCRIPTEN__ #elif _WIN32 #include #elif __APPLE__ #include #elif __linux__ #include #include #endif FontData::FontData() { #ifdef __EMSCRIPTEN__ mgr = SkFontMgr_New_Custom_Empty(); #elif _WIN32 mgr = SkFontMgr_New_GDI(); #elif __APPLE__ mgr = SkFontMgr_New_Custom_Empty(); #elif __linux__ mgr = SkFontMgr_New_FontConfig(nullptr, SkFontScanner_Make_FreeType()); #else mgr = SkFontMgr_New_Custom_Empty(); #endif map["Roboto"] = mgr->makeFromFile("data/fonts/Roboto-variable.ttf"); } FontData::~FontData() { } Vector2f get_str_font_bounds(const SkFont& font, const std::string& str) { SkFontMetrics metrics; font.getMetrics(&metrics); float nextText = font.measureText(str.data(), str.length(), SkTextEncoding::kUTF8, nullptr); return Vector2f{nextText, - metrics.fAscent + metrics.fDescent}; }