18 static unsigned char *data
;
20 static void xerror(char *msg
)
26 static size_t file_size(int fd
)
43 struct tf_header
*head
;
44 fd
= open(TINYFONT
, O_RDONLY
);
46 xerror("can't open font");
47 fcntl(fd
, F_SETFD
, fcntl(fd
, F_GETFD
) | FD_CLOEXEC
);
48 tf
= mmap(NULL
, file_size(fd
), PROT_READ
, MAP_SHARED
, fd
, 0);
50 xerror("can't mmap font file");
51 head
= (struct tf_header
*) tf
;
55 glyphs
= (int *) (tf
+ sizeof(*head
));
56 data
= (unsigned char *) (glyphs
+ n
);
59 static int find_glyph(int c
)
75 unsigned char *font_bitmap(int c
)
77 int i
= find_glyph(c
);
78 return i
>= 0 ? &data
[i
* rows
* cols
] : NULL
;
83 munmap(tf
, file_size(fd
));