From 09cdcbcfb0bee229d1302eab205eddf3a5bda52d Mon Sep 17 00:00:00 2001
From: Stefano Ceccherini <stefano.ceccherini@gmail.com>
Date: Fri, 21 Feb 2014 22:39:26 +0100
Subject: [PATCH] Server side support for BFont::IsFullAndHalfFixed(). Check a
range of charachters to see if they have the same width.
---
src/servers/app/font/FontStyle.cpp | 23 ++++++++++++++++++++++-
src/servers/app/font/FontStyle.h | 3 ++-
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/src/servers/app/font/FontStyle.cpp b/src/servers/app/font/FontStyle.cpp
index 5719e60..137b38b 100644
a
|
b
|
FontStyle::FontStyle(node_ref& nodeRef, const char* path, FT_Face face)
|
37 | 37 | fFamily(NULL), |
38 | 38 | fID(0), |
39 | 39 | fBounds(0, 0, 0, 0), |
40 | | fFace(_TranslateStyleToFace(face->style_name)) |
| 40 | fFace(_TranslateStyleToFace(face->style_name)), |
| 41 | fFullAndHalfFixed(false) |
41 | 42 | { |
42 | 43 | fName.Truncate(B_FONT_STYLE_LENGTH); |
43 | 44 | // make sure this style can be found using the Be API |
… |
… |
FontStyle::FontStyle(node_ref& nodeRef, const char* path, FT_Face face)
|
50 | 51 | // calculate it because height = ascending + descending + leading |
51 | 52 | fHeight.leading = (double)(face->height - face->ascender + face->descender) |
52 | 53 | / face->units_per_EM; |
| 54 | |
| 55 | if (IsFixedWidth()) |
| 56 | return; |
| 57 | |
| 58 | // manually check if all applicable chars are the same width |
| 59 | |
| 60 | FT_Int32 loadFlags = FT_LOAD_NO_SCALE | FT_LOAD_TARGET_NORMAL; |
| 61 | if (FT_Load_Char(face, (uint32)' ', loadFlags) != 0) |
| 62 | return; |
| 63 | |
| 64 | int firstWidth = face->glyph->advance.x; |
| 65 | for (uint32 c = ' ' + 1; c <= 0x7e; c++) { |
| 66 | if (FT_Load_Char(face, c, loadFlags) != 0) |
| 67 | return; |
| 68 | |
| 69 | if (face->glyph->advance.x != firstWidth) |
| 70 | return; |
| 71 | } |
| 72 | |
| 73 | fFullAndHalfFixed = true; |
53 | 74 | } |
54 | 75 | |
55 | 76 | |
diff --git a/src/servers/app/font/FontStyle.h b/src/servers/app/font/FontStyle.h
index b64542b..5103afa 100644
a
|
b
|
class FontStyle : public ReferenceCounting, public Hashable {
|
82 | 82 | \return false (for now) |
83 | 83 | */ |
84 | 84 | bool IsFullAndHalfFixed() const |
85 | | { return false; }; |
| 85 | { return fFullAndHalfFixed; }; |
86 | 86 | |
87 | 87 | /*! |
88 | 88 | \fn bool FontStyle::IsScalable(void) |
… |
… |
class FontStyle : public ReferenceCounting, public Hashable {
|
171 | 171 | |
172 | 172 | font_height fHeight; |
173 | 173 | uint16 fFace; |
| 174 | bool fFullAndHalfFixed; |
174 | 175 | }; |
175 | 176 | |
176 | 177 | #endif // FONT_STYLE_H_ |