From d2eb968ee61576b34d369ff05d11b1d18855c13f Mon Sep 17 00:00:00 2001 From: Jim Huang Date: Sun, 2 Feb 2025 21:36:26 +0800 Subject: [PATCH] font-edit: Unify the build system 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. --- .github/workflows/main.yml | 1 + .gitignore | 7 +++---- Makefile | 14 ++++++++++++++ configs/Kconfig | 14 ++++++++++++++ tools/font-edit/Makefile | 14 -------------- tools/font-edit/README.md | 15 +++++++-------- tools/font-edit/{twin-fedit.c => font-edit.c} | 4 ++-- tools/font-edit/{twin-fedit.h => font-edit.h} | 0 tools/font-edit/sfit.c | 2 +- 9 files changed, 42 insertions(+), 29 deletions(-) delete mode 100644 tools/font-edit/Makefile rename tools/font-edit/{twin-fedit.c => font-edit.c} (99%) rename tools/font-edit/{twin-fedit.h => font-edit.h} (100%) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 85cf356..abfe8d8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -43,6 +43,7 @@ jobs: run: | sudo apt-get update -q -y sudo apt install libsdl2-dev libjpeg-dev libpng-dev + sudo apt install libcairo2-dev shell: bash - name: default build run: | diff --git a/.gitignore b/.gitignore index fa53b1f..5d13656 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,8 @@ *.a demo-* .demo-* +font-edit +.font-edit # Swap [._]*.s[a-v][a-z] @@ -28,8 +30,5 @@ __pycache__/ .config.old config.h -# Tools -tools/ttf/twin-ttf - # CI pipeline -expected-format \ No newline at end of file +expected-format diff --git a/Makefile b/Makefile index d7dd21f..e61260f 100644 --- a/Makefile +++ b/Makefile @@ -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)) diff --git a/configs/Kconfig b/configs/Kconfig index 1a601fc..7e281f1 100644 --- a/configs/Kconfig +++ b/configs/Kconfig @@ -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 diff --git a/tools/font-edit/Makefile b/tools/font-edit/Makefile deleted file mode 100644 index 1b25526..0000000 --- a/tools/font-edit/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -TARGET = twin-fedit - -CFLAGS = $(shell pkg-config --cflags cairo) $(shell sdl2-config --cflags) -g -Wall -LIBS = $(shell pkg-config --libs cairo) $(shell sdl2-config --libs) - -OBJS = \ - twin-fedit.o \ - sfit.o - -$(TARGET): $(OBJS) - $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS) - -clean: - rm -f $(TARGET) $(OBJS) diff --git a/tools/font-edit/README.md b/tools/font-edit/README.md index f1d2379..0c40bdc 100644 --- a/tools/font-edit/README.md +++ b/tools/font-edit/README.md @@ -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.

@@ -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, @@ -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. @@ -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. \ No newline at end of file +1. Use u key. diff --git a/tools/font-edit/twin-fedit.c b/tools/font-edit/font-edit.c similarity index 99% rename from tools/font-edit/twin-fedit.c rename to tools/font-edit/font-edit.c index c2e8437..3987a57 100644 --- a/tools/font-edit/twin-fedit.c +++ b/tools/font-edit/font-edit.c @@ -21,13 +21,13 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#include "twin-fedit.h" - #include #include #include #include +#include "font-edit.h" + static SDL_Window *window; static cairo_t *cr; static cairo_surface_t *surface; diff --git a/tools/font-edit/twin-fedit.h b/tools/font-edit/font-edit.h similarity index 100% rename from tools/font-edit/twin-fedit.h rename to tools/font-edit/font-edit.h diff --git a/tools/font-edit/sfit.c b/tools/font-edit/sfit.c index 7ef122b..f0db071 100644 --- a/tools/font-edit/sfit.c +++ b/tools/font-edit/sfit.c @@ -20,7 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#include "twin-fedit.h" +#include "font-edit.h" static double min(double a, double b) {