btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / apps / terminal / Globals.cpp
blob48ed5cf116aa13c4200b38b727dfbc6ce5c570e9
1 /*
2 * Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
6 #include "Globals.h"
8 #include <math.h>
9 #include <stddef.h>
11 #include <Font.h>
14 BClipboard* gMouseClipboard = NULL;
17 bool
18 IsFontUsable(const BFont& font)
20 // TODO: If BFont::IsFullAndHalfFixed() was implemented, we could
21 // use that. But I don't think it's easily implementable using
22 // Freetype.
24 if (font.IsFixed())
25 return true;
27 // manually check if all applicable chars are the same width
28 char buffer[2] = { ' ', 0 };
29 int firstWidth = (int)ceilf(font.StringWidth(buffer));
31 // TODO: Workaround for broken fonts/font_subsystem
32 if (firstWidth <= 0)
33 return false;
35 for (int c = ' ' + 1; c <= 0x7e; c++) {
36 buffer[0] = c;
37 int width = (int)ceilf(font.StringWidth(buffer));
39 if (width != firstWidth)
40 return false;
43 return true;