Skip to content

Commit 54d876b

Browse files
committed
Port font editor to SDL2
Replace X11 with SDL2 to improve the portability and cross-platform support Migrated window creation from X11's `XCreateWindow` to `SDL_CreateWindow`. Replaced X11 event handling with SDL2’s event loop (`SDL_PollEvent`) to capture input events such as keyboard and mouse interactions. Updated rendering to use `SDL_Renderer` and `SDL_Surface`, replacing X11's rendering functions. * Modified some key event logic: 1. SDLK_ESCAPE: ESC now exits the program. 2. SDL_QUIT: Clicking the "X" on the window exits the program. * Unchanged key event logic: 1. SDLK_q: Switches to the next font. * Rename delete function: 1. Rename delete() to delete_char() to avoid `clang-format` misinterpreting `delete()` as the C++ the keyword, which cauese an extra space to be added when running `clang-format`, turning `delete()` to `delete ()`. * Add operation instructions in the READMD.
1 parent 35ddf50 commit 54d876b

File tree

4 files changed

+188
-144
lines changed

4 files changed

+188
-144
lines changed

tools/font-edit/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
TARGET = twin-fedit
22

3-
CFLAGS = $(shell pkg-config --cflags cairo x11) -g -Wall
4-
LIBS = $(shell pkg-config --libs cairo x11)
3+
CFLAGS = $(shell pkg-config --cflags cairo) $(shell sdl2-config --cflags) -g -Wall
4+
LIBS = $(shell pkg-config --libs cairo) $(shell sdl2-config --libs)
55

66
OBJS = \
77
twin-fedit.o \

tools/font-edit/README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ screens.
55

66
## Build Dependency
77
```shell
8-
sudo apt-get install libx11-dev libcairo2-dev
8+
sudo apt-get install libsdl2-dev libcairo2-dev
99
```
1010

1111
## Usage
@@ -14,4 +14,13 @@ make
1414
./twin-fedit < nchars
1515
```
1616

17-
(press 'q' to next character)
17+
| Key binding | Function |
18+
| --- | --- |
19+
| `esc` | Exit program |
20+
| `left mouse button` | Select a point as start point |
21+
| `right mouse button` | Select a point as end point |
22+
| `d` | Delete selected point|
23+
| `f`| Replace a line with a spline |
24+
| `q` | Next character |
25+
| `s` | Split a spline into two splines by start point and end point |
26+
| `u` | Undo the last operation |

0 commit comments

Comments
 (0)