src/xftfont.cpp

Go to the documentation of this file.
00001 // Copyright (c) 2003 - 2004 Anselm R. Garbe <anselmg at t-online.de>
00002 // See ../LICENSE.txt for license details.
00003 //
00004 // $Id: xftfont.cpp 2 2007-05-16 10:38:27Z eg $
00005 
00006 #include "xftfont.h"
00007 
00008 #ifdef XFT_SUPPORT
00009 
00010 extern "C" {
00011 #include <X11/Xlib.h>
00012 }
00013 
00014 #include "monitor.h"
00015 #include "xcore.h"
00016 
00017 WXftFont::WXftFont(Monitor *monitor, XftFont *font) :
00018     WFont(monitor)
00019 {
00020     font_ = font;
00021     type_ = WFont::XFT;
00022 }
00023 
00024 WXftFont *WXftFont::load(Monitor *monitor, string name) {
00025 
00026     XftFont *font = XCORE->xftOpenFontName(monitor->id(), name);
00027 
00028     WXftFont *result = 0;
00029     if (font) {
00030         result = new WXftFont(monitor, font);
00031         result->setHeight(font->height);
00032     }
00033     return result;
00034 }
00035 
00036 WXftFont::~WXftFont() {
00037     XCORE->xftCloseFont(font_);
00038 }
00039 
00040 int WXftFont::textWidth(string text) {
00041     return XCORE->textWidth(font_, text);
00042 }
00043 
00044 unsigned int WXftFont::height() {
00045     return height_;
00046 }
00047 
00048 void WXftFont::setHeight(unsigned int height) {
00049     height_ = height;
00050 }
00051 
00052 void WXftFont::drawText(Window window, GC gc, int x, int y, string text) {
00053     XCORE->drawText(font_, window, gc, monitor_->id(),  x, y, text);
00054 }
00055 
00056 int WXftFont::ascent() {
00057     return font_->ascent;
00058 }
00059 
00060 int WXftFont::descent() {
00061     return font_->descent;
00062 }
00063 
00064 #endif

Generated on Thu May 24 15:19:32 2007 for ncwm by  doxygen 1.5.1