OpenCPN Partial API docs
Loading...
Searching...
No Matches
ssfn.h File Reference

Scalable Screen Font renderer in a single ANSI C/C++ header. More...

Go to the source code of this file.

Classes

struct  ssfn_font_t
 
struct  ssfn_glyph_t
 
struct  ssfn_t
 

Macros

#define SSFN_MAGIC   "SSFN"
 
#define SSFN_COLLECTION   "SFNC"
 
#define SSFN_ENDMAGIC   "NFSS"
 
#define SSFN_FAMILY_SERIF   0
 
#define SSFN_FAMILY_SANS   1
 
#define SSFN_FAMILY_DECOR   2
 
#define SSFN_FAMILY_MONOSPACE   3
 
#define SSFN_FAMILY_HAND   4
 
#define SSFN_STYLE_REGULAR   0
 
#define SSFN_STYLE_BOLD   1
 
#define SSFN_STYLE_ITALIC   2
 
#define SSFN_FEAT_HASBMAP   1 /* there's at least one bitmap fragment */
 
#define SSFN_FEAT_HASCMAP
 
#define SSFN_FEAT_HASHINT   4 /* there's at least one hinting fragment */
 
#define SSFN_FEAT_KBIGLKP   8 /* big offsets in kerning look up table */
 
#define SSFN_FEAT_KBIGCHR   16 /* big characters in kerning look up tables */
 
#define SSFN_FEAT_KBIGCRD   32 /* big coordinates in kerning groups */
 
#define SSFN_FEAT_HBIGCRD   64 /* bit coordinates in autohinting fragments */
 
#define SSFN_CONTOUR_MOVE   0
 
#define SSFN_CONTOUR_LINE   1
 
#define SSFN_CONTOUR_QUAD   2
 
#define SSFN_CONTOUR_CUBIC   3
 
#define SSFN_CONTOUR_COLOR   4
 
#define SSFN_FRAG_BITMAP   0
 
#define SSFN_FRAG_LBITMAP   1
 
#define SSFN_FRAG_PIXMAP   2
 
#define SSFN_FRAG_HINTING   3
 
#define SSFN_VARIANT_DEFAULT   0 /* default, also isolated glyphs */
 
#define SSFN_VARIANT_LOCAL0   0
 
#define SSFN_VARIANT_INITIAL
 
#define SSFN_VARIANT_LOCAL1    1 /* so its only purpose is to store Serbian / Macedonian B D G P T */
 
#define SSFN_VARIANT_MEDIAL   2
 
#define SSFN_VARIANT_LOCAL2   2
 
#define SSFN_VARIANT_FINAL   3
 
#define SSFN_VARIANT_LOCAL3   3
 
#define SSFN_VARIANT_LOCAL4   4
 
#define SSFN_VARIANT_LOCAL5   5
 
#define SSFN_VARIANT_LOCAL6   6
 
#define SSFN_NUMVARIANTS   7
 
#define SSFN_FAMILY_ANY   0xff /* select the first loaded font */
 
#define SSFN_FAMILY_BYNAME   0xfe /* select font by its unique name */
 
#define SSFN_STYLE_UNDERLINE   4 /* under line glyph */
 
#define SSFN_STYLE_STHROUGH   8 /* strike through glyph */
 
#define SSFN_STYLE_NOHINTING   0x40 /* no auto hinting grid */
 
#define SSFN_STYLE_ABS_SIZE   0x80 /* use absolute size value */
 
#define SSFN_FRAG_CONTOUR   255
 
#define SSFN_OK   0 /* success */
 
#define SSFN_ERR_ALLOC   1 /* allocation error */
 
#define SSFN_ERR_NOFACE   2 /* no font face selected */
 
#define SSFN_ERR_INVINP   3 /* invalid input */
 
#define SSFN_ERR_BADFILE   4 /* bad SSFN file format */
 
#define SSFN_ERR_BADSTYLE   5 /* bad style */
 
#define SSFN_ERR_BADSIZE   6 /* bad size */
 
#define SSFN_ERR_BADMODE   7 /* bad mode */
 
#define SSFN_ERR_NOGLYPH   8 /* glyph (or kerning info) not found */
 
#define SSFN_ERR_NOVARIANT   9 /* no such glyph variant */
 
#define SSFN_MODE_NONE    0 /* just select the font to get the glyph (for kerning) */
 
#define SSFN_MODE_OUTLINE   1 /* return the glyph's outlines */
 
#define SSFN_MODE_BITMAP   2 /* render into bitmap */
 
#define SSFN_MODE_ALPHA   3 /* render into alpha channel */
 
#define SSFN_MODE_CMAP   4 /* render into color map indexed buffer */
 
#define SSFN_HINTING_THRESHOLD    16 /* don't change unless you really know what you're doing */
 
#define SSFN_DATA_MAX   65536
 
#define ssfn_lasterr(ctx)   ((ssfn_t *)ctx)->err /* return last error code */
 
#define ssfn_error(err)
 
#define NULL   (void *)0
 
#define ssfn_private
 
#define SSFN_memcmp   memcmp
 
#define SSFN_memset   memset
 
#define SSFN_realloc   realloc
 
#define SSFN_free   free
 
#define _ssfn_i2g(x)   ((x) ? (((x) << 16) - (1 << 15)) / ctx->m : 0)
 
#define _ssfn_g2o(x)   (((x) * ctx->m + (1 << 7)) >> 8)
 
#define _ssfn_g2i(x)   (((x) * ctx->m + (1 << 15)) >> 16)
 
#define _ssfn_g2ic(x)   (((x) * ctx->m + (1 << 16) - 1) >> 16)
 
#define _ssfn_f2i(x)   ((((x) << s) * ctx->m + (1 << 15)) >> 16)
 
#define _ssfn_o2i(x)   (((x) + (1 << 7)) >> 8)
 
#define _ssfn_o2ic(x)   ((x + (1 << 8) - 1) >> 8)
 
#define _ssfn_g2ox(x)   ((x) >= (4095 << 4) ? _ssfn_g2o(x) : ctx->h[((x) >> 4)])
 
#define _ssfn_g2ix(x)    ((x) >= (4095 << 4) ? _ssfn_g2i(x) : _ssfn_o2i(ctx->h[((x) >> 4)]))
 
#define _ssfn_g2ixc(x)    ((x) >= (4095 << 4) ? _ssfn_g2ic(x) : _ssfn_o2ic(ctx->h[((x) >> 4)]))
 
#define _ssfn_g2oy(y)   (_ssfn_g2o(y))
 
#define _ssfn_g2iy(y)   (_ssfn_g2i(y))
 
#define _ssfn_g2iyc(y)   (_ssfn_g2ic(y))
 
#define _ssfn_igg(y)   (((4096 << 4) - (y)) >> (2))
 
#define _ssfn_igi(y)    ((((4096 << 4) - (y)) * ctx->m + (1 << (15 + 3))) >> (16 + 3))
 
#define SSFN_CMAP_TO_ARGB(p, c, fg)    (p >= 0xF0 ? (uint32_t)((p << 28) | ((p & 0xF) << 24) | fg) : c[p])
 Decode a color map pixel into ARGB.
 

Typedefs

typedef unsigned char uint8_t
 
typedef unsigned short int uint16_t
 
typedef unsigned int uint32_t
 

Functions

int ssfn_load (ssfn_t *ctx, const ssfn_font_t *font)
 Load a font or font collection into renderer context.
 
int ssfn_select (ssfn_t *ctx, int family, char *name, int style, int size, int mode)
 Set up rendering parameters.
 
int ssfn_variant (ssfn_t *ctx, int variant)
 Set glyph variant.
 
uint32_t ssfn_utf8 (char **s)
 Decode an UTF-8 multibyte, advance string pointer and return UNICODE.
 
ssfn_glyph_tssfn_render (ssfn_t *ctx, uint32_t unicode)
 Glyph renderer.
 
int ssfn_kern (ssfn_t *ctx, uint32_t unicode, uint32_t nextunicode, int *x, int *y)
 Return kerning information.
 
int ssfn_bbox (ssfn_t *ctx, char *str, int usekern, int *w, int *h)
 Returns the bounding box of the rendered text.
 
