gpforge
An advanced bitmap font editor
Loading...
Searching...
No Matches
cell.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*
3 * Copyright (C) 2026 Cyril Hrubis <metan@ucw.cz>
4 */
17#ifndef GPFORGE_CELL_H
18#define GPFORGE_CELL_H
19
20#include <gfxprim.h>
21
22#include "font.h"
23
29struct gpf_cell {
31 unsigned int w, h;
33 unsigned int label_h;
35 unsigned int ref_h;
40 int top;
42 unsigned int pad;
47 unsigned int zoom;
49 int x0, y0;
57 gp_pixel bg;
58};
59
72void gpf_cell_init(struct gpf_cell *self, const gp_widget_render_ctx *ctx,
73 unsigned int max_h);
74
88void gpf_cell_center(struct gpf_cell *self, const gp_pixmap *p,
89 unsigned int cols, unsigned int rows);
90
102int gpf_cell_at(const struct gpf_cell *self, unsigned int cols,
103 unsigned int rows, gp_coord x, gp_coord y);
104
120void gpf_cell_draw(gp_pixmap *p, const gp_widget_render_ctx *ctx,
121 const struct gpf_cell *self, int x, int y, uint32_t code);
122
139void gpf_cell_draw_glyph(gp_pixmap *p, const gp_widget_render_ctx *ctx,
140 const struct gpf_cell *self, int x, int y,
141 uint32_t code, const struct gpf_glyph *glyph);
142
152void gpf_cell_grid(gp_pixmap *p, const gp_widget_render_ctx *ctx,
153 const struct gpf_cell *self, unsigned int cols,
154 unsigned int rows);
155
156#endif /* GPFORGE_CELL_H */
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.
Definition cell.c:241
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.
Definition cell.c:228
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.
Definition cell.c:61
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.
Definition cell.c:69
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.
Definition cell.c:215
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.
Definition cell.c:13
The in-memory font model.
A glyph cell geometry.
Definition cell.h:29
gp_pixel bg
The color the cells are drawn on, the selected one is highlighted instead.
Definition cell.h:57
unsigned int label_h
The height of the codepoint line at the top.
Definition cell.h:33
unsigned int w
The cell size in pixels.
Definition cell.h:31
int x0
Where the grid starts in the pixmap, see gpf_cell_center().
Definition cell.h:49
unsigned int pad
The theme's padding, above the glyph and below it.
Definition cell.h:42
int top
How far the font's ink reaches above the baseline, at least the ascent.
Definition cell.h:40
unsigned int zoom
The pixel multiplier, the table's, or less when there is no room.
Definition cell.h:47
unsigned int ref_h
The line under it, where the widget font draws the character.
Definition cell.h:35
A glyph.
Definition font.h:80