Get font info.
This commit is contained in:
27
API.md
27
API.md
@@ -3727,6 +3727,33 @@ Measure string size for Font
|
||||
|
||||
---
|
||||
|
||||
> baseSize = RL_GetFontBaseSize( Font font )
|
||||
|
||||
Get font baseSize
|
||||
|
||||
- Failure return false
|
||||
- Success return int
|
||||
|
||||
---
|
||||
|
||||
> glyphCount = RL_GetFontGlyphCount( Font font )
|
||||
|
||||
Get font glyphCount
|
||||
|
||||
- Failure return false
|
||||
- Success return int
|
||||
|
||||
---
|
||||
|
||||
> glyphPadding = RL_GetFontGlyphPadding( Font font )
|
||||
|
||||
Get font glyphPadding
|
||||
|
||||
- Failure return false
|
||||
- Success return int
|
||||
|
||||
---
|
||||
|
||||
## Models - Basic
|
||||
|
||||
---
|
||||
|
||||
@@ -25,6 +25,7 @@ List of some MISSING features that are planned to be included. For specific func
|
||||
* LoadImageFromMemory
|
||||
* Text
|
||||
* LoadFontFromMemory
|
||||
* GlyphInfo
|
||||
* Audio
|
||||
* LoadWaveFromMemory
|
||||
* LoadMusicStreamFromMemory
|
||||
|
||||
@@ -14,6 +14,7 @@ function init()
|
||||
local winSize = RL_GetWindowSize()
|
||||
|
||||
RL_SetWindowState( FLAG_WINDOW_RESIZABLE )
|
||||
RL_SetWindowState( FLAG_VSYNC_HINT )
|
||||
RL_SetWindowPosition( { mPos[1] + mSize[1] / 2 - winSize[1] / 2, mPos[2] + mSize[2] / 2 - winSize[2] / 2 } )
|
||||
RL_SetWindowTitle( "Camera 2D" )
|
||||
|
||||
|
||||
@@ -74,6 +74,7 @@ function init()
|
||||
RL_SetExitKey( KEY_ESCAPE )
|
||||
-- framebuffer = RL_LoadRenderTexture( res )
|
||||
RL_SetWindowState( FLAG_WINDOW_RESIZABLE )
|
||||
RL_SetWindowState( FLAG_VSYNC_HINT )
|
||||
RL_SetWindowPosition( { mPos[1] + mSize[1] / 2 - winSize[1] / 2, mPos[2] + mSize[2] / 2 - winSize[2] / 2 } )
|
||||
|
||||
texture = RL_LoadTexture( RL_GetBasePath().."../resources/images/tiles.png" )
|
||||
|
||||
@@ -28,6 +28,7 @@ function init()
|
||||
|
||||
RL_GuiSetFont( 0 )
|
||||
RL_SetWindowState( FLAG_WINDOW_RESIZABLE )
|
||||
RL_SetWindowState( FLAG_VSYNC_HINT )
|
||||
RL_SetWindowPosition( { mPos[1] + mSize[1] / 2 - winSize[1] / 2, mPos[2] + mSize[2] / 2 - winSize[2] / 2 } )
|
||||
end
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ function init()
|
||||
local winSize = RL_GetWindowSize()
|
||||
|
||||
RL_SetWindowState( FLAG_WINDOW_RESIZABLE )
|
||||
RL_SetWindowState( FLAG_VSYNC_HINT )
|
||||
RL_SetWindowPosition( { mPos[1] + mSize[1] / 2 - winSize[1] / 2, mPos[2] + mSize[2] / 2 - winSize[2] / 2 } )
|
||||
|
||||
camera = RL_CreateCamera3D()
|
||||
|
||||
@@ -11,6 +11,7 @@ function init()
|
||||
local winSize = RL_GetWindowSize()
|
||||
|
||||
RL_SetWindowState( FLAG_WINDOW_RESIZABLE )
|
||||
RL_SetWindowState( FLAG_VSYNC_HINT )
|
||||
RL_SetWindowPosition( { mPos[1] + mSize[1] / 2 - winSize[1] / 2, mPos[2] + mSize[2] / 2 - winSize[2] / 2 } )
|
||||
image = RL_GenImageColor( winSize[1], winSize[2], WHITE )
|
||||
-- Test changing working directory.
|
||||
|
||||
@@ -18,6 +18,7 @@ function init()
|
||||
local winSize = RL_GetWindowSize()
|
||||
|
||||
RL_SetWindowState( FLAG_WINDOW_RESIZABLE )
|
||||
RL_SetWindowState( FLAG_VSYNC_HINT )
|
||||
RL_SetWindowPosition( { mPos[1] + mSize[1] / 2 - winSize[1] / 2, mPos[2] + mSize[2] / 2 - winSize[2] / 2 } )
|
||||
camera = RL_CreateCamera3D()
|
||||
RL_SetCamera3DPosition( camera, { 0, 2, 4 } )
|
||||
|
||||
@@ -16,6 +16,7 @@ function init()
|
||||
local winSize = RL_GetWindowSize()
|
||||
|
||||
RL_SetWindowState( FLAG_WINDOW_RESIZABLE )
|
||||
RL_SetWindowState( FLAG_VSYNC_HINT )
|
||||
RL_SetWindowPosition( { mPos[1] + mSize[1] / 2 - winSize[1] / 2, mPos[2] + mSize[2] / 2 - winSize[2] / 2 } )
|
||||
|
||||
camera = RL_CreateCamera3D()
|
||||
|
||||
@@ -12,6 +12,7 @@ local winSize = { res[1] * scale, res[2] * scale }
|
||||
|
||||
function init()
|
||||
RL_SetWindowState( FLAG_WINDOW_RESIZABLE )
|
||||
RL_SetWindowState( FLAG_VSYNC_HINT )
|
||||
RL_SetWindowPosition( { mPos[1] + mSize[1] / 2 - winSize[1] / 2, mPos[2] + mSize[2] / 2 - winSize[2] / 2 } )
|
||||
RL_SetWindowSize( winSize )
|
||||
tex = RL_LoadTexture( RL_GetBasePath().."../resources/images/cat.png" )
|
||||
|
||||
@@ -90,9 +90,9 @@ function init()
|
||||
local monitorPos = Vec2:new( RL_GetMonitorPosition( monitor ) )
|
||||
local monitorSize = Vec2:new( RL_GetMonitorSize( monitor ) )
|
||||
|
||||
RL_SetConfigFlags( FLAG_VSYNC_HINT )
|
||||
RL_SetWindowTitle( "Platformer" )
|
||||
RL_SetWindowState( FLAG_WINDOW_RESIZABLE )
|
||||
RL_SetWindowState( FLAG_VSYNC_HINT )
|
||||
RL_SetWindowSize( winSize )
|
||||
RL_SetWindowPosition( { monitorPos.x + monitorSize.x / 2 - winSize.x / 2, monitorPos.y + monitorSize.y / 2 - winSize.y / 2 } )
|
||||
|
||||
|
||||
@@ -34,9 +34,8 @@ function init()
|
||||
local mSize = RL_GetMonitorSize( monitor )
|
||||
local winSize = { 1920, 1080 }
|
||||
|
||||
RL_SetConfigFlags( FLAG_VSYNC_HINT )
|
||||
|
||||
RL_SetWindowState( FLAG_WINDOW_RESIZABLE )
|
||||
RL_SetWindowState( FLAG_VSYNC_HINT )
|
||||
RL_SetWindowPosition( { mPos[1] + mSize[1] / 2 - winSize[1] / 2, mPos[2] + mSize[2] / 2 - winSize[2] / 2 } )
|
||||
RL_SetWindowSize( winSize )
|
||||
camera = RL_CreateCamera3D()
|
||||
|
||||
@@ -53,6 +53,7 @@ function init()
|
||||
local mPos = RL_GetMonitorPosition( monitor )
|
||||
local mSize = RL_GetMonitorSize( monitor )
|
||||
|
||||
RL_SetWindowState( FLAG_VSYNC_HINT )
|
||||
RL_SetWindowSize( winSize )
|
||||
RL_SetWindowPosition( { mPos[1] + mSize[1] / 2 - winSize[1] / 2, mPos[2] + mSize[2] / 2 - winSize[2] / 2 } )
|
||||
RL_SetWindowTitle( "Pong" )
|
||||
|
||||
@@ -9,6 +9,7 @@ local function setupWindow()
|
||||
local winSize = RL_GetWindowSize()
|
||||
|
||||
RL_SetWindowState( FLAG_WINDOW_RESIZABLE )
|
||||
RL_SetWindowState( FLAG_VSYNC_HINT )
|
||||
RL_SetWindowPosition( { mPos[1] + mSize[1] / 2 - winSize[1] / 2, mPos[2] + mSize[2] / 2 - winSize[2] / 2 } )
|
||||
end
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ function utillib.deepCopy( orig )
|
||||
copy = {}
|
||||
|
||||
for origKey, origValue in next, orig, nil do
|
||||
-- If object has clone method use that. Mainly for vector libraries.
|
||||
-- If object has clone method, use that.
|
||||
if type( origValue ) == "table" and type( origValue.clone ) == "function" then
|
||||
copy[ utillib.deepCopy( origKey ) ] = orig_value:clone()
|
||||
else
|
||||
|
||||
@@ -14,6 +14,7 @@ function init()
|
||||
local winSize = RL_GetWindowSize()
|
||||
|
||||
RL_SetWindowState( FLAG_WINDOW_RESIZABLE )
|
||||
RL_SetWindowState( FLAG_VSYNC_HINT )
|
||||
RL_SetWindowPosition( { mPos[1] + mSize[1] / 2 - winSize[1] / 2, mPos[2] + mSize[2] / 2 - winSize[2] / 2 } )
|
||||
|
||||
texture = RL_LoadTexture( RL_GetBasePath().."../resources/images/cat.png" )
|
||||
|
||||
@@ -66,6 +66,7 @@ end
|
||||
|
||||
function init()
|
||||
RL_SetWindowState( FLAG_WINDOW_RESIZABLE )
|
||||
RL_SetWindowState( FLAG_VSYNC_HINT )
|
||||
RL_SetWindowSize( winSize )
|
||||
RL_SetWindowPosition( { monitorPos[1] + monitorSize[1] / 2 - winSize[1] / 2, monitorPos[2] + monitorSize[2] / 2 - winSize[2] / 2 } )
|
||||
RL_SetWindowTitle( "Snake" )
|
||||
|
||||
@@ -17,6 +17,7 @@ function init()
|
||||
|
||||
RL_SetWindowTitle( "Waving cubes" )
|
||||
RL_SetWindowState( FLAG_WINDOW_RESIZABLE )
|
||||
RL_SetWindowState( FLAG_VSYNC_HINT )
|
||||
RL_SetWindowPosition( { mPos[1] + mSize[1] / 2 - winSize[1] / 2, mPos[2] + mSize[2] / 2 - winSize[2] / 2 } )
|
||||
|
||||
camera = RL_CreateCamera3D()
|
||||
|
||||
@@ -5,6 +5,7 @@ local text = "Congrats! You created your first window!"
|
||||
|
||||
function init()
|
||||
RL_SetWindowTitle( "First window" )
|
||||
RL_SetWindowState( FLAG_VSYNC_HINT )
|
||||
end
|
||||
|
||||
function process( delta )
|
||||
|
||||
@@ -78,5 +78,4 @@ typedef struct {
|
||||
extern State *state;
|
||||
|
||||
bool stateInit( const char *exePath );
|
||||
// bool stateRun();
|
||||
void stateFree();
|
||||
|
||||
@@ -12,3 +12,6 @@ int ltextDrawText( lua_State *L );
|
||||
int ltextDrawTextPro( lua_State *L );
|
||||
/* Misc. */
|
||||
int ltextMeasureText( lua_State *L );
|
||||
int ltextGetFontBaseSize( lua_State *L );
|
||||
int ltextGetFontGlyphCount( lua_State *L );
|
||||
int ltextGetFontGlyphPadding( lua_State *L );
|
||||
|
||||
@@ -664,7 +664,7 @@ int lcoreSetConfigFlags( lua_State *L ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
SetConfigFlags( lua_tointeger( L, -1 ) );
|
||||
SetConfigFlags( (unsigned int)lua_tointeger( L, -1 ) );
|
||||
lua_pushboolean( L, true );
|
||||
|
||||
return 1;
|
||||
|
||||
@@ -529,6 +529,9 @@ bool luaInit() {
|
||||
luaRegister();
|
||||
defineGlobals();
|
||||
|
||||
// SetConfigFlags( FLAG_VSYNC_HINT );
|
||||
// SetWindowState( FLAG_VSYNC_HINT );
|
||||
|
||||
return luaCallMain();
|
||||
}
|
||||
|
||||
@@ -1060,6 +1063,9 @@ void luaRegister() {
|
||||
lua_register( L, "RL_DrawTextPro", ltextDrawTextPro );
|
||||
/* Misc. */
|
||||
lua_register( L, "RL_MeasureText", ltextMeasureText );
|
||||
lua_register( L, "RL_GetFontBaseSize", ltextGetFontBaseSize );
|
||||
lua_register( L, "RL_GetFontGlyphCount", ltextGetFontGlyphCount );
|
||||
lua_register( L, "RL_GetFontGlyphPadding", ltextGetFontGlyphPadding );
|
||||
|
||||
/* Audio. */
|
||||
/* Audio device management. */
|
||||
|
||||
75
src/text.c
75
src/text.c
@@ -261,3 +261,78 @@ int ltextMeasureText( lua_State *L ) {
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> baseSize = RL_GetFontBaseSize( Font font )
|
||||
|
||||
Get font baseSize
|
||||
|
||||
- Failure return false
|
||||
- Success return int
|
||||
*/
|
||||
int ltextGetFontBaseSize( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, -1 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GetFontBaseSize( Font font )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
size_t fontId = lua_tointeger( L, -1 );
|
||||
|
||||
if ( !validFont( fontId ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
lua_pushinteger( L, state->fonts[ fontId ]->baseSize );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> glyphCount = RL_GetFontGlyphCount( Font font )
|
||||
|
||||
Get font glyphCount
|
||||
|
||||
- Failure return false
|
||||
- Success return int
|
||||
*/
|
||||
int ltextGetFontGlyphCount( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, -1 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GetFontGlyphCount( Font font )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
size_t fontId = lua_tointeger( L, -1 );
|
||||
|
||||
if ( !validFont( fontId ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
lua_pushinteger( L, state->fonts[ fontId ]->glyphCount );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> glyphPadding = RL_GetFontGlyphPadding( Font font )
|
||||
|
||||
Get font glyphPadding
|
||||
|
||||
- Failure return false
|
||||
- Success return int
|
||||
*/
|
||||
int ltextGetFontGlyphPadding( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, -1 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GetFontGlyphPadding( Font font )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
size_t fontId = lua_tointeger( L, -1 );
|
||||
|
||||
if ( !validFont( fontId ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
lua_pushinteger( L, state->fonts[ fontId ]->glyphPadding );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user