aboutsummaryrefslogtreecommitdiff
path: root/src/tests/testFont.cc
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-10-19 14:13:05 (GMT)
committerfluxgen <fluxgen>2002-10-19 14:13:05 (GMT)
commit2b934318c754cfa8872e62dc162cc96e2cdc691c (patch)
treea3a49404981f57168cfc6ac5ea03eb4a66f54562 /src/tests/testFont.cc
parent799617f6d1ef27de7126b05e27d1ba6e0814bc39 (diff)
downloadfluxbox-2b934318c754cfa8872e62dc162cc96e2cdc691c.zip
fluxbox-2b934318c754cfa8872e62dc162cc96e2cdc691c.tar.bz2
lines
Diffstat (limited to 'src/tests/testFont.cc')
-rw-r--r--src/tests/testFont.cc23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/tests/testFont.cc b/src/tests/testFont.cc
index 48291ed..a2fda0f 100644
--- a/src/tests/testFont.cc
+++ b/src/tests/testFont.cc
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: testFont.cc,v 1.2 2002/10/19 10:04:20 fluxgen Exp $ 22// $Id: testFont.cc,v 1.3 2002/10/19 14:13:05 fluxgen Exp $
23 23
24#include "Font.hh" 24#include "Font.hh"
25#include "BaseDisplay.hh" 25#include "BaseDisplay.hh"
@@ -27,7 +27,7 @@
27#include <X11/Xlib.h> 27#include <X11/Xlib.h>
28#include <X11/Xutil.h> 28#include <X11/Xutil.h>
29#include <X11/keysym.h> 29#include <X11/keysym.h>
30 30#include <X11/Xft/Xft.h>
31#include <string> 31#include <string>
32#include <iostream> 32#include <iostream>
33using namespace std; 33using namespace std;
@@ -72,11 +72,22 @@ public:
72 } 72 }
73 } 73 }
74 void redraw() { 74 void redraw() {
75 size_t text_w = m_font.textWidth(m_text.c_str(), m_text.size());
76 size_t text_h = m_font.height();
77 int x = 640/2 - text_w/2;
78 int y = 480/2 - text_h/2;
75 XClearWindow(getXDisplay(), m_win); 79 XClearWindow(getXDisplay(), m_win);
76 GC wingc = DefaultGC(getXDisplay(), 0); 80 GC wingc = DefaultGC(getXDisplay(), 0);
81
82 XDrawLine(getXDisplay(), m_win, wingc,
83 x, y + m_font.descent(), x + text_w, y + m_font.descent());
84 XSetForeground(getXDisplay(), wingc, 0xFF00FF); // don't care what color it is
85 XDrawLine(getXDisplay(), m_win, wingc,
86 x, y - text_h , x + text_w, y - text_h );
87 XSetForeground(getXDisplay(), wingc, 0);
77 m_font.drawText(m_win, 0, wingc, 88 m_font.drawText(m_win, 0, wingc,
78 m_text.c_str(), m_text.size(), 89 m_text.c_str(), m_text.size(),
79 640/2 - m_font.textWidth(m_text.c_str(), m_text.size())/2, 480/2); 90 x, y);
80 91
81 } 92 }
82 Window win() const { return m_win; } 93 Window win() const { return m_win; }
@@ -92,7 +103,7 @@ int main(int argc, char **argv) {
92 bool antialias = false; 103 bool antialias = false;
93 string fontname("fixed"); 104 string fontname("fixed");
94 string displayname(""); 105 string displayname("");
95 string text("testTEST0123456789,-+.;:\\!{}[]()"); 106 string text("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,.-_¯åäöÅÄÖ^~+=`\"!#¤%&/()=¡@£$½¥{[]}¶½§±");
96 for (int a=1; a<argc; ++a) { 107 for (int a=1; a<argc; ++a) {
97 if (strcmp("-font", argv[a])==0 && a + 1 < argc) { 108 if (strcmp("-font", argv[a])==0 && a + 1 < argc) {
98 fontname = argv[++a]; 109 fontname = argv[++a];
@@ -104,7 +115,7 @@ int main(int argc, char **argv) {
104 text = argv[++a]; 115 text = argv[++a];
105 } 116 }
106 } 117 }
107 118
108 App app(displayname.c_str()); 119 App app(displayname.c_str());
109 app.font().setAntialias(antialias); 120 app.font().setAntialias(antialias);
110 if (!app.font().load(fontname.c_str())) 121 if (!app.font().load(fontname.c_str()))