diff --git a/src/apps/terminal/AppearPrefView.cpp b/src/apps/terminal/AppearPrefView.cpp index 67a5ab1cef..d9a689cf5c 100644 --- a/src/apps/terminal/AppearPrefView.cpp +++ b/src/apps/terminal/AppearPrefView.cpp @@ -27,6 +27,7 @@ #include #include "Colors.h" +#include "Globals.h" #include "PrefHandler.h" #include "TermConst.h" #include "TermWindow.h" @@ -36,35 +37,6 @@ #define B_TRANSLATION_CONTEXT "Terminal AppearancePrefView" -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; - - // manually check if all applicable chars are the same width - char buffer[2] = { ' ', 0 }; - int firstWidth = (int)ceilf(font.StringWidth(buffer)); - - // TODO: Workaround for broken fonts/font_subsystem - if (firstWidth <= 0) - return false; - - for (int c = ' ' + 1; c <= 0x7e; c++) { - buffer[0] = c; - int width = (int)ceilf(font.StringWidth(buffer)); - - if (width != firstWidth) - return false; - } - - return true; -} - // #pragma mark - @@ -501,10 +473,9 @@ AppearancePrefView::_MakeFontMenu(uint32 command, { BPopUpMenu* menu = new BPopUpMenu(""); int32 numFamilies = count_font_families(); - uint32 flags; - for (int32 i = 0; i < numFamilies; i++) { font_family family; + uint32 flags; if (get_font_family(i, &family, &flags) == B_OK) { BFont font; font_style style; diff --git a/src/apps/terminal/Globals.cpp b/src/apps/terminal/Globals.cpp index e59fd51a5e..48ed5cf116 100644 --- a/src/apps/terminal/Globals.cpp +++ b/src/apps/terminal/Globals.cpp @@ -3,9 +3,42 @@ * Distributed under the terms of the MIT License. */ +#include "Globals.h" + +#include #include -#include "Globals.h" +#include BClipboard* gMouseClipboard = NULL; + + +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; + + // manually check if all applicable chars are the same width + char buffer[2] = { ' ', 0 }; + int firstWidth = (int)ceilf(font.StringWidth(buffer)); + + // TODO: Workaround for broken fonts/font_subsystem + if (firstWidth <= 0) + return false; + + for (int c = ' ' + 1; c <= 0x7e; c++) { + buffer[0] = c; + int width = (int)ceilf(font.StringWidth(buffer)); + + if (width != firstWidth) + return false; + } + + return true; +} diff --git a/src/apps/terminal/Globals.h b/src/apps/terminal/Globals.h index 7acad62a83..a976192230 100644 --- a/src/apps/terminal/Globals.h +++ b/src/apps/terminal/Globals.h @@ -7,9 +7,12 @@ class BClipboard; +class BFont; extern BClipboard* gMouseClipboard; // clipboard used for mouse copy'n'paste +bool IsFontUsable(const BFont& font); + #endif // GLOBALS_H