Commit Graph

11 Commits

Author SHA1 Message Date
jonko0493
8932de1fff rich text: Optionally return cursor position from dry run & allow indenting text
Some checks failed
Documentation / Generate website (push) Has been cancelled
Documentation / Publish website with GitHub pages (push) Has been cancelled
The goal of the changes made in this PR is to create something with this
effect ("Jonko" is in in green, the rest is in white):

    "Dear god." Jonko quickly replied,
    crestfallen.

In order to do this, I need to call `NE_RichTextRender3D` or
`NE_RichTextRender3DAlpha` three times: once to draw the first part of
the sentence with the white font, once to draw "Jonko" in turquoise, and
once to draw the remainder of the sentence in white again. In order to
ensure that text is being drawn in the correct location, I need the
position where the previous call stopped drawing, which leads to the
first change this PR makes: I have added a version of
`DSF_StringRenderDryRun` which accepts pointers to `final_x` and
`final_y` and stores the last position of `font->pointer_x` and
`font->pointer_y` in them and I have added a new variant of
`NE_RichTextRenderDryRun` called `NE_RichTextRenderDryRunWithPos` which
uses that DSF function and has analogous parameters.

These functions get us the position where we need to place the next
cursor, but the next issue is that currently NitroEngine and libDSF only
allow for specifying the position of the overall box to draw text in,
but not where to offset the cursor in that box. This leads to the
following problem ("Jonko" is in in green, the rest is in white):

    "Dear god." Jonko quickly replied,
                        crestfallen.

Thus, the second change: I have introduced new versions of
`DSF_StringRender3D` and `DSF_StringRender3DAlpha` which accept an
`xStart` position that is added to the `pointerX`. Correspondingly, I
have added versions of `NE_RichTextRender3D` and
`NE_RichTextRender3DAlpha` that use these new functions as well.

Let me know if there are any issues with how I've written this (C is not
my forte, after all), but the first screenshot is this being tested in
production code.
2025-06-11 00:03:38 +01:00
jonko0493
6e1dca996c rich text: Allow the number of fonts to be specified dynamically 2025-05-24 09:37:46 -07:00
Antonio Niño Díaz
5a4824f461 library: Fix use-after-free in RichText module
When this function doesn't fail, it should preserve the buffers that
have just been allocated, as they will be used later.
2024-08-14 00:47:06 +01:00
Antonio Niño Díaz
de16a59722 library: Fixes to RichText module 2024-08-14 00:45:07 +01:00
Antonio Niño Díaz
3f3e266a4f library: Implement priority setting functions in RichText
This reverts commit 48ff37231f ("library: Remove unimplemented
functions from RichText system").

I thought the 3D drawing functions took a "depth" argument, but I was
wrong. I'm re-introducing the functions (and, this time, with an actual
implementation).
2024-03-30 00:34:39 +00:00
Antonio Niño Díaz
5ce71a9b02 library: Add function to calculate rendered text size
This simply exposes DSF_StringRenderDryRun() in a way that can be easily
used with Nitro Engine.
2024-03-29 22:21:22 +00:00
William
ff734036fc
fix: NE_RichTextMetadataLoadFAT returning error code on success 2024-03-28 14:19:30 +00:00
Antonio Niño Díaz
521012d4d1 library: Add function to reset rich text system 2024-03-07 01:26:15 +00:00
Antonio Niño Díaz
dd746c0ef5 library: Allow loading font bitmaps from RAM, not just the filesystem 2024-03-07 01:20:00 +00:00
Antonio Niño Díaz
227bffddc5 library: Fix compilation with devkitARM 2024-03-06 01:31:40 +00:00
Antonio Niño Díaz
50e14b2c21 library: Add rich text support
This support relies on BMFont: https://www.angelcode.com/products/bmfont/

Nitro Engine doesn't support that format directly. Instead, it uses
LibDSF internally: https://github.com/AntonioND/libdsf
2024-03-02 13:07:44 +00:00