Portál AbcLinuxu, 30. října 2025 18:08
#include <stdio.h>
#include <string.h>
#include <ft2build.h>
#include FT_FREETYPE_H
FT_Library ftlib;
int ftlib_init() {
return (FT_Init_FreeType(&ftlib) == 0);
}
int ftlib_done() {
FT_Done_FreeType(ftlib);
return 0;
}
char *yesno[2] = { "no", "yes" };
int main(int argc, char **argv) {
int ft_error;
FT_Face ftface;
int i;
if (argc < 2) {
printf("syntax: fn_info font(s)\n");
return 0;
}
if (!ftlib_init()) {
printf("ERROR: can't initialize FreeType library.\n");
}
for (i = 1; i < argc; i++) {
ft_error = FT_New_Face(ftlib, argv[i], 0, &ftface);
printf("Loading '%s': ", argv[i]);
if (ft_error != 0) {
if (ft_error == FT_Err_Unknown_File_Format) {
printf("Incorrect font format.\n");
} else {
printf("The font file can't be loaded.\n");
}
} else {
printf("OK.\n");
printf("Font information:\n");
printf("\tname: '%s'\n", ftface->family_name);
printf("\ttype: '%s'\n", ftface->style_name);
printf("\tnumber of faces: %lu\n", ftface->num_faces);
printf("\tnumber of glyphs in current face: %lu\n", ftface->num_glyphs);
printf("\tscalable font: %s\n", yesno[(ftface->face_flags & FT_FACE_FLAG_SCALABLE) != 0]);
FT_Done_Face(ftface);
printf("\n");
}
}
ftlib_done();
return 0;
}
Přeloží se to třeba takto:
gcc -s -o fn_info -I/usr/include/freetype2 fn_info.c -lfreetypeDalší informace lze přidat snadno podle dokumentace freetype.
Toto byl jen výcuc z jednoho malýho prográmku, kterej jsem napsal asi před 2-3 roky.
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.