Initial Commit
This commit is contained in:
commit
6088fc29ed
978 changed files with 353647 additions and 0 deletions
22
src/FontData.cpp
Normal file
22
src/FontData.cpp
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#include "FontData.hpp"
|
||||
//#include <include/ports/SkFontMgr_directory.h>
|
||||
#include <include/ports/SkFontMgr_empty.h>
|
||||
#include <include/core/SkFontMetrics.h>
|
||||
#include <include/core/SkTextBlob.h>
|
||||
#include <iostream>
|
||||
|
||||
FontData::FontData():
|
||||
mgr(SkFontMgr_New_Custom_Empty())
|
||||
{
|
||||
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};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue