-
-
Notifications
You must be signed in to change notification settings - Fork 34
Improve the performance of text rendering #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
212ba7c
116f09e
52f0cbc
716c205
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| #pragma once | ||
| #include <c2d/base.h> | ||
| #include <3ds/font.h> | ||
|
|
||
| typedef struct | ||
| { | ||
|
|
@@ -77,6 +78,7 @@ struct C2D_Font_s | |
| CFNT_s* cfnt; | ||
| C3D_Tex* glyphSheets; | ||
| float textScale; | ||
| fontGlyphPos_s asciiCache[128]; | ||
| }; | ||
|
|
||
| static inline C2Di_Context* C2Di_GetContext(void) | ||
|
|
@@ -117,3 +119,9 @@ void C2Di_AppendQuad(void); | |
| void C2Di_AppendVtx(float x, float y, float z, float u, float v, float ptx, float pty, u32 color); | ||
| void C2Di_FlushVtxBuf(void); | ||
| void C2Di_Update(void); | ||
|
|
||
| #define NUM_ASCII_CHARACTERS 128 | ||
| extern fontGlyphPos_s g_systemFontASCIICache[NUM_ASCII_CHARACTERS]; | ||
|
|
||
| #define SHEETS_PER_BIG_SHEET 32 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same comment from the hbmenu PR about not hardcoding this applies here. In citro2d, it's even more relevant, as citro2d supports using arbitrary fonts (not just the system font).
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So note here that I intentionally limit the big sheets optimization to the system font only, since I'd like to assume that mkcbfnt will create an efficient amount of sheets anyway. What do you think?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not all fonts are necessarly going to be mkbcfnt generated. A trivial example is a different region's system font (which, yes, most of those do not have the same issue as the standard one, but is still a consideration), and less trivial would be a plugin or something that wants to use a game's assets, for whatever reason. It is relatively easy to access the assets of any installed title, so I could absolutely see that being done
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see... I think I can try applying the optimization to all fonts then. Though, are different regions' system fonts not just the system font? Also, do you all think it makes any sense to wrap the system font around a
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are four different system fonts: "standard", Korean, Chinese Traditional, and Chinese Simplified. Also, the choice was originally made to have NULL be the system font on purpose; this allows the old API without font selection to continue to use the new API internally. I suppose having an internal dummy isn't the worst idea; that could be returned instead of NULL if one were to load the system font. |
||
| extern u32 g_numFontSheetsCombined; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is incorrect in C:
()is the same as(...).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh woops, I didn't even mean to change that... This I do know.