Skip to content

Commit

Permalink
font-edit: Unify the build system
Browse files Browse the repository at this point in the history
The 'font-edit' tool previously used a simple Makefile for building, but
has now been integrated into the unified build system used across all
modules.
  • Loading branch information
jserv committed Feb 2, 2025
1 parent eeb3303 commit 4c1c687
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 29 deletions.
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*.a
demo-*
.demo-*
font-edit
.font-edit

# Swap
[._]*.s[a-v][a-z]
Expand All @@ -28,8 +30,5 @@ __pycache__/
.config.old
config.h

# Tools
tools/ttf/twin-ttf

# CI pipeline
expected-format
expected-format
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,20 @@ demo-$(BACKEND)_ldflags-y := \
$(TARGET_LIBS)
endif

ifeq ($(CONFIG_TOOLS), y)
target-$(CONFIG_TOOL_FONTEDIT) += font-edit
font-edit_files-y = \
tools/font-edit/sfit.c \
tools/font-edit/font-edit.c
font-edit_includes-y := tools/font-edit
font-edit_cflags-y := \
$(shell pkg-config --cflags cairo) \
$(shell sdl2-config --cflags)
font-edit_ldflags-y := \
$(shell pkg-config --libs cairo) \
$(shell sdl2-config --libs)
endif

CFLAGS += -include config.h

check_goal := $(strip $(MAKECMDGOALS))
Expand Down
14 changes: 14 additions & 0 deletions configs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,18 @@ config DEMO_IMAGE
select LOADER_TVG
default y
depends on DEMO_APPLICATIONS

endmenu

menu "Tools"

config TOOLS
bool "Build tools"
default y

config TOOL_FONTEDIT
bool "Build scalable font editor"
default y
depends on TOOLS

endmenu
14 changes: 0 additions & 14 deletions tools/font-edit/Makefile

This file was deleted.

15 changes: 7 additions & 8 deletions tools/font-edit/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# twin-fedit
`twin-fedit` is a tool allowing users to edit specific scalable fonts
# font-edit
`font-edit` is a tool allowing users to edit specific scalable fonts
which are expected to fit the requirements of embedded systems with larger screens.

<p align="center">
Expand All @@ -13,14 +13,13 @@ sudo apt-get install libsdl2-dev libcairo2-dev

## Usage
```shell
make
./twin-fedit nchars
./font-edit nchars
```

## Background
The glyphs in `twin-fedit` is originated from [Hershey vector fonts](https://en.wikipedia.org/wiki/Hershey_fonts), which were created by Dr. A. V. Hershey while working at the U. S. National Bureau of Standards.
The glyphs in `font-edit` is originated from [Hershey vector fonts](https://en.wikipedia.org/wiki/Hershey_fonts), which were created by Dr. A. V. Hershey while working at the U. S. National Bureau of Standards.

The Hershey vector fonts set of `twin-fedit` is [`nchars`](nchars), for example, the interpolation points and operations used to draw the glyph `1` are as follows
The Hershey vector fonts set of `font-edit` is [`nchars`](nchars), for example, the interpolation points and operations used to draw the glyph `1` are as follows
```
/* 0x31 '1' offset 666 */
0, 10, 42, 0, 2, 3,
Expand Down Expand Up @@ -51,7 +50,7 @@ According to the steps outlined above for drawing glyph `1`, it can be split int
3. `'l' 10,0`: Starting from `10,-42` and ending at `10,0`, draw a straight line.
4. `'e'`: End the drawing of glyph `1`.

Each point seen in `twin-fedit` corresponds to an operation. By selecting a point in `twin-fedit`, you can modify the coordinates to edit any glyph.
Each point seen in `font-edit` corresponds to an operation. By selecting a point in `font-edit`, you can modify the coordinates to edit any glyph.

## Quick Guide
For each glyph, there are the following shortcut keys used for editing the glyph.
Expand Down Expand Up @@ -90,4 +89,4 @@ To delete a point
2. Use d key to delete the selected point.

To undo any operations above
1. Use u key.
1. Use u key.
4 changes: 2 additions & 2 deletions tools/font-edit/twin-fedit.c → tools/font-edit/font-edit.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
* PERFORMANCE OF THIS SOFTWARE.
*/

#include "twin-fedit.h"

#include <SDL.h>
#include <SDL_keycode.h>
#include <cairo.h>
#include <stdbool.h>

#include "font-edit.h"

static SDL_Window *window;
static cairo_t *cr;
static cairo_surface_t *surface;
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tools/font-edit/sfit.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/

#include "twin-fedit.h"
#include "font-edit.h"

static double min(double a, double b)
{
Expand Down

0 comments on commit 4c1c687

Please sign in to comment.