Inheritance #
- AudioServer
- CameraServer
- ClassDB
- DisplayServer
- EditorFileSystemDirectory
- EditorInterface
- EditorPaths
- EditorSelection
- EditorUndoRedoManager
- EditorVCSInterface
- Engine
- EngineDebugger
- FramebufferCacheRD
- GDExtensionManager
- Geometry2D
- Geometry3D
- IP
- Input
- InputMap
- JNISingleton
- JSONRPC
- JavaClassWrapper
- JavaScriptBridge
- MainLoop (1)
- Marshalls
- MovieWriter
- NativeMenu
- NavigationMeshGenerator
- NavigationServer2D
- NavigationServer3D
- Node (21)
- OS
- OpenXRExtensionWrapperExtension
- OpenXRInteractionProfileMetadata
- Performance
- PhysicsDirectBodyState2D (1)
- PhysicsDirectBodyState3D (1)
- PhysicsDirectSpaceState2D (1)
- PhysicsDirectSpaceState3D (1)
- PhysicsServer2D (1)
- PhysicsServer2DManager
- PhysicsServer3D (1)
- PhysicsServer3DManager
- PhysicsServer3DRendering
ServerHandler
- ProjectSettings
- RefCounted (121)
- RenderData (2)
- RenderSceneData (2)
- RenderingDevice
- RenderingServer
- ResourceLoader
- ResourceSaver
- ResourceUID
- ScriptLanguage (1)
- ShaderIncludeDB
- TextServerManager
- ThemeDB
- TileData
- Time
- TranslationServer
- TreeItem
- UndoRedo
- UniformSetCacheRD
- WorkerThreadPool
- XRServer
- XRVRS
- AESContext
- AStar2D
- AStar3D
- AStarGrid2D
- AudioEffectInstance (1)
- AudioSample
- AudioSamplePlayback
- AudioStreamPlayback (5)
- CameraFeed
- CharFXTransform
- ConfigFile
- Crypto
- DTLSServer
- DirAccess
- ENetConnection
- EditorContextMenuPlugin
- EditorDebuggerPlugin
- EditorDebuggerSession
- EditorExportPlatform (6)
- EditorExportPlugin
- EditorExportPreset
- EditorFeatureProfile
- EditorFileSystemImportFormatSupportQuery
- EditorInspectorPlugin
- EditorResourceConversionPlugin
- EditorResourcePreviewGenerator
- EditorResourceTooltipPlugin
- EditorSceneFormatImporter (4)
- EditorScenePostImport
- EditorScenePostImportPlugin
- EditorScript
- EditorTranslationParserPlugin
- EncodedObjectAsID
- EngineProfiler
- Expression
- FileAccess
- GLTFObjectModelProperty
- HMACContext
- HTTPClient
- HashingContext
- ImageFormatLoader (1)
- JavaClass
- JavaObject
- JavaScriptObject
- KinematicCollision2D
- KinematicCollision3D
- Lightmapper (1)
- MeshConvexDecompositionSettings
- MeshDataTool
- MultiplayerAPI (2)
- Mutex
- NavigationPathQueryParameters2D
- NavigationPathQueryParameters3D
- NavigationPathQueryResult2D
- NavigationPathQueryResult3D
- Node3DGizmo (1)
- OggPacketSequencePlayback
- OpenXRAPIExtension
- PCKPacker
- PackedDataContainerRef
- PacketPeer (8)
- PhysicsPointQueryParameters2D
- PhysicsPointQueryParameters3D
- PhysicsRayQueryParameters2D
- PhysicsRayQueryParameters3D
- PhysicsShapeQueryParameters2D
- PhysicsShapeQueryParameters3D
- PhysicsTestMotionParameters2D
- PhysicsTestMotionParameters3D
- PhysicsTestMotionResult2D
- PhysicsTestMotionResult3D
- RDAttachmentFormat
- RDFramebufferPass
- RDPipelineColorBlendState
- RDPipelineColorBlendStateAttachment
- RDPipelineDepthStencilState
- RDPipelineMultisampleState
- RDPipelineRasterizationState
- RDPipelineSpecializationConstant
- RDSamplerState
- RDShaderSource
- RDTextureFormat
- RDTextureView
- RDUniform
- RDVertexAttribute
- RandomNumberGenerator
- RegEx
- RegExMatch
- RenderSceneBuffers (2)
- RenderSceneBuffersConfiguration
- Resource (103)
- ResourceFormatLoader
- ResourceFormatSaver
- ResourceImporter (16)
- SceneState
- SceneTreeTimer
- Semaphore
- SkinReference
- StreamPeer (5)
- SurfaceTool
- TCPServer
- TLSOptions
- TextLine
- TextParagraph
- TextServer (1)
- Thread
- TranslationDomain
- TriangleMesh
- Tween
- Tweener (5)
- UDPServer
- UPNP
- UPNPDevice
- WeakRef
- WebRTCPeerConnection (1)
- XMLParser
- XRInterface (4)
- XRPose
- XRTracker (2)
- ZIPPacker
- ZIPReader
- Animation
- AnimationLibrary
- AnimationNode (6)
- AnimationNodeStateMachinePlayback
- AnimationNodeStateMachineTransition
- AudioBusLayout
- AudioEffect (17)
- AudioStream (10)
- BitMap
- BoneMap
- ButtonGroup
- CameraAttributes (2)
- ColorPalette
- Compositor
- CompositorEffect
- CryptoKey
- Curve
- Curve2D
- Curve3D
- EditorNode3DGizmoPlugin
- EditorSettings
- Environment
- Font (3)
- GDExtension
- GLTFAccessor
- GLTFAnimation
- GLTFBufferView
- GLTFCamera
- GLTFDocument (1)
- GLTFDocumentExtension (1)
- GLTFLight
- GLTFMesh
- GLTFNode
- GLTFPhysicsBody
- GLTFPhysicsShape
- GLTFSkeleton
- GLTFSkin
- GLTFSpecGloss
- GLTFState (1)
- GLTFTexture
- GLTFTextureSampler
- Gradient
- Image
- ImporterMesh
- InputEvent (6)
- JSON
- LabelSettings
- LightmapGIData
- Material (9)
- Mesh (4)
- MeshLibrary
- MissingResource
- MultiMesh
- NavigationMesh
- NavigationMeshSourceGeometryData2D
- NavigationMeshSourceGeometryData3D
- NavigationPolygon
- Noise (1)
- Occluder3D (5)
- OccluderPolygon2D
- OggPacketSequence
- OpenXRAction
- OpenXRActionMap
- OpenXRActionSet
- OpenXRBindingModifier (2)
- OpenXRHapticBase (1)
- OpenXRIPBinding
- OpenXRInteractionProfile
- PackedDataContainer
- PackedScene
- PhysicsMaterial
- PolygonPathFinder
- RDShaderFile
- RDShaderSPIRV
- RichTextEffect
- SceneReplicationConfig
- Script (3)
- Shader (1)
- ShaderInclude
- Shape2D (8)
- Shape3D (9)
- Shortcut
- SkeletonModification2D (7)
- SkeletonModificationStack2D
- SkeletonProfile (1)
- Skin
- Sky
- SpriteFrames
- StyleBox (4)
- SyntaxHighlighter (2)
- Texture (3)
- Theme
- TileMapPattern
- TileSet
- TileSetSource (2)
- Translation (1)
- VideoStream (1)
- VideoStreamPlayback
- VisualShaderNode (62)
- VoxelGIData
- World2D
- World3D
- X509Certificate
Table of contents
-
var allow_system_fallback: bool = true -
var antialiasing = FONT_ANTIALIASING_GRAY -
var data: PackedByteArray = PackedByteArray() -
var disable_embedded_bitmaps: bool = true -
var fixed_size: int = 0 -
var fixed_size_scale_mode = FIXED_SIZE_SCALE_DISABLE -
var font_name: String = "" -
var font_stretch: int = 100 -
var font_style: int = 0 -
var font_weight: int = 400 -
var force_autohinter: bool = false -
var generate_mipmaps: bool = false -
var hinting = HINTING_LIGHT -
var keep_rounding_remainders: bool = true -
var msdf_pixel_range: int = 16 -
var msdf_size: int = 48 -
var multichannel_signed_distance_field: bool = false -
var opentype_feature_overrides: Dictionary = {} -
var oversampling: float = 0.0 -
var style_name: String = "" -
var subpixel_positioning = SUBPIXEL_POSITIONING_AUTO -
func clear_cache() -> void -
func clear_glyphs(size: Vector2i) -> void -
func clear_kerning_map(size: int) -> void -
func clear_size_cache(cache_index: int) -> void -
func clear_textures(size: Vector2i) -> void -
const func get_cache_ascent(size: int) -> float -
const func get_cache_count() -> int -
const func get_cache_descent(size: int) -> float -
const func get_cache_scale(size: int) -> float -
const func get_cache_underline_position(size: int) -> float -
const func get_cache_underline_thickness(size: int) -> float -
const func get_char_from_glyph_index(glyph_index: int) -> int -
const func get_embolden(cache_index: int) -> float -
const func get_extra_baseline_offset(cache_index: int) -> float -
const func get_extra_spacing(spacing: int enumTextServer.SpacingType) -> int -
const func get_face_index(cache_index: int) -> int -
const func get_glyph_advance(glyph: int) -> Vector2 -
const func get_glyph_index(variation_selector: int) -> int -
const func get_glyph_list(size: Vector2i) -> PackedInt32Array -
const func get_glyph_offset(glyph: int) -> Vector2 -
const func get_glyph_size(glyph: int) -> Vector2 -
const func get_glyph_texture_idx(glyph: int) -> int -
const func get_glyph_uv_rect(glyph: int) -> Rect2 -
const func get_kerning(glyph_pair: Vector2i) -> Vector2 -
const func get_kerning_list(size: int) -> Vector2i[] -
const func get_language_support_override(language: String) -> bool -
const func get_language_support_overrides() -> PackedStringArray -
const func get_script_support_override(script: String) -> bool -
const func get_script_support_overrides() -> PackedStringArray -
const func get_size_cache_list(cache_index: int) -> Vector2i[] -
const func get_texture_count(size: Vector2i) -> int -
const func get_texture_image(texture_index: int) -> Image -
const func get_texture_offsets(texture_index: int) -> PackedInt32Array -
const func get_transform(cache_index: int) -> Transform2D -
const func get_variation_coordinates(cache_index: int) -> Dictionary -
func load_bitmap_font(path: String) -> intError -
func load_dynamic_font(path: String) -> intError -
func remove_cache(cache_index: int) -> void -
func remove_glyph(glyph: int) -> void -
func remove_kerning(glyph_pair: Vector2i) -> void -
func remove_language_support_override(language: String) -> void -
func remove_script_support_override(script: String) -> void -
func remove_size_cache(size: Vector2i) -> void -
func remove_texture(texture_index: int) -> void -
func render_glyph(index: int) -> void -
func render_range(end: int) -> void -
func set_cache_ascent(ascent: float) -> void -
func set_cache_descent(descent: float) -> void -
func set_cache_scale(scale: float) -> void -
func set_cache_underline_position(underline_position: float) -> void -
func set_cache_underline_thickness(underline_thickness: float) -> void -
func set_embolden(strength: float) -> void -
func set_extra_baseline_offset(baseline_offset: float) -> void -
func set_extra_spacing(value: int) -> void -
func set_face_index(face_index: int) -> void -
func set_glyph_advance(advance: Vector2) -> void -
func set_glyph_offset(offset: Vector2) -> void -
func set_glyph_size(gl_size: Vector2) -> void -
func set_glyph_texture_idx(texture_idx: int) -> void -
func set_glyph_uv_rect(uv_rect: Rect2) -> void -
func set_kerning(kerning: Vector2) -> void -
func set_language_support_override(supported: bool) -> void -
func set_script_support_override(supported: bool) -> void -
func set_texture_image(image: Image) -> void -
func set_texture_offsets(offset: PackedInt32Array) -> void -
func set_transform(transform: Transform2D) -> void -
func set_variation_coordinates(variation_coordinates: Dictionary) -> void
FontFile #
is_refcounted, is_instantiable, resource, core, not_builtin_classes
Holds font source data and prerendered glyph cache, imported from a dynamic or a bitmap font.
FontFile contains a set of glyphs to represent Unicode characters imported from a font file, as well as a cache of rasterized glyphs, and a set of fallback Fonts to use.
Use FontVariation to access specific OpenType variation of the font, create simulated bold / slanted version, and draw lines of text.
For more complex text processing, use FontVariation in conjunction with TextLine or TextParagraph.
Supported font formats:
- Dynamic font importer: TrueType (.ttf), TrueType collection (.ttc), OpenType (.otf), OpenType collection (.otc), WOFF (.woff), WOFF2 (.woff2), Type 1 (.pfb, .pfm).
- Bitmap font importer: AngelCode BMFont (.fnt, .font), text and binary (version 3) format variants.
- Monospace image font importer: All supported image formats.
Note: A character is a symbol that represents an item (letter, digit etc.) in an abstract way.
Note: A glyph is a bitmap or a shape used to draw one or more characters in a context-dependent manner. Glyph indices are bound to the specific font data source.
Note: If none of the font data sources contain glyphs for a character used in a string, the character in question will be replaced with a box displaying its hexadecimal code.
GDScript
var f = load("res://BarlowCondensed-Bold.ttf")
$Label.add_theme_font_override("font", f)
$Label.add_theme_font_size_override("font_size", 64)C#
var f = ResourceLoader.Load("res://BarlowCondensed-Bold.ttf");
GetNode("Label").AddThemeFontOverride("font", f);
GetNode("Label").AddThemeFontSizeOverride("font_size", 64); Members #
var allow_system_fallback: bool = true#
If set to true, system fonts can be automatically used as fallbacks.
var antialiasing = FONT_ANTIALIASING_GRAY#
Font anti-aliasing mode.
var data: PackedByteArray = PackedByteArray()#
Contents of the dynamic font source file.
var disable_embedded_bitmaps: bool = true#
If set to true, embedded font bitmap loading is disabled (bitmap-only and color fonts ignore this property).
var fixed_size: int = 0#
Font size, used only for the bitmap fonts.
var fixed_size_scale_mode = FIXED_SIZE_SCALE_DISABLE#
Scaling mode, used only for the bitmap fonts with fixed_size greater than zero.
var font_name: String = ""#
Font family name.
var font_stretch: int = 100#
Font stretch amount, compared to a normal width. A percentage value between 50% and 200%.
var font_style: int = 0#
Font style flags, see TextServer.FontStyle.
var font_weight: int = 400#
Weight (boldness) of the font. A value in the 100...999 range, normal font weight is 400, bold font weight is 700.
var force_autohinter: bool = false#
If set to true, auto-hinting is supported and preferred over font built-in hinting. Used by dynamic fonts only (MSDF fonts don't support hinting).
var generate_mipmaps: bool = false#
If set to true, generate mipmaps for the font textures.
var hinting = HINTING_LIGHT#
Font hinting mode. Used by dynamic fonts only.
var keep_rounding_remainders: bool = true#
If set to true, when aligning glyphs to the pixel boundaries rounding remainders are accumulated to ensure more uniform glyph distribution. This setting has no effect if subpixel positioning is enabled.
var msdf_pixel_range: int = 16#
The width of the range around the shape between the minimum and maximum representable signed distance. If using font outlines, msdf_pixel_range must be set to at least twice the size of the largest font outline. The default msdf_pixel_range value of 16 allows outline sizes up to 8 to look correct.
var msdf_size: int = 48#
Source font size used to generate MSDF textures. Higher values allow for more precision, but are slower to render and require more memory. Only increase this value if you notice a visible lack of precision in glyph rendering.
var multichannel_signed_distance_field: bool = false#
If set to true, glyphs of all sizes are rendered using single multichannel signed distance field (MSDF) generated from the dynamic font vector data. Since this approach does not rely on rasterizing the font every time its size changes, this allows for resizing the font in real-time without any performance penalty. Text will also not look grainy for Controls that are scaled down (or for Label3Ds viewed from a long distance). As a downside, font hinting is not available with MSDF. The lack of font hinting may result in less crisp and less readable fonts at small sizes.
Note: If using font outlines, msdf_pixel_range must be set to at least twice the size of the largest font outline.
Note: MSDF font rendering does not render glyphs with overlapping shapes correctly. Overlapping shapes are not valid per the OpenType standard, but are still commonly found in many font files, especially those converted by Google Fonts. To avoid issues with overlapping glyphs, consider downloading the font file directly from the type foundry instead of relying on Google Fonts.
var opentype_feature_overrides: Dictionary = {}#
Font OpenType feature set override.
var oversampling: float = 0.0#
Font oversampling factor. If set to 0.0, the global oversampling factor is used instead. Used by dynamic fonts only (MSDF fonts ignore oversampling).
var style_name: String = ""#
Font style name.
var subpixel_positioning = SUBPIXEL_POSITIONING_AUTO#
Font glyph subpixel positioning mode. Subpixel positioning provides shaper text and better kerning for smaller font sizes, at the cost of higher memory usage and lower font rasterization speed. Use TextServer.SUBPIXEL_POSITIONING_AUTO to automatically enable it based on the font size.
Methods #
func clear_cache() -> void#
Removes all font cache entries.
func clear_glyphs(size: Vector2i) -> void#
Removes all rendered glyph information from the cache entry.
Note: This function will not remove textures associated with the glyphs, use remove_texture to remove them manually.
func clear_kerning_map(size: int) -> void#
Removes all kerning overrides.
func clear_size_cache(cache_index: int) -> void#
Removes all font sizes from the cache entry.
func clear_textures(size: Vector2i) -> void#
Removes all textures from font cache entry.
Note: This function will not remove glyphs associated with the texture, use remove_glyph to remove them manually.
const func get_cache_ascent(size: int) -> float#
Returns the font ascent (number of pixels above the baseline).
const func get_cache_count() -> int#
Returns number of the font cache entries.
const func get_cache_descent(size: int) -> float#
Returns the font descent (number of pixels below the baseline).
const func get_cache_scale(size: int) -> float#
Returns scaling factor of the color bitmap font.
const func get_cache_underline_position(size: int) -> float#
Returns pixel offset of the underline below the baseline.
const func get_cache_underline_thickness(size: int) -> float#
Returns thickness of the underline in pixels.
const func get_char_from_glyph_index(glyph_index: int) -> int#
Returns character code associated with glyph_index, or 0 if glyph_index is invalid. See get_glyph_index.
const func get_embolden(cache_index: int) -> float#
Returns embolden strength, if is not equal to zero, emboldens the font outlines. Negative values reduce the outline thickness.
const func get_extra_baseline_offset(cache_index: int) -> float#
Returns extra baseline offset (as a fraction of font height).
const func get_extra_spacing(spacing: int enumTextServer.SpacingType) -> int#
Returns spacing for spacing (see TextServer.SpacingType) in pixels (not relative to the font size).
const func get_face_index(cache_index: int) -> int#
Returns an active face index in the TrueType / OpenType collection.
const func get_glyph_advance(glyph: int) -> Vector2#
Returns glyph advance (offset of the next glyph).
Note: Advance for glyphs outlines is the same as the base glyph advance and is not saved.
const func get_glyph_index(variation_selector: int) -> int#
Returns the glyph index of a char, optionally modified by the variation_selector.
const func get_glyph_list(size: Vector2i) -> PackedInt32Array#
Returns list of rendered glyphs in the cache entry.
const func get_glyph_offset(glyph: int) -> Vector2#
Returns glyph offset from the baseline.
const func get_glyph_size(glyph: int) -> Vector2#
Returns glyph size.
const func get_glyph_texture_idx(glyph: int) -> int#
Returns index of the cache texture containing the glyph.
const func get_glyph_uv_rect(glyph: int) -> Rect2#
Returns rectangle in the cache texture containing the glyph.
const func get_kerning(glyph_pair: Vector2i) -> Vector2#
Returns kerning for the pair of glyphs.
const func get_kerning_list(size: int) -> Vector2i[]#
Returns list of the kerning overrides.
const func get_language_support_override(language: String) -> bool#
Returns true if support override is enabled for the language.
const func get_language_support_overrides() -> PackedStringArray#
Returns list of language support overrides.
const func get_script_support_override(script: String) -> bool#
Returns true if support override is enabled for the script.
const func get_script_support_overrides() -> PackedStringArray#
Returns list of script support overrides.
const func get_size_cache_list(cache_index: int) -> Vector2i[]#
Returns list of the font sizes in the cache. Each size is Vector2i with font size and outline size.
const func get_texture_count(size: Vector2i) -> int#
Returns number of textures used by font cache entry.
const func get_texture_image(texture_index: int) -> Image#
Returns a copy of the font cache texture image.
const func get_texture_offsets(texture_index: int) -> PackedInt32Array#
Returns a copy of the array containing glyph packing data.
const func get_transform(cache_index: int) -> Transform2D#
Returns 2D transform, applied to the font outlines, can be used for slanting, flipping and rotating glyphs.
const func get_variation_coordinates(cache_index: int) -> Dictionary#
Returns variation coordinates for the specified font cache entry. See Font.get_supported_variation_list for more info.
func load_bitmap_font(path: String) -> intError#
Loads an AngelCode BMFont (.fnt, .font) bitmap font from file path.
Warning: This method should only be used in the editor or in cases when you need to load external fonts at run-time, such as fonts located at the user:// directory.
func load_dynamic_font(path: String) -> intError#
Loads a TrueType (.ttf), OpenType (.otf), WOFF (.woff), WOFF2 (.woff2) or Type 1 (.pfb, .pfm) dynamic font from file path.
Warning: This method should only be used in the editor or in cases when you need to load external fonts at run-time, such as fonts located at the user:// directory.
func remove_cache(cache_index: int) -> void#
Removes specified font cache entry.
func remove_glyph(glyph: int) -> void#
Removes specified rendered glyph information from the cache entry.
Note: This function will not remove textures associated with the glyphs, use remove_texture to remove them manually.
func remove_kerning(glyph_pair: Vector2i) -> void#
Removes kerning override for the pair of glyphs.
func remove_language_support_override(language: String) -> void#
Remove language support override.
func remove_script_support_override(script: String) -> void#
Removes script support override.
func remove_size_cache(size: Vector2i) -> void#
Removes specified font size from the cache entry.
func remove_texture(texture_index: int) -> void#
Removes specified texture from the cache entry.
Note: This function will not remove glyphs associated with the texture. Remove them manually using remove_glyph.
func render_glyph(index: int) -> void#
Renders specified glyph to the font cache texture.
func render_range(end: int) -> void#
Renders the range of characters to the font cache texture.
func set_cache_ascent(ascent: float) -> void#
Sets the font ascent (number of pixels above the baseline).
func set_cache_descent(descent: float) -> void#
Sets the font descent (number of pixels below the baseline).
func set_cache_scale(scale: float) -> void#
Sets scaling factor of the color bitmap font.
func set_cache_underline_position(underline_position: float) -> void#
Sets pixel offset of the underline below the baseline.
func set_cache_underline_thickness(underline_thickness: float) -> void#
Sets thickness of the underline in pixels.
func set_embolden(strength: float) -> void#
Sets embolden strength, if is not equal to zero, emboldens the font outlines. Negative values reduce the outline thickness.
func set_extra_baseline_offset(baseline_offset: float) -> void#
Sets extra baseline offset (as a fraction of font height).
func set_extra_spacing(value: int) -> void#
Sets the spacing for spacing (see TextServer.SpacingType) to value in pixels (not relative to the font size).
func set_face_index(face_index: int) -> void#
Sets an active face index in the TrueType / OpenType collection.
func set_glyph_advance(advance: Vector2) -> void#
Sets glyph advance (offset of the next glyph).
Note: Advance for glyphs outlines is the same as the base glyph advance and is not saved.
func set_glyph_offset(offset: Vector2) -> void#
Sets glyph offset from the baseline.
func set_glyph_size(gl_size: Vector2) -> void#
Sets glyph size.
func set_glyph_texture_idx(texture_idx: int) -> void#
Sets index of the cache texture containing the glyph.
func set_glyph_uv_rect(uv_rect: Rect2) -> void#
Sets rectangle in the cache texture containing the glyph.
func set_kerning(kerning: Vector2) -> void#
Sets kerning for the pair of glyphs.
func set_language_support_override(supported: bool) -> void#
Adds override for Font.is_language_supported.
func set_script_support_override(supported: bool) -> void#
Adds override for Font.is_script_supported.
func set_texture_image(image: Image) -> void#
Sets font cache texture image.
func set_texture_offsets(offset: PackedInt32Array) -> void#
Sets array containing glyph packing data.
func set_transform(transform: Transform2D) -> void#
Sets 2D transform, applied to the font outlines, can be used for slanting, flipping, and rotating glyphs.
func set_variation_coordinates(variation_coordinates: Dictionary) -> void#
Sets variation coordinates for the specified font cache entry. See Font.get_supported_variation_list for more info.