diff --git a/bindings/src/index.ts b/bindings/src/index.ts index ca9485a..daf0149 100644 --- a/bindings/src/index.ts +++ b/bindings/src/index.ts @@ -294,6 +294,7 @@ function main(){ baseSize: { get: true }, glyphCount: { get: true }, glyphPadding: { get: true }, + texture: { get: true }, }, //destructor: "UnloadFont" } diff --git a/examples/lib.raylib.d.ts b/examples/lib.raylib.d.ts index 753df65..9e44f88 100644 --- a/examples/lib.raylib.d.ts +++ b/examples/lib.raylib.d.ts @@ -137,6 +137,8 @@ interface Font { glyphCount: number, /** Padding around the glyph characters */ glyphPadding: number, + /** Texture atlas containing the glyphs */ + texture: Texture, } declare var Font: { prototype: Font; diff --git a/src/bindings/js_raylib_core.h b/src/bindings/js_raylib_core.h index 026c006..d1542a5 100644 --- a/src/bindings/js_raylib_core.h +++ b/src/bindings/js_raylib_core.h @@ -846,10 +846,21 @@ static JSValue js_Font_get_glyphPadding(JSContext* ctx, JSValueConst this_val) { return ret; } +static JSValue js_Font_get_texture(JSContext* ctx, JSValueConst this_val) { + Font* ptr = JS_GetOpaque2(ctx, this_val, js_Font_class_id); + Texture2D texture = ptr->texture; + Texture2D* ret_ptr = (Texture2D*)js_malloc(ctx, sizeof(Texture2D)); + *ret_ptr = texture; + JSValue ret = JS_NewObjectClass(ctx, js_Texture_class_id); + JS_SetOpaque(ret, ret_ptr); + return ret; +} + static const JSCFunctionListEntry js_Font_proto_funcs[] = { JS_CGETSET_DEF("baseSize",js_Font_get_baseSize,NULL), JS_CGETSET_DEF("glyphCount",js_Font_get_glyphCount,NULL), JS_CGETSET_DEF("glyphPadding",js_Font_get_glyphPadding,NULL), + JS_CGETSET_DEF("texture",js_Font_get_texture,NULL), JS_PROP_STRING_DEF("[Symbol.toStringTag]","Font", JS_PROP_CONFIGURABLE), };