FontFile

package
v0.0.0-...-c909628 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2025 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package FontFile provides methods for working with FontFile object instances.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type Any

type Any interface {
	gd.IsClass
	AsFontFile() Instance
}

type Instance

type Instance [1]gdclass.FontFile

[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 [Font]s 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. [b]Note:[/b] A character is a symbol that represents an item (letter, digit etc.) in an abstract way. [b]Note:[/b] 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. [b]Note:[/b] 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. [codeblocks] [gdscript] var f = load("res://BarlowCondensed-Bold.ttf") $Label.add_theme_font_override("font", f) $Label.add_theme_font_size_override("font_size", 64) [/gdscript] [csharp] var f = ResourceLoader.Load<FontFile>("res://BarlowCondensed-Bold.ttf"); GetNode("Label").AddThemeFontOverride("font", f); GetNode("Label").AddThemeFontSizeOverride("font_size", 64); [/csharp] [/codeblocks]

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AllowSystemFallback

func (self Instance) AllowSystemFallback() bool

func (Instance) Antialiasing

func (self Instance) Antialiasing() gdclass.TextServerFontAntialiasing

func (Instance) AsFont

func (self Instance) AsFont() Font.Instance

func (Instance) AsFontFile

func (self Instance) AsFontFile() Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsRefCounted

func (self Instance) AsRefCounted() [1]gd.RefCounted

func (Instance) AsResource

func (self Instance) AsResource() Resource.Instance

func (Instance) ClearCache

func (self Instance) ClearCache()

Removes all font cache entries.

func (Instance) ClearGlyphs

func (self Instance) ClearGlyphs(cache_index int, size Vector2i.XY)

Removes all rendered glyph information from the cache entry. [b]Note:[/b] This function will not remove textures associated with the glyphs, use [method remove_texture] to remove them manually.

func (Instance) ClearKerningMap

func (self Instance) ClearKerningMap(cache_index int, size int)

Removes all kerning overrides.

func (Instance) ClearSizeCache

func (self Instance) ClearSizeCache(cache_index int)

Removes all font sizes from the cache entry

func (Instance) ClearTextures

func (self Instance) ClearTextures(cache_index int, size Vector2i.XY)

Removes all textures from font cache entry. [b]Note:[/b] This function will not remove glyphs associated with the texture, use [method remove_glyph] to remove them manually.

func (Instance) Data

func (self Instance) Data() []byte

func (Instance) DisableEmbeddedBitmaps

func (self Instance) DisableEmbeddedBitmaps() bool

func (Instance) FixedSize

func (self Instance) FixedSize() int

func (Instance) FixedSizeScaleMode

func (self Instance) FixedSizeScaleMode() gdclass.TextServerFixedSizeScaleMode

func (Instance) ForceAutohinter

func (self Instance) ForceAutohinter() bool

func (Instance) GenerateMipmaps

func (self Instance) GenerateMipmaps() bool

func (Instance) GetCacheAscent

func (self Instance) GetCacheAscent(cache_index int, size int) Float.X

Returns the font ascent (number of pixels above the baseline).

func (Instance) GetCacheCount

func (self Instance) GetCacheCount() int

Returns number of the font cache entries.

func (Instance) GetCacheDescent

func (self Instance) GetCacheDescent(cache_index int, size int) Float.X

Returns the font descent (number of pixels below the baseline).

func (Instance) GetCacheScale

func (self Instance) GetCacheScale(cache_index int, size int) Float.X

Returns scaling factor of the color bitmap font.

func (Instance) GetCacheUnderlinePosition

func (self Instance) GetCacheUnderlinePosition(cache_index int, size int) Float.X

Returns pixel offset of the underline below the baseline.

func (Instance) GetCacheUnderlineThickness

func (self Instance) GetCacheUnderlineThickness(cache_index int, size int) Float.X

Returns thickness of the underline in pixels.

func (Instance) GetCharFromGlyphIndex

func (self Instance) GetCharFromGlyphIndex(size int, glyph_index int) int

Returns character code associated with [param glyph_index], or [code]0[/code] if [param glyph_index] is invalid. See [method get_glyph_index].

func (Instance) GetEmbolden

func (self Instance) GetEmbolden(cache_index int) Float.X

Returns embolden strength, if is not equal to zero, emboldens the font outlines. Negative values reduce the outline thickness.

func (Instance) GetExtraBaselineOffset

func (self Instance) GetExtraBaselineOffset(cache_index int) Float.X

Returns extra baseline offset (as a fraction of font height).

func (Instance) GetExtraSpacing

func (self Instance) GetExtraSpacing(cache_index int, spacing gdclass.TextServerSpacingType) int

Returns spacing for [param spacing] (see [enum TextServer.SpacingType]) in pixels (not relative to the font size).

func (Instance) GetFaceIndex

func (self Instance) GetFaceIndex(cache_index int) int

Returns an active face index in the TrueType / OpenType collection.

func (Instance) GetGlyphAdvance

func (self Instance) GetGlyphAdvance(cache_index int, size int, glyph int) Vector2.XY

Returns glyph advance (offset of the next glyph). [b]Note:[/b] Advance for glyphs outlines is the same as the base glyph advance and is not saved.

func (Instance) GetGlyphIndex

func (self Instance) GetGlyphIndex(size int, char int, variation_selector int) int

Returns the glyph index of a [param char], optionally modified by the [param variation_selector].

func (Instance) GetGlyphList

func (self Instance) GetGlyphList(cache_index int, size Vector2i.XY) []int32

Returns list of rendered glyphs in the cache entry.

func (Instance) GetGlyphOffset

func (self Instance) GetGlyphOffset(cache_index int, size Vector2i.XY, glyph int) Vector2.XY

Returns glyph offset from the baseline.

func (Instance) GetGlyphSize

func (self Instance) GetGlyphSize(cache_index int, size Vector2i.XY, glyph int) Vector2.XY

Returns glyph size.

func (Instance) GetGlyphTextureIdx

func (self Instance) GetGlyphTextureIdx(cache_index int, size Vector2i.XY, glyph int) int

Returns index of the cache texture containing the glyph.

func (Instance) GetGlyphUvRect

func (self Instance) GetGlyphUvRect(cache_index int, size Vector2i.XY, glyph int) Rect2.PositionSize

Returns rectangle in the cache texture containing the glyph.

func (Instance) GetKerning

func (self Instance) GetKerning(cache_index int, size int, glyph_pair Vector2i.XY) Vector2.XY

Returns kerning for the pair of glyphs.

func (Instance) GetKerningList

func (self Instance) GetKerningList(cache_index int, size int) []Vector2i.XY

Returns list of the kerning overrides.

func (Instance) GetLanguageSupportOverride

func (self Instance) GetLanguageSupportOverride(language string) bool

Returns [code]true[/code] if support override is enabled for the [param language].

func (Instance) GetLanguageSupportOverrides

func (self Instance) GetLanguageSupportOverrides() []string

Returns list of language support overrides.

func (Instance) GetScriptSupportOverride

func (self Instance) GetScriptSupportOverride(script string) bool

Returns [code]true[/code] if support override is enabled for the [param script].

func (Instance) GetScriptSupportOverrides

func (self Instance) GetScriptSupportOverrides() []string

Returns list of script support overrides.

func (Instance) GetSizeCacheList

func (self Instance) GetSizeCacheList(cache_index int) []Vector2i.XY

Returns list of the font sizes in the cache. Each size is [Vector2i] with font size and outline size.

func (Instance) GetTextureCount

func (self Instance) GetTextureCount(cache_index int, size Vector2i.XY) int

Returns number of textures used by font cache entry.

func (Instance) GetTextureImage

func (self Instance) GetTextureImage(cache_index int, size Vector2i.XY, texture_index int) [1]gdclass.Image

Returns a copy of the font cache texture image.

func (Instance) GetTextureOffsets

func (self Instance) GetTextureOffsets(cache_index int, size Vector2i.XY, texture_index int) []int32

Returns a copy of the array containing glyph packing data.

func (Instance) GetTransform

func (self Instance) GetTransform(cache_index int) Transform2D.OriginXY

Returns 2D transform, applied to the font outlines, can be used for slanting, flipping and rotating glyphs.

func (Instance) GetVariationCoordinates

func (self Instance) GetVariationCoordinates(cache_index int) map[string]float32

Returns variation coordinates for the specified font cache entry. See [method Font.get_supported_variation_list] for more info.

func (Instance) Hinting

func (self Instance) Hinting() gdclass.TextServerHinting

func (Instance) LoadBitmapFont

func (self Instance) LoadBitmapFont(path string) error

Loads an AngelCode BMFont (.fnt, .font) bitmap font from file [param path]. [b]Warning:[/b] 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 [code]user://[/code] directory.

func (Instance) LoadDynamicFont

func (self Instance) LoadDynamicFont(path string) error

Loads a TrueType (.ttf), OpenType (.otf), WOFF (.woff), WOFF2 (.woff2) or Type 1 (.pfb, .pfm) dynamic font from file [param path]. [b]Warning:[/b] 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 [code]user://[/code] directory.

func (Instance) MsdfPixelRange

func (self Instance) MsdfPixelRange() int

func (Instance) MsdfSize

func (self Instance) MsdfSize() int

func (Instance) MultichannelSignedDistanceField

func (self Instance) MultichannelSignedDistanceField() bool

func (Instance) OpentypeFeatureOverrides

func (self Instance) OpentypeFeatureOverrides() map[any]any

func (Instance) Oversampling

func (self Instance) Oversampling() Float.X

func (Instance) RemoveCache

func (self Instance) RemoveCache(cache_index int)

Removes specified font cache entry.

func (Instance) RemoveGlyph

func (self Instance) RemoveGlyph(cache_index int, size Vector2i.XY, glyph int)

Removes specified rendered glyph information from the cache entry. [b]Note:[/b] This function will not remove textures associated with the glyphs, use [method remove_texture] to remove them manually.

func (Instance) RemoveKerning

func (self Instance) RemoveKerning(cache_index int, size int, glyph_pair Vector2i.XY)

Removes kerning override for the pair of glyphs.

func (Instance) RemoveLanguageSupportOverride

func (self Instance) RemoveLanguageSupportOverride(language string)

Remove language support override.

func (Instance) RemoveScriptSupportOverride

func (self Instance) RemoveScriptSupportOverride(script string)

Removes script support override.

func (Instance) RemoveSizeCache

func (self Instance) RemoveSizeCache(cache_index int, size Vector2i.XY)

Removes specified font size from the cache entry.

func (Instance) RemoveTexture

func (self Instance) RemoveTexture(cache_index int, size Vector2i.XY, texture_index int)

Removes specified texture from the cache entry. [b]Note:[/b] This function will not remove glyphs associated with the texture. Remove them manually using [method remove_glyph].

func (Instance) RenderGlyph

func (self Instance) RenderGlyph(cache_index int, size Vector2i.XY, index int)

Renders specified glyph to the font cache texture.

func (Instance) RenderRange

func (self Instance) RenderRange(cache_index int, size Vector2i.XY, start int, end int)

Renders the range of characters to the font cache texture.

func (Instance) SetAllowSystemFallback

func (self Instance) SetAllowSystemFallback(value bool)

func (Instance) SetAntialiasing

func (self Instance) SetAntialiasing(value gdclass.TextServerFontAntialiasing)

func (Instance) SetCacheAscent

func (self Instance) SetCacheAscent(cache_index int, size int, ascent Float.X)

Sets the font ascent (number of pixels above the baseline).

func (Instance) SetCacheDescent

func (self Instance) SetCacheDescent(cache_index int, size int, descent Float.X)

Sets the font descent (number of pixels below the baseline).

func (Instance) SetCacheScale

func (self Instance) SetCacheScale(cache_index int, size int, scale Float.X)

Sets scaling factor of the color bitmap font.

func (Instance) SetCacheUnderlinePosition

func (self Instance) SetCacheUnderlinePosition(cache_index int, size int, underline_position Float.X)

Sets pixel offset of the underline below the baseline.

func (Instance) SetCacheUnderlineThickness

func (self Instance) SetCacheUnderlineThickness(cache_index int, size int, underline_thickness Float.X)

Sets thickness of the underline in pixels.

func (Instance) SetData

func (self Instance) SetData(value []byte)

func (Instance) SetDisableEmbeddedBitmaps

func (self Instance) SetDisableEmbeddedBitmaps(value bool)

func (Instance) SetEmbolden

func (self Instance) SetEmbolden(cache_index int, strength Float.X)

Sets embolden strength, if is not equal to zero, emboldens the font outlines. Negative values reduce the outline thickness.

func (Instance) SetExtraBaselineOffset

func (self Instance) SetExtraBaselineOffset(cache_index int, baseline_offset Float.X)

Sets extra baseline offset (as a fraction of font height).

func (Instance) SetExtraSpacing

func (self Instance) SetExtraSpacing(cache_index int, spacing gdclass.TextServerSpacingType, value int)

Sets the spacing for [param spacing] (see [enum TextServer.SpacingType]) to [param value] in pixels (not relative to the font size).

func (Instance) SetFaceIndex

func (self Instance) SetFaceIndex(cache_index int, face_index int)

Sets an active face index in the TrueType / OpenType collection.

func (Instance) SetFixedSize

func (self Instance) SetFixedSize(value int)

func (Instance) SetFixedSizeScaleMode

func (self Instance) SetFixedSizeScaleMode(value gdclass.TextServerFixedSizeScaleMode)

func (Instance) SetFontName

func (self Instance) SetFontName(value string)

func (Instance) SetFontStretch

func (self Instance) SetFontStretch(value int)

func (Instance) SetFontStyle

func (self Instance) SetFontStyle(value gdclass.TextServerFontStyle)

func (Instance) SetFontWeight

func (self Instance) SetFontWeight(value int)

func (Instance) SetForceAutohinter

func (self Instance) SetForceAutohinter(value bool)

func (Instance) SetGenerateMipmaps

func (self Instance) SetGenerateMipmaps(value bool)

func (Instance) SetGlyphAdvance

func (self Instance) SetGlyphAdvance(cache_index int, size int, glyph int, advance Vector2.XY)

Sets glyph advance (offset of the next glyph). [b]Note:[/b] Advance for glyphs outlines is the same as the base glyph advance and is not saved.

func (Instance) SetGlyphOffset

func (self Instance) SetGlyphOffset(cache_index int, size Vector2i.XY, glyph int, offset Vector2.XY)

Sets glyph offset from the baseline.

func (Instance) SetGlyphSize

func (self Instance) SetGlyphSize(cache_index int, size Vector2i.XY, glyph int, gl_size Vector2.XY)

Sets glyph size.

func (Instance) SetGlyphTextureIdx

func (self Instance) SetGlyphTextureIdx(cache_index int, size Vector2i.XY, glyph int, texture_idx int)

Sets index of the cache texture containing the glyph.

func (Instance) SetGlyphUvRect

func (self Instance) SetGlyphUvRect(cache_index int, size Vector2i.XY, glyph int, uv_rect Rect2.PositionSize)

Sets rectangle in the cache texture containing the glyph.

func (Instance) SetHinting

func (self Instance) SetHinting(value gdclass.TextServerHinting)

func (Instance) SetKerning

func (self Instance) SetKerning(cache_index int, size int, glyph_pair Vector2i.XY, kerning Vector2.XY)

Sets kerning for the pair of glyphs.

func (Instance) SetLanguageSupportOverride

func (self Instance) SetLanguageSupportOverride(language string, supported bool)

Adds override for [method Font.is_language_supported].

func (Instance) SetMsdfPixelRange

func (self Instance) SetMsdfPixelRange(value int)

func (Instance) SetMsdfSize

func (self Instance) SetMsdfSize(value int)

func (Instance) SetMultichannelSignedDistanceField

func (self Instance) SetMultichannelSignedDistanceField(value bool)

func (Instance) SetOpentypeFeatureOverrides

func (self Instance) SetOpentypeFeatureOverrides(value map[any]any)

func (Instance) SetOversampling

func (self Instance) SetOversampling(value Float.X)

func (Instance) SetScriptSupportOverride

func (self Instance) SetScriptSupportOverride(script string, supported bool)

Adds override for [method Font.is_script_supported].

func (Instance) SetStyleName

func (self Instance) SetStyleName(value string)

func (Instance) SetSubpixelPositioning

func (self Instance) SetSubpixelPositioning(value gdclass.TextServerSubpixelPositioning)

func (Instance) SetTextureImage

func (self Instance) SetTextureImage(cache_index int, size Vector2i.XY, texture_index int, image [1]gdclass.Image)

Sets font cache texture image.

func (Instance) SetTextureOffsets

func (self Instance) SetTextureOffsets(cache_index int, size Vector2i.XY, texture_index int, offset []int32)

Sets array containing glyph packing data.

func (Instance) SetTransform

func (self Instance) SetTransform(cache_index int, transform Transform2D.OriginXY)

Sets 2D transform, applied to the font outlines, can be used for slanting, flipping, and rotating glyphs.

func (Instance) SetVariationCoordinates

func (self Instance) SetVariationCoordinates(cache_index int, variation_coordinates map[string]float32)

Sets variation coordinates for the specified font cache entry. See [method Font.get_supported_variation_list] for more info.

func (Instance) SubpixelPositioning

func (self Instance) SubpixelPositioning() gdclass.TextServerSubpixelPositioning

func (*Instance) UnsafePointer

func (self *Instance) UnsafePointer() unsafe.Pointer

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL