Server side support for BFont::IsFullAndHalfFixed().
Check a range of characters to see if they have the same width. Change-Id: I9cef12f78d1e1d01acc6284eae90dbfb86166fc6 Reviewed-on: https://review.haiku-os.org/47 Reviewed-by: Adrien Destugues <[email protected]> Reviewed-by: Jérôme Duval <[email protected]>
This commit is contained in:
committed by
Jérôme Duval
parent
20694a0458
commit
d9eeaa720a
@@ -37,7 +37,8 @@ FontStyle::FontStyle(node_ref& nodeRef, const char* path, FT_Face face)
|
|||||||
fFamily(NULL),
|
fFamily(NULL),
|
||||||
fID(0),
|
fID(0),
|
||||||
fBounds(0, 0, 0, 0),
|
fBounds(0, 0, 0, 0),
|
||||||
fFace(_TranslateStyleToFace(face->style_name))
|
fFace(_TranslateStyleToFace(face->style_name)),
|
||||||
|
fFullAndHalfFixed(false)
|
||||||
{
|
{
|
||||||
fName.Truncate(B_FONT_STYLE_LENGTH);
|
fName.Truncate(B_FONT_STYLE_LENGTH);
|
||||||
// make sure this style can be found using the Be API
|
// make sure this style can be found using the Be API
|
||||||
@@ -50,6 +51,26 @@ FontStyle::FontStyle(node_ref& nodeRef, const char* path, FT_Face face)
|
|||||||
// calculate it because height = ascending + descending + leading
|
// calculate it because height = ascending + descending + leading
|
||||||
fHeight.leading = (double)(face->height - face->ascender + face->descender)
|
fHeight.leading = (double)(face->height - face->ascender + face->descender)
|
||||||
/ face->units_per_EM;
|
/ face->units_per_EM;
|
||||||
|
|
||||||
|
if (IsFixedWidth())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// manually check if all applicable chars are the same width
|
||||||
|
|
||||||
|
FT_Int32 loadFlags = FT_LOAD_NO_SCALE | FT_LOAD_TARGET_NORMAL;
|
||||||
|
if (FT_Load_Char(face, (uint32)' ', loadFlags) != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int firstWidth = face->glyph->advance.x;
|
||||||
|
for (uint32 c = ' ' + 1; c <= 0x7e; c++) {
|
||||||
|
if (FT_Load_Char(face, c, loadFlags) != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (face->glyph->advance.x != firstWidth)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fFullAndHalfFixed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ class FontStyle : public ReferenceCounting, public Hashable {
|
|||||||
\return false (for now)
|
\return false (for now)
|
||||||
*/
|
*/
|
||||||
bool IsFullAndHalfFixed() const
|
bool IsFullAndHalfFixed() const
|
||||||
{ return false; };
|
{ return fFullAndHalfFixed; };
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn bool FontStyle::IsScalable(void)
|
\fn bool FontStyle::IsScalable(void)
|
||||||
@@ -171,6 +171,7 @@ class FontStyle : public ReferenceCounting, public Hashable {
|
|||||||
|
|
||||||
font_height fHeight;
|
font_height fHeight;
|
||||||
uint16 fFace;
|
uint16 fFace;
|
||||||
|
bool fFullAndHalfFixed;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FONT_STYLE_H_
|
#endif // FONT_STYLE_H_
|
||||||
|
|||||||
Reference in New Issue
Block a user