#endif
}
-int
-main (void)
+static FT_Face
+load_ft_face_for_family (const char *family)
{
/* XXX: Instead of a hard-coded filename here, we should really be
- * taking args.family and using fontconfig to map that to a
+ * taking family and using fontconfig to map that to a
* filename. */
const char font_filename[] = "./Vera.ttf";
+
+ int error;
+ FT_Face ft_face;
+ FT_Library library;
+
+ error = FT_Init_FreeType( &library );
+ if ( error ) {
+ fprintf (stderr, "Fatal error initializing freetype.\n");
+ exit (1);
+ }
+
+ error = FT_New_Face( library, font_filename,
+ 0,
+ &ft_face );
+ if ( error == FT_Err_Unknown_File_Format ) {
+ fprintf (stderr, "Unsupported font format: %s\n", font_filename);
+ exit (1);
+ } else if ( error ) {
+ fprintf (stderr, "Failed to open file: %s\n", font_filename);
+ exit (1);
+ }
+
+ return ft_face;
+}
+
+int
+main (void)
+{
char outputJson = FALSE;
char characters[] = {
int i;
args_t args;
+ FT_Face ft_face;
+ FT_UInt left_index, right_index;
+ FT_Bool use_kerning;
+ FT_Vector kerning;
parse_args (&args);
}
#endif
- int error;
- FT_Library library;
- FT_Face ft_face;
- FT_Bool use_kerning;
- FT_UInt left_index, right_index;
- FT_Vector kerning;
-
- error = FT_Init_FreeType( &library );
- if ( error ) {
- fprintf (stderr, "Fatal error initializing freetype.\n");
- exit (1);
- }
-
- error = FT_New_Face( library, font_filename,
- 0,
- &ft_face );
- if ( error == FT_Err_Unknown_File_Format ) {
- fprintf (stderr, "Unsupported font format: %s\n", font_filename);
- exit (1);
- } else if ( error ) {
- fprintf (stderr, "Failed to open file: %s\n", font_filename);
- exit (1);
- }
+ ft_face = load_ft_face_for_family (args.family);
use_kerning = FT_HAS_KERNING( ft_face );