20#include <grass/glocale.h>
21#include <grass/fontcap.h>
29 return access(
name, R_OK) >= 0;
43 char name[GNAME_MAX], longname[GNAME_MAX],
path[GPATH_MAX], encoding[128];
46 if (sscanf(str,
"%[^|]|%[^|]|%d|%[^|]|%d|%[^|]|",
name, longname, &type,
47 path, &index, encoding) == 6) {
52 else if (sscanf(str,
"%[^|]|%[^|]|%d||%d|%[^|]|",
name, longname, &type,
53 &index, encoding) == 5)
59 e->longname =
G_store(longname);
63 e->encoding =
G_store(encoding);
75 char *capfile,
file[GPATH_MAX];
79 struct GFONT_CAP *fonts =
NULL;
82 if ((capfile = getenv(
"GRASS_FONT_CAP"))) {
83 if ((fp = fopen(capfile,
"r")) ==
NULL)
85 _(
"%s: Unable to read font definition file; use the default"),
95 while (fgets(buf,
sizeof(buf), fp) && !feof(fp)) {
107 G_realloc(fonts, (fonts_count + 1) *
sizeof(
struct GFONT_CAP));
108 fonts[fonts_count++] = cap;
114 fonts = G_realloc(fonts, (fonts_count + 1) *
sizeof(
struct GFONT_CAP));
115 fonts[fonts_count].name =
NULL;
116 fonts[fonts_count].path =
NULL;
133 for (i = 0;
ftcap[i].name; i++) {
void G_free(void *buf)
Free allocated memory.
void G_warning(const char *msg,...)
Print a warning message to stderr.
const char * G_gisbase(void)
Get full path name of the top level module directory.
struct GFONT_CAP * parse_fontcap(void)
Parse fontcaps.
int font_exists(const char *name)
Check if font exists.
void free_fontcap(struct GFONT_CAP *ftcap)
Free allocated GFONT_CAP structure.
int parse_fontcap_entry(struct GFONT_CAP *e, const char *str)
Parse fontcap entry.
char * G_store(const char *s)
Copy string to allocated memory.