pix 0.7: Reference Manual

::pix::fontTop, Main, Index

Enum HorizontalAlignment:Top, Main, Index

HorizontalAlignmentenum
LeftAlign 
CenterAlign 
RightAlign 

Enum VerticalAlignment:Top, Main, Index

VerticalAlignmentenum
TopAlign 
MiddleAlign 
BottomAlign 

CommandsTop, Main, Index

ascent [::pix::font]Top, Main, Index

The font ascender value in font units.

ascent typeface
Parameters
typefacefont::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).

capHeight typeface
Parameters
typefacefont::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).

color font color
Parameters
fontfont::newFont
colorstring color
Return value

Nothing.

computeBounds [::pix::font]Top, Main, Index

Computes the bounds of an arrangement object.

computeBounds arrangement ?transform?
Parameters
arrangementfont::typeset
transformmatrix 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.

configure font options
Parameters
fontfont::readFont
optionsA 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.

copy font
Parameters
fontfont::readFont
Return value

A new font object.

defaultLineHeight [::pix::font]Top, Main, Index

The default line height in pixels for the current font size.

defaultLineHeight font
Parameters
fontfont::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.

descent typeface
Parameters
typefacefont::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.

destroy value
Parameters
valuefont::readFont or string
Return value

Nothing.

fallbackTypeface [::pix::font]Top, Main, Index

Looks through fallback typefaces to find one that has the glyph.

fallbackTypeface typeface char
Parameters
typefacefont::readTypeface
charchar
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.

getAdvance typeface char
Parameters
typefacefont::readTypeface
charchar
Return value

A value is in pixels

getGlyphPath [::pix::font]Top, Main, Index

The glyph path for the rune.

getGlyphPath typeface char
Parameters
typefacefont::readTypeface
charchar
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.

getKerningAdjustment typeface char1 char2
Parameters
typefacefont::readTypeface
char1char
char2char
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.

hasGlyph typeface char
Parameters
typefacefont::readTypeface
charchar
Return value

A Tcl boolean value.

layoutBounds [::pix::font]Top, Main, Index

Computes the width and height in pixels.

layoutBounds object text
Parameters
objectfont::typeset, font::readFont or font::newSpan
textstring (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.

lineGap typeface
Parameters
typefacefont::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.

lineHeight typeface
Parameters
typefacefont::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.

name typeface
Parameters
typefacefont::readTypeface
Return value

The name of the font.

newFont [::pix::font]Top, Main, Index

Create a new pixie.Font from the given TypeFace object.

newFont typeface
Parameters
typefacefont::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.

newSpan font text
Parameters
fontfont::newFont
textstring
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.

paint font ?paint?
Parameters
fontfont::newFont
paintpaint::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.

parseOtf buffer
Parameters
bufferstring
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.

parseSvgFont buffer
Parameters
bufferstring
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.

parseTtf buffer
Parameters
bufferstring
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.

readFont filePath
Parameters
filePathfile 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.

readTypeface filePath
Parameters
filePathfile 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).

readTypefaces filePath
Parameters
filePathfile font
Return value

A Tcl list with Typeface objects.

scale [::pix::font]Top, Main, Index

The scale factor to transform font units into pixels.

scale object
Parameters
objectfont::readFont or font::readTypeface object.
Return value

A Tcl double value.

selectionRects [::pix::font]Top, Main, Index

Gets coordinates rectangle for font::typeset.

selectionRects arrangement
Parameters
arrangementfont::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).

size font size
Parameters
fontfont::newFont
sizedouble value
Return value

Nothing.

typeset [::pix::font]Top, Main, Index

Lays out the character glyphs and returns the arrangement.

typeset object ?options?
Parameters
objectfont::readFont or font::newSpan
optionsA 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.