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