Unicode input processing in games

I have a game that requires me to allow players to communicate with each other over the network. Everything is fine, except for the part where players can enter Unicode input.

So, the question can be divided into two parts:

  • When the type of players, how can I grab input? I did this before using game input processing (polling), however it is not as responsive as something like Windows Forms.

  • After entering input into a string, how do I output it using TrueType Fonts? The reason I ask about this is because, as a rule, I would like to build bitmap fonts at the beginning of the game from all the text used in the game. But with the entrance to unicode, about 10 thousand characters are required, which cannot be created at the beginning of the game.

PS My target input languages ​​are more specific to Chinese, Korean, and Japanese.

+3
source share
5 answers

To enter

For rendering

, , 16px, , 4096 1024x1024 , , (. fontgen, , ). , TTF.

, , , glTexSubImage2D, .

- , . , , . , , .

+8

, ?

, . SDL. Linux X , (, Quake, ).

, TrueType Fonts?

FreeType2. TrueType () .

unicode 10 . , .

. , MRU ( ) . , .

0

, SDL.

SDL, EventPoll. , .

void EventPoll (ulong mask)
{
SDL_Event event;
while (SDL_PollEvent (&event)) {
   switch(event.type) {
      case SDL_KEYDOWN:
         KeyHandler (reinterpret_cast<SDL_KeyboardEvent*> (&event));
         break;
      case SDL_KEYUP:
         KeyHandler (reinterpret_cast<SDL_KeyboardEvent*> (&event));
         break;
      // handle other events
      }
   }
}

void KeyHandler (SDL_KeyboardEvent *event)
{
   SDLKey      keySym = event->keysym.sym;
   wchar_t     unicode = event->keysym.unicode;
   int         keyState = (event->state == SDL_PRESSED);

// process key info, e.g. put key into a buffer and 
// store keyboard state 
}

, OpenGL: http://www.opengl.org/resources/features/fontsurvey/

, , (), .

0

, , , 2 :

. , , " " . , , (, ). , , , - , .

0

, , , ++.

For fonts, GNU Unifont has a full BMP glyph cover, available in the convenient TTF format.

0
source

Source: https://habr.com/ru/post/1717313/


All Articles