The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

fontft1.c - Freetype 1.x font driver for Imager

SYNOPSIS

  handle = i_tt_new(path_to_ttf);
  rc = i_tt_bbox(handle, points, "foo", 3, int cords[6], utf8);
  i_tt_destroy(handle);

  // and much more

DESCRIPTION

fontft1.c implements font creation, rendering, bounding box functions and more for Imager using Freetype 1.x.

In general this driver should be ignored in favour of the FT2 driver.

FUNCTION REFERENCE

Some of these functions are internal.

init_tt()

Initializes the freetype font rendering engine (if needed)

i_tt_get_instance(handle, points, smooth)

Finds a points+smooth instance or if one doesn't exist in the cache allocates room and returns its cache entry

   fontname - path to the font to load
   handle   - handle to the font.
   points   - points of the requested font
   smooth   - boolean (True: antialias on, False: antialias is off)
i_tt_new(fontname)

Creates a new font handle object, finds a character map and initialise the the font handle's cache

   fontname - path to the font to load
i_tt_init_raster_map(bit, width, height, smooth)

Allocates internal memory for the bitmap as needed by the parameters (internal)

   bit    - bitmap to allocate into
   width  - width of the bitmap
   height - height of the bitmap
   smooth - boolean (True: antialias on, False: antialias is off)
i_tt_clear_raster_map(bit)

Frees the bitmap data and sets pointer to NULL (internal)

   bit - bitmap to free
i_tt_clear_raster_map(bit)

Clears the specified bitmap (internal)

   bit - bitmap to zero
i_tt_blit_or(dst, src, x_off, y_off)

function that blits one raster map into another (internal)

   dst   - destination bitmap
   src   - source bitmap
   x_off - x offset into the destination bitmap
   y_off - y offset into the destination bitmap
i_tt_get_glyph(handle, inst, j)

Function to see if a glyph exists and if so cache it (internal)

   handle - pointer to font handle
   inst   - font instance
   j      - charcode of glyph
i_tt_has_chars(handle, text, len, utf8, out)

Check if the given characters are defined by the font. Note that len is the number of bytes, not the number of characters (when utf8 is non-zero).

Returns the number of characters that were checked.

i_tt_destroy(handle)

Clears the data taken by a font including all cached data such as pixmaps and glyphs

   handle - pointer to font handle
i_tt_render_glyph(handle, gmetrics, bit, smallbit, x_off, y_off, smooth)

Renders a single glyph into the bit rastermap (internal)

   handle   - pointer to font handle
   gmetrics - the metrics for the glyph to be rendered
   bit      - large bitmap that is the destination for the text
   smallbit - small bitmap that is used only if smooth is true
   x_off    - x offset of glyph
   y_off    - y offset of glyph
   smooth   - boolean (True: antialias on, False: antialias is off)
i_tt_render_all_glyphs(handle, inst, bit, small_bit, cords, txt, len, smooth)

calls i_tt_render_glyph to render each glyph into the bit rastermap (internal)

   handle   - pointer to font handle
   inst     - font instance
   bit      - large bitmap that is the destination for the text
   smallbit - small bitmap that is used only if smooth is true
   txt      - string to render
   len      - length of the string to render
   smooth   - boolean (True: antialias on, False: antialias is off)
i_tt_dump_raster_map2(im, bit, xb, yb, cl, smooth)

Function to dump a raster onto an image in color used by i_tt_text() (internal).

   im     - image to dump raster on
   bit    - bitmap that contains the text to be dumped to im
   xb, yb - coordinates, left edge and baseline
   cl     - color to use for text
   smooth - boolean (True: antialias on, False: antialias is off)
i_tt_dump_raster_map_channel(im, bit, xb, yb, channel, smooth)

Function to dump a raster onto a single channel image in color (internal)

   im      - image to dump raster on
   bit     - bitmap that contains the text to be dumped to im
   xb, yb  - coordinates, left edge and baseline
   channel - channel to copy to
   smooth  - boolean (True: antialias on, False: antialias is off)
i_tt_rasterize(handle, bit, cords, points, txt, len, smooth)

interface for generating single channel raster of text (internal)

   handle - pointer to font handle
   bit    - the bitmap that is allocated, rendered into and NOT freed
   cords  - the bounding box (modified in place)
   points - font size to use
   txt    - string to render
   len    - length of the string to render
   smooth - boolean (True: antialias on, False: antialias is off)
i_tt_cp(handle, im, xb, yb, channel, points, txt, len, smooth, utf8)

Interface to text rendering into a single channel in an image

   handle  - pointer to font handle
   im      - image to render text on to
   xb, yb  - coordinates, left edge and baseline
   channel - channel to render into
   points  - font size to use
   txt     - string to render
   len     - length of the string to render
   smooth  - boolean (True: antialias on, False: antialias is off)
i_tt_text(handle, im, xb, yb, cl, points, txt, len, smooth, utf8)

Interface to text rendering in a single color onto an image

   handle  - pointer to font handle
   im      - image to render text on to
   xb, yb  - coordinates, left edge and baseline
   cl      - color to use for text
   points  - font size to use
   txt     - string to render
   len     - length of the string to render
   smooth  - boolean (True: antialias on, False: antialias is off)
i_tt_bbox_inst(handle, inst, txt, len, cords, utf8)

Function to get texts bounding boxes given the instance of the font (internal)

   handle - pointer to font handle
   inst   -  font instance
   txt    -  string to measure
   len    -  length of the string to render
   cords  - the bounding box (modified in place)
i_tt_bbox(handle, points, txt, len, cords, utf8)

Interface to get a strings bounding box

   handle - pointer to font handle
   points - font size to use
   txt    - string to render
   len    - length of the string to render
   cords  - the bounding box (modified in place)
i_tt_face_name(handle, name_buf, name_buf_size)

Retrieve's the font's postscript name.

This is complicated by the need to handle encodings and so on.

i_tt_push_error(code)

Push an error message and code onto the Imager error stack.

AUTHOR

Arnar M. Hrafnkelsson <addi@umich.edu>

SEE ALSO

Imager(3)