int ssfn_mem (ssfn_t *ctx)
 Returns how much memory a context consumes.
 
void ssfn_free (ssfn_t *ctx)
 Free renderer context.
 
int ssfn_putc (uint32_t unicode)
 
ssfn_private uint8_t * _ssfn_c (const ssfn_font_t *font, uint32_t unicode, int v)
 
ssfn_private void _ssfn_l (ssfn_t *ctx, int x, int y, int l)
 
void _ssfn_b (ssfn_t *ctx, int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3, int l)
 
ssfn_private void _ssfn_r (ssfn_t *ctx)
 
ssfn_private void _ssfn_a (ssfn_t *ctx)
 
ssfn_private void _ssfn_g (ssfn_t *ctx, uint8_t *rg, int render)
 

Variables

const char * ssfn_errstr []
 Error code strings.
 

Detailed Description

Scalable Screen Font renderer in a single ANSI C/C++ header.

Definition in file ssfn.h.

Macro Definition Documentation

◆ _ssfn_f2i

#define _ssfn_f2i (   x)    ((((x) << s) * ctx->m + (1 << 15)) >> 16)

Definition at line 302 of file ssfn.h.

◆ _ssfn_g2i

#define _ssfn_g2i (   x)    (((x) * ctx->m + (1 << 15)) >> 16)

Definition at line 300 of file ssfn.h.

◆ _ssfn_g2ic

#define _ssfn_g2ic (   x)    (((x) * ctx->m + (1 << 16) - 1) >> 16)

Definition at line 301 of file ssfn.h.

◆ _ssfn_g2ix

#define _ssfn_g2ix (   x)     ((x) >= (4095 << 4) ? _ssfn_g2i(x) : _ssfn_o2i(ctx->h[((x) >> 4)]))

Definition at line 306 of file ssfn.h.

◆ _ssfn_g2ixc

#define _ssfn_g2ixc (   x)     ((x) >= (4095 << 4) ? _ssfn_g2ic(x) : _ssfn_o2ic(ctx->h[((x) >> 4)]))

Definition at line 308 of file ssfn.h.

◆ _ssfn_g2iy

#define _ssfn_g2iy (   y)    (_ssfn_g2i(y))

Definition at line 311 of file ssfn.h.

◆ _ssfn_g2iyc

#define _ssfn_g2iyc (   y)    (_ssfn_g2ic(y))

Definition at line 312 of file ssfn.h.

◆ _ssfn_g2o

#define _ssfn_g2o (   x)    (((x) * ctx->m + (1 << 7)) >> 8)

Definition at line 299 of file ssfn.h.

◆ _ssfn_g2ox

#define _ssfn_g2ox (   x)    ((x) >= (4095 << 4) ? _ssfn_g2o(x) : ctx->h[((x) >> 4)])

Definition at line 305 of file ssfn.h.

◆ _ssfn_g2oy

#define _ssfn_g2oy (   y)    (_ssfn_g2o(y))

Definition at line 310 of file ssfn.h.

◆ _ssfn_i2g

#define _ssfn_i2g (   x)    ((x) ? (((x) << 16) - (1 << 15)) / ctx->m : 0)

Definition at line 298 of file ssfn.h.

◆ _ssfn_igg

#define _ssfn_igg (   y)    (((4096 << 4) - (y)) >> (2))

Definition at line 313 of file ssfn.h.

◆ _ssfn_igi

#define _ssfn_igi (   y)     ((((4096 << 4) - (y)) * ctx->m + (1 << (15 + 3))) >> (16 + 3))

Definition at line 314 of file ssfn.h.

◆ _ssfn_o2i

#define _ssfn_o2i (   x)    (((x) + (1 << 7)) >> 8)

Definition at line 303 of file ssfn.h.

◆ _ssfn_o2ic

#define _ssfn_o2ic (   x)    ((x + (1 << 8) - 1) >> 8)

Definition at line 304 of file ssfn.h.

◆ NULL

#define NULL   (void *)0

Definition at line 236 of file ssfn.h.

◆ SSFN_CMAP_TO_ARGB

