FixImage Documentation

Back to summary

import "image/font";

Font class

TrueType font.

Initialization

static function load(data: Byte[]): Font
Loads the font from given byte buffer. The byte buffer is accessed later for obtaining the individual glyphs.

Properties

function get_ascent(): Float
Returns the ascent of the font in normalized coordinates (must multiply with the actual font size).
function get_descent(): Float
Returns the descent of the font in normalized coordinates (must multiply with the actual font size).
function get_height(): Float
Returns the height of the font in normalized coordinates (must multiply with the actual font size).

Text shapes

function get_char_shape(char: Integer, off_x: Float, off_y: Float, size_x: Float, size_y: Float): Shape
Returns a new shape for given character, scaled and offsetted.
function get_string_shape(s: String, off_x: Float, off_y: Float, size_x: Float, size_y: Float): Shape
function get_string_shape(s: String, off: Integer, len: Integer, off_x: Float, off_y: Float, size_x: Float, size_y: Float): Shape
Returns a new shape for given string (or portion of it), scaled and offsetted.
function append_char_shape(shape: Shape, char: Integer, off_x: Float, off_y: Float, size_x: Float, size_y: Float)
Appends the shape of a given character to provided shape, scaled and offsetted.
function append_string_shape(shape: Shape, s: String, off_x: Float, off_y: Float, size_x: Float, size_y: Float)
function append_string_shape(shape: Shape, s: String, off: Integer, len: Integer, off_x: Float, off_y: Float, size_x: Float, size_y: Float)
Appends the shape of a given string (or portion of it) to provided shape, scaled and offsetted.
function get_char_bounds(bounds: Float[], char: Integer, off_x: Float, off_y: Float, size_x: Float, size_y: Float): Float[]
Retrieves a bounding box of a given character, scaled and offsetted. The result is stored to the bounds array of 4 floats (created if null is passed) and the array is returned. The order is: min_x, min_y, max_x, max_y.
function get_string_bounds(bounds: Float[], s: String, off_x: Float, off_y: Float, size_x: Float, size_y: Float): Float[]
function get_string_bounds(bounds: Float[], s: String, off: Integer, len: Integer, off_x: Float, off_y: Float, size_x: Float, size_y: Float): Float[]
Retrieves a bounding box of a given string (or portion of it), scaled and offsetted. The result is stored to the bounds array of 4 floats (created if null is passed) and the array is returned. The order is: min_x, min_y, max_x, max_y.

Positioning

function get_char_advance(char: Integer): Float
Returns the character horizontal advance in normalized coordinates (must multiply with the actual font size).
function get_string_advance(s: String): Float
function get_string_advance(s: String, off: Integer, len: Integer): Float
Returns the horizontal advance of the string (or portion of it) in normalized coordinates (must multiply with the actual font size).
function get_string_position(s: String, x: Float): Float
function get_string_position(s: String, off: Integer, len: Integer, x: Float): Float
Returns the fractional position inside the string (or portion of it) based on the normalized coordinate (the coordinate must be divided by the actual font size).