gpforge
An advanced bitmap font editor
Loading...
Searching...
No Matches
edit.h File Reference

Glyph editing. More...

#include "font.h"

Go to the source code of this file.

Functions

int gpf_glyph_pixel_get (const struct gpf_glyph *self, int col, int height)
 Returns a glyph pixel at a given position.
int gpf_glyph_pixel_set (struct gpf_glyph *self, int col, int height, int set)
 Sets or clears a glyph pixel.
void gpf_glyph_shift (struct gpf_glyph *self, int dx, int dy)
 Moves the glyph ink.
void gpf_glyph_flip_h (struct gpf_glyph *self)
 Mirrors the ink horizontally.
void gpf_glyph_flip_v (struct gpf_glyph *self)
 Mirrors the ink vertically.
void gpf_glyph_clear_ink (struct gpf_glyph *self)
 Clears the glyph ink.

Detailed Description

Glyph editing.

Pixels are addressed in glyph coordinates, a column counted from the origin and a height counted from the baseline, positive up, never in ink box coordinates.

The ink box is derived from the ink, it grows and shrinks as pixels are set and cleared, and nothing outside of this file needs to know it exists.

Definition in file edit.h.

Function Documentation

◆ gpf_glyph_clear_ink()

void gpf_glyph_clear_ink ( struct gpf_glyph * self)

Clears the glyph ink.

The bearings are reset to zero, the advance is kept.

Parameters
selfA glyph to clear.

Definition at line 114 of file edit.c.

References gpf_glyph::bearing_x, gpf_glyph::bearing_y, gpf_glyph::bits, gpf_glyph::height, and gpf_glyph::width.

◆ gpf_glyph_flip_h()

void gpf_glyph_flip_h ( struct gpf_glyph * self)

Mirrors the ink horizontally.

Mirrors the ink horizontally within the advance.

Parameters
selfA glyph to mirror.

Definition at line 81 of file edit.c.

References gpf_glyph::advance, gpf_glyph::bearing_x, gpf_glyph::bits, gpf_glyph::height, and gpf_glyph::width.

◆ gpf_glyph_flip_v()

void gpf_glyph_flip_v ( struct gpf_glyph * self)

Mirrors the ink vertically.

Mirrors the ink vertically within the ink box.

Parameters
selfA glyph to mirror.

Definition at line 99 of file edit.c.

References gpf_glyph::bits, gpf_glyph::height, and gpf_glyph::width.

◆ gpf_glyph_pixel_get()

int gpf_glyph_pixel_get ( const struct gpf_glyph * self,
int col,
int height )

Returns a glyph pixel at a given position.

Parameters
selfA glyph.
colA column counted from a glyph origin.
heightA height from a baseline, positive up.
Returns
A pixel value 0 or 1.

Definition at line 11 of file edit.c.

References gpf_glyph::bearing_x, gpf_glyph::bearing_y, gpf_glyph::bits, gpf_glyph::height, and gpf_glyph::width.

◆ gpf_glyph_pixel_set()

int gpf_glyph_pixel_set ( struct gpf_glyph * self,
int col,
int height,
int set )

Sets or clears a glyph pixel.

The ink box grows or is trimmed as needed.

Parameters
selfA glyph.
colA column counted from a glyph origin.
heightA height from a baseline, positive up.
setA value to set the pixel to 0 or 1.
Returns
Non-zero on an allocation failure.

Definition at line 22 of file edit.c.

References gpf_glyph::bearing_x, gpf_glyph::bearing_y, gpf_glyph::bits, GPF_MAX, GPF_MIN, gpf_glyph::height, and gpf_glyph::width.

◆ gpf_glyph_shift()

void gpf_glyph_shift ( struct gpf_glyph * self,
int dx,
int dy )

Moves the glyph ink.

Moves the ink, which is how the bearings are edited. A glyph with no ink is left alone.

Parameters
selfA glyph to shift.
dxAn x offset to shift the glyph by, positive right.
dyA y offset to shift the glyph by, positive up.

Definition at line 72 of file edit.c.

References gpf_glyph::bearing_x, gpf_glyph::bearing_y, and gpf_glyph::width.