Documentation / device / GlyphManager
Class: GlyphManager
Defined in: libs/device/src/helpers/glyphmanager.ts:10
Manager of texture glyphs
Extends
Constructors
Constructor
new GlyphManager(
device,binWidth,binHeight,border):GlyphManager
Defined in: libs/device/src/helpers/glyphmanager.ts:18
Creates a new glyph manager instance
Parameters
device
The render device
binWidth
number
Width of an atlas bin
binHeight
number
Height of an atlas bin
border
number
Border width of an atlas
Returns
GlyphManager
Overrides
TextureAtlasManager.constructor
Accessors
atlasTextureRestoreHandler
Get Signature
get atlasTextureRestoreHandler(): (
tex) =>void
Defined in: libs/device/src/helpers/textureatlas.ts:77
The texture restore handler callback function This callback function will be called whenever the device has been restored
Returns
(tex) => void
Set Signature
set atlasTextureRestoreHandler(
f):void
Defined in: libs/device/src/helpers/textureatlas.ts:80
Parameters
f
(tex) => void
Returns
void
Inherited from
TextureAtlasManager.atlasTextureRestoreHandler
binWidth
Get Signature
get binWidth():
number
Defined in: libs/device/src/helpers/textureatlas.ts:94
Width of each atlas bin in texels.
Returns
number
Inherited from
binHeight
Get Signature
get binHeight():
number
Defined in: libs/device/src/helpers/textureatlas.ts:100
Height of each atlas bin in texels.
Returns
number
Inherited from
rectBorderWidth
Get Signature
get rectBorderWidth():
number
Defined in: libs/device/src/helpers/textureatlas.ts:106
Border reserved around each packed rectangle in texels.
Returns
number
Inherited from
TextureAtlasManager.rectBorderWidth
Methods
getGlyphSize()
getGlyphSize(
char,font):number[]
Defined in: libs/device/src/helpers/glyphmanager.ts:32
Gets the size for given character
Parameters
char
string
The character
font
Font of the character
Returns
number[]
[width, height]
getGlyphInfo()
getGlyphInfo(
char,font):AtlasInfo
Defined in: libs/device/src/helpers/glyphmanager.ts:35
Parameters
char
string
font
Returns
measureStringWidth()
measureStringWidth(
str,charMargin,font):number
Defined in: libs/device/src/helpers/glyphmanager.ts:53
Measuring the width of a string
Parameters
str
string
The string to be measured
charMargin
number
margin size between characters
font
Font of the string
Returns
number
Width of the string
clipStringToWidth()
clipStringToWidth(
str,width,charMargin,start,font):number
Defined in: libs/device/src/helpers/glyphmanager.ts:69
Clips a string so that it's width is not larger than the given value
Parameters
str
string
The string to be clipped
width
number
The desired maximum width
charMargin
number
Margin size between characters
start
number
Start index of the string to be clipped
font
Font of the string
Returns
number
getCharWidth()
getCharWidth(
char,font):number
Defined in: libs/device/src/helpers/glyphmanager.ts:86
Measuring width of a character
Parameters
char
string
The character to be measured
font
Font of the character
Returns
number
Width of the character
getAtlasTexture()
getAtlasTexture(
index):Texture2D<unknown>
Defined in: libs/device/src/helpers/textureatlas.ts:88
Gets the atlas texture of a given index
Parameters
index
number
Index of the atlas bin
Returns
Texture2D<unknown>
Atlas texture for given index
Inherited from
TextureAtlasManager.getAtlasTexture
getAtlasInfo()
getAtlasInfo(
key):AtlasInfo
Defined in: libs/device/src/helpers/textureatlas.ts:114
Gets the information about specified atlas
Parameters
key
string
Key of the atlas
Returns
Information of the atlas
Inherited from
TextureAtlasManager.getAtlasInfo
isEmpty()
isEmpty():
boolean
Defined in: libs/device/src/helpers/textureatlas.ts:121
Check if no atlas has been created
Returns
boolean
true if no atlas has been created
Inherited from
clear()
clear():
void
Defined in: libs/device/src/helpers/textureatlas.ts:127
Removes all created atlases
Returns
void
Inherited from
pushCanvas()
pushCanvas(
key,ctx,x,y,w,h):AtlasInfo
Defined in: libs/device/src/helpers/textureatlas.ts:145
Inserts a rectangle of a canvas to the atlas texture
Parameters
key
string
Key of the atlas
ctx
CanvasRenderingContext2D
The canvas context
x
number
x offset of the rectangle
y
number
y offset of the rectangle
w
number
width of the rectangle
h
number
height of the rectangle
Returns
The atals info or null if insert failed
Inherited from
TextureAtlasManager.pushCanvas
pushBitmap()
pushBitmap(
key,bitmap):AtlasInfo
Defined in: libs/device/src/helpers/textureatlas.ts:171
Inserts a bitmap to the atlas texture
Parameters
key
string
Key of the atlas
bitmap
ImageBitmap | ImageData
The bitmap object
Returns
The atals info or null if insert failed