/** * Check that a font option is valid, and fix it if not. * * \param option pointer to option, as used by options.[ch] * \param family font family to use if option is not set, or the set * family is not available * \param fallback font family to use if family is not available either */ static void nsfont_check_option(char **option, const char *family, const char *fallback) { if (*option && !nsfont_exists(*option)) { free(*option); *option = 0; } if (!*option) { if (nsfont_exists(family)) *option = strdup(family); else *option = strdup(fallback); } }
void ro_gui_options_fonts_default(wimp_pointer *pointer) { const char *fallback = nsfont_fallback_font(); /* set the default values */ ro_gui_set_icon_decimal(pointer->w, FONT_DEFAULT_SIZE, 128, 1); ro_gui_set_icon_decimal(pointer->w, FONT_MINIMUM_SIZE, 85, 1); ro_gui_set_icon_string(pointer->w, FONT_SANS_FIELD, nsfont_exists("Homerton") ? "Homerton" : fallback, true); ro_gui_set_icon_string(pointer->w, FONT_SERIF_FIELD, nsfont_exists("Trinity") ? "Trinity" : fallback, true); ro_gui_set_icon_string(pointer->w, FONT_MONOSPACE_FIELD, nsfont_exists("Corpus") ? "Corpus" : fallback, true); ro_gui_set_icon_string(pointer->w, FONT_CURSIVE_FIELD, nsfont_exists("Churchill") ? "Churchill" : fallback, true); ro_gui_set_icon_string(pointer->w, FONT_FANTASY_FIELD, nsfont_exists("Sassoon") ? "Sassoon" : fallback, true); ro_gui_set_icon_string(pointer->w, FONT_DEFAULT_FIELD, font_names[0], true); }
/** * Retrieve the fallback font name * * \return Fallback font name */ const char *nsfont_fallback_font(void) { const char *fallback = "Homerton"; if (!nsfont_exists(fallback)) { LOG("Homerton not found, dumping RUfl family list"); for (unsigned int i = 0; i < rufl_family_list_entries; i++) { LOG("'%s'", rufl_family_list[i]); } fallback = rufl_family_list[0]; } return fallback; }