From 972a896df904b74566db9a7dffac9849443fed09 Mon Sep 17 00:00:00 2001 From: skyjake Date: Wed, 5 Jun 2013 18:58:03 +0300 Subject: [PATCH] Fixed|Unix|libgui: Text bounds measurements Also defined some fonts for Unix in the client's Default Style pack. --- .../client/data/defaultstyle.pack/fonts.dei | 18 +++++ .../client/data/defaultstyle.pack/fonts.dei~ | 67 +++++++++++++++++++ doomsday/libgui/src/font.cpp | 10 +++ 3 files changed, 95 insertions(+) create mode 100644 doomsday/client/data/defaultstyle.pack/fonts.dei~ diff --git a/doomsday/client/data/defaultstyle.pack/fonts.dei b/doomsday/client/data/defaultstyle.pack/fonts.dei index 6c77adf484..3954c3a0cd 100644 --- a/doomsday/client/data/defaultstyle.pack/fonts.dei +++ b/doomsday/client/data/defaultstyle.pack/fonts.dei @@ -31,6 +31,24 @@ group { } } +group { + condition: Version.OS == 'unix' + + font default { + family: Liberation Sans + size: 14pt + weight: normal + style: normal + } + + font monospace { + family: FreeMono + size: 12pt + weight: normal + style: normal + } +} + font title inherits default { size $: gui.scale(__this__.size, 1.5) weight: bold diff --git a/doomsday/client/data/defaultstyle.pack/fonts.dei~ b/doomsday/client/data/defaultstyle.pack/fonts.dei~ new file mode 100644 index 0000000000..8de2eec448 --- /dev/null +++ b/doomsday/client/data/defaultstyle.pack/fonts.dei~ @@ -0,0 +1,67 @@ +# Fonts for the default UI style +# +# - size can be "pt" or "px", defaults to "pt" +# - weight: normal bold light +# - style: normal italic + +script { import Version, gui } + +font default condition "Version.OS == 'windows'" { + family: Segoe UI + size: 12pt + weight: normal + style: normal +} + +group { + condition: Version.OS == 'macx' + + font default { + family: Helvetica Neue + size: 16pt + weight: normal + style: normal + } + + font monospace { + family: Consolas + size: 14pt + weight: normal + style: normal + } +} + +group { + condition: Version.OS == 'linux' + + font default { + family: Liberation Sans + size: 14pt + weight: normal + style: normal + } + + font monospace { + family: FreeMono + size: 12pt + weight: normal + style: normal + } +} + +font title inherits default { + size $: gui.scale(__this__.size, 1.5) + weight: bold +} + +group log { + font normal inherits default {} +} + +group editor { + font plaintext inherits default {} + font hint inherits default { + style: italic + weight: light + } +} diff --git a/doomsday/libgui/src/font.cpp b/doomsday/libgui/src/font.cpp index 7e840826ea..f1774949fa 100644 --- a/doomsday/libgui/src/font.cpp +++ b/doomsday/libgui/src/font.cpp @@ -23,6 +23,10 @@ #include #include +#if defined(WIN32) || defined(MACOSX) +# define LIBGUI_ACCURATE_TEXT_BOUNDS +#endif + namespace de { Font::RichFormat::RichFormat() : _style(0) @@ -466,7 +470,13 @@ QImage Font::rasterize(String const &textLine, return QImage(); } +#ifdef LIBGUI_ACCURATE_TEXT_BOUNDS Rectanglei const bounds = measure(textLine, format); +#else + Rectanglei const bounds(0, 0, + advanceWidth(textLine, format), + d->metrics->height()); +#endif QColor fgColor(foreground.x, foreground.y, foreground.z, foreground.w); QColor bgColor(background.x, background.y, background.z, background.w);