Skip to content

Commit

Permalink
Fixed|Unix|libgui: Text bounds measurements
Browse files Browse the repository at this point in the history
Also defined some fonts for Unix in the client's Default Style pack.
  • Loading branch information
skyjake committed Jun 5, 2013
1 parent bce1edf commit 972a896
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 0 deletions.
18 changes: 18 additions & 0 deletions doomsday/client/data/defaultstyle.pack/fonts.dei
Expand Up @@ -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
Expand Down
67 changes: 67 additions & 0 deletions 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
}
}
10 changes: 10 additions & 0 deletions doomsday/libgui/src/font.cpp
Expand Up @@ -23,6 +23,10 @@
#include <QImage>
#include <QPainter>

#if defined(WIN32) || defined(MACOSX)
# define LIBGUI_ACCURATE_TEXT_BOUNDS
#endif

namespace de {

Font::RichFormat::RichFormat() : _style(0)
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 972a896

Please sign in to comment.