update
This commit is contained in:
parent
ef8d623525
commit
c9ebd448f9
7 changed files with 278 additions and 73 deletions
|
|
@ -56,4 +56,15 @@ Font::Font(const std::filesystem::path& fontFilePath) {
|
|||
this->ascent = ascent;
|
||||
this->descent = descent;
|
||||
this->lineGap = lineGap;
|
||||
}
|
||||
|
||||
std::uint32_t Font::GetLineWidth(const std::string_view text, float size) {
|
||||
float scale = stbtt_ScaleForPixelHeight(&font, size);
|
||||
std::uint32_t lineWidth = 0;
|
||||
for (const char c : text) {
|
||||
int advance, lsb;
|
||||
stbtt_GetCodepointHMetrics(&font, c, &advance, &lsb);
|
||||
lineWidth += (int)(advance * scale);
|
||||
}
|
||||
return lineWidth;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue