Skip to content

Commit

Permalink
- export FFont::GetChar() to ZScript
Browse files Browse the repository at this point in the history
  • Loading branch information
madame-rachelle committed Jan 29, 2024
1 parent 5925a6a commit a9523ea
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/common/scripting/interface/vmnatives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,24 @@ DEFINE_ACTION_FUNCTION_NATIVE(FFont, GetDisplayTopOffset, GetDisplayTopOffset)
ACTION_RETURN_FLOAT(GetDisplayTopOffset(self, code));
}

static int GetChar(FFont* font, int c)
{
int texc = 0;
auto getch = font->GetChar(c, CR_UNDEFINED, nullptr);
if (getch)
texc = getch->GetID().GetIndex();
return texc;
}

DEFINE_ACTION_FUNCTION_NATIVE(FFont, GetChar, ::GetChar)
{
PARAM_SELF_STRUCT_PROLOGUE(FFont);
PARAM_INT(mchar);

ACTION_RETURN_INT(::GetChar(self, mchar));
}


//==========================================================================
//
// file system
Expand Down
1 change: 1 addition & 0 deletions wadsrc/static/zscript/engine/base.zs
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ struct Font native
native BrokenLines BreakLines(String text, int maxlen);
native int GetGlyphHeight(int code);
native int GetDefaultKerning();
native TextureID GetChar(int c);
}

struct Console native
Expand Down

0 comments on commit a9523ea

Please sign in to comment.