Skip to content

Commit

Permalink
Font::fixedCharWidth
Browse files Browse the repository at this point in the history
  • Loading branch information
krystalgamer committed Sep 21, 2024
1 parent a624eea commit 160902c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
29 changes: 29 additions & 0 deletions FontTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,35 @@

#include <cstring>

// @Ok
i32 Font::fixedCharWidth(char c)
{
if (this->isEscapeChar(c))
return 0;

if (this->field_58 != 0 && this->field_58 != 2)
{
if (this->field_58 == 1)
{
if (c == ':')
{
return this->field_34 * (this->field_C + this->pCharTab[10].W) >> 12;
}

return this->field_34 * (this->field_C + this->pCharTab->W) >> 12;
}
else
{
print_if_false(0, "Unrecognized char mapping");
return 0;
}
}
else
{
return (this->field_34 * (this->field_C + this->pCharTab->W)) >> 12;
}
}

// @Ok
// @Matching
Font::Font(void)
Expand Down
1 change: 1 addition & 0 deletions FontTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class Font : public CClass
EXPORT i32 heightBelowBaseline(char*);
EXPORT i32 heightAboveBaseline(char*);
EXPORT void draw(i32, i32, const char*, i32, float);
EXPORT i32 fixedCharWidth(char);

i32 field_4;
i32 field_8;
Expand Down

0 comments on commit 160902c

Please sign in to comment.