Skip to content

Commit

Permalink
* mlfc/main.c: Minor fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
arakiken committed Mar 9, 2023
1 parent 7d4f762 commit 96fbf41
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions tool/mlfc/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,34 +464,40 @@ static int check_font_config(const char *default_family /* family name */
if (m_idx == num_matches) {
if (did_search)
break;
matches = realloc(matches, sizeof(*matches) * (num_matches + 1));
if ((matches = realloc(matches, sizeof(*matches) * (num_matches + 1))) == NULL) {
return 0;
}

if (!(matches[num_matches] = search_next_font(pattern))) {
u_int count;
FcPattern *pat = FcPatternCreate();
FcObjectSet *objset = FcObjectSetBuild(FC_FAMILY, FC_FILE, FC_CHARSET, NULL);
FcFontSet *fontset = FcFontList(NULL, pat, objset);
matches = realloc(matches, sizeof(*matches) * (num_matches + fontset->nfont));

for (count = 0; count < fontset->nfont; count++) {
matches[num_matches + count] = fontset->fonts[count];
FcPatternGet(matches[num_matches + count], FC_FAMILY, 0, &val);
did_search = true;
if (fontset->nfont == 0) {
break;
} else {
if ((matches = realloc(matches,
sizeof(*matches) * (num_matches + fontset->nfont))) == NULL) {
return 0;
}

count = 0;
do {
matches[num_matches + count] = fontset->fonts[count];
#if 0
fprintf(stderr, "%u Add Font List %s\n", num_matches + count, val.u.s);
FcPatternGet(matches[num_matches + count], FC_FAMILY, 0, &val);
fprintf(stderr, "%u Add Font List %s\n", num_matches + count, val.u.s);
#endif
} while (++count < fontset->nfont);
num_matches += fontset->nfont;
}
did_search = true;
num_matches += fontset->nfont;
} else {
num_matches++;
}

}

if (!matches[m_idx]) {
break;
}

if (FcPatternGetCharSet(matches[m_idx], FC_CHARSET, 0, &charset) == FcResultMatch &&
(FcCharSetHasChar(charset, blocks[b_idx].beg) ||
FcCharSetHasChar(charset, blocks[b_idx].beg + 1))) {
Expand Down

0 comments on commit 96fbf41

Please sign in to comment.