|
1 | 1 | # twin-fedit
|
2 | 2 | `twin-fedit` is a tool allowing users to edit specific scalable fonts
|
3 |
| -which are expected to fit the requirements of embedded systems with larger |
4 |
| -screens. |
| 3 | +which are expected to fit the requirements of embedded systems with larger screens. |
| 4 | + |
| 5 | +<p align="center"> |
| 6 | + <img src="./assets/demo.gif" /> |
| 7 | +</p> |
5 | 8 |
|
6 | 9 | ## Build Dependency
|
7 | 10 | ```shell
|
8 |
| -sudo apt-get install libx11-dev libcairo2-dev |
| 11 | +sudo apt-get install libsdl2-dev libcairo2-dev |
9 | 12 | ```
|
10 | 13 |
|
11 | 14 | ## Usage
|
12 | 15 | ```shell
|
13 | 16 | make
|
14 |
| -./twin-fedit < nchars |
| 17 | +./twin-fedit nchars |
| 18 | +``` |
| 19 | + |
| 20 | +## Background |
| 21 | +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. |
| 22 | + |
| 23 | +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 |
| 24 | +``` |
| 25 | +/* 0x31 '1' offset 666 */ |
| 26 | + 0, 10, 42, 0, 2, 3, |
| 27 | + 0, 10, /* snap_x */ |
| 28 | + -21, -15, 0, /* snap_y */ |
| 29 | + 'm', 0, -34, |
| 30 | + 'c', 4, -35, 8, -38, 10, -42, |
| 31 | + 'l', 10, 0, |
| 32 | + 'e', |
15 | 33 | ```
|
16 | 34 |
|
17 |
| -(press 'q' to next character) |
| 35 | +The first line to 4-th line are used to draw the glyph. |
| 36 | + |
| 37 | +The first line of is the header that contains the information of the character `1`, `0x31` is the ASCII code of `1` and offset `666` is the |
| 38 | + |
| 39 | +The character `m` is an abbreviation for `move to`, and the values following `m` represent the x and y positions to move to in the drawing window's coordinate system, respectively. |
| 40 | + |
| 41 | +The character `c` is an abbreviation for `curve to`, and the values following `c` represent three x-y coordinate points used to draw a cubic Bézier curve, in the order of the first control point, the second control point, and the endpoint. |
| 42 | + |
| 43 | +The character `l` is an abbreviation for `line to`, and the values following `l` represent the x and y positions to move to, relative to the position from the previous operation, in the drawing window's coordinate system, respectively. |
| 44 | + |
| 45 | +The character `e` is an abbreviation for `end`. |
| 46 | + |
| 47 | +According to the steps outlined above for drawing glyph `1`, it can be split into the following steps: |
| 48 | + |
| 49 | +1. `'m' 0,-34`: Move to `0,-34` and plot a point at `0,-34`. |
| 50 | +2. `'c' 4, -35, 8, -38, 10, -42`: Starting from `0,-34` and ending at `10,-42`, draw a curve using Bézier curve with the first control point at `4,-35` and the second control point at `8,-38`. |
| 51 | +3. `'l' 10,0`: Starting from `10,-42` and ending at `10,0`, draw a straight line. |
| 52 | +4. `'e'`: End the drawing of glyph `1`. |
| 53 | + |
| 54 | +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. |
| 55 | + |
| 56 | +## Quick Guide |
| 57 | +For each glyph, there are the following shortcut keys used for editing the glyph. |
| 58 | + |
| 59 | +| Key | Functionality | |
| 60 | +| --- | --- | |
| 61 | +| ESC | Exit program | |
| 62 | +| left mouse button | Select a point as the first operation for that glyph | |
| 63 | +| right mouse button | Select a point as the last operation for that glyph | |
| 64 | +| d | Delete selected point| |
| 65 | +| f | Replace a line with a spline | |
| 66 | +| q | Switch to next character | |
| 67 | +| s | Split a spline into two splines by start point and end point | |
| 68 | +| u | Undo the last operation | |
| 69 | + |
| 70 | + |
| 71 | +To move a point |
| 72 | +1. Select a point by left mouse button, |
| 73 | +2. Use arrow keys to move the selected point. |
| 74 | + |
| 75 | +To move a control point |
| 76 | +1. Select a point with two control points by left mouse button, |
| 77 | +2. Use arrow keys to move the first control point, |
| 78 | +3. Keep pressing shift key and use arrow keys to move the second control point. |
| 79 | + |
| 80 | +To split a spline or line |
| 81 | +1. Select two point by left and right mouse button, |
| 82 | +2. Use s key to split the line or spline into two segments. |
| 83 | + |
| 84 | +To replace the line or spline by another spline |
| 85 | +1. Select two point by left and right mouse button as start and end of the another spline, |
| 86 | +2. Use f key to replace the line or spline with another spline. |
| 87 | + |
| 88 | +To delete a point |
| 89 | +1. Select a point by left mouse button, |
| 90 | +2. Use d key to delete the selected point. |
| 91 | + |
| 92 | +To undo any operations above |
| 93 | +1. Use u key. |
0 commit comments