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

A glyph cell rendering. More...

#include <gfxprim.h>
#include "font.h"

Go to the source code of this file.

Data Structures

struct  gpf_cell
 A glyph cell geometry. More...

Functions

void gpf_cell_init (struct gpf_cell *self, const gp_widget_render_ctx *ctx, unsigned int max_h)
 Sizes a cell for the current font and zoom.
void gpf_cell_center (struct gpf_cell *self, const gp_pixmap *p, unsigned int cols, unsigned int rows)
 Centres a grid of cells in a pixmap.
int gpf_cell_at (const struct gpf_cell *self, unsigned int cols, unsigned int rows, gp_coord x, gp_coord y)
 Finds the cell under a point.
void gpf_cell_draw (gp_pixmap *p, const gp_widget_render_ctx *ctx, const struct gpf_cell *self, int x, int y, uint32_t code)
 Draws a glyph cell.
void gpf_cell_draw_glyph (gp_pixmap *p, const gp_widget_render_ctx *ctx, const struct gpf_cell *self, int x, int y, uint32_t code, const struct gpf_glyph *glyph)
 Draws a glyph cell with the ink handed to it.
void gpf_cell_grid (gp_pixmap *p, const gp_widget_render_ctx *ctx, const struct gpf_cell *self, unsigned int cols, unsigned int rows)
 Draws the lines between the cells of a grid.

Detailed Description

A glyph cell rendering.

One glyph cell: the codepoint, then the character as the widget font draws it, then the glyph itself. The glyph table is a grid of these and so is the strip of accented letters, and they are the same thing on the screen because they are the same thing to read.

The middle line is a reference: what the letter is supposed to look like, from a font that is not the one being edited, right above the one that is.

Definition in file cell.h.

Function Documentation

◆ gpf_cell_at()

int gpf_cell_at ( const struct gpf_cell * self,
unsigned int cols,
unsigned int rows,
gp_coord x,
gp_coord y )

Finds the cell under a point.

Parameters
selfA cell.
colsThe grid width in cells.
rowsThe grid height in cells.
xA pixmap x coordinate.
yA pixmap y coordinate.
Returns
The index of the cell, counted along the rows, or -1 when the point is not on the grid.

Definition at line 69 of file cell.c.

References gpf_cell::w, and gpf_cell::x0.

◆ gpf_cell_center()

void gpf_cell_center ( struct gpf_cell * self,
const gp_pixmap * p,
unsigned int cols,
unsigned int rows )

Centres a grid of cells in a pixmap.

A pixmap is sized by the layout and a cell by the font, so the one is rarely a whole number of the other, and the slack is split on both sides rather than left as a strip on the right and at the bottom. The positions the cells are drawn at stay relative to the grid; the drawing adds the origin.

Parameters
selfA cell, its origin is set.
pThe pixmap the grid is drawn into.
colsThe grid width in cells.
rowsThe grid height in cells.

Definition at line 61 of file cell.c.

References GPF_MAX, gpf_cell::w, and gpf_cell::x0.

◆ gpf_cell_draw()

void gpf_cell_draw ( gp_pixmap * p,
const gp_widget_render_ctx * ctx,
const struct gpf_cell * self,
int x,
int y,
uint32_t code )

Draws a glyph cell.

The codepoint, dimmed when the font has not got the glyph, inverted when the variant has an entry of its own and red when that entry is modified; then the character as the widget font draws it, then the glyph as the variant being edited resolves it, centred on its advance.

Parameters
pThe pixmap to draw into.
ctxThe widget render context.
selfA cell.
xThe cell x offset relative to the grid origin.
yThe cell y offset relative to the grid origin.
codeThe glyph codepoint.

Definition at line 215 of file cell.c.

References gpf_resolved::glyph, gpf_resolve(), gpf_resolved_clear(), and gpf_cell::x0.

◆ gpf_cell_draw_glyph()

void gpf_cell_draw_glyph ( gp_pixmap * p,
const gp_widget_render_ctx * ctx,
const struct gpf_cell * self,
int x,
int y,
uint32_t code,
const struct gpf_glyph * glyph )

Draws a glyph cell with the ink handed to it.

The same cell with the ink handed to it instead of resolved: the compose view draws a letter that is not in the font, as it would come out with the accent that is being edited on it. The codepoint above it still says what the font holds, which is not the same question.

Parameters
pThe pixmap to draw into.
ctxThe widget render context.
selfA cell.
xThe cell x offset relative to the grid origin.
yThe cell y offset relative to the grid origin.
codeThe codepoint the label is drawn for.
glyphThe ink to draw.

Definition at line 228 of file cell.c.

References gpf_resolved::glyph, gpf_resolve(), gpf_resolved_clear(), and gpf_cell::x0.

◆ gpf_cell_grid()

void gpf_cell_grid ( gp_pixmap * p,
const gp_widget_render_ctx * ctx,
const struct gpf_cell * self,
unsigned int cols,
unsigned int rows )

Draws the lines between the cells of a grid.

Parameters
pThe pixmap to draw into.
ctxThe widget render context.
selfA cell.
colsThe grid width in cells.
rowsThe grid height in cells.

Definition at line 241 of file cell.c.

References gpf_cell::w, and gpf_cell::x0.

◆ gpf_cell_init()

void gpf_cell_init ( struct gpf_cell * self,
const gp_widget_render_ctx * ctx,
unsigned int max_h )

Sizes a cell for the current font and zoom.

The glyph box comes from the ink extent of the whole font plus the theme's padding, not from the ascent and the descent, so that an accent over a capital is not cut off.

Parameters
selfA cell to fill in.
ctxThe widget render context.
max_hZero means "as much as you like", anything else caps the zoom so that the cell fits it.

Definition at line 13 of file cell.c.

References gpf_cell::bg, gpf_family_meta::em, gpf_font_ink_extent(), GPF_MAX, GPF_MIN, gpf_cell::label_h, gpf_font::meta, gpf_cell::pad, gpf_cell::ref_h, gpf_cell::top, gpf_cell::w, gpf_cell::x0, and gpf_cell::zoom.