static duk_ret_t js_Font_clone(duk_context* ctx) { font_t* font; duk_push_this(ctx); duk_get_prop_string(ctx, -1, "\xFF" "ptr"); font = duk_get_pointer(ctx, -1); duk_pop(ctx); duk_pop(ctx); // TODO: actually clone font in Font:clone() duk_push_sphere_font(ctx, font); return 1; }
static duk_ret_t js_Font_clone(duk_context* ctx) { font_t* dolly_font; font_t* font; duk_push_this(ctx); font = duk_require_sphere_obj(ctx, -1, "Font"); duk_pop(ctx); if (!(dolly_font = clone_font(font))) duk_error_ni(ctx, -1, DUK_ERR_ERROR, "Font:clone(): unable to clone font"); duk_push_sphere_font(ctx, dolly_font); return 1; }
static duk_ret_t js_new_Font(duk_context* ctx) { const char* filename; font_t* font; filename = duk_require_path(ctx, 0, NULL, false); font = load_font(filename); if (font == NULL) duk_error_ni(ctx, -1, DUK_ERR_ERROR, "Font(): unable to load font file `%s`", filename); duk_push_sphere_font(ctx, font); free_font(font); return 1; }
static duk_ret_t js_LoadFont(duk_context* ctx) { const char* filename = duk_require_string(ctx, 0); font_t* font; char* path = get_asset_path(filename, "fonts", false); font = load_font(path); free(path); if (font == NULL) duk_error_ni(ctx, -1, DUK_ERR_ERROR, "LoadFont(): Failed to load font file '%s'", filename); duk_push_sphere_font(ctx, font); free_font(font); return 1; }
static duk_ret_t js_GetSystemFont(duk_context* ctx) { duk_push_sphere_font(ctx, g_sys_font); return 1; }