#define SSFN_CMAP_TO_ARGB (   p,
  c,
  fg 
)     (p >= 0xF0 ? (uint32_t)((p << 28) | ((p & 0xF) << 24) | fg) : c[p])

Decode a color map pixel into ARGB.

Parameters
puint8_t color map pixel
cuint32_t* pointer to color map
fguint32_t foreground color
Returns
uint32_t ARGB pixel

Definition at line 1005 of file ssfn.h.

◆ SSFN_COLLECTION

#define SSFN_COLLECTION   "SFNC"

Definition at line 53 of file ssfn.h.

◆ SSFN_CONTOUR_COLOR

#define SSFN_CONTOUR_COLOR   4

Definition at line 83 of file ssfn.h.

◆ SSFN_CONTOUR_CUBIC

#define SSFN_CONTOUR_CUBIC   3

Definition at line 82 of file ssfn.h.

◆ SSFN_CONTOUR_LINE

#define SSFN_CONTOUR_LINE   1

Definition at line 80 of file ssfn.h.

◆ SSFN_CONTOUR_MOVE

#define SSFN_CONTOUR_MOVE   0

Definition at line 79 of file ssfn.h.

◆ SSFN_CONTOUR_QUAD

#define SSFN_CONTOUR_QUAD   2

Definition at line 81 of file ssfn.h.

◆ SSFN_DATA_MAX

#define SSFN_DATA_MAX   65536

Definition at line 167 of file ssfn.h.

◆ SSFN_ENDMAGIC

#define SSFN_ENDMAGIC   "NFSS"

Definition at line 54 of file ssfn.h.

◆ SSFN_ERR_ALLOC

#define SSFN_ERR_ALLOC   1 /* allocation error */

Definition at line 144 of file ssfn.h.

◆ SSFN_ERR_BADFILE

#define SSFN_ERR_BADFILE   4 /* bad SSFN file format */

Definition at line 147 of file ssfn.h.

◆ SSFN_ERR_BADMODE

#define SSFN_ERR_BADMODE   7 /* bad mode */

Definition at line 150 of file ssfn.h.

◆ SSFN_ERR_BADSIZE

#define SSFN_ERR_BADSIZE   6 /* bad size */

Definition at line 149 of file ssfn.h.

◆ SSFN_ERR_BADSTYLE

#define SSFN_ERR_BADSTYLE   5 /* bad style */

Definition at line 148 of file ssfn.h.

◆ SSFN_ERR_INVINP

#define SSFN_ERR_INVINP   3 /* invalid input */

Definition at line 146 of file ssfn.h.

◆ SSFN_ERR_NOFACE

#define SSFN_ERR_NOFACE   2 /* no font face selected */

Definition at line 145 of file ssfn.h.

◆ SSFN_ERR_NOGLYPH

#define SSFN_ERR_NOGLYPH   8 /* glyph (or kerning info) not found */

Definition at line 151 of file ssfn.h.

◆ SSFN_ERR_NOVARIANT

#define SSFN_ERR_NOVARIANT   9 /* no such glyph variant */

Definition at line 152 of file ssfn.h.

◆ ssfn_error

#define ssfn_error (   err)
Value:
(err >= 0 && err <= 9 ? ssfn_errstr[err] \
: "Unknown error") /* return string for error code */
const char * ssfn_errstr[]
Error code strings.
Definition ssfn.h:284

Definition at line 222 of file ssfn.h.

◆ SSFN_FAMILY_ANY

#define SSFN_FAMILY_ANY   0xff /* select the first loaded font */

Definition at line 132 of file ssfn.h.

◆ SSFN_FAMILY_BYNAME

#define SSFN_FAMILY_BYNAME   0xfe /* select font by its unique name */

Definition at line 133 of file ssfn.h.

◆ SSFN_FAMILY_DECOR

#define SSFN_FAMILY_DECOR   2

Definition at line 59 of file ssfn.h.

◆ SSFN_FAMILY_HAND

#define SSFN_FAMILY_HAND   4

Definition at line 61 of file ssfn.h.

◆ SSFN_FAMILY_MONOSPACE

#define SSFN_FAMILY_MONOSPACE   3

Definition at line 60 of file ssfn.h.

◆ SSFN_FAMILY_SANS

