libcaca  0.99.beta19
About: libcaca is a graphics library that outputs text instead of pixels, so that it can work on older video cards or text terminals (something like an advanced AAlib library).
  Fossies Dox: libcaca-0.99.beta19.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

figfont.c
Go to the documentation of this file.
1 /*
2  * libcaca Colour ASCII-Art library
3  * Copyright (c) 2002-2012 Sam Hocevar <sam@hocevar.net>
4  * All Rights Reserved
5  *
6  * This library is free software. It comes without any warranty, to
7  * the extent permitted by applicable law. You can redistribute it
8  * and/or modify it under the terms of the Do What the Fuck You Want
9  * to Public License, Version 2, as published by Sam Hocevar. See
10  * http://www.wtfpl.net/ for more details.
11  */
12 
13 /*
14  * This file contains FIGlet and TOIlet font handling functions.
15  */
16 
17 /*
18  * FIXME: this file needs huge cleanup to be usable
19  */
20 
21 #include "config.h"
22 
23 #if !defined(__KERNEL__)
24 # include <stdio.h>
25 # include <stdlib.h>
26 # include <string.h>
27 #endif
28 
29 #include "caca.h"
30 #include "caca_internals.h"
31 
32 #if defined _WIN32 && defined __GNUC__ && __GNUC__ >= 3
33 int sprintf_s(char *s, size_t n, const char *fmt, ...) CACA_WEAK;
34 int vsnprintf(char *s, size_t n, const char *fmt, va_list ap) CACA_WEAK;
35 #endif
36 
38 {
40  int x, y, w, h, lines;
41 
44  uint32_t hardblank;
48  int glyphs;
50  int *left, *right; /* Unused yet */
51  uint32_t *lookup;
52 };
53 
54 static uint32_t hsmush(uint32_t ch1, uint32_t ch2, int rule);
55 static caca_charfont_t * open_charfont(char const *);
56 static int free_charfont(caca_charfont_t *);
58 
60 int caca_canvas_set_figfont(caca_canvas_t *cv, char const *path)
61 {
62  caca_charfont_t *ff = NULL;
63 
64  if (path)
65  {
66  ff = open_charfont(path);
67  if (!ff)
68  return -1;
69  }
70 
71  if (cv->ff)
72  {
74  free(cv->ff->left);
75  free(cv->ff->right);
77  }
78 
79  cv->ff = ff;
80 
81  if (!path)
82  return 0;
83 
84  /* from TOIlet’s main.c -- can be overriden by user */
85  ff->term_width = 80;
86  ff->hmode = H_DEFAULT;
87 
88  /* from TOIlet’s render.c */
89  ff->x = ff->y = 0;
90  ff->w = ff->h = 0;
91  ff->lines = 0;
92  caca_set_canvas_size(cv, 0, 0); /* XXX */
93 
94  cv->ff = ff;
95 
97 
98  return 0;
99 }
100 
103 {
104  caca_charfont_t *ff = cv->ff;
105 
106  if (!cv->ff)
107  return 0;
108 
109  ff->term_width = width;
110 
112 
113  return 0;
114 }
115 
118 {
119  caca_charfont_t *ff = cv->ff;
120 
121  if (!cv->ff)
122  return 0;
123 
124  if (!strcasecmp(mode, "default"))
125  ff->hmode = H_DEFAULT;
126  else if (!strcasecmp(mode, "kern"))
127  ff->hmode = H_KERN;
128  else if (!strcasecmp(mode, "smush"))
129  ff->hmode = H_SMUSH;
130  else if (!strcasecmp(mode, "none"))
131  ff->hmode = H_NONE;
132  else if (!strcasecmp(mode, "overlap"))
133  ff->hmode = H_OVERLAP;
134  else
135  ff->hmode = H_DEFAULT;
136 
138 
139  return 0;
140 }
141 
144 {
145  caca_charfont_t *ff = cv->ff;
146  int c, w, h, x, y, overlap, extra, xleft, xright;
147 
148  if (!ff)
149  return -1;
150 
151  switch(ch)
152  {
153  case (uint32_t)'\r':
154  return 0;
155  case (uint32_t)'\n':
156  ff->x = 0;
157  ff->y += ff->height;
158  return 0;
159  /* FIXME: handle '\t' */
160  }
161 
162  /* Look whether our glyph is available */
163  for(c = 0; c < ff->glyphs; c++)
164  if(ff->lookup[c * 2] == ch)
165  break;
166 
167  if(c == ff->glyphs)
168  return 0;
169 
170  w = ff->lookup[c * 2 + 1];
171  h = ff->height;
172 
173  caca_set_canvas_handle(ff->fontcv, 0, c * ff->height);
174  caca_blit(ff->charcv, 0, 0, ff->fontcv, NULL);
175 
176  /* Check whether we reached the end of the screen */
177  if(ff->x && ff->x + w > ff->term_width)
178  {
179  ff->x = 0;
180  ff->y += h;
181  }
182 
183  /* Compute how much the next character will overlap */
184  switch(ff->hmode)
185  {
186  case H_SMUSH:
187  case H_KERN:
188  case H_OVERLAP:
189  extra = (ff->hmode == H_OVERLAP);
190  overlap = w;
191  for(y = 0; y < h; y++)
192  {
193  /* Compute how much spaces we can eat from the new glyph */
194  for(xright = 0; xright < overlap; xright++)
195  if(caca_get_char(ff->charcv, xright, y) != ' ')
196  break;
197 
198  /* Compute how much spaces we can eat from the previous glyph */
199  for(xleft = 0; xright + xleft < overlap && xleft < ff->x; xleft++)
200  if(caca_get_char(cv, ff->x - 1 - xleft, ff->y + y) != ' ')
201  break;
202 
203  /* Handle overlapping */
204  if(ff->hmode == H_OVERLAP && xleft < ff->x)
205  xleft++;
206 
207  /* Handle smushing */
208  if(ff->hmode == H_SMUSH)
209  {
210  if(xleft < ff->x &&
211  hsmush(caca_get_char(cv, ff->x - 1 - xleft, ff->y + y),
212  caca_get_char(ff->charcv, xright, y),
213  ff->hsmushrule))
214  xleft++;
215  }
216 
217  if(xleft + xright < overlap)
218  overlap = xleft + xright;
219  }
220  break;
221  case H_NONE:
222  overlap = 0;
223  break;
224  default:
225  return -1;
226  }
227 
228  /* Check whether the current canvas is large enough */
229  if(ff->x + w - overlap > ff->w)
230  ff->w = ff->x + w - overlap < ff->term_width
231  ? ff->x + w - overlap : ff->term_width;
232 
233  if(ff->y + h > ff->h)
234  ff->h = ff->y + h;
235 
236 #if 0 /* deactivated for libcaca insertion */
237  if(attr)
238  caca_set_attr(cv, attr);
239 #endif
240  caca_set_canvas_size(cv, ff->w, ff->h);
241 
242  /* Render our char (FIXME: create a rect-aware caca_blit_canvas?) */
243  for(y = 0; y < h; y++)
244  for(x = 0; x < w; x++)
245  {
246  uint32_t ch1, ch2;
247  uint32_t tmpat = caca_get_attr(ff->fontcv, x, y + c * ff->height);
248  ch2 = caca_get_char(ff->charcv, x, y);
249  if(ch2 == ' ')
250  continue;
251  ch1 = caca_get_char(cv, ff->x + x - overlap, ff->y + y);
252  if(ch1 == ' ' || ff->hmode != H_SMUSH)
253  caca_put_char(cv, ff->x + x - overlap, ff->y + y, ch2);
254  else
255  caca_put_char(cv, ff->x + x - overlap, ff->y + y,
256  hsmush(ch1, ch2, ff->hsmushrule));
257  caca_put_attr(cv, ff->x + x, ff->y + y, tmpat);
258  }
259 
260  /* Advance cursor */
261  ff->x += w - overlap;
262 
263  return 0;
264 }
265 
268 {
269  caca_charfont_t *ff = cv->ff;
270  int x, y;
271 
272  if (!ff)
273  return -1;
274 
275  //ff->torender = cv;
276  //caca_set_canvas_size(ff->torender, ff->w, ff->h);
277  caca_set_canvas_size(cv, ff->w, ff->h);
278 
279  /* FIXME: do this somewhere else, or record hardblank positions */
280  for(y = 0; y < ff->h; y++)
281  for(x = 0; x < ff->w; x++)
282  if(caca_get_char(cv, x, y) == 0xa0)
283  {
284  uint32_t attr = caca_get_attr(cv, x, y);
285  caca_put_char(cv, x, y, ' ');
286  caca_put_attr(cv, x, y, attr);
287  }
288 
289  ff->x = ff->y = 0;
290  ff->w = ff->h = 0;
291 
292  //cv = caca_create_canvas(1, 1); /* XXX */
293 
294  /* from render.c */
296 
297  return 0;
298 }
299 
300 #define STD_GLYPHS (127 - 32)
301 #define EXT_GLYPHS (STD_GLYPHS + 7)
302 
303 static caca_charfont_t * open_charfont(char const *path)
304 {
305  char buf[2048];
306  char hardblank[10];
307  caca_charfont_t *ff;
308  char *data = NULL;
309  caca_file_t *f;
310 #if !defined __KERNEL__ && (defined HAVE_SNPRINTF || defined HAVE_SPRINTF_S)
311  int const pathlen = 2048;
312  char *altpath = NULL;
313 #endif
314  int i, j, size, comment_lines;
315 
316  ff = malloc(sizeof(caca_charfont_t));
317  if(!ff)
318  {
319  seterrno(ENOMEM);
320  return NULL;
321  }
322 
323  /* Open font: if not found, try .tlf, then .flf */
324  f = caca_file_open(path, "r");
325 #if !defined __KERNEL__ && (defined HAVE_SNPRINTF || defined HAVE_SPRINTF_S)
326  if(!f)
327  altpath = malloc(pathlen);
328  if(!f)
329  {
330 #if defined HAVE_SPRINTF_S
331  sprintf_s(altpath, pathlen - 1, "%s.tlf", path);
332 #else
333  snprintf(altpath, pathlen - 1, "%s.tlf", path);
334 #endif
335  altpath[pathlen - 1] = '\0';
336  f = caca_file_open(altpath, "r");
337  }
338  if(!f)
339  {
340 #if defined HAVE_SPRINTF_S
341  sprintf_s(altpath, pathlen - 1, "%s.flf", path);
342 #else
343  snprintf(altpath, pathlen - 1, "%s.flf", path);
344 #endif
345  altpath[pathlen - 1] = '\0';
346  f = caca_file_open(altpath, "r");
347  }
348  if (altpath)
349  free(altpath);
350 #endif
351  if(!f)
352  {
353  free(ff);
354  seterrno(ENOENT);
355  return NULL;
356  }
357 
358  /* Read header */
359  ff->print_direction = 0;
360  ff->full_layout = 0;
361  ff->codetag_count = 0;
362  caca_file_gets(f, buf, 2048);
363  if(sscanf(buf, "%*[ft]lf2a%6s %u %u %u %i %u %u %u %u\n", hardblank,
364  &ff->height, &ff->baseline, &ff->max_length,
365  &ff->old_layout, &comment_lines, &ff->print_direction,
366  &ff->full_layout, &ff->codetag_count) < 6)
367  {
368  debug("figfont error: `%s' has invalid header: %s", path, buf);
369  caca_file_close(f);
370  free(ff);
371  seterrno(EINVAL);
372  return NULL;
373  }
374 
375  if(ff->old_layout < -1 || ff->old_layout > 63 || ff->full_layout > 32767
376  || ((ff->full_layout & 0x80) && (ff->full_layout & 0x3f) == 0
377  && ff->old_layout))
378  {
379  debug("figfont error: `%s' has invalid layout %i/%u",
380  path, ff->old_layout, ff->full_layout);
381  caca_file_close(f);
382  free(ff);
383  seterrno(EINVAL);
384  return NULL;
385  }
386 
387  ff->hardblank = caca_utf8_to_utf32(hardblank, NULL);
388 
389  /* Skip comment lines */
390  for(i = 0; i < comment_lines; i++)
391  caca_file_gets(f, buf, 2048);
392 
393  /* Read mandatory characters (32-127, 196, 214, 220, 228, 246, 252, 223)
394  * then read additional characters. */
395  ff->glyphs = 0;
396  ff->lookup = NULL;
397 
398  for(i = 0, size = 0; !caca_file_eof(f); ff->glyphs++)
399  {
400  if((ff->glyphs % 2048) == 0)
401  ff->lookup = realloc(ff->lookup,
402  (ff->glyphs + 2048) * 2 * sizeof(int));
403 
404  if(ff->glyphs < STD_GLYPHS)
405  {
406  ff->lookup[ff->glyphs * 2] = 32 + ff->glyphs;
407  }
408  else if(ff->glyphs < EXT_GLYPHS)
409  {
410  static int const tab[7] = { 196, 214, 220, 228, 246, 252, 223 };
411  ff->lookup[ff->glyphs * 2] = tab[ff->glyphs - STD_GLYPHS];
412  }
413  else
414  {
415  unsigned int tmp;
416 
417  if(caca_file_gets(f, buf, 2048) == NULL)
418  break;
419 
420  /* Ignore blank lines, as in jacky.flf */
421  if(buf[0] == '\n' || buf[0] == '\r')
422  continue;
423 
424  /* Ignore negative indices for now, as in ivrit.flf */
425  if(buf[0] == '-')
426  {
427  for(j = 0; j < ff->height; j++)
428  caca_file_gets(f, buf, 2048);
429  continue;
430  }
431 
432  if(!buf[0] || buf[0] < '0' || buf[0] > '9')
433  {
434  debug("figfont error: glyph #%u in `%s'", ff->glyphs, path);
435  free(data);
436  free(ff->lookup);
437  free(ff);
438  seterrno(EINVAL);
439  return NULL;
440  }
441 
442  sscanf(buf, buf[1] == 'x' ? "%x" : "%u", &tmp);
443  ff->lookup[ff->glyphs * 2] = tmp;
444  }
445 
446  ff->lookup[ff->glyphs * 2 + 1] = 0;
447 
448  for(j = 0; j < ff->height; j++)
449  {
450  if(i + 2048 >= size)
451  data = realloc(data, size += 2048);
452 
453  caca_file_gets(f, data + i, 2048);
454  i = (uintptr_t)strchr(data + i, 0) - (uintptr_t)data;
455  }
456  }
457 
458  caca_file_close(f);
459 
460  if(ff->glyphs < EXT_GLYPHS)
461  {
462  debug("figfont error: only %u glyphs in `%s', expected at least %u",
463  ff->glyphs, path, EXT_GLYPHS);
464  free(data);
465  free(ff->lookup);
466  free(ff);
467  seterrno(EINVAL);
468  return NULL;
469  }
470 
471  /* Remaining initialisation */
472  ff->charcv = NULL;
473  ff->left = NULL;
474  ff->right = NULL;
475 
476  /* Import buffer into canvas */
477  ff->fontcv = caca_create_canvas(0, 0);
478  caca_import_canvas_from_memory(ff->fontcv, data, i, "utf8");
479  free(data);
480 
481  /* Remove EOL characters. For now we ignore hardblanks, don’t do any
482  * smushing, nor any kind of error checking. */
483  for(j = 0; j < ff->height * ff->glyphs; j++)
484  {
485  uint32_t ch, oldch = 0;
486 
487  for(i = ff->max_length; i--;)
488  {
489  ch = caca_get_char(ff->fontcv, i, j);
490 
491  /* Replace hardblanks with U+00A0 NO-BREAK SPACE */
492  if(ch == ff->hardblank)
493  caca_put_char(ff->fontcv, i, j, ch = 0xa0);
494 
495  if(oldch && ch != oldch)
496  {
497  if(!ff->lookup[j / ff->height * 2 + 1])
498  ff->lookup[j / ff->height * 2 + 1] = i + 1;
499  }
500  else if(oldch && ch == oldch)
501  caca_put_char(ff->fontcv, i, j, ' ');
502  else if(ch != ' ')
503  {
504  oldch = ch;
505  caca_put_char(ff->fontcv, i, j, ' ');
506  }
507  }
508  }
509 
510  return ff;
511 }
512 
514 {
516  free(ff->lookup);
517  free(ff);
518 
519  return 0;
520 }
521 
523 {
524  caca_charfont_t *ff = cv->ff;
525 
526  if (!cv->ff)
527  return;
528 
529  /* from TOIlet’s figlet.c */
530  if (ff->full_layout & 0x3f)
531  ff->hsmushrule = ff->full_layout & 0x3f;
532  else if (ff->old_layout > 0)
533  ff->hsmushrule = ff->old_layout;
534 
535  switch (ff->hmode)
536  {
537  case H_DEFAULT:
538  if (ff->old_layout == -1)
539  ff->hmode = H_NONE;
540  else if (ff->old_layout == 0 && (ff->full_layout & 0xc0) == 0x40)
541  ff->hmode = H_KERN;
542  else if ((ff->old_layout & 0x3f) && (ff->full_layout & 0x3f)
543  && (ff->full_layout & 0x80))
544  {
545  ff->hmode = H_SMUSH;
546  ff->hsmushrule = ff->full_layout & 0x3f;
547  }
548  else if (ff->old_layout == 0 && (ff->full_layout & 0xbf) == 0x80)
549  {
550  ff->hmode = H_SMUSH;
551  ff->hsmushrule = 0x3f;
552  }
553  else
554  ff->hmode = H_OVERLAP;
555  break;
556  default:
557  break;
558  }
559 
560  if (ff->charcv)
562  ff->charcv = caca_create_canvas(ff->max_length - 2, ff->height);
563 
564  free(ff->left);
565  free(ff->right);
566  ff->left = malloc(ff->height * sizeof(int));
567  ff->right = malloc(ff->height * sizeof(int));
568 }
569 
570 static uint32_t hsmush(uint32_t ch1, uint32_t ch2, int rule)
571 {
572  /* Rule 1 */
573  if((rule & 0x01) && ch1 == ch2 && ch1 != 0xa0)
574  return ch2;
575 
576  if(ch1 < 0x80 && ch2 < 0x80)
577  {
578  char const charlist[] = "|/\\[]{}()<>";
579  char *tmp1, *tmp2;
580 
581  /* Rule 2 */
582  if(rule & 0x02)
583  {
584  if(ch1 == '_' && strchr(charlist, ch2))
585  return ch2;
586 
587  if(ch2 == '_' && strchr(charlist, ch1))
588  return ch1;
589  }
590 
591  /* Rule 3 */
592  if((rule & 0x04) &&
593  (tmp1 = strchr(charlist, ch1)) && (tmp2 = strchr(charlist, ch2)))
594  {
595  int cl1 = (tmp1 + 1 - charlist) / 2;
596  int cl2 = (tmp2 + 1 - charlist) / 2;
597 
598  if(cl1 < cl2)
599  return ch2;
600  if(cl1 > cl2)
601  return ch1;
602  }
603 
604  /* Rule 4 */
605  if(rule & 0x08)
606  {
607  uint16_t s = ch1 + ch2;
608  uint16_t p = ch1 * ch2;
609 
610  if(p == 15375 /* '{' * '}' */
611  || p == 8463 /* '[' * ']' */
612  || (p == 1640 && s == 81)) /* '(' *|+ ')' */
613  return '|';
614  }
615 
616  /* Rule 5 */
617  if(rule & 0x10)
618  {
619  switch((ch1 << 8) | ch2)
620  {
621  case 0x2f5c: return '|'; /* /\ */
622  case 0x5c2f: return 'Y'; /* \/ */
623  case 0x3e3c: return 'X'; /* >< */
624  }
625  }
626 
627  /* Rule 6 */
628  if((rule & 0x20) && ch1 == ch2 && ch1 == 0xa0)
629  return 0xa0;
630  }
631 
632  return 0;
633 }
634 
635 /*
636  * Functions for the mingw32 runtime
637  */
638 
639 #if defined _WIN32 && defined __GNUC__ && __GNUC__ >= 3
640 int sprintf_s(char *s, size_t n, const char *fmt, ...)
641 {
642  va_list args;
643  int ret;
644  va_start(args, fmt);
645  ret = vsnprintf(s, n, fmt, args);
646  va_end(args);
647  return ret;
648 }
649 
650 int vsnprintf(char *s, size_t n, const char *fmt, va_list ap)
651 {
652  return 0;
653 }
654 #endif
655 
656 /*
657  * XXX: The following functions are aliases.
658  */
659 
660 int cucul_canvas_set_figfont(cucul_canvas_t *, char const *)
664 
open_charfont
static caca_charfont_t * open_charfont(char const *)
Definition: figfont.c:303
caca_charfont::fontcv
caca_canvas_t * fontcv
Definition: figfont.c:49
caca_file
Definition: file.c:38
CACA_ALIAS
#define CACA_ALIAS(x)
Definition: caca.h:689
caca_charfont::y
int y
Definition: figfont.c:40
caca_blit
int caca_blit(caca_canvas_t *, int, int, caca_canvas_t const *, caca_canvas_t const *)
Blit a canvas onto another one.
Definition: string.c:455
caca_charfont::right
int * right
Definition: figfont.c:50
caca_canvas_set_figfont
int caca_canvas_set_figfont(caca_canvas_t *cv, char const *path)
load a figfont and attach it to a canvas
Definition: figfont.c:60
CACA_WEAK
#define CACA_WEAK
Definition: caca.h:695
caca_charfont::left
int * left
Definition: figfont.c:50
free_charfont
static int free_charfont(caca_charfont_t *)
Definition: figfont.c:513
caca_charfont::H_DEFAULT
Definition: figfont.c:42
y
static int y
Definition: cacadraw.c:27
caca_charfont::H_OVERLAP
Definition: figfont.c:42
caca_set_attr
int caca_set_attr(caca_canvas_t *cv, uint32_t attr)
Set the default character attribute.
Definition: attr.c:97
caca_flush_figlet
int caca_flush_figlet(caca_canvas_t *cv)
flush the figlet context
Definition: figfont.c:267
caca_file_eof
int caca_file_eof(caca_file_t *)
Tell whether a file handle reached end of file.
Definition: file.c:298
update_figfont_settings
static void update_figfont_settings(caca_canvas_t *cv)
Definition: figfont.c:522
caca_create_canvas
caca_canvas_t * caca_create_canvas(int, int)
Initialise a libcaca canvas.
Definition: canvas.c:54
caca_free_canvas
int caca_free_canvas(caca_canvas_t *)
Free a libcaca canvas.
Definition: canvas.c:308
caca_get_canvas_height
int caca_get_canvas_height(caca_canvas_t const *)
Get the canvas height.
Definition: canvas.c:253
caca_charfont::max_length
int max_length
Definition: figfont.c:45
caca_put_figchar
int caca_put_figchar(caca_canvas_t *cv, uint32_t ch)
paste a character using the current figfont
Definition: figfont.c:143
caca_charfont::height
int height
Definition: figfont.c:45
caca_charfont::print_direction
int print_direction
Definition: figfont.c:47
caca_charfont::glyphs
int glyphs
Definition: figfont.c:48
caca_charfont::full_layout
int full_layout
Definition: figfont.c:47
strcasecmp
#define strcasecmp
Definition: config.h:95
caca_set_figfont_width
int caca_set_figfont_width(caca_canvas_t *cv, int width)
set the width of the figfont rendering
Definition: figfont.c:102
snprintf
#define snprintf
Definition: config.h:96
seterrno
#define seterrno(x)
Definition: caca_stubs.h:27
caca_charfont::lookup
uint32_t * lookup
Definition: figfont.c:51
mode
int mode
Definition: cacaview.c:60
caca_get_attr
uint32_t caca_get_attr(caca_canvas_t const *cv, int x, int y)
Get the text attribute at the given coordinates.
Definition: attr.c:66
cucul_put_figchar
#define cucul_put_figchar
Definition: caca.h:847
cucul_canvas_t
#define cucul_canvas_t
Definition: caca.h:763
cucul_flush_figlet
#define cucul_flush_figlet
Definition: caca.h:848
cv
caca_canvas_t * cv
Definition: cacaview.c:45
caca_file_close
int caca_file_close(caca_file_t *)
Close a file handle.
Definition: file.c:151
caca_set_figfont_smush
int caca_set_figfont_smush(caca_canvas_t *cv, char const *mode)
set the smushing mode of the figfont rendering
Definition: figfont.c:117
caca_charfont::old_layout
int old_layout
Definition: figfont.c:46
caca_charfont::codetag_count
int codetag_count
Definition: figfont.c:47
caca_charfont::h
int h
Definition: figfont.c:40
caca_import_canvas_from_memory
ssize_t caca_import_canvas_from_memory(caca_canvas_t *, void const *, size_t, char const *)
Import a memory buffer into a canvas.
Definition: import.c:73
caca_put_char
int caca_put_char(caca_canvas_t *, int, int, uint32_t)
Print an ASCII or Unicode character.
Definition: string.c:120
caca_internals.h
caca_charfont::x
int x
Definition: figfont.c:40
caca_charfont::hsmushrule
int hsmushrule
Definition: figfont.c:43
caca_set_canvas_handle
int caca_set_canvas_handle(caca_canvas_t *, int, int)
Set cursor handle.
Definition: string.c:403
caca_put_attr
int caca_put_attr(caca_canvas_t *cv, int x, int y, uint32_t attr)
Set the character attribute at the given coordinates.
Definition: attr.c:182
caca_charfont::term_width
int term_width
Definition: figfont.c:39
caca_utf8_to_utf32
uint32_t caca_utf8_to_utf32(char const *, size_t *)
Convert a UTF-8 character to UTF-32.
Definition: charset.c:112
caca_canvas::ff
caca_charfont_t * ff
Definition: caca_internals.h:77
caca_charfont::baseline
int baseline
Definition: figfont.c:45
caca_file_open
caca_file_t * caca_file_open(char const *, const char *)
Open a file for reading or writing.
Definition: file.c:64
caca_set_canvas_size
int caca_set_canvas_size(caca_canvas_t *, int, int)
Resize a canvas.
Definition: canvas.c:212
caca.h
The libcaca public header.
caca_charfont::H_NONE
Definition: figfont.c:42
caca_charfont
Definition: figfont.c:37
config.h
caca_get_char
uint32_t caca_get_char(caca_canvas_t const *, int, int)
Get the Unicode character at the given coordinates.
Definition: string.c:224
STD_GLYPHS
#define STD_GLYPHS
Definition: figfont.c:300
caca_charfont::H_KERN
Definition: figfont.c:42
caca_charfont::hmode
enum caca_charfont::@9 hmode
caca_charfont::hardblank
uint32_t hardblank
Definition: figfont.c:44
caca_charfont::charcv
caca_canvas_t * charcv
Definition: figfont.c:49
debug
#define debug(format,...)
Definition: caca_debug.h:36
cucul_canvas_set_figfont
#define cucul_canvas_set_figfont
Definition: caca.h:846
hsmush
static uint32_t hsmush(uint32_t ch1, uint32_t ch2, int rule)
Definition: figfont.c:570
caca_file_gets
char * caca_file_gets(caca_file_t *, char *, int)
Read a line from a file handle.
Definition: file.c:255
caca_charfont::w
int w
Definition: figfont.c:40
EXT_GLYPHS
#define EXT_GLYPHS
Definition: figfont.c:301
caca_charfont::lines
int lines
Definition: figfont.c:40
caca_charfont::H_SMUSH
Definition: figfont.c:42
caca_canvas
Definition: caca_internals.h:47
x
static int x
Definition: cacadraw.c:27