Applied patch by h.z. (slightly modified by myself) included in bug #2715. I tested it briefly with Konatu Tohaba font and it seems to work correctly. Please review.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29129 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2009-02-03 14:04:52 +00:00
parent 64f6da317c
commit f498be9297
7 changed files with 69 additions and 13 deletions
+26 -1
View File
@@ -18,9 +18,34 @@
#include <MenuItem.h>
#include <PopUpMenu.h>
#include <stdio.h>
#include <stdlib.h>
static bool
IsFontUsable(const BFont &font)
{
// TODO: If BFont::IsFullAndHalfFixed() was implemented, we could
// use that. But I don't think it's easily implementable using
// Freetype.
if (font.IsFixed())
return true;
bool widthOk = true;
int lastWidth;
for (int c = 0x20 ; c <= 0x7e; c++){
char buf[4];
snprintf(buf, sizeof(buf), "%c", c);
int tmpWidth = (int)font.StringWidth(buf);
if (c > 0x20 &&(tmpWidth != lastWidth))
widthOk = false;
lastWidth = tmpWidth;
}
return widthOk;
}
AppearancePrefView::AppearancePrefView(BRect frame, const char *name,
BMessenger messenger)
: PrefView(frame, name),
@@ -170,7 +195,7 @@ AppearancePrefView::_MakeFontMenu(uint32 command, const char *defaultFontName)
if (get_font_family(i, &family, &flags) == B_OK) {
BFont font;
font.SetFamilyAndStyle(family, NULL);
if (font.IsFixed()) {
if (IsFontUsable(font)) {
BMenuItem *item = new BMenuItem(family, new BMessage(command));
menu->AddItem(item);
if (!strcmp(defaultFontName, family))