#define SSFN_FAMILY_SANS   1

Definition at line 58 of file ssfn.h.

◆ SSFN_FAMILY_SERIF

#define SSFN_FAMILY_SERIF   0

Definition at line 57 of file ssfn.h.

◆ SSFN_FEAT_HASBMAP

#define SSFN_FEAT_HASBMAP   1 /* there's at least one bitmap fragment */

Definition at line 69 of file ssfn.h.

◆ SSFN_FEAT_HASCMAP

#define SSFN_FEAT_HASCMAP
Value:
2 /* there's at least one pixmap fragment or one color command, so a color \
map too */

Definition at line 70 of file ssfn.h.

◆ SSFN_FEAT_HASHINT

#define SSFN_FEAT_HASHINT   4 /* there's at least one hinting fragment */

Definition at line 72 of file ssfn.h.

◆ SSFN_FEAT_HBIGCRD

#define SSFN_FEAT_HBIGCRD   64 /* bit coordinates in autohinting fragments */

Definition at line 76 of file ssfn.h.

◆ SSFN_FEAT_KBIGCHR

#define SSFN_FEAT_KBIGCHR   16 /* big characters in kerning look up tables */

Definition at line 74 of file ssfn.h.

◆ SSFN_FEAT_KBIGCRD

#define SSFN_FEAT_KBIGCRD   32 /* big coordinates in kerning groups */

Definition at line 75 of file ssfn.h.

◆ SSFN_FEAT_KBIGLKP

#define SSFN_FEAT_KBIGLKP   8 /* big offsets in kerning look up table */

Definition at line 73 of file ssfn.h.

◆ SSFN_FRAG_BITMAP

#define SSFN_FRAG_BITMAP   0

Definition at line 86 of file ssfn.h.

◆ SSFN_FRAG_CONTOUR

#define SSFN_FRAG_CONTOUR   255

Definition at line 140 of file ssfn.h.

◆ SSFN_FRAG_HINTING

#define SSFN_FRAG_HINTING   3

Definition at line 89 of file ssfn.h.

◆ SSFN_FRAG_LBITMAP

#define SSFN_FRAG_LBITMAP   1

Definition at line 87 of file ssfn.h.

◆ SSFN_FRAG_PIXMAP

#define SSFN_FRAG_PIXMAP   2

Definition at line 88 of file ssfn.h.

◆ SSFN_free

#define SSFN_free   free

Definition at line 277 of file ssfn.h.

◆ SSFN_HINTING_THRESHOLD

#define SSFN_HINTING_THRESHOLD    16 /* don't change unless you really know what you're doing */

Definition at line 163 of file ssfn.h.

◆ ssfn_lasterr

#define ssfn_lasterr (   ctx)    ((ssfn_t *)ctx)->err /* return last error code */

Definition at line 221 of file ssfn.h.

◆ SSFN_MAGIC

#define SSFN_MAGIC   "SSFN"

Definition at line 52 of file ssfn.h.

◆ SSFN_memcmp

#define SSFN_memcmp   memcmp

Definition at line 253 of file ssfn.h.

◆ SSFN_memset

#define SSFN_memset   memset

Definition at line 261 of file ssfn.h.

◆ SSFN_MODE_ALPHA

#define SSFN_MODE_ALPHA   3 /* render into alpha channel */

Definition at line 159 of file ssfn.h.

◆ SSFN_MODE_BITMAP

#define SSFN_MODE_BITMAP   2 /* render into bitmap */

Definition at line 158 of file ssfn.h.

◆ SSFN_MODE_CMAP

#define SSFN_MODE_CMAP   4 /* render into color map indexed buffer */

Definition at line 160 of file ssfn.h.

◆ SSFN_MODE_NONE

#define SSFN_MODE_NONE    0 /* just select the font to get the glyph (for kerning) */

Definition at line 155 of file ssfn.h.

◆ SSFN_MODE_OUTLINE

#define SSFN_MODE_OUTLINE   1 /* return the glyph's outlines */

Definition at line 157 of file ssfn.h.

◆ SSFN_NUMVARIANTS

#define SSFN_NUMVARIANTS   7

