Commit: 923782e086908681d52afed2279cd165487f677a
Parent: a0cb71c949534dc5117b9a58594c92f0c6f56d57
Author: Randy Palamar
Date: Thu, 22 Aug 2024 17:48:30 -0600
don't hold onto a FcConfig pointer
You don't actually need this; you can just pass NULL to the
functions instead.
Diffstat:
2 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/font.c b/font.c
@@ -7,23 +7,25 @@ init_font(FontAtlas *fa, Font *f, u8 *fontstr)
fprintf(stderr, "init_font: failed to parse font name to pattern: %s\n", fontstr);
return 0;
}
- FcConfigSubstitute(fa->fc, f->pattern, FcMatchPattern);
+ FcConfigSubstitute(NULL, f->pattern, FcMatchPattern);
FcDefaultSubstitute(f->pattern);
FcResult res;
- FcPattern *font = FcFontMatch(fa->fc, f->pattern, &res);
+ FcPattern *font = FcFontMatch(NULL, f->pattern, &res);
if (!font)
goto err_fc1;
u8 *file = 0;
- if (!(FcPatternGetString(font, FC_FILE, 0, &file) == FcResultMatch))
+ if (FcPatternGetString(font, FC_FILE, 0, &file) != FcResultMatch)
goto err_fc2;
f64 pixelsize = 0;
- if (!(FcPatternGetDouble(font, FC_PIXEL_SIZE, 0, &pixelsize) == FcResultMatch))
+ if (FcPatternGetDouble(font, FC_PIXEL_SIZE, 0, &pixelsize) != FcResultMatch)
goto err_fc2;
f->fontsize = (u32)pixelsize;
+ FcPatternDestroy(font);
+
os_mapped_file map = os_map_file((char *)file, OS_MAP_READ, OS_MAP_PRIVATE);
f->bufsize = map.len;
@@ -36,8 +38,6 @@ init_font(FontAtlas *fa, Font *f, u8 *fontstr)
if (FT_Select_Charmap(f->face, FT_ENCODING_UNICODE))
goto err_ft2;
- FcPatternDestroy(font);
-
return 1;
err_ft2:
@@ -115,8 +115,6 @@ init_fonts(Term *t, Arena *a)
u32 nfontstrs = ARRAY_COUNT(g_fonts);
if (FT_Init_FreeType(&t->fa.ftlib))
die("init_fonts: failed to init FreeType\n");
- if (!(t->fa.fc = FcInitLoadConfigAndFonts()))
- die("init_fonts: failed to init FontConfig\n");
b32 valid_atlas = 0;
t->fa.fonts = alloc(a, Font, nfontstrs);
diff --git a/util.h b/util.h
@@ -266,7 +266,6 @@ typedef struct {
typedef struct {
FT_Library ftlib;
- FcConfig *fc;
Font *fonts;
u32 nfonts;
uv2 size;