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 —
TCastleComponent
,TCastleTransform
,TCastleUserInterace
etc. It is similar to VCL/LCL non-visual components: it doesn’t really matter where you drop them on the form. -
Then assign this font to TCastleLabel.CustomFont. Or any other UI control descending from TCastleUserInterfaceFont, like TCastleButton or TCastleEdit.
New property TCastleText.CustomFont is also available, and you can also assign to it using CGE editor. This allows to adjust the (potentially 3D)
TCastleText
in 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:
TCastleFontFamily
has been moved toCastleFonts
unit, andTRichText
has been moved toCastleInternalRichText
unit andCastleFontFamily
unit has been deprecated. In effect: user code needs to use 1 less unit (no need to useCastleFontFamily
unit), and some internal things (TRichText
and friends) have been hidden to make API easier. -
-
TCastleFont gets new comfortable properties:
-
URL (font file URL, e.g. TTF or OTF),
-
LoadBasicCharacters to control the loaded font.
-
-
TCastleBitmapFont gets comfortable properties:
-
When the font is not loaded (e.g.
TCastleFont.URL
was not set, orTCastleFontFamily
hasTCastleFontFamily.Regular
not set) then we always display some default font (Window.Container.DefaultFont
, falling back on global defaultUIFont
) to avoid having invisible e.g.TCastleLabel
. -
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.
-
TCastleText
is 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.
Start the discussion at Castle Game Engine Forum