| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- #include <stdio.h>
- #include <unistd.h>
- #include <fcntl.h>
- #include <sys/types.h>
- #include <string.h>
- #include <stdlib.h>
- /*
- * we supports PSF format in XNIX.
- * in linux, PSF fonts are in /usr/share/kbd/consolefonts, and they are always compressed.
- * */
- #define PSF_MAGIC 0x864ab572
- struct psf_header {
- __uint32_t magic;
- /* zero */
- __uint32_t version;
- __uint32_t header_size;
- /* zero if there's no unicode table */
- __uint32_t flags;
- /* in psf, a font calls glyph */
- __uint32_t glyphs_count;
- /* size of a glyph */
- __uint32_t glyph_size;
- __uint32_t height;
- __uint32_t width;
- } psf;
- int main(int argc, const char **argv) {
- if (!argv[1]) {
- printf("fatal error: no input file. \n");
- return 1;
- }
- int fd = open(argv[1], O_RDONLY);
- read(fd, (void *) &psf, sizeof(struct psf_header));
- printf("magic: %x\n", psf.magic);
- printf("version: %d\n", psf.version);
- printf("header size: %d\n", psf.header_size);
- printf("flags (zero if no unicode table): %d\n", psf.flags);
- printf("glyphs count: %d\n", psf.glyphs_count);
- printf("glyph size (byte): %d\n", psf.glyph_size);
- printf("height: %d, width: %d\n", psf.height, psf.width);
- close(fd);
- return 0;
- }
|