NX Fonts Support (NXFONTS)

NXFONTS types

struct nx_fontmetric_s

This structures provides the metrics for one glyph:

struct nx_fontmetric_s
{
  uint32_t stride   : 2;      /* Width of one font row in bytes */
  uint32_t width    : 6;      /* Width of the font in bits */
  uint32_t height   : 6;      /* Height of the font in rows */
  uint32_t xoffset  : 6;      /* Top, left-hand corner X-offset in pixels */
  uint32_t yoffset  : 6;      /* Top, left-hand corner y-offset in pixels */
  uint32_t unused   : 6;
};
struct nx_fontbitmap_s

This structure binds the glyph metrics to the glyph bitmap:

struct nx_fontbitmap_s
{
  struct nx_fontmetric_s metric; /* Character metrics */
  FAR const uint8_t *bitmap;     /* Pointer to the character bitmap */
};
struct nx_fontset_s

This structure describes one contiguous grouping of glyphs that can be described by an array starting with encoding first and extending through (first + nchars - 1).

struct nx_fontset_s
{
  uint8_t  first;             /* First bitmap character code */
  uint8_t  nchars;            /* Number of bitmap character codes */
  FAR const struct nx_fontbitmap_s *bitmap;
};
struct nx_font_s

This structure describes the overall fontset.

struct nx_font_s
{
  uint8_t  mxheight;          /* Max height of one glyph in rows */
  uint8_t  mxwidth;           /* Max width of any glyph in pixels */
  uint8_t  mxbits;            /* Max number of bits per character code */
  uint8_t  spwidth;           /* The width of a space in pixels */
};
NXHANDLE nxf_getfonthandle(enum nx_fontid_e fontid);

Given a numeric font ID, return a handle that may be subsequently be used to access the font data sets.

Parameters:
  • fontid – Identifies the font set to use

Returns:

A handle that may be subsequently be used to access the font data sets.

FAR const struct nx_font_s *nxf_getfontset(NXHANDLE handle);

Return information about the current font set.

Parameters:
Returns:

An instance of struct nx_font_s describing the font set.

FAR const struct nx_fontbitmap_s *nxf_getbitmap(NXHANDLE handle, uint16_t ch)

Return font bitmap information for the selected character encoding.

Parameters:
  • ch – The char code for the requested bitmap.

  • handle – A font handle previously returned by nxf_getfonthandle().

Returns:

An instance of nx_fontbitmap_s describing the glyph.

int nxf_convert_2bpp(FAR uint8_t *dest, uint16_t height, uint16_t width, uint16_t stride, FAR const struct nx_fontbitmap_s *bm, nxgl_mxpixel_t color);
int nxf_convert_4bpp(FAR uint8_t *dest, uint16_t height, uint16_t width, uint16_t stride, FAR const struct nx_fontbitmap_s *bm, nxgl_mxpixel_t color);
int nxf_convert_8bpp(FAR uint8_t *dest, uint16_t height, uint16_t width, uint16_t stride, FAR const struct nx_fontbitmap_s *bm, nxgl_mxpixel_t color);
int nxf_convert_16bpp(FAR uint16_t *dest, uint16_t height, uint16_t width, uint16_t stride, FAR const struct nx_fontbitmap_s *bm, nxgl_mxpixel_t color);
int nxf_convert_24bpp(FAR uint32_t *dest, uint16_t height, uint16_t width, uint16_t stride, FAR const struct nx_fontbitmap_s *bm, nxgl_mxpixel_t color);
int nxf_convert_32bpp(FAR uint32_t *dest, uint16_t height, uint16_t width, uint16_t stride, FAR const struct nx_fontbitmap_s *bm, nxgl_mxpixel_t color);

Convert the 1BPP font to a new pixel depth.

Parameters:
  • dest – The destination buffer provided by the caller.

  • height – The max height of the returned char in rows.

  • width – The max width of the returned char in pixels.

  • stride – The width of the destination buffer in bytes.

  • bm – Describes the character glyph to convert

  • color – The color to use for ‘1’ bits in the font bitmap (0 bits are transparent).

Returns:

OK on success; ERROR on failure with errno set appropriately.