Handle font style on loading default Terminal preferences
Fix the PrefHandler::_ConfirmFont to take into account not only the font family but the font style too. This improves the popup menu checkmark synchronization in the Preferences View. This problem can be reproduced on very first start of application without previously stored Terminal settings. Default family/style for this case is currently defined as "Courier 19BT"/"Regular" but default fixed font has correspondently "DejaVu Sans Mono"/"Book". Previous version of _ConfirmFont() process only the family and left the style in default "Regular" one. So opening Preferences View and attempting to set the checkmark on corresponding family/style menuitem was usually failed.
This commit is contained in:
parent
d58ff0b187
commit
ef60154123
@ -105,7 +105,7 @@ PrefHandler::PrefHandler()
|
||||
GetDefaultPath(path);
|
||||
OpenText(path.Path());
|
||||
|
||||
_ConfirmFont(PREF_HALF_FONT_FAMILY, be_fixed_font);
|
||||
_ConfirmFont(be_fixed_font);
|
||||
}
|
||||
|
||||
|
||||
@ -377,29 +377,34 @@ PrefHandler::IsEmpty() const
|
||||
|
||||
|
||||
void
|
||||
PrefHandler::_ConfirmFont(const char *key, const BFont *fallback)
|
||||
PrefHandler::_ConfirmFont(const BFont *fallbackFont)
|
||||
{
|
||||
int32 count = count_font_families();
|
||||
const char *font = getString(key);
|
||||
if (font == NULL)
|
||||
count = 0;
|
||||
|
||||
font_family family;
|
||||
font_style style;
|
||||
|
||||
for (int32 i = 0; i < count; i++) {
|
||||
if (get_font_family(i, &family) != B_OK)
|
||||
const char *prefFamily = getString(PREF_HALF_FONT_FAMILY);
|
||||
int32 familiesCount = (prefFamily != NULL) ? count_font_families() : 0;
|
||||
|
||||
for (int32 i = 0; i < familiesCount; i++) {
|
||||
if (get_font_family(i, &family) != B_OK
|
||||
|| strcmp(family, prefFamily) != 0)
|
||||
continue;
|
||||
|
||||
if (strcmp(family, font) == 0) {
|
||||
// found font family: we can safely use this font
|
||||
return;
|
||||
const char *prefStyle = getString(PREF_HALF_FONT_STYLE);
|
||||
int32 stylesCount = (prefStyle != NULL) ? count_font_styles(family) : 0;
|
||||
|
||||
for (int32 j = 0; j < stylesCount; j++) {
|
||||
// check style if we can safely use this font
|
||||
if (get_font_style(family, j, &style) == B_OK
|
||||
&& strcmp(style, prefStyle) == 0)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// use fall-back font
|
||||
|
||||
fallback->GetFamilyAndStyle(&family, NULL);
|
||||
setString(key, family);
|
||||
fallbackFont->GetFamilyAndStyle(&family, &style);
|
||||
setString(PREF_HALF_FONT_FAMILY, family);
|
||||
setString(PREF_HALF_FONT_STYLE, style);
|
||||
}
|
||||
|
||||
|
||||
|
@ -72,7 +72,7 @@ class PrefHandler {
|
||||
static status_t GetDefaultPath(BPath& path);
|
||||
|
||||
private:
|
||||
void _ConfirmFont(const char *key, const BFont *fallback);
|
||||
void _ConfirmFont(const BFont *fallbackFont);
|
||||
status_t _LoadFromDefault(const pref_defaults* defaults = NULL);
|
||||
status_t _LoadFromTextFile(const char * path);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user