Definition at line 105 of file ssfn.h.

◆ SSFN_OK

#define SSFN_OK   0 /* success */

Definition at line 143 of file ssfn.h.

◆ ssfn_private

#define ssfn_private

Definition at line 242 of file ssfn.h.

◆ SSFN_realloc

#define SSFN_realloc   realloc

Definition at line 269 of file ssfn.h.

◆ SSFN_STYLE_ABS_SIZE

#define SSFN_STYLE_ABS_SIZE   0x80 /* use absolute size value */

Definition at line 138 of file ssfn.h.

◆ SSFN_STYLE_BOLD

#define SSFN_STYLE_BOLD   1

Definition at line 65 of file ssfn.h.

◆ SSFN_STYLE_ITALIC

#define SSFN_STYLE_ITALIC   2

Definition at line 66 of file ssfn.h.

◆ SSFN_STYLE_NOHINTING

#define SSFN_STYLE_NOHINTING   0x40 /* no auto hinting grid */

Definition at line 137 of file ssfn.h.

◆ SSFN_STYLE_REGULAR

#define SSFN_STYLE_REGULAR   0

Definition at line 64 of file ssfn.h.

◆ SSFN_STYLE_STHROUGH

#define SSFN_STYLE_STHROUGH   8 /* strike through glyph */

Definition at line 136 of file ssfn.h.

◆ SSFN_STYLE_UNDERLINE

#define SSFN_STYLE_UNDERLINE   4 /* under line glyph */

Definition at line 135 of file ssfn.h.

◆ SSFN_VARIANT_DEFAULT

#define SSFN_VARIANT_DEFAULT   0 /* default, also isolated glyphs */

Definition at line 92 of file ssfn.h.

◆ SSFN_VARIANT_FINAL

#define SSFN_VARIANT_FINAL   3

Definition at line 100 of file ssfn.h.

◆ SSFN_VARIANT_INITIAL

#define SSFN_VARIANT_INITIAL
Value:
1 /* currently not needed because contextual glyphs has their own UNICODE \
code points, */

Definition at line 94 of file ssfn.h.

◆ SSFN_VARIANT_LOCAL0

#define SSFN_VARIANT_LOCAL0   0

Definition at line 93 of file ssfn.h.

◆ SSFN_VARIANT_LOCAL1

#define SSFN_VARIANT_LOCAL1    1 /* so its only purpose is to store Serbian / Macedonian B D G P T */

Definition at line 96 of file ssfn.h.

◆ SSFN_VARIANT_LOCAL2

#define SSFN_VARIANT_LOCAL2   2

Definition at line 99 of file ssfn.h.

◆ SSFN_VARIANT_LOCAL3

#define SSFN_VARIANT_LOCAL3   3

Definition at line 101 of file ssfn.h.

◆ SSFN_VARIANT_LOCAL4

#define SSFN_VARIANT_LOCAL4   4

Definition at line 102 of file ssfn.h.

◆ SSFN_VARIANT_LOCAL5

#define SSFN_VARIANT_LOCAL5   5

Definition at line 103 of file ssfn.h.

◆ SSFN_VARIANT_LOCAL6

#define SSFN_VARIANT_LOCAL6   6

Definition at line 104 of file ssfn.h.

◆ SSFN_VARIANT_MEDIAL

#define SSFN_VARIANT_MEDIAL   2

Definition at line 98 of file ssfn.h.

Typedef Documentation

◆ uint16_t

typedef unsigned short int uint16_t

Definition at line 45 of file ssfn.h.

◆ uint32_t

typedef unsigned int uint32_t

Definition at line 46 of file ssfn.h.

◆ uint8_t

typedef unsigned char uint8_t

Definition at line 44 of file ssfn.h.

Function Documentation

◆ _ssfn_a()

ssfn_private void _ssfn_a ( ssfn_t ctx)

Definition at line 491 of file ssfn.h.

◆ _ssfn_b()

void _ssfn_b ( ssfn_t ctx,
int  x0,
int  y0,
int  x1,
int  y1,
int  x2,
int  y2,
int  x3,
int  y3,
int  l 
)

Definition at line 373 of file ssfn.h.

◆ _ssfn_c()

ssfn_private uint8_t * _ssfn_c ( const ssfn_font_t font,
uint32_t  unicode,
int  v 
)

Definition at line 318 of file ssfn.h.

◆ _ssfn_g()

ssfn_private void _ssfn_g ( ssfn_t ctx,
uint8_t *  rg,
int  render 
)

Definition at line 548 of file ssfn.h.

◆ _ssfn_l()

ssfn_private void _ssfn_l ( ssfn_t ctx,
int  x,
int  y,
int  l 
)

Definition at line 349 of file ssfn.h.

◆ _ssfn_r()

ssfn_private void _ssfn_r ( ssfn_t ctx)

Definition at line 396 of file ssfn.h.

◆ ssfn_bbox()

int ssfn_bbox ( ssfn_t ctx,
char *  str,
int  usekern,
int *  w,
int *  h 
)

Returns the bounding box of the rendered text.

Parameters
ctxrendering context
*strstring
usekernuse kerning when calculating size
*wpointer to an integer, returned width
*hpointer to an integer, returned height
Returns
error code, and bounding box size in *w, *h

Definition at line 1452 of file ssfn.h.

◆ ssfn_free()

void ssfn_free ( ssfn_t ctx)

Free renderer context.

Parameters
ctxrendering context

Definition at line 1502 of file ssfn.h.

◆ ssfn_kern()

int ssfn_kern ( ssfn_t ctx,
uint32_t  unicode,
uint32_t  nextunicode,
int *  x,
int *  y 
)

Return kerning information.

Parameters
ctxrendering context
unicodecurrent unicode character
nextunicodenext unicode character
*xpointer to an integer
*ypointer to an integer
Returns
error code, and relative offsets adjusted to *x, *y

Definition at line 1369 of file ssfn.h.

◆ ssfn_load()

int ssfn_load ( ssfn_t ctx,
const ssfn_font_t font 
)

Load a font or font collection into renderer context.

Parameters
ctxrendering context
fontSSFN font or font collection in memory
Returns
error code

Definition at line 1015 of file ssfn.h.

◆ ssfn_mem()

int ssfn_mem ( ssfn_t ctx)

Returns how much memory a context consumes.

Parameters
ctxrendering context
Returns
total memory used by that context

Definition at line 1484 of file ssfn.h.

◆ ssfn_render()

ssfn_glyph_t * ssfn_render ( ssfn_t ctx,
uint32_t  unicode 
)

Glyph renderer.

Parameters
ctxrendering context
unicodecharacter to render
Returns
newly allocated rasterized glyph

Definition at line 1131 of file ssfn.h.

◆ ssfn_select()

int ssfn_select ( ssfn_t ctx,
int  family,
char *  name,
int  style,
int  size,
int  mode 
)

Set up rendering parameters.

Parameters
ctxrendering context
familyone of SSFN_FAMILY_*
nameNULL or UTF-8 string if family is SSFN_FAMILY_BYNAME
styleOR'd values of SSFN_STYLE_*
sizehow big glyph it should render, 8 - 255
moderendering mode, one of SSFN_MODE_*
Returns
error code

Definition at line 1060 of file ssfn.h.

◆ ssfn_utf8()

uint32_t ssfn_utf8 ( char **  s)

Decode an UTF-8 multibyte, advance string pointer and return UNICODE.

Watch out, no input checks

Parameters
**spointer to an UTF-8 string pointer
Returns
unicode, and *s moved to next multibyte sequence

Definition at line 1529 of file ssfn.h.

◆ ssfn_variant()

int ssfn_variant ( ssfn_t ctx,
int  variant 
)

Set glyph variant.

Parameters
ctxrendering context
variantone of SSFN_VARIANT_* defines
Returns
error code

Definition at line 1116 of file ssfn.h.

Variable Documentation

◆ ssfn_errstr

const char * ssfn_errstr
Initial value:
= {"",
"Memory allocation error",
"No font face found",
"Invalid input value",
"Bad file format",
"Invalid style",
"Invalid size",
"Invalid mode",
"Glyph not found",
"Glyph variant not found"}

Error code strings.

Definition at line 284 of file ssfn.h.