Is there any way to change the default font file of all UI components in the entire view? If setting it in the UI causes slow game entry and slow UI opening, I can only manually adjust it ChrName.CustomFont := g_GameFont;
ChrGrade.CustomFont := g_GameFont;
ChrJob.CustomFont := g_GameFont; But the components are very accurate. Is there any way to directly set the default font file for this view?, The current method is to start reading configuration file settings, but it affects the speed of entering the game
You can use Customize look by CastleSettings.xml | Manual | Castle Game Engine to change the default font of the entire application.
But I understand this may be too much, you say you only want to change given view. You can use a routine like this (adapted from castle-engine/src/ui/castlecontrols_uifont.inc at 6d619d93a51e5b80a6494f17672427a50fc77100 · castle-engine/castle-engine · GitHub ):
procedure ForceMyFont(const Ui: TCastleUserInterface; const MyFont: TCastleFont);
var
Child: TCastleUserInterface;
begin
if Ui is TCastleUserInterfaceFont then
TCastleUserInterfaceFont(Ui).CustomFont := MyFont;
for Child in Ui do
ForceMyFont(Child, MyFont);
end;
From you view’s Start
method just call it like ForceMyFont(Self, MyFont)
.
Thank you.