TCastleFont LoadCharacters problem

  • How to use TCastleFont load font character file All of the words within directly mounted to the font Without the need for each TCastleFont. LoadCharacters = * * * can be normal use

There is no option to do exactly that yet. We plan to have more options to load characters in the future – to load “everything from the font” (as you ask) or load “sections, on demand, when they are used by the text”.

For now, we always load glyphs you explicitly request. Which is, by default, basic ASCII + all characters you put in LoadCharacters.

The simplest solution for now is to just fill LoadCharacters will everything you need. You can do it from code, you can load any file(s) that have all the characters you need. See what castle-engine/tools/texture-font-to-pascal/texture-font-to-pascal.lpr at master · castle-engine/castle-engine · GitHub does :slight_smile:

  • Creates Characters: TUnicodeCharList instance

  • Add there characters from indicated file using Characters.Add(FileToString('castle-data:/my_file.txt'))

  • You can then convert them to a simple string using Characters.ToString , so e.g. set MyFont.LoadCharacters := MyCharactersList.ToString; .

The default fonts in CGE are loaded with all characters from this file: castle-engine/src/fonts/common_unicode_chars.txt at master · castle-engine/castle-engine · GitHub . You can literally use this file, i.e. place it in your data, and add all characters using e.g. Characters.Add(FileToString('castle-data:/common_unicode_chars.txt')) from code.