| SCHRIFT(3) | Library Functions Manual | SCHRIFT(3) | 
schrift, libschrift —
#include <schrift.h>
const char *
  
  sft_version(void);
SFT_Font *
  
  sft_loadmem(const
    void *mem, unsigned long
    size);
SFT_Font *
  
  sft_loadfile(const
    char *filename);
void
  
  sft_freefont(SFT_Font
    *font);
int
  
  sft_lmetrics(const
    struct SFT *sft, struct
    SFT_LMetrics *metrics);
int
  
  sft_lookup(const
    struct SFT *sft, unsigned
    long codepoint, SFT_Glyph
    *glyph);
int
  
  sft_hmetrics(const
    struct SFT *sft,
    SFT_Glyph glyph,
    struct SFT_HMetrics
    *metrics);
int
  
  sft_kerning(const
    struct SFT *sft,
    SFT_Glyph leftGlyph,
    SFT_Glyph rightGlyph,
    struct SFT_Kerning
    *kerning);
int
  
  sft_extents(const
    struct SFT *sft,
    SFT_Glyph glyph,
    struct SFT_Extents
    *extents);
int
  
  sft_render(const
    struct SFT *sft,
    SFT_Glyph glyph,
    struct SFT_Image
  image);
sft_version() may be called to determine
  the version of schrift. Since
  schrift uses semantic versioning, the returned string
  is of the form "MAJOR.MINOR.PATCH".
sft_loadfile() will load a font from a given filename
  (by mapping it into memory), whereas sft_loadmem() can
  be given an arbitrary memory address and size (in bytes). This allows loading
  fonts from ZIP file streams etc.
Once a particular font is no longer needed, its memory should be
    freed again by calling sft_freefont(). If the font
    has been loaded with sft_loadmem(), the underlying
    memory region will have to be freed separately.
If the SFT_DOWNWARD_Y flag is set, the Y
    axis is interpreted to point downwards. Per default, it points upwards.
schrift operates in terms of glyph ids (of type
  SFT_Glyph), which are font-specific identifiers assigned
  to renderable symbols (glyphs). The way to obtain a glyph id is to call
  sft_lookup(). This function takes a Unicode codepoint
  in codepoint and writes its corresponding glyph id into
  the variable pointed to by glyph.
sft_lmetrics() calculates the typographic metrics
  neccessary for laying out multiple lines of text.
This function writes its output into the structure pointed to by metrics. The fields are as follows:
When displaying multiple glyphs in a line, you have to keep track
    of the pen position. sft_hmetrics() tells you where
    to draw the next glyph with respect to the pen position, and how to update
    it after rendering the glyph.
This function writes its output into the structure pointed to by metrics. The fields are as follows:
Some sequences of glyphs may look awkward if they're layed out
    naively. For example, the gap between the two characters "VA"
    might look disproportionally large. Kerning is a way to combat this
    phenomenon, by slightly moving the second character closer or further away
    by a small amount. sft_kerning() may be used to
    retrieve kerning information for a given pair of glyph ids.
This function writes its output into the structure pointed to by kerning. The fields are as follows:
sft_extents() computes bounding box information of a
  glyph without having to render it.
This function writes its output into the structure pointed to by extents. The fields are as follows:
To actually render a glyph into a easily-displayable raster image,
    use sft_render().
Other than most functions, sft_render()
    takes a structure in image that is to be filled out by
    the caller. The fields are as follows:
The image will be rendered into the memory provided in
    pixels. Each byte corresponds to one pixel, with rows
    of the image being directly adjacent in memory without padding between them.
    Glyphs are rendered "white on black", meaning the background has a
    pixel value of 0, and the foreground goes up to a value of 255. Pixel values
    follow a linear color ramp, unlike conventional computer screens. That is to
    say, they are not gamma-corrected. These properties make
    it very easy to use images rendered with
    sft_render() as alpha masks.
sft_loadmem() and sft_loadfile()
  return NULL on error.
sft_lmetrics(),
    sft_lookup(),
    sft_hmetrics(),
    sft_kerning(),
    sft_extents(), and
    sft_render() all return 0 on success and -1 on
    error.
schrift.
schrift understands is
  Unicode.
Similarly, the only kind of font file supported right now are TrueType (.ttf) fonts (Some OpenType fonts might work too, as OpenType is effectively a superset of TrueType).
As of v0.10.0, there is no support for right-to-left scripts yet.
schrift currently does not implement font
    hinting and probably never will.
| December 20, 2020 | Void Linux |