Skip to content
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

gsKit_fontm_print_scaled: Alignment does not take into account special characters #45

Open
ticky opened this issue Jul 16, 2021 · 0 comments

Comments

@ticky
Copy link

ticky commented Jul 16, 2021

When printing characters in the JIS range using the \f prefix in the gsFontM module, centered or right-aligned text is measured based on the full string length including the four digit character code and the \f character.

i.e. a string of "\f0062 Enter" is treated as 11 characters long, rather than 7.

The same goes for the \e helper, though due to the variable lengths this one probably requires a more complex solution.

I haven't been able to build gsKit myself but I believe this patch would help, if my maths is right, presuming that the programmer didn't input an invalid character code:

diff --git a/ee/gs/src/gsFontM.c b/ee/gs/src/gsFontM.c
index 983e05e..0f189d7 100644
--- a/ee/gs/src/gsFontM.c
+++ b/ee/gs/src/gsFontM.c
@@ -357,6 +357,11 @@ void gsKit_fontm_print_scaled(GSGLOBAL *gsGlobal, GSFONTM *gsFontM, float X, flo
 			numlines++;
 			linechars[numlines] = 0;
 		}
+		else if(cur == '\f')
+		{
+			linechars[numlines]++;
+			pos += 4;
+		}
 		else if(cur == '\t' && gsFontM->Align != GSKIT_FALIGN_LEFT)
 		{
 			printf("WARNING: Tabs not supported in GSKIT_FALIGN_CENTER/RIGHT\n");
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

No branches or pull requests

1 participant