-
-
Notifications
You must be signed in to change notification settings - Fork 250
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
Multilingual font rendering #1991
base: master
Are you sure you want to change the base?
Conversation
put your ttf file into "3rdparty\extras\xash-extras\gfx\fonts\" change cl_font.c FONT_COUNT g_FontsPath g_FontsSize
engine/client/console.c
Outdated
@@ -619,17 +619,71 @@ Convert utf char to current font's single-byte encoding | |||
*/ | |||
int Con_UtfProcessCharForce( int in ) | |||
{ | |||
// TODO: get rid of global state where possible |
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.
Why you did that?
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 can accurately process characters, as previous functions were unable to handle them correctly
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.
Sorry, I haven't read Q-DecodeUTF8 function. If Con-UtfProcessCharForce is not modified, the Chinese will become "?"
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.
Q_DecodeUTF8 must be able to decode Chinese symbols (as long as they're encoded in UTF-8). If it doesn't, it's a bug in Q_DecodeUTF8, and not in this function.
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.
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.
I think I have a better solution for this problem.
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.
Nevermind, setting it up to zero is absolutely fine for what we're trying to achieve here.
This code will be removed once engine will completely draw text on it's own, without relying on provided bitmap fonts (which are often in CP1251 or CP1252, thus the logic)
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.
I believe the core issue now is whether the implementation of my code is correct. Currently, multilingual rendering in the engine does not appear to be inherently difficult. Let’s prioritize finalizing this feature as soon as possible XD
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.
There is absolutely no need to hurry. I didn't even start on the thing that your code doesn't even compile.
// skip setting rendermode, it was changed for this string already | ||
draw_len += CL_DrawCharacter( x + draw_len, y, (byte)*s, current_color, font, flags | FONT_DRAW_NORENDERMODE ); | ||
if( ch ) |
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.
You also absolutely don't have to do this.
If you don't try to override CL_DrawCharacter with your own function (i.e. Font_DrawChar) it will actually decode UTF-8 for you.
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.
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.
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.
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.
That's a valid concern actually.
put your ttf file into "3rdparty\extras\xash-extras\gfx\fonts"
change cl_font.c
FONT_COUNT
g_FontsPath
g_FontsSize