mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-14 08:21:27 -04:00
font: cleanup
This commit is contained in:
parent
92319d1570
commit
00b6948d9f
1 changed files with 7 additions and 30 deletions
37
font.c
37
font.c
|
|
@ -34,16 +34,6 @@ fini(void)
|
||||||
FcFini();
|
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
|
static bool
|
||||||
from_font_set(FcPattern *pattern, FcFontSet *fonts, int start_idx, const font_list_t *fallbacks,
|
from_font_set(FcPattern *pattern, FcFontSet *fonts, int start_idx, const font_list_t *fallbacks,
|
||||||
const char *attributes, struct font *font, bool is_fallback)
|
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(font_idx != -1);
|
||||||
assert(final_pattern != NULL);
|
assert(final_pattern != NULL);
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (is_fallback) {
|
|
||||||
FcFontSetDestroy(fonts);
|
|
||||||
FcPatternDestroy(pattern);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
double dpi;
|
double dpi;
|
||||||
if (FcPatternGetDouble(final_pattern, FC_DPI, 0, &dpi) != FcResultMatch)
|
if (FcPatternGetDouble(final_pattern, FC_DPI, 0, &dpi) != FcResultMatch)
|
||||||
dpi = 96;
|
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)) {
|
if (FcPatternGetDouble(final_pattern, FC_PIXEL_SIZE, 0, &size)) {
|
||||||
LOG_ERR("%s: failed to get size", face_file);
|
LOG_ERR("%s: failed to get size", face_file);
|
||||||
FcPatternDestroy(final_pattern);
|
FcPatternDestroy(final_pattern);
|
||||||
#if 0
|
|
||||||
if (!is_fallback) {
|
|
||||||
FcFontSetDestroy(fonts);
|
|
||||||
FcPatternDestroy(pattern);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return false;
|
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->pixel_size_fixup = scalable ? pixel_fixup : 1.;
|
||||||
font->fc_idx = font_idx;
|
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) {
|
if (fallbacks != NULL) {
|
||||||
tll_foreach(*fallbacks, it) {
|
tll_foreach(*fallbacks, it) {
|
||||||
size_t len = strlen(it->item) + (have_attrs ? 1 : 0) + attr_len + 1;
|
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
|
static bool
|
||||||
from_name(const char *base_name, const font_list_t *fallbacks, const char *attributes, struct font *font, bool is_fallback)
|
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);
|
size_t attr_len = attributes == NULL ? 0 : strlen(attributes);
|
||||||
bool have_attrs = attr_len > 0;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_fallback) {
|
if (is_fallback) {
|
||||||
font->fc_pattern = pattern;
|
|
||||||
font->fc_fonts = fonts;
|
|
||||||
font->cache = calloc(cache_size, sizeof(font->cache[0]));
|
|
||||||
} else {
|
|
||||||
FcFontSetDestroy(fonts);
|
FcFontSetDestroy(fonts);
|
||||||
FcPatternDestroy(pattern);
|
FcPatternDestroy(pattern);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue