aboutsummaryrefslogtreecommitdiffstats
path: root/misc/xosd
diff options
context:
space:
mode:
authordanfe <danfe@FreeBSD.org>2012-11-11 00:30:46 +0800
committerdanfe <danfe@FreeBSD.org>2012-11-11 00:30:46 +0800
commitbc573d2b20e0dedf42fc609dae2ac7bd90cd75e5 (patch)
treea9aab2431958106137f03bcfdb7158b2ff3ceb82 /misc/xosd
parent76f87dbfcdd3a3408d05791bfc1f4213a2cf42b6 (diff)
downloadfreebsd-ports-gnome-bc573d2b20e0dedf42fc609dae2ac7bd90cd75e5.tar.gz
freebsd-ports-gnome-bc573d2b20e0dedf42fc609dae2ac7bd90cd75e5.tar.zst
freebsd-ports-gnome-bc573d2b20e0dedf42fc609dae2ac7bd90cd75e5.zip
- Allow to build with unofficial Xft support
- Rebase existing milliseconds timeout patch up to -p1 so we can have Xft patch unmodified to avoid gratuitous differences with various GNU/Linux distributions out there Obtained from: Puppy Linux Discussion Forum Feature safe: yes
Diffstat (limited to 'misc/xosd')
-rw-r--r--misc/xosd/Makefile12
-rw-r--r--misc/xosd/files/extra-patch-xft593
2 files changed, 603 insertions, 2 deletions
diff --git a/misc/xosd/Makefile b/misc/xosd/Makefile
index 53a7d6e3788c..1d13c02c83d5 100644
--- a/misc/xosd/Makefile
+++ b/misc/xosd/Makefile
@@ -12,6 +12,7 @@ COMMENT= X11 on-screen-display program and library
LICENSE= GPLv2
+PATCH_STRIP= -p1
USE_AUTOTOOLS= libtool
USE_CSTD= gnu89
USE_GMAKE= yes
@@ -32,10 +33,11 @@ MAN3= xosd.3 xosd_create.3 xosd_destroy.3 xosd_display.3 \
xosd_show.3 xosd_uninit.3
PORTDOCS= AUTHORS ChangeLog TODO
-OPTIONS_DEFINE= XMMS MSEC
+OPTIONS_DEFINE= XMMS MSEC XFT
OPTIONS_DEFAULT= XMMS
XMMS_DESC= Build and install XMMS-OSD plugin
MSEC_DESC= Use milliseconds timeout (breaks compatibility!)
+XFT_DESC= Unofficial Xft support
.include <bsd.port.options.mk>
@@ -52,12 +54,18 @@ PLIST_SUB= XMMS="@comment "
.endif
.if ${PORT_OPTIONS:MMSEC}
-DELAY_UNITS= milliseconds
EXTRA_PATCHES= ${FILESDIR}/extra-patch-msec-timeout
+DELAY_UNITS= milliseconds
.else
DELAY_UNITS= seconds
.endif
+.if ${PORT_OPTIONS:MXFT}
+EXTRA_PATCHES+= ${FILESDIR}/extra-patch-xft
+USE_GNOME= pango
+USE_XORG+= xft
+.endif
+
post-patch:
@${REINPLACE_CMD} -e 's,-lc_r,-lblahblah,' ${WRKSRC}/ltmain.sh
@${REINPLACE_CMD} -e 's,-lpthread,${PTHREAD_LIBS}, ; \
diff --git a/misc/xosd/files/extra-patch-xft b/misc/xosd/files/extra-patch-xft
new file mode 100644
index 000000000000..ba4f5a529c0e
--- /dev/null
+++ b/misc/xosd/files/extra-patch-xft
@@ -0,0 +1,593 @@
+diff -ruN xosd-2.2.14/src/libxosd/intern.h xosd-2.2.14-xft-new/src/libxosd/intern.h
+--- xosd-2.2.14/src/libxosd/intern.h 2004-11-05 03:50:45.000000000 +0800
++++ xosd-2.2.14-xft-new/src/libxosd/intern.h 2009-09-21 15:56:28.000000000 +0800
+@@ -26,6 +26,14 @@
+ #include <X11/Xutil.h>
+ #include <X11/extensions/shape.h>
+ #include <X11/Xatom.h>
++
++/*For pango xft support*/
++#include <X11/Xft/Xft.h>
++#include <pango/pango.h>
++#include <pango/pangoxft.h>
++#include <pango/pango-font.h>
++#include <locale.h>
++
+ #ifdef HAVE_XINERAMA
+ # include <X11/extensions/Xinerama.h>
+ #endif
+@@ -144,6 +152,28 @@
+
+ int timeout; /* CONF delta time */
+ struct timeval timeout_start; /* DYN Absolute start of timeout */
++
++/*For pango xft support*/
++// XftColor xftnorm[ColLast];
++ XftColor xftcolour;
++ XftColor outline_xftcolour;
++ XftColor shadow_xftcolour;
++ XftColor * draw_xftcolour;
++ enum {
++ XOSD_XFT_NORM = 0,
++ XOSD_XFT_OUTLINE,
++ XOSD_XFT_SHADOW,
++ } xft_font_colour;
++ XftDraw *xftdrawable;
++ XftDraw *xftdrawable_msk;
++ PangoContext *pgc;
++ PangoLayout *plo;
++ PangoFontDescription *pfd;
++ int xftascent;
++ int xftdescent;
++ int xftheight;
++ int x;
++ int y;
+ };
+
+ static const int XOSD_MAX_PRINTF_BUF_SIZE=2000;
+diff -ruN xosd-2.2.14/src/libxosd/Makefile.am xosd-2.2.14-xft-new/src/libxosd/Makefile.am
+--- xosd-2.2.14/src/libxosd/Makefile.am 2004-08-20 06:39:33.000000000 +0800
++++ xosd-2.2.14-xft-new/src/libxosd/Makefile.am 2009-09-21 16:19:09.000000000 +0800
+@@ -1,4 +1,4 @@
+-AM_CFLAGS = -I$(top_srcdir)/src
++AM_CFLAGS = -I$(top_srcdir)/src `pkg-config --cflags xft pango pangoxft`
+ # Library
+ lib_LTLIBRARIES = libxosd.la
+ libxosd_la_SOURCES = xosd.c intern.h
+diff -ruN xosd-2.2.14/src/libxosd/Makefile.in xosd-2.2.14-xft-new/src/libxosd/Makefile.in
+--- xosd-2.2.14/src/libxosd/Makefile.in 2004-11-18 03:30:23.000000000 +0800
++++ xosd-2.2.14-xft-new/src/libxosd/Makefile.in 2009-09-21 16:18:42.000000000 +0800
+@@ -210,7 +210,7 @@
+ sharedstatedir = @sharedstatedir@
+ sysconfdir = @sysconfdir@
+ target_alias = @target_alias@
+-AM_CFLAGS = -I$(top_srcdir)/src
++AM_CFLAGS = -I$(top_srcdir)/src `pkg-config --cflags xft pango pangoxft`
+ # Library
+ lib_LTLIBRARIES = libxosd.la
+ libxosd_la_SOURCES = xosd.c intern.h
+diff -ruN xosd-2.2.14/src/libxosd/xosd.c xosd-2.2.14-xft-new/src/libxosd/xosd.c
+--- xosd-2.2.14/src/libxosd/xosd.c 2004-11-18 03:27:11.000000000 +0800
++++ xosd-2.2.14-xft-new/src/libxosd/xosd.c 2009-09-21 15:56:34.000000000 +0800
+@@ -24,12 +24,17 @@
+ #define XOFFSET 10
+
+ const char *osd_default_font =
+- "-misc-fixed-medium-r-semicondensed--*-*-*-*-c-*-*-*";
++ "Sans 8";
++/* "-misc-fixed-medium-r-semicondensed--*-*-*-*-c-*-*-*";*/
+ #if 0
+ "-adobe-helvetica-bold-r-*-*-10-*";
+ #endif
+ const char *osd_default_colour = "green";
+
++const char *osd_default_shadow_colour = "black";
++
++const char *osd_default_outline_colour = "black";
++
+ /** Global error string. */
+ char *xosd_error;
+
+@@ -45,6 +50,28 @@
+ pthread_mutex_unlock(&osd->mutex_sync);
+ }
+
++
++static Pixmap
++take_snapshot(xosd *osd) {
++ Pixmap pixmap;
++ GC gc;
++
++ /* create a pixmap to hold the screenshot. */
++ pixmap = XCreatePixmap(osd->display, osd->window,
++ osd->screen_width, osd->height,
++ osd->depth);
++
++ /* then copy the screen into the pixmap. */
++ gc = XCreateGC(osd->display, pixmap, 0, NULL);
++ XSetSubwindowMode(osd->display, gc, IncludeInferiors);
++ XCopyArea(osd->display, DefaultRootWindow(osd->display), pixmap, gc,
++ osd->x, osd->y, osd->screen_width, osd->height,
++ 0, 0);
++ XSetSubwindowMode(osd->display, gc, ClipByChildren);
++ XFreeGC(osd->display, gc);
++
++ return pixmap;
++}
+ /* }}} */
+
+ /* Serialize access to the X11 connection. {{{
+@@ -110,7 +137,7 @@
+ rs[1].height = mod->height + p->height;
+ for (i = 0; i < nbars; i++, rs[0].x = rs[1].x += p->width) {
+ XRectangle *r = &(rs[is_slider ? (i == on) : (i < on)]);
+- XFillRectangles(osd->display, osd->mask_bitmap, osd->mask_gc, r, 1);
++// XFillRectangles(osd->display, osd->mask_bitmap, osd->mask_gc, r, 1);
+ XFillRectangles(osd->display, osd->line_bitmap, osd->gc, r, 1);
+ }
+ FUNCTION_END(Dfunction);
+@@ -123,9 +150,10 @@
+ XRectangle p, m;
+ p.x = XOFFSET;
+ p.y = osd->line_height * line;
+- p.width = -osd->extent->y / 2;
+- p.height = -osd->extent->y;
+-
++// p.width = -osd->extent->y / 2;
++// p.height = -osd->extent->y;
++ p.width = osd->xftheight / 2;
++ p.height = osd->xftheight;
+ assert(osd);
+ FUNCTION_START(Dfunction);
+
+@@ -181,22 +209,46 @@
+
+ /* }}} */
+
++ void
++set_xft_font_colour(xosd * osd, int ind)
++{
++ switch (ind) {
++ case XOSD_XFT_NORM:
++ osd->draw_xftcolour= & (osd ->xftcolour);
++ break;
++ case XOSD_XFT_OUTLINE:
++ osd->draw_xftcolour = & (osd->outline_xftcolour);
++ break;
++ case XOSD_XFT_SHADOW:
++ osd->draw_xftcolour = & (osd->shadow_xftcolour);
++ break;
++ }
++}
++
++
+ /* Draw text. {{{ */
+ static void /*inline */
+ _draw_text(xosd * osd, char *string, int x, int y)
+ {
+ int len = strlen(string);
+ FUNCTION_START(Dfunction);
+- XmbDrawString(osd->display, osd->mask_bitmap, osd->fontset, osd->mask_gc, x,
+- y, string, len);
+- XmbDrawString(osd->display, osd->line_bitmap, osd->fontset, osd->gc, x, y,
+- string, len);
++// XmbDrawString(osd->display, osd->mask_bitmap, osd->fontset, osd->mask_gc, x,
++// y, string, len);
++// XmbDrawString(osd->display, osd->line_bitmap, osd->fontset, osd->gc, x, y,
++// string, len);
++
++pango_layout_set_text(osd->plo, string, len);
++pango_xft_render_layout(osd->xftdrawable, osd->draw_xftcolour, osd->plo, x * PANGO_SCALE, y * PANGO_SCALE);
++//pango_xft_render_layout(osd->xftdrawable, &osd->xftcolour, osd->plo, x * PANGO_SCALE, y * PANGO_SCALE);
++
+ FUNCTION_END(Dfunction);
+ }
++
+ static void
+ draw_text(xosd * osd, int line)
+ {
+- int x = XOFFSET, y = osd->line_height * line - osd->extent->y;
++// int x = XOFFSET, y = osd->line_height * line - osd->extent->y;
++ int x = XOFFSET, y = osd->line_height * line ;//- osd->xftdescent;
+ struct xosd_text *l = &osd->lines[line].text;
+
+ assert(osd);
+@@ -206,9 +258,17 @@
+ return;
+
+ if (l->width < 0) {
++/*
+ XRectangle rect;
+ XmbTextExtents(osd->fontset, l->string, strlen(l->string), NULL, &rect);
+ l->width = rect.width;
++*/
++/*Pango XFT support*/
++ PangoRectangle r;
++ pango_layout_set_text(osd->plo, l->string, strlen(l->string));
++ pango_layout_get_extents(osd->plo, &r, 0);
++ l->width= r.width / PANGO_SCALE;
++
+ }
+
+ switch (osd->align) {
+@@ -223,12 +283,14 @@
+
+ if (osd->shadow_offset) {
+ XSetForeground(osd->display, osd->gc, osd->shadow_pixel);
++ set_xft_font_colour(osd, XOSD_XFT_SHADOW);
+ _draw_text(osd, l->string, x + osd->shadow_offset,
+ y + osd->shadow_offset);
+ }
+ if (osd->outline_offset) {
+ int i, j;
+ XSetForeground(osd->display, osd->gc, osd->outline_pixel);
++ set_xft_font_colour(osd, XOSD_XFT_OUTLINE);
+ /* FIXME: echo . | osd_cat -O 50 -p middle -A center */
+ for (i = 1; i <= osd->outline_offset; i++)
+ for (j = 0; j < 9; j++)
+@@ -238,6 +300,7 @@
+ }
+ if (1) {
+ XSetForeground(osd->display, osd->gc, osd->pixel);
++ set_xft_font_colour(osd, XOSD_XFT_NORM);
+ _draw_text(osd, l->string, x, y);
+ }
+ }
+@@ -291,11 +354,16 @@
+ /* The font, outline or shadow was changed. Recalculate line height,
+ * resize window and bitmaps. */
+ if (osd->update & UPD_size) {
++/*
+ XFontSetExtents *extents = XExtentsOfFontSet(osd->fontset);
+ DEBUG(Dupdate, "UPD_size");
+ osd->extent = &extents->max_logical_extent;
+ osd->line_height = osd->extent->height + osd->shadow_offset + 2 *
++ osd->outline_offset;*/
++ osd->line_height = osd->xftheight + osd->shadow_offset + 2 *
+ osd->outline_offset;
++
++
+ osd->height = osd->line_height * osd->number_lines;
+ for (line = 0; line < osd->number_lines; line++)
+ if (osd->lines[line].type == LINE_text)
+@@ -303,13 +371,32 @@
+
+ XResizeWindow(osd->display, osd->window, osd->screen_width,
+ osd->height);
+- XFreePixmap(osd->display, osd->mask_bitmap);
+- osd->mask_bitmap = XCreatePixmap(osd->display, osd->window,
+- osd->screen_width, osd->height, 1);
++// XFreePixmap(osd->display, osd->mask_bitmap);
++// osd->mask_bitmap = XCreatePixmap(osd->display, osd->window,
++ // osd->screen_width, osd->height, 1);
+ XFreePixmap(osd->display, osd->line_bitmap);
+ osd->line_bitmap = XCreatePixmap(osd->display, osd->window,
+ osd->screen_width, osd->height,
+ osd->depth);
++ xosd_xypos(osd);
++ //printf("osd->screen_width=%d,osd->height=%d,osd->x=%d,osd->y=%d\n",osd->screen_width,osd->height,osd->x,osd->y);
++
++ XCopyArea(osd->display, take_snapshot(osd), osd->line_bitmap, osd->gc,
++ 0, 0, osd->screen_width, osd->height, 0, 0);
++
++
++ //printf("osd->screen_width=%d, osd->height=%d\n",osd->screen_width, osd->height);
++/*BEGIN For pango XFT support*/
++//osd->xftdrawable_msk = XftDrawCreate(osd->display, osd->mask_bitmap, osd->visual, DefaultColormap(osd->display, osd->screen));
++//if(!osd->xftdrawable_msk)
++// printf("error, cannot create drawable_msk\n");
++
++ osd->xftdrawable = XftDrawCreate(osd->display, osd->line_bitmap, osd->visual, DefaultColormap(osd->display, osd->screen));
++ if(!osd->xftdrawable)
++ printf("error, cannot create drawable\n");
++/*END*/
++
++
+ }
+ /* H/V offset or vertical positon was changed. Horizontal alignment is
+ * handles internally as line realignment with UPD_content. */
+@@ -334,6 +421,7 @@
+ case XOSD_top:
+ y = osd->voffset;
+ }
++ osd->x=x; osd->y=y;
+ XMoveWindow(osd->display, osd->window, x, y);
+ }
+ /* If the content changed, redraw lines in background buffer.
+@@ -347,10 +435,10 @@
+ XFillRectangle(osd->display, osd->line_bitmap, osd->gc, 0,
+ y, osd->screen_width, osd->line_height);
+ #endif
+- if (osd->update & UPD_mask) {
+- XFillRectangle(osd->display, osd->mask_bitmap, osd->mask_gc_back, 0,
+- y, osd->screen_width, osd->line_height);
+- }
++ //if (osd->update & UPD_mask) {
++ // XFillRectangle(osd->display, osd->mask_bitmap, osd->mask_gc_back, 0,
++ // y, osd->screen_width, osd->line_height);
++ // }
+ switch (osd->lines[line].type) {
+ case LINE_text:
+ draw_text(osd, line);
+@@ -365,11 +453,12 @@
+ }
+ #ifndef DEBUG_XSHAPE
+ /* More than colours was changed, also update XShape. */
++/*
+ if (osd->update & UPD_mask) {
+ DEBUG(Dupdate, "UPD_mask");
+ XShapeCombineMask(osd->display, osd->window, ShapeBounding, 0, 0,
+ osd->mask_bitmap, ShapeSet);
+- }
++ }*/
+ #endif
+ /* Show display requested. */
+ if (osd->update & UPD_show) {
+@@ -504,6 +593,19 @@
+
+ /* }}} */
+
++ static int parse_xft_colour(xosd * osd, XftColor * color, unsigned long *pixel, const char *colorstr){
++ Colormap cmap = DefaultColormap(osd->display, osd->screen);
++ int retval = 0;
++
++ if(!XftColorAllocName(osd->display, osd->visual, cmap, colorstr, color)){
++ printf("error, cannot allocate color '%s'\n", colorstr);
++ retval = -1;
++ } else
++ retval = 0;
++ *pixel = color->pixel;
++ return retval;
++ }
++
+ /* Parse textual colour value. {{{ */
+ static int
+ parse_colour(xosd * osd, XColor * col, unsigned long *pixel,
+@@ -611,16 +713,39 @@
+ XRaiseWindow(dpy, win);
+ }
+
+-/* }}} */
+-
++ /* }}} */
++void xosd_xypos(xosd *osd)
++{
++ int x,y;
++ switch (osd->align) {
++ case XOSD_left:
++ case XOSD_center:
++ x = osd->screen_xpos + osd->hoffset;
++ break;
++ case XOSD_right:
++ x = osd->screen_xpos - osd->hoffset;
++ }
++ switch (osd->pos) {
++ case XOSD_bottom:
++ y = osd->screen_height - osd->height - osd->voffset;
++ break;
++ case XOSD_middle:
++ y = (osd->screen_height - osd->height) / 2 - osd->voffset;
++ break;
++ case XOSD_top:
++ y = osd->voffset;
++ }
++ //printf("in xosd_xypos x=%d, y=%d, osd->height =%d, osd->screen_height=%d, osd->voffset=%d \n",x,y,osd->height, osd->screen_height, osd->voffset);
++ osd->x=x; osd->y=y;
++}
+ /* xosd_init -- Create a new xosd "object" {{{
+ * Deprecated: Use xosd_create. */
+ xosd *
+ xosd_init(const char *font, const char *colour, int timeout, xosd_pos pos,
+ int voffset, int shadow_offset, int number_lines)
+ {
+- xosd *osd = xosd_create(number_lines);
+
++ xosd *osd = xosd_create(number_lines);
+ FUNCTION_START(Dfunction);
+ if (osd == NULL)
+ return NULL;
+@@ -631,19 +756,22 @@
+ * we do not set xosd_error, as set_font has already set it to
+ * a sensible error message.
+ */
++ printf("xosd_set_font(osd, font) == -1\n");
+ return NULL;
+ }
++// xosd_xypos(osd);
+ xosd_set_colour(osd, colour);
+ xosd_set_timeout(osd, timeout);
+ xosd_set_pos(osd, pos);
+ xosd_set_vertical_offset(osd, voffset);
+ xosd_set_shadow_offset(osd, shadow_offset);
+-
+ return osd;
+ }
+
+ /* }}} */
+
++
++
+ /* xosd_create -- Create a new xosd "object" {{{ */
+ xosd *
+ xosd_create(int number_lines)
+@@ -658,7 +786,6 @@
+ int dummy_a, dummy_b;
+ XineramaScreenInfo *screeninfo = NULL;
+ #endif
+-
+ FUNCTION_START(Dfunction);
+ DEBUG(Dtrace, "getting display");
+ display = getenv("DISPLAY");
+@@ -730,13 +857,13 @@
+
+ DEBUG(Dtrace, "font selection info");
+ xosd_set_font(osd, osd_default_font);
+- if (osd->fontset == NULL) {
++ //if (osd->fontset == NULL) {
+ /*
+ * if we still don't have a fontset, then abort
+ */
+- xosd_error = "Default font not found";
+- goto error3;
+- }
++ // xosd_error = "Default font not found";
++ // goto error3;
++ //}
+
+ DEBUG(Dtrace, "width and height initialization");
+ #ifdef HAVE_XINERAMA
+@@ -772,16 +899,22 @@
+ CopyFromParent,
+ osd->visual, CWOverrideRedirect, &setwinattr);
+ XStoreName(osd->display, osd->window, "XOSD");
+-
++/*
+ osd->mask_bitmap =
+ XCreatePixmap(osd->display, osd->window, osd->screen_width,
+- osd->height, 1);
++ osd->height, 1);*/
+ osd->line_bitmap =
+ XCreatePixmap(osd->display, osd->window, osd->screen_width,
+ osd->line_height, osd->depth);
+
+ osd->gc = XCreateGC(osd->display, osd->window, GCGraphicsExposures, &xgcv);
+- osd->mask_gc = XCreateGC(osd->display, osd->mask_bitmap, GCGraphicsExposures, &xgcv);
++ //xosd_xypos(osd);
++ /*copy back ground to the image*/
++ //printf("1 osd->screen_width=%d,osd->height=%d,osd->x=%d,osd->y=%d\n",osd->screen_width,osd->height,osd->x,osd->y);
++ //XCopyArea(osd->display, take_snapshot(osd), osd->line_bitmap, osd->gc,
++ // 0, 0, osd->screen_width, osd->height, 0, 0);
++
++/* osd->mask_gc = XCreateGC(osd->display, osd->mask_bitmap, GCGraphicsExposures, &xgcv);
+ osd->mask_gc_back = XCreateGC(osd->display, osd->mask_bitmap, GCGraphicsExposures, &xgcv);
+
+ XSetBackground(osd->display, osd->gc,
+@@ -796,10 +929,22 @@
+ WhitePixel(osd->display, osd->screen));
+ XSetBackground(osd->display, osd->mask_gc,
+ BlackPixel(osd->display, osd->screen));
++*/
++/*BEGIN For pango XFT support*/
++//osd->xftdrawable_msk = XftDrawCreate(osd->display, osd->mask_bitmap, osd->visual, DefaultColormap(osd->display, osd->screen));
++//if(!osd->xftdrawable_msk)
++// printf("error, cannot create drawable_msk\n");
+
+
++osd->xftdrawable = XftDrawCreate(osd->display, osd->line_bitmap, osd->visual, DefaultColormap(osd->display, osd->screen));
++if(!osd->xftdrawable)
++ printf("error, cannot create drawable\n");
++/*END*/
++
+ DEBUG(Dtrace, "setting colour");
+ xosd_set_colour(osd, osd_default_colour);
++ xosd_set_shadow_colour(osd, osd_default_shadow_colour);
++ xosd_set_outline_colour(osd, osd_default_outline_colour);
+
+ DEBUG(Dtrace, "stay on top");
+ stay_on_top(osd->display, osd->window);
+@@ -859,11 +1004,11 @@
+
+ DEBUG(Dtrace, "freeing X resources");
+ XFreeGC(osd->display, osd->gc);
+- XFreeGC(osd->display, osd->mask_gc);
+- XFreeGC(osd->display, osd->mask_gc_back);
++// XFreeGC(osd->display, osd->mask_gc);
++// XFreeGC(osd->display, osd->mask_gc_back);
+ XFreePixmap(osd->display, osd->line_bitmap);
+- XFreeFontSet(osd->display, osd->fontset);
+- XFreePixmap(osd->display, osd->mask_bitmap);
++// XFreeFontSet(osd->display, osd->fontset);
++// XFreePixmap(osd->display, osd->mask_bitmap);
+ XDestroyWindow(osd->display, osd->window);
+
+ XCloseDisplay(osd->display);
+@@ -1036,8 +1181,9 @@
+ return -1;
+
+ _xosd_lock(osd);
++ retval = parse_xft_colour(osd, &osd->xftcolour, &osd->pixel, colour);
+ retval = parse_colour(osd, &osd->colour, &osd->pixel, colour);
+- osd->update |= UPD_lines;
++ osd->update |= UPD_lines;
+ _xosd_unlock(osd);
+
+ return retval;
+@@ -1056,6 +1202,8 @@
+ return -1;
+
+ _xosd_lock(osd);
++ //printf("xosd_set_shadow_colour %s\n",colour);
++ retval = parse_xft_colour(osd, &osd->shadow_xftcolour, &osd->shadow_pixel, colour);
+ retval = parse_colour(osd, &osd->shadow_colour, &osd->shadow_pixel, colour);
+ osd->update |= UPD_lines;
+ _xosd_unlock(osd);
+@@ -1076,6 +1224,7 @@
+ return -1;
+
+ _xosd_lock(osd);
++ retval = parse_xft_colour(osd, &osd->outline_xftcolour, &osd->pixel, colour);
+ retval =
+ parse_colour(osd, &osd->outline_colour, &osd->outline_pixel, colour);
+ osd->update |= UPD_lines;
+@@ -1107,6 +1256,8 @@
+ * Try to create the new font. If it doesn't succeed, keep old font.
+ */
+ _xosd_lock(osd);
++/*Mod by Waspee, for pango xft font*/
++/*
+ fontset2 = XCreateFontSet(osd->display, font, &missing, &nmissing, &defstr);
+ XFreeStringList(missing);
+ if (fontset2 == NULL) {
+@@ -1118,6 +1269,26 @@
+ osd->fontset = fontset2;
+ osd->update |= UPD_font;
+ }
++*/
++PangoFontMetrics *metrics;
++osd->pgc = pango_xft_get_context(osd->display, osd->screen);
++osd->pfd = pango_font_description_from_string(font);
++osd->update |= UPD_font;
++
++metrics = pango_context_get_metrics(osd->pgc, osd->pfd, pango_language_from_string(setlocale(LC_CTYPE, "")));
++//
++//dc.font.ascent = pango_font_metrics_get_ascent(metrics) / PANGO_SCALE;
++//dc.font.descent = pango_font_metrics_get_descent(metrics) / PANGO_SCALE;
++
++// pango_font_metrics_unref(metrics);
++
++osd->plo = pango_layout_new(osd->pgc);
++pango_layout_set_font_description(osd->plo, osd->pfd);
++
++osd->xftascent = pango_font_metrics_get_ascent(metrics) / PANGO_SCALE ;
++osd->xftdescent = pango_font_metrics_get_descent(metrics) / PANGO_SCALE ;
++osd->xftheight = osd->xftascent + osd->xftdescent;
++//printf("osd->xftheight=%d\n",osd->xftheight);
+ _xosd_unlock(osd);
+
+ return ret;
+diff -ruN xosd-2.2.14/src/Makefile.am xosd-2.2.14-xft-new/src/Makefile.am
+--- xosd-2.2.14/src/Makefile.am 2004-11-09 04:03:23.000000000 +0800
++++ xosd-2.2.14-xft-new/src/Makefile.am 2009-09-21 16:05:29.000000000 +0800
+@@ -5,8 +5,8 @@
+ osd_cat_SOURCES = osd_cat.c
+ testprog_SOURCES = testprog.c
+
+-osd_cat_LDADD = libxosd/libxosd.la
+-testprog_LDADD = libxosd/libxosd.la
++osd_cat_LDADD = libxosd/libxosd.la `pkg-config --libs xft pango pangoxft`
++testprog_LDADD = libxosd/libxosd.la `pkg-config --libs xft pango pangoxft`
+
+ include_HEADERS = xosd.h
+
+diff -ruN xosd-2.2.14/src/Makefile.in xosd-2.2.14-xft-new/src/Makefile.in
+--- xosd-2.2.14/src/Makefile.in 2004-11-18 03:30:22.000000000 +0800
++++ xosd-2.2.14-xft-new/src/Makefile.in 2009-09-21 16:17:57.000000000 +0800
+@@ -140,7 +140,7 @@
+ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+ LDFLAGS = @LDFLAGS@
+ LIBOBJS = @LIBOBJS@
+-LIBS = @LIBS@
++LIBS = @LIBS@ `pkg-config --libs xft pango pangoxft`
+ LIBTOOL = @LIBTOOL@
+ LN_S = @LN_S@
+ LTLIBOBJS = @LTLIBOBJS@