mirror of
git://projects.qi-hardware.com/antorcha.git
synced 2024-11-01 05:15:20 +02:00
tools/libtxt/edit.c (do_edit): load a default font if user doesn't set one
Before, we simply segfaulted.
This commit is contained in:
parent
6bf69b9358
commit
3219319716
@ -20,6 +20,9 @@
|
|||||||
#include "libtxt.h"
|
#include "libtxt.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define DEFAULT_FONT "5x7"
|
||||||
|
|
||||||
|
|
||||||
/* ----- Render a list of editing instructions ----------------------------- */
|
/* ----- Render a list of editing instructions ----------------------------- */
|
||||||
|
|
||||||
|
|
||||||
@ -95,6 +98,11 @@ static int do_edit(uint8_t *canvas, int width, int height,
|
|||||||
while (e) {
|
while (e) {
|
||||||
switch (e->type) {
|
switch (e->type) {
|
||||||
case edit_string:
|
case edit_string:
|
||||||
|
if (!font) {
|
||||||
|
font = load_font(DEFAULT_FONT, error);
|
||||||
|
if (!font)
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
for (s = e->u.s; *s; s++) {
|
for (s = e->u.s; *s; s++) {
|
||||||
xo = draw_char(canvas, width, height,
|
xo = draw_char(canvas, width, height,
|
||||||
font, *s, x, y);
|
font, *s, x, y);
|
||||||
|
Loading…
Reference in New Issue
Block a user