Skip to content

feat: add text rendering functionality with custom font support#5

Merged
burdockcascade merged 12 commits into
masterfrom
add_text
Jul 26, 2026
Merged

feat: add text rendering functionality with custom font support#5
burdockcascade merged 12 commits into
masterfrom
add_text

Conversation

@burdockcascade

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings July 25, 2026 22:37
@burdockcascade burdockcascade linked an issue Jul 25, 2026 that may be closed by this pull request

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces text rendering to the 2D rendering API exposed to QuickJS, including a new Font class to allow loading and using custom fonts from JavaScript.

Changes:

  • Added Font and TextOptions types on the host side and exposed Font in the JS module exports.
  • Added a new render.text.drawText(...) binding backed by raylib DrawTextPro.
  • Added a new example demonstrating custom font usage for text rendering.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/api/js_types.hpp Adds host-side JSFont and JSTextOptions types to support text rendering configuration.
src/api/hostapi.hpp Exports the new Font class from the vectorjs JS module.
src/api/api_context.cpp Refactors 2D sub-objects and adds the text.drawText binding + option parsing.
src/api/api_classes.cpp Registers the new Font QuickJS class and integrates it into class registration.
examples/2d/text.js Adds a runnable example showcasing render.text.drawText and custom fonts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/api/js_types.hpp
Comment thread src/api/api_classes.cpp
Comment thread src/api/api_classes.cpp
Comment thread src/api/api_context.cpp Outdated
Comment thread examples/2d/text.js Outdated
Comment thread examples/2d/text.js Outdated
Comment thread examples/2d/text.js Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.

Comment thread src/api/api_context.cpp
Comment on lines 19 to +23
JSValue create_update_context_object(JSContext* ctx) {
return JS_NewObject(ctx);
}

JSValue create_draw_render_object(JSContext* ctx) {
Utils::ScopedJSValue render2d_obj(ctx, JS_NewObject(ctx));

// --- FPS Binding ---
JS_SetPropertyStr(ctx, render2d_obj, "drawFPS", JS_NewCFunction(ctx, [](JSContext* c, JSValueConst, int argc, JSValueConst* argv) -> JSValue {
if (argc < 1) return JS_ThrowTypeError(c, "drawFPS requires a Vector2 position argument");
const auto pos = Utils::get_opaque_or<JSVector2>(c, argv[0], js_vector2_class_id, {0, 0});
::DrawFPS(static_cast<int>(pos.x), static_cast<int>(pos.y));
return JS_UNDEFINED;
}, "drawFPS", 1));

// --- Shapes Sub-Object ---
static JSValue create_shapes_object(JSContext* ctx) {
Comment thread src/api/js_types.hpp

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.

Comment thread src/api/api_context.cpp
Comment thread src/api/api_context.cpp
@burdockcascade
burdockcascade merged commit f07f22f into master Jul 26, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add text & fonts

2 participants