::pix::fontTop, Main, Index
Enum HorizontalAlignment:Top, Main, Index
| enum | |
Enum VerticalAlignment:Top, Main, Index
| enum | |
CommandsTop, Main, Index
ascent [::pix::font]Top, Main, Index
The font ascender value in font units.
Parameters
typeface | font::readTypeface |
Description
The ascender is the distance from the baseline to the highest point of any glyph in the font. This value is used to position text in the y-direction. The value is in the font's coordinate system. The value is in pixels but can be a floating point value. The value is positive.
Return value
A Tcl double value.
capHeight [::pix::font]Top, Main, Index
The font cap height value in font units (pixie >= 5.1.0).
Parameters
typeface | font::readTypeface |
Description
The cap height is the distance from the baseline to the highest point of any glyph in the font. This value is used to position text in the y-direction.
Return value
A value is in pixels but can be a floating point value.
color [::pix::font]Top, Main, Index
Sets font color (Same as pix::font::configure procedure).
Parameters
font | font::newFont |
color | string color |
Return value
Nothing.
computeBounds [::pix::font]Top, Main, Index
Computes the bounds of an arrangement object.
Parameters
arrangement | font::typeset |
transform | matrix list Optional, default mat3. |
Description
The bounds is the axis-aligned bounding box of all the glyphs in the arrangement. The bounds is computed in the arrangement's coordinate system. The bounds does not include the outline of the glyphs, only the filled region.
If the transform argument is provided, the bounds is computed after applying the transformation matrix to the arrangement. The transformation matrix is a 3x3 matrix as a list of 9 elements.
Return value
A Tcl dict value where:
x : is the x offset of the top-left corner of the bounds.
y : is the y offset of the top-left corner of the bounds.
w : is the width of the bounds.
h : is the height of the bounds.
configure [::pix::font]Top, Main, Index
Configure font::readFont parameters.
Parameters
font | font::readFont |
options | A Tcl dict, see description below. |
Description
| noKerningAdjustments | A boolean value. |
| underline | A boolean value. |
| strikethrough | A boolean value. |
| size | A double value. |
| lineHeight | A double value. |
| paint | A list of paint objects. |
| color | A string color. |
Return value
Nothing.
copy [::pix::font]Top, Main, Index
Copy font.
Parameters
font | font::readFont |
Return value
A new font object.
defaultLineHeight [::pix::font]Top, Main, Index
The default line height in pixels for the current font size.
Parameters
font | font::readFont |
Description
This proc calculates and returns the default line height of the font in pixels, based on its current size and other internal properties. The line height is used to determine the vertical distance between the baselines of two lines of text.
For example, if the line height is 15.0, then the baseline of the second line of text will be 15.0 pixels below the baseline of the first line of text.
Return value
The line height is in pixels.
descent [::pix::font]Top, Main, Index
The font descender value in font units.
Parameters
typeface | font::readTypeface |
Description
The descent is the distance from the baseline to the lowest point of any glyph in the font. This value is used to position text in the y-direction. The value is negative.
Return value
A value is in pixels but can be a floating point value.
destroy [::pix::font]Top, Main, Index
Destroy current font or all fonts if special word all is specified.
Parameters
value | font::readFont or string |
Return value
Nothing.
fallbackTypeface [::pix::font]Top, Main, Index
Looks through fallback typefaces to find one that has the glyph.
Parameters
typeface | font::readTypeface |
char | char |
Return value
A new Tcl TypeFace or the arg TypeFace if typeface has glyph.
getAdvance [::pix::font]Top, Main, Index
Try to get the advance width for the given rune in pixels. If the rune is not supported by the typeface, this will raise an exception.
Parameters
typeface | font::readTypeface |
char | char |
Return value
A value is in pixels
getGlyphPath [::pix::font]Top, Main, Index
The glyph path for the rune.
Parameters
typeface | font::readTypeface |
char | char |
Return value
A new path.
getKerningAdjustment [::pix::font]Top, Main, Index
Retrieve the kerning adjustment for the pair of characters (c1, c2) from the typeface.
Parameters
typeface | font::readTypeface |
char1 | char |
char2 | char |
Description
Kerning is the process of adjusting the space between characters in a proportional font. The kerning adjustment is measured in pixels and is specific to the pair of characters. This allows for more visually pleasing and readable text by reducing or increasing space between specific pairs of characters, depending on the typeface design.
Return value
A Tcl double value.
hasGlyph [::pix::font]Top, Main, Index
Guess if the glyph exists for this rune.
Parameters
typeface | font::readTypeface |
char | char |
Return value
A Tcl boolean value.
layoutBounds [::pix::font]Top, Main, Index
Computes the width and height in pixels.
Parameters
object | font::typeset, font::readFont or font::newSpan |
text | string (if font object is present) |
Description
The bounds does not include the outline of the glyphs, only the filled region.
Return value
A Tcl dict value {x y} where the x is the width of the bounds in pixels, and the y is the height of the bounds in pixels.
lineGap [::pix::font]Top, Main, Index
Gets the font line gap value in font units.
Parameters
typeface | font::readTypeface |
Description
The line gap is the distance in font units between the baseline of one line of text and the baseline of the next. The line gap is used to determine the spacing between lines of text.
Return value
The line gap value in font units.
lineHeight [::pix::font]Top, Main, Index
The default line height in font units.
Parameters
typeface | font::readTypeface |
Description
The line height is the height of a line of text in the font, which is typically slightly larger than the ascent of the font (the height above the baseline) plus the descent of the font (the height below the baseline).
The line height is typically used to determine the vertical distance between the baselines of two lines of text.
Return value
A Tcl double value.
name [::pix::font]Top, Main, Index
This procedure retrieves the name of a given typeface object.
Parameters
typeface | font::readTypeface |
Return value
The name of the font.
newFont [::pix::font]Top, Main, Index
Create a new pixie.Font from the given TypeFace object.
Parameters
typeface | font::readTypeface |
Description
The size of the font is set to 0 (which is the default value). The paint object is initialized with a default Color (black). The text buffer is initialized with a default string (""). The flags are initialized with a default value of 0.
Return value
A new font.
newSpan [::pix::font]Top, Main, Index
Sets new Span.
Parameters
font | font::newFont |
text | string |
Return value
A new span object.
paint [::pix::font]Top, Main, Index
Sets font Paint if paint optional argument is set, otherwise gets the font paint.
Parameters
font | font::newFont |
paint | paint::new Optional, default "". |
Return value
A new paint if no paint optional argument is set, otherwise set the font paint.
parseOtf [::pix::font]Top, Main, Index
Parse Otf string.
Parameters
buffer | string |
Description
The goal is to take a string buffer containing an Otf (Open Type Font) and parse it into a TypeFace object.
Return value
A new TypeFace object.
parseSvgFont [::pix::font]Top, Main, Index
Parse Svg Font string.
Parameters
buffer | string |
Description
The pix::font::parseSvgFont function is used to interpret the string as an SVG font and convert it into a TypeFace object.
Return value
A new TypeFace object.
parseTtf [::pix::font]Top, Main, Index
Parse Ttf string.
Parameters
buffer | string |
Description
The pix::font::parseTtf function is used to interpret the string as a Ttf (TrueType Font) and convert it into a TypeFace object.
Return value
A new TypeFace object.
readFont [::pix::font]Top, Main, Index
Try to read the font from the file located at the given path.
Parameters
filePath | file font |
Description
Pixie will take care of the rest (loading the font, verifying it, etc.).
If there is an error (like the file not existing), an exception will be raised which we will catch and return the error message.
Return value
A new font object.
readTypeface [::pix::font]Top, Main, Index
Loads a typeface from a file.
Parameters
filePath | file font |
Return value
A new Typeface object.
See also
font::parseTtf, font::parseOtf, font::parseSvgFont
readTypefaces [::pix::font]Top, Main, Index
Loads a OpenType Collection (.ttc).
Parameters
filePath | file font |
Return value
A Tcl list with Typeface objects.
scale [::pix::font]Top, Main, Index
The scale factor to transform font units into pixels.
Parameters
object | font::readFont or font::readTypeface object. |
Return value
A Tcl double value.
selectionRects [::pix::font]Top, Main, Index
Gets coordinates rectangle for font::typeset.
Parameters
arrangement | font::typeset |
Description
The selectionRects method returns a seq of vec4 that represents the coordinates of the rectangles that are used to render the text for the given arrangement object.
The coordinates are in the format (x, y, w, h) where: x and y are the top-left corner of the rectangle w and h are the width and height of the rectangle
Return value
A Tcl dictionary with keys that contains the coordinates of the rectangle in the format (x, y, w, h).
size [::pix::font]Top, Main, Index
Sets font Size (Same as pix::font::configure procedure).
Parameters
font | font::newFont |
size | double value |
Return value
Nothing.
typeset [::pix::font]Top, Main, Index
Lays out the character glyphs and returns the arrangement.
Parameters
object | font::readFont or font::newSpan |
options | A Tcl dict, see description below. Optional, default "". |
Description
| bounds | A list coordinates. |
| hAlign | A Enum value. |
| vAlign | A Enum value. |
| wrap | A boolean value. |
Return value
A new arrangement object.