-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Port font editor to SDL2 #59
base: main
Are you sure you want to change the base?
Conversation
You don't have to write the message |
54d876b
to
dd01a82
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can I control the second control point, pt[1], when I press pt[2]? I can currently only control the first control point, pt[0].
Sorry, this function is not supported now. I'm trying to figure out how to let the second control point be moved by user. |
I figure out how to control second point. Press shift and arrow key at same time to move the control point. static void tweak_spline(char_t *c, cmd_t *first, int p2, double dx, double dy)
{
int i = p2 ? 1 : 0;
push(c);
first->pt[i].x += dx;
first->pt[i].y += dy;
} This |
The statement |
b10cff1
to
ada8e48
Compare
{ | ||
char_t *c; | ||
|
||
if (!init(argc, argv)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dump the usage before calling exit
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+ char_t *c;
+
+ /*
+ * Use the following command to start twin-fedit:
Don't do that. Dump the message.
What kind of usage should I dump here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can simply change the behavior of this font editor, allowing read a file from given filename (argv[1]
). Thus, you can check argument count and the existence of file to proceed.
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_first_cmd() 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 instructions and descriptions in the READMD. 1. Add the background of twin-fedit 2. Add Key bindings 3. Add a quick guide 4. Add demo GIF of twin-fedit
char_t *c; | ||
|
||
/* | ||
* Use the following command to start twin-fedit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't do that. Dump the message.
|
||
XClearArea(dpy, win, 0, 0, 0, 0, True); | ||
for (;;) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to merge the outer and inner loop. That is, use one while
statement.
## 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 Hershey vector fonts set of `twin-fedit` is [`nchars`](./nchars), for example, the interpolation points and operations used to draw the font `1` are as follows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop ./
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1
is not "font". Instead, it is a glyph.
Replace X11 with SDL2 to improve the portability and cross-platform support
Migrated window creation from X11's
XCreateWindow
toSDL_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
andSDL_Surface
, replacing X11's rendering functions.