diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2019-08-10 19:10:56 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2019-08-10 19:10:56 +0000 |
| commit | 00b6948d9fc53100527a829b6466551cde9718a8 (patch) | |
| tree | d55a0f59187dabce17882b91c41a3ead855c7ac8 | |
| parent | font: initial support for fontconfig font fallback (diff) | |
font: cleanup
| -rw-r--r-- | font.c | 37 |
1 files changed, 7 insertions, 30 deletions
@@ -34,16 +34,6 @@ fini(void) FcFini(); } -#if 0 -static void -font_populate_glyph_cache(struct font *font) -{ - memset(font->cache, 0, sizeof(font->cache)); - for (size_t i = 0; i < 256; i++) - font_glyph_for_utf8(font, &(char){i}, &font->cache[i]); -} -#endif - static bool from_font_set(FcPattern *pattern, FcFontSet *fonts, int start_idx, const font_list_t *fallbacks, const char *attributes, struct font *font, bool is_fallback) @@ -76,13 +66,6 @@ from_font_set(FcPattern *pattern, FcFontSet *fonts, int start_idx, const font_li assert(font_idx != -1); assert(final_pattern != NULL); -#if 0 - if (is_fallback) { - FcFontSetDestroy(fonts); - FcPatternDestroy(pattern); - } -#endif - double dpi; if (FcPatternGetDouble(final_pattern, FC_DPI, 0, &dpi) != FcResultMatch) dpi = 96; @@ -91,12 +74,6 @@ from_font_set(FcPattern *pattern, FcFontSet *fonts, int start_idx, const font_li if (FcPatternGetDouble(final_pattern, FC_PIXEL_SIZE, 0, &size)) { LOG_ERR("%s: failed to get size", face_file); FcPatternDestroy(final_pattern); -#if 0 - if (!is_fallback) { - FcFontSetDestroy(fonts); - FcPatternDestroy(pattern); - } -#endif return false; } @@ -207,6 +184,12 @@ from_font_set(FcPattern *pattern, FcFontSet *fonts, int start_idx, const font_li font->pixel_size_fixup = scalable ? pixel_fixup : 1.; font->fc_idx = font_idx; + if (!is_fallback) { + font->fc_pattern = pattern; + font->fc_fonts = fonts; + font->cache = calloc(cache_size, sizeof(font->cache[0])); + } + if (fallbacks != NULL) { tll_foreach(*fallbacks, it) { size_t len = strlen(it->item) + (have_attrs ? 1 : 0) + attr_len + 1; @@ -229,8 +212,6 @@ from_font_set(FcPattern *pattern, FcFontSet *fonts, int start_idx, const font_li static bool from_name(const char *base_name, const font_list_t *fallbacks, const char *attributes, struct font *font, bool is_fallback) { - //memset(font, 0, sizeof(*font)); - size_t attr_len = attributes == NULL ? 0 : strlen(attributes); bool have_attrs = attr_len > 0; @@ -271,11 +252,7 @@ from_name(const char *base_name, const font_list_t *fallbacks, const char *attri return false; } - if (!is_fallback) { - font->fc_pattern = pattern; - font->fc_fonts = fonts; - font->cache = calloc(cache_size, sizeof(font->cache[0])); - } else { + if (is_fallback) { FcFontSetDestroy(fonts); FcPatternDestroy(pattern); } |
