FontStyles are now also orded, but not alphabetically: their faces determine
the order, regular fonts come first, then bold, and then italics. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14828 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
fff7b3cd5d
commit
831a01f893
@ -22,6 +22,34 @@
|
|||||||
const uint32 kInvalidFamilyFlags = ~0UL;
|
const uint32 kInvalidFamilyFlags = ~0UL;
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
font_score(const FontStyle* style)
|
||||||
|
{
|
||||||
|
int score = 0;
|
||||||
|
if (style->Face() & B_REGULAR_FACE)
|
||||||
|
score += 10;
|
||||||
|
else {
|
||||||
|
if (style->Face() & B_BOLD_FACE)
|
||||||
|
score += 5;
|
||||||
|
if (style->Face() & B_ITALIC_FACE)
|
||||||
|
score--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return score;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
compare_font_styles(const FontStyle* a, const FontStyle* b)
|
||||||
|
{
|
||||||
|
// Regular fonts come first, then bold, then italics
|
||||||
|
return font_score(b) - font_score(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Constructor
|
\brief Constructor
|
||||||
\param filepath path to a font file
|
\param filepath path to a font file
|
||||||
@ -277,8 +305,10 @@ FontFamily::AddStyle(FontStyle *style)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!fStyles.BinaryInsert(style, compare_font_styles))
|
||||||
|
return false;
|
||||||
|
|
||||||
style->_SetFontFamily(this, fNextID++);
|
style->_SetFontFamily(this, fNextID++);
|
||||||
fStyles.AddItem(style);
|
|
||||||
|
|
||||||
// force a refresh if a request for font flags is needed
|
// force a refresh if a request for font flags is needed
|
||||||
fFlags = kInvalidFamilyFlags;
|
fFlags = kInvalidFamilyFlags;
|
||||||
|
Loading…
Reference in New Issue
Block a user