Class TCastleUserInterfaceFont

Unit

Declaration

type TCastleUserInterfaceFont = class(TCastleUserInterface)

Description

Base class for all user interface controls using a font. Allows to customize font and font size per-control, or use defaults.

Hierarchy

Overview

Methods

Protected procedure UIScaleChanged; override;
Protected procedure Notification(AComponent: TComponent; Operation: TOperation); override;
Public constructor Create(AOwner: TComponent); override;
Public destructor Destroy; override;
Public procedure GLContextClose; override;
Public function TooltipExists: boolean; override;
Public procedure TooltipRender; override;
Public procedure Render; override;
Public function PropertySection(const PropertyName: String): TPropertySection; override;
Public procedure AssignFont(const Source: TCastleUserInterfaceFont);
Public function Font: TCastleFont;
Public procedure CheckFontChanged;
Public procedure FontChanged; virtual;

Properties

Public property OwnsCustomFont: boolean read FOwnsCustomFont write FOwnsCustomFont default false; deprecated 'use TCastleFont (inherited from TComponent) owner mechanism';
Public property SmallFont: boolean read FSmallFont write SetSmallFont default false; deprecated 'use "FontScale := 0.5" or "CustomFont := MySmalFont" instead of "SmallFont := true", this is more flexible';
Public property OutlineColor: TCastleColor read FOutlineColor write SetOutlineColor;
Published property Tooltip: string read FTooltip write FTooltip;
Published property CustomFont: TCastleFont read FCustomFont write SetCustomFont;
Published property FontSize: Single read FFontSize write SetFontSize default 0.0;
Published property FontScale: Single read FFontScale write SetFontScale default 1.0;
Published property Outline: Cardinal read FOutline write SetOutline default 0;
Published property OutlineHighQuality: boolean read FOutlineHighQuality write SetOutlineHighQuality default false;
Published property OutlineColorPersistent: TCastleColorPersistent read FOutlineColorPersistent ;

Description

Methods

Protected procedure UIScaleChanged; override;
 
Protected procedure Notification(AComponent: TComponent; Operation: TOperation); override;
 
Public constructor Create(AOwner: TComponent); override;
 
Public destructor Destroy; override;
 
Public procedure GLContextClose; override;
 
Public function TooltipExists: boolean; override;
 
Public procedure TooltipRender; override;
 
Public procedure Render; override;
 
Public function PropertySection(const PropertyName: String): TPropertySection; override;
 
Public procedure AssignFont(const Source: TCastleUserInterfaceFont);

Copy font properties from another control.

Public function Font: TCastleFont;

Font used for rendering and measuring this control.

Depending on which one is set, this method returns CustomFont or TUIContainer.DefaultFont or global UIFont. It may also return a TFontFamily instance that wraps (and scales) one of them.

Public procedure CheckFontChanged;

Check does currently used font (see Font) changed, and eventually call FontChanged method now.

You only need to explicitly call this in very specific circumstances, when you just changed UIFont or TUIContainer.DefaultFont and you want control size to be updated immediately (for example, you need EffectiveHeight to be immediately valid). Without calling this, it could be updated only at next Render call.

Changing CustomFont automatically calls this.

Public procedure FontChanged; virtual;

Force considering font changed (font instance, or glyphs, or sizes changed).

Usually, you don't need to call this explicitly from the outside. Changing font, like CustomFont or TUIContainer.DefaultFont or UIFont, or any property that may affect the font is automatically applied.

But there are exceptions: right now, if you call Load on a font, it's measurements will change but some controls using it will not recalculate sizes automatically. In this case, call this method.

Properties

Public property OwnsCustomFont: boolean read FOwnsCustomFont write FOwnsCustomFont default false; deprecated 'use TCastleFont (inherited from TComponent) owner mechanism';

Warning: this symbol is deprecated: use TCastleFont (inherited from TComponent) owner mechanism

 
Public property SmallFont: boolean read FSmallFont write SetSmallFont default false; deprecated 'use "FontScale := 0.5" or "CustomFont := MySmalFont" instead of "SmallFont := true", this is more flexible';

Warning: this symbol is deprecated: use "FontScale := 0.5" or "CustomFont := MySmalFont" instead of "SmallFont := true", this is more flexible

Use smaller font. Right now this just says to scale font by 0.5.

Public property OutlineColor: TCastleColor read FOutlineColor write SetOutlineColor;

Outline color, used only if Outline <> 0. Default is black.

See also
Outline
Outline size around the font.
Published property Tooltip: string read FTooltip write FTooltip;

Tooltip string, displayed when user hovers the mouse over a control.

Note that you can override TCastleUserInterface.TooltipExists and TCastleUserInterface.TooltipStyle and TCastleUserInterface.TooltipRender to customize the tooltip drawing.

Published property CustomFont: TCastleFont read FCustomFont write SetCustomFont;

When non-nil, this font will be used to draw this control. Otherwise the TUIContainer.DefaultFont will be used, or the global UIFont.

Published property FontSize: Single read FFontSize write SetFontSize default 0.0;

Use given font size when drawing. Leave at default zero to use the default size of the current font.

Published property FontScale: Single read FFontScale write SetFontScale default 1.0;

Scale the font. This additionally scales the font defined by all other properties of this class, thus you can use it to reliably scale the font (regardless if you use CustomFont or not, regardless if you set FontSize or not).

Published property Outline: Cardinal read FOutline write SetOutline default 0;

Outline size around the font. Note that the current implementation is very simple, it will only look sensible for small outline values (like 1 or 2).

See TCastleFont.Outline for more details.

Specifying a non-zero outline for a label overrides the default outline settings for the current font. By default, fonts do not have an outline.

TODO: UI scaling (TUIContainer.UIScaling) doesn't affect outline size now.

See also
OutlineHighQuality
Optionally force better outline quality.
Published property OutlineHighQuality: boolean read FOutlineHighQuality write SetOutlineHighQuality default false;

Optionally force better outline quality. Used only if Outline <> 0. High quality outline looks better, but is about 2x more expensive to draw.

See also
Outline
Outline size around the font.
Published property OutlineColorPersistent: TCastleColorPersistent read FOutlineColorPersistent ;

OutlineColor that can be visually edited in Castle Game Engine Editor, Lazarus and Delphi. Normal user code does not need to deal with this, instead read or write OutlineColor directly.

See also
OutlineColor
Outline color, used only if Outline <> 0.

Generated by PasDoc 0.15.0.