You can now add and configure fonts in CGE editor.
Use the “Design -> Add Non-Visual Component” menu item, or the context menu (when you right-click in the hierarchy on the left). Font is added as “Non-Visual Component” to whatever parent you selected.
The parent that keeps reference to the font node can be anything —
TCastleUserInteraceetc. It is similar to VCL/LCL non-visual components: it doesn’t really matter where you drop them on the form.
New property TCastleText.CustomFont is also available, and you can also assign to it using CGE editor. This allows to adjust the (potentially 3D)
TCastleTextin the same way.
Along with this change, we upgrade our font classes:
Renames to better names:
TCastleFont -> TCastleAbstractFont
TTextureFont -> TCastleFont (definitely the most common font class you will use)
TSimpleTextureFont -> TCastleBitmapFont
TFontFamily -> TCastleFontFamily
TCustomizedFont -> for now not renamed and not published in CGE editor, as it doesn’t seem critical enough, use-case is only to provide multiple alternative “optimal sizes”. We may integrate this use-case into TCastleFont one day.
Some unit cleanup has been done by the way:
TCastleFontFamilyhas been moved to
TRichTexthas been moved to
CastleFontFamilyunit has been deprecated. In effect: user code needs to use 1 less unit (no need to use
CastleFontFamilyunit), and some internal things (
TRichTextand friends) have been hidden to make API easier.
TCastleFont gets new comfortable properties:
TCastleBitmapFont gets comfortable properties:
When the font is not loaded (e.g.
TCastleFont.URLwas not set, or
TCastleFontFamily.Regularnot set) then we always display some default font (
Window.Container.DefaultFont, falling back on global default
UIFont) to avoid having invisible e.g.
As usual, assigning URL to ” (empty) is allowed and valid way to just “unload” the font.
FreeType version distributed in our Windows DLLs has been updated.
TCastleTextis now a sans-serif font by default. This follows the UI default fonts.
See examples, e.g. examples/fonts/text_tests for initial demos of it.
TODO: Manual page about text and fonts will be soon updated to reflect all of the above.