Font

Principle

The Font module contains the C part of the MicroVG implementation, which manages vectorial fonts. This module is composed of two elements:

  • an implementation of Low-Level APIs to manipulate font files,
  • an implementation of Low-Level APIs for MicroVG drawings.

Functional Description

The Font module implements the MicroVG VectorFont framework. It provides Low-Level APIs that consist of opening and decoding a font file and getting the font’s characteristics.

A font file:

  • is either a TTF or an OTF,
  • is identified by the resource name,
  • can be stored as internal resource or external (see Application Resources).

No data is stored in the Java heap. The implementation is responsible for the font’s cycle life: allocation and release.

A font is used to draw a string with a color or with a linear gradient.

Low-Level API

There are two separate Low-Level API header files (see LLVG_FONT: Vector Font):

  • LLVG_FONT_impl.h specifies the Low-Level APIs used to open and retrieve the font’s characteristics.
  • LLVG_FONT_PAINTER_impl.h lists the Low-Level APIs called by VectorGraphicsPainter to draw a string with the font.
MicroVG Font Low Level

Font Low-Level API

  • MicroVG library calls the BSP functions through the header files LLVG_FONT_impl.h and LLVG_FONT_PAINTER_impl.h.
  • The C module MicroVG provides a default implementation of LLVG_FONT_impl.h over Freetype.
  • The C module Freetype provides an implementation of LLVG_FONT_PAINTER_impl.h over the Vivante VGLite library. It also redirects the complex layout to a third party C module.
  • The drawer also manages the Gradient.
  • The C module Harfbuzz provides an implementation of complex layout.
  • These files are automatically copied in the BSP project when fetching the C modules during the platform build.

Use

The MicroVG Font APIs are available in the class ej.microvg.VectorFont.