gpforge
An advanced bitmap font editor
Loading...
Searching...
No Matches
gui.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 */
18#ifndef GPFORGE_GUI_H
19#define GPFORGE_GUI_H
20
21#include <widgets/gp_widgets.h>
22
23#include "font.h"
24#include "resolve.h"
25#include "face.h"
26#include "undo.h"
27#include "unicode_blocks.h"
28
35 uint32_t min;
37 uint32_t table;
42 uint32_t code;
43};
44
48struct gpf_gui {
50 struct gpf_font *font;
52 const char *path;
55 char *save_path;
56
60 uint32_t code;
64 unsigned int block;
68 unsigned int zoom;
70 unsigned int canvas_zoom;
71
81 int drag;
84
86 struct gpf_undo *undo;
88 int dirty;
90 int update;
92 unsigned int browser_page;
94 unsigned int deps_off;
97 uint32_t deps_anchor;
100
110
112 gp_htable *uids;
113
115 gp_widget *canvas;
117 gp_widget *browser;
119 gp_widget *preview;
121 gp_widget *strip;
123 gp_widget *status;
125 gp_widget *blocks;
129 gp_widget *family_label;
131 gp_widget *deps;
133 gp_widget *advance_widget;
134 gp_widget *bearing_x_widget;
135 gp_widget *bearing_y_widget;
137 gp_widget *block_start;
139 gp_widget *preview_text;
142 int rule_strike;
143 int rule_overline;
145 gp_widget *save_button;
147 gp_widget *export_button;
149 gp_widget *family_button;
151 gp_widget *undo_button;
152 gp_widget *redo_button;
154 gp_widget *paste_button;
156 gp_widget *lint_label;
159 gp_widget *lint_errors;
160 gp_widget *lint_warnings;
161
163 gp_font_face *faces[GPF_VARIANTS];
164};
165
167extern struct gpf_gui gui;
168
177const gp_font_face *gpf_gui_face(enum gpf_variant_id id);
178
185void gpf_gui_invalidate(void);
186
192void gpf_gui_select(uint32_t code);
193
202void gpf_gui_select_keep(uint32_t code);
203
213void gpf_gui_create_glyph(uint32_t code);
214
225void gpf_gui_pixel_set(int col, int height, int set);
226
237unsigned int gpf_gui_accented(uint32_t *codes, unsigned int max);
238
244void gpf_gui_set_block(unsigned int block);
245
255gp_pixel gpf_gui_back_color(gp_widget *self);
256
262void gpf_gui_set_canvas_zoom(unsigned int zoom);
263
272void gpf_gui_sync_block(unsigned int block);
273
280
286void gpf_gui_move_variant(int offset);
287
294void gpf_gui_redraw(void);
295
301const struct gpf_ucode_block *gpf_gui_blocks(void);
302
308const struct gpf_ucode_block *gpf_gui_block(void);
309
317void gpf_gui_set_dirty(int dirty);
318
328int gpf_gui_modified(uint32_t code);
329
338struct gpf_glyph *gpf_gui_edit_glyph(void);
339
350struct gpf_glyph *gpf_gui_edit_code(uint32_t code);
351
360void gpf_gui_shift(int dx, int dy);
361
367void gpf_gui_edit_begin(void);
368
372void gpf_gui_edit_commit(void);
373
379void gpf_gui_edited(void);
380
388void gpf_pixmap_resize(gp_widget_event *ev);
389
390#endif /* GPFORGE_GUI_H */
Compiles a gfxprim font face from an in-memory gpf font.
The in-memory font model.
gpf_variant_id
Font face variant.
Definition font.h:34
@ GPF_VARIANTS
Number of font variants.
Definition font.h:44
void gpf_gui_sync_block(unsigned int block)
Makes the block selector follow the table.
Definition gpforge.c:942
void gpf_gui_pixel_set(int col, int height, int set)
Sets or clears a pixel of the glyph being edited.
Definition gpforge.c:488
int gpf_gui_modified(uint32_t code)
Whether the glyph has changed since the font was written.
Definition gpforge.c:712
void gpf_gui_redraw(void)
Repaints everything that shows the font.
Definition gpforge.c:762
void gpf_gui_select_keep(uint32_t code)
Selects a glyph without moving the table to it.
Definition gpforge.c:877
unsigned int gpf_gui_accented(uint32_t *codes, unsigned int max)
The accented letters that follow the glyph being edited.
Definition gpforge.c:458
void gpf_gui_edit_begin(void)
Starts an edit, one undo entry.
Definition gpforge.c:664
void gpf_gui_set_variant(enum gpf_variant_id id)
Switches the variant being edited.
Definition gpforge.c:957
struct gpf_glyph * gpf_gui_edit_code(uint32_t code)
The glyph entry to edit, for any glyph.
Definition gpforge.c:443
const struct gpf_ucode_block * gpf_gui_block(void)
The block being browsed.
Definition gpforge.c:78
void gpf_gui_move_variant(int offset)
Moves the current variant in the variant ordering.
Definition gpforge.c:967
void gpf_gui_set_block(unsigned int block)
Selects a block and turns the table to its first page.
Definition gpforge.c:882
struct gpf_glyph * gpf_gui_edit_glyph(void)
The glyph entry to edit in the current variant.
Definition gpforge.c:448
void gpf_gui_set_dirty(int dirty)
Marks the font as changed or as written.
Definition gpforge.c:697
void gpf_gui_select(uint32_t code)
Selects a glyph and turns the table to it.
Definition gpforge.c:872
gp_pixel gpf_gui_back_color(gp_widget *self)
The color a widget is drawn on.
Definition gpforge.c:1161
void gpf_gui_shift(int dx, int dy)
Moves the ink of the glyph being edited.
Definition gpforge.c:1996
void gpf_gui_invalidate(void)
Throws the compiled faces away.
Definition gpforge.c:57
void gpf_pixmap_resize(gp_widget_event *ev)
Allocates the backing pixmap on a resize.
Definition gpforge.c:982
void gpf_gui_edit_commit(void)
Commits the edit started by gpf_gui_edit_begin() and repaints.
Definition gpforge.c:676
const gp_font_face * gpf_gui_face(enum gpf_variant_id id)
The resolved variant compiled into a gfxprim face.
Definition gpforge.c:46
void gpf_gui_create_glyph(uint32_t code)
Creates a glyph the font has not got.
Definition gpforge.c:641
void gpf_gui_edited(void)
The font changed.
Definition gpforge.c:732
void gpf_gui_set_canvas_zoom(unsigned int zoom)
Sets the canvas zoom and the spinner that shows it.
Definition gpforge.c:1175
const struct gpf_ucode_block * gpf_gui_blocks(void)
The block list, built on demand.
Definition gpforge.c:67
The glyph variant lattice.
The glyph selected last in a block, to go back to when the block is switched to again.
Definition gui.h:33
uint32_t min
The block, by its first codepoint: indices move on a rebuild.
Definition gui.h:35
uint32_t code
The glyph selected, the table one or one picked from the accented letters strip, which may be out of ...
Definition gui.h:42
uint32_t table
The glyph selected in its table.
Definition gui.h:37
A font family.
Definition font.h:274
A glyph.
Definition font.h:80
int dx
Accent offset, positive right and up, compose only.
Definition font.h:156
uint32_t code
Unicode code point.
Definition font.h:84
The editor state.
Definition gui.h:48
unsigned int zoom
The pixel multiplier the table glyphs are drawn with.
Definition gui.h:68
unsigned int block
The index of the block being browsed.
Definition gui.h:64
gp_widget * advance_widget
The glyph metrics, editable.
Definition gui.h:133
int paint_val
The value the stroke paints.
Definition gui.h:79
gp_widget * undo_button
Enabled only when the journal has something to take back.
Definition gui.h:151
gp_widget * strip
The variant strip, see preview.h.
Definition gui.h:121
gp_widget * browser
The glyph table, see browser.h.
Definition gui.h:117
unsigned int deps_off
The first cell of the accented letters strip, which scrolls.
Definition gui.h:94
struct gpf_block_sel * block_sels
The glyph selected last in each block, see gpf_gui_select().
Definition gui.h:66
gp_widget * deps
The accented letters strip, see preview.h.
Definition gui.h:131
gp_widget * save_button
Enabled only when there is something to save.
Definition gui.h:145
gp_widget * canvas
The glyph canvas, see canvas.h.
Definition gui.h:115
struct gpf_glyph clipboard
The glyph copied last, the ink and the metrics.
Definition gui.h:107
gp_htable * uids
The widget uids of the layout.
Definition gui.h:112
gp_font_face * faces[GPF_VARIANTS]
The compiled faces, built lazily, one per variant.
Definition gui.h:163
uint32_t deps_anchor
The letter or the mark the strip lists, so that the offset resets.
Definition gui.h:97
char * save_path
Where a font imported from a BDF is saved, once it has been asked.
Definition gui.h:55
gp_widget * family_button
The same, for the font properties.
Definition gui.h:149
int in_stroke
A mouse stroke is in progress.
Definition gui.h:77
gp_widget * preview_text
The line the user types to see it in the preview.
Definition gui.h:139
gp_widget * canvas_zoom_widget
The canvas zoom spinner.
Definition gui.h:127
int drag_col
The column the drag is at.
Definition gui.h:83
const char * path
The path the font was opened from.
Definition gui.h:52
gp_widget * block_start
The block's first codepoint, in hex, editable.
Definition gui.h:137
gp_widget * blocks
The block selector.
Definition gui.h:125
gp_widget * preview
The sample text, see preview.h.
Definition gui.h:119
int cur_col
The column of the pixel the keyboard edits.
Definition gui.h:73
unsigned int canvas_zoom
The same for the glyph on the canvas, 0 until it is fitted.
Definition gui.h:70
enum gpf_variant_id variant
The variant being edited.
Definition gui.h:58
int drag
A metric being dragged instead, see canvas.c.
Definition gui.h:81
int rule_underline
Which of the three rules the preview draws over its text.
Definition gui.h:141
gp_widget * export_button
Enabled only when there is a font to export.
Definition gui.h:147
int dirty
The font has changed since it was last written.
Definition gui.h:88
gp_widget * status
The status line, what the selected glyph resolves to.
Definition gui.h:123
unsigned int browser_page
The page the browser is at; it pages rather than scrolls.
Definition gui.h:92
struct gpf_font * font
The font being edited, NULL when there is none.
Definition gui.h:50
gp_widget * paste_button
Enabled once there is something to paste.
Definition gui.h:154
gp_widget * family_label
The family name and size.
Definition gui.h:129
gp_widget * lint_errors
And how much it says about the whole font, next to its button.
Definition gui.h:159
int clipboard_full
Something was copied, a space copies no ink.
Definition gui.h:109
int cur_height
The height of the pixel the keyboard edits.
Definition gui.h:75
uint32_t code
The selected glyph.
Definition gui.h:60
struct gpf_undo * undo
The journal.
Definition gui.h:86
struct gpf_ucode_block * block_list
The block list, see gpf_gui_blocks().
Definition gui.h:62
int update
Copy the edits of a letter into its accented forms.
Definition gui.h:90
gp_widget * lint_label
What the lint says about the glyph being edited.
Definition gui.h:156
int browser_follow
Turn to the page with the selection on the next draw.
Definition gui.h:99
A unicode block description.
The undo journal.
The BMP part of unicode block table and the blocks of a font.