replace xft with cairo, remove sample theme because it's redundant,

remove optional pango support as its now required because we're using
cairo
This commit is contained in:
speedie 2023-05-21 04:16:55 +02:00
parent cba20c7ce1
commit a750da978c
9 changed files with 94 additions and 377 deletions

View file

@ -210,11 +210,8 @@ time.</li>
<li>Used to calculate MD5 of images if image support is enabled, can be <li>Used to calculate MD5 of images if image support is enabled, can be
disabled during compile time.</li> disabled during compile time.</li>
</ul></li> </ul></li>
<li>Pango <li>Pango</li>
<ul> <li>Cairo</li>
<li>Can be disabled if you dont want/need Pango markup during compile
time.</li>
</ul></li>
<li>libconfig <li>libconfig
<ul> <ul>
<li>Can be disabled if you dont want/need config file support during <li>Can be disabled if you dont want/need config file support during
@ -285,7 +282,6 @@ issues!</p>
MD5() is deprecated as of OpenSSL 3.0, but this would also make it very MD5() is deprecated as of OpenSSL 3.0, but this would also make it very
easy to have LibreSSL compatibility.</li> easy to have LibreSSL compatibility.</li>
<li>Image support: Ability to display icons, similar to rofi</li> <li>Image support: Ability to display icons, similar to rofi</li>
<li>Text drawing: Use cairo for text drawing over Xft.</li>
<li>Lines: Rofi-like newlines in the same entry <li>Lines: Rofi-like newlines in the same entry
<ul> <ul>
<li>Just need to <code>XMoveResizeWindow()</code> as well as <li>Just need to <code>XMoveResizeWindow()</code> as well as
@ -308,10 +304,10 @@ but maybe at some point in the distant future</h3>
<li>Wayland: Wayland support, but only if it doesnt require writing any <li>Wayland: Wayland support, but only if it doesnt require writing any
extra code which as of now seems unlikely, or if someone makes a patch. extra code which as of now seems unlikely, or if someone makes a patch.
<ul> <ul>
<li>Before this can even be done, replace Xft with cairo, deal with <li>Before this can even be done, deal with keybinds in some Wayland
keybinds in some Wayland compatible way, remove .Xresources usage and compatible way, remove .Xresources usage and figure out a way to
figure out a way to preserve X11 compatibility as I do not want to use preserve X11 compatibility as I do not want to use Wayland as of
Wayland as of now.</li> now.</li>
<li>You can just use XWayland anyway if you happen to use Wayland, so <li>You can just use XWayland anyway if you happen to use Wayland, so
its not like you will be unable to use spmenu in its current its not like you will be unable to use spmenu in its current
state.</li> state.</li>

View file

@ -33,7 +33,7 @@ There are way too many to list, but spmenu has a
- Used to calculate MD5 of images if image support is enabled, can be - Used to calculate MD5 of images if image support is enabled, can be
disabled during compile time. disabled during compile time.
- Pango - Pango
- Can be disabled if you don't want/need Pango markup during compile time. - Cairo
- libconfig - libconfig
- Can be disabled if you don't want/need config file support during compile time. - Can be disabled if you don't want/need config file support during compile time.
- meson - meson
@ -115,7 +115,6 @@ Pull requests would be greatly appreciated for any of these issues!
is deprecated as of OpenSSL 3.0, but this would also make it very easy to is deprecated as of OpenSSL 3.0, but this would also make it very easy to
have LibreSSL compatibility. have LibreSSL compatibility.
- Image support: Ability to display icons, similar to rofi - Image support: Ability to display icons, similar to rofi
- Text drawing: Use cairo for text drawing over Xft.
- Lines: Rofi-like newlines in the same entry - Lines: Rofi-like newlines in the same entry
- Just need to `XMoveResizeWindow()` as well as `mh += bh` and `y += bh` - Just need to `XMoveResizeWindow()` as well as `mh += bh` and `y += bh`
for each added line. for each added line.
@ -130,10 +129,9 @@ common dependency most people already have.
- X11: Move from Xlib to libXcb - X11: Move from Xlib to libXcb
- Wayland: Wayland support, but only if it doesn't require writing any extra - Wayland: Wayland support, but only if it doesn't require writing any extra
code which as of now seems unlikely, or if someone makes a patch. code which as of now seems unlikely, or if someone makes a patch.
- Before this can even be done, replace Xft with cairo, - Before this can even be done, deal with keybinds in some Wayland compatible
deal with keybinds in some Wayland compatible way, remove .Xresources way, remove .Xresources usage and figure out a way to preserve X11
usage and figure out a way to preserve X11 compatibility as I do compatibility as I do not want to use Wayland as of now.
not want to use Wayland as of now.
- You can just use XWayland anyway if you happen to use Wayland, so it's not - You can just use XWayland anyway if you happen to use Wayland, so it's not
like you will be unable to use spmenu in its current state. like you will be unable to use spmenu in its current state.

View file

@ -3,81 +3,19 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xft/Xft.h> #include <cairo/cairo.h>
#include <cairo/cairo-ft.h>
#ifndef PANGO #include <cairo/cairo-xlib.h>
#define USEPANGO 0
#else
#define USEPANGO 1
#ifndef UTF8
#define USEUTF8 0
#else
#define USEUTF8 1
#endif
#endif
#if USEPANGO
#include <pango/pango.h> #include <pango/pango.h>
#include <pango/pangoxft.h> #include <pango/pangocairo.h>
#include <iconv.h> #include <iconv.h>
#endif
#include "drw.h" #include "drw.h"
#include "../sl/main.h" #include "../sl/main.h"
#if !USEPANGO Clr transcheme[3]; // transition colorscheme
#define UTF_INVALID 0xFFFD
#define UTF_SIZ 4
static const unsigned char utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0}; Drw *drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap) {
static const unsigned char utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8};
static const long utfmin[UTF_SIZ + 1] = { 0, 0, 0x80, 0x800, 0x10000};
static const long utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF};
static long utf8decodebyte(const char c, size_t *i) {
for (*i = 0; *i < (UTF_SIZ + 1); ++(*i))
if (((unsigned char)c & utfmask[*i]) == utfbyte[*i])
return (unsigned char)c & ~utfmask[*i];
return 0;
}
static size_t utf8validate(long *u, size_t i) {
if (!BETWEEN(*u, utfmin[i], utfmax[i]) || BETWEEN(*u, 0xD800, 0xDFFF))
*u = UTF_INVALID;
for (i = 1; *u > utfmax[i]; ++i)
;
return i;
}
static size_t utf8decode(const char *c, long *u, size_t clen) {
size_t i, j, len, type;
long udecoded;
*u = UTF_INVALID;
if (!clen)
return 0;
udecoded = utf8decodebyte(c[0], &len);
if (!BETWEEN(len, 1, UTF_SIZ))
return 1;
for (i = 1, j = 1; i < clen && j < len; ++i, ++j) {
udecoded = (udecoded << 6) | utf8decodebyte(c[i], &type);
if (type)
return j;
}
if (j < len)
return 0;
*u = udecoded;
utf8validate(u, len);
return len;
}
#else
static char *parse_utf(char *str, size_t clen);
#endif
Clr transcheme[3];
Drw * drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap) {
Drw *drw = ecalloc(1, sizeof(Drw)); Drw *drw = ecalloc(1, sizeof(Drw));
drw->dpy = dpy; drw->dpy = dpy;
@ -101,8 +39,10 @@ void drw_resize(Drw *drw, unsigned int w, unsigned int h) {
drw->w = w; drw->w = w;
drw->h = h; drw->h = h;
if (drw->drawable) if (drw->drawable)
XFreePixmap(drw->dpy, drw->drawable); XFreePixmap(drw->dpy, drw->drawable);
drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, drw->depth); drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, drw->depth);
} }
@ -113,8 +53,7 @@ void drw_free(Drw *drw) {
free(drw); free(drw);
} }
#if USEPANGO static Fnt *xfont_create(Drw *drw, const char *fontname) {
static Fnt * xfont_create(Drw *drw, const char *fontname) {
Fnt *font; Fnt *font;
PangoFontMap *fontmap; PangoFontMap *fontmap;
PangoContext *context; PangoContext *context;
@ -128,7 +67,7 @@ static Fnt * xfont_create(Drw *drw, const char *fontname) {
font = ecalloc(1, sizeof(Fnt)); font = ecalloc(1, sizeof(Fnt));
font->dpy = drw->dpy; font->dpy = drw->dpy;
fontmap = pango_xft_get_font_map(drw->dpy, drw->screen); fontmap = pango_cairo_font_map_new();
context = pango_font_map_create_context(fontmap); context = pango_font_map_create_context(fontmap);
desc = pango_font_description_from_string(fontname); desc = pango_font_description_from_string(fontname);
font->layout = pango_layout_new(context); font->layout = pango_layout_new(context);
@ -150,101 +89,37 @@ void xfont_free(Fnt *font) {
g_object_unref(font->layout); g_object_unref(font->layout);
free(font); free(font);
} }
#else
static Fnt * xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern) {
Fnt *font;
XftFont *xfont = NULL;
FcPattern *pattern = NULL;
if (fontname) {
/* Using the pattern found at font->xfont->pattern does not yield the
* same substitution results as using the pattern returned by
* FcNameParse; using the latter results in the desired fallback
* behaviour whereas the former just results in missing-character
* rectangles being drawn, at least with some fonts. */
if (!(xfont = XftFontOpenName(drw->dpy, drw->screen, fontname))) {
fprintf(stderr, "error, cannot load font from name: '%s'\n", fontname);
return NULL;
}
if (fontname[0] == '-')
pattern = XftXlfdParse(fontname, False, False);
else
pattern = FcNameParse((FcChar8 *) fontname);
if (!pattern) {
fprintf(stderr, "error, cannot parse font name to pattern: '%s'\n", fontname);
XftFontClose(drw->dpy, xfont);
return NULL;
}
} else if (fontpattern) {
if (!(xfont = XftFontOpenPattern(drw->dpy, fontpattern))) {
fprintf(stderr, "spmenu: cannot load font from pattern.\n");
return NULL;
}
} else {
die("spmenu: no font specified.");
}
font = ecalloc(1, sizeof(Fnt));
font->xfont = xfont;
font->pattern = pattern;
font->h = xfont->ascent + xfont->descent;
font->dpy = drw->dpy;
return font;
}
void xfont_free(Fnt *font) {
if (!font)
return;
if (font->pattern)
FcPatternDestroy(font->pattern);
XftFontClose(font->dpy, font->xfont);
free(font);
}
#endif
Fnt* drw_font_create(Drw* drw, char *font[], size_t fontcount) { Fnt* drw_font_create(Drw* drw, char *font[], size_t fontcount) {
if (!drw || !font) if (!drw || !font)
return NULL; return NULL;
#if USEPANGO
Fnt *fnt = NULL; Fnt *fnt = NULL;
fnt = xfont_create(drw, *font); fnt = xfont_create(drw, *font);
return (drw->font = fnt);
#else
Fnt *cur, *ret = NULL;
size_t i;
for (i = 1; i <= fontcount; i++) { return (drw->font = fnt);
if ((cur = xfont_create(drw, font[fontcount - i], NULL))) {
cur->next = ret;
ret = cur;
}
}
return (drw->font = ret);
#endif
} }
void drw_font_free(Fnt *font) { void drw_font_free(Fnt *font) {
if (font) { if (font) {
#if !USEPANGO
drw_font_free(font->next);
#endif
xfont_free(font); xfont_free(font);
} }
} }
void drw_clr_create(Drw *drw, Clr *dest, char *clrname, unsigned int alpha) { void drw_clr_create(Drw *drw, Clr *dest, char *clrname, unsigned int alpha) {
XColor color;
if (!drw || !dest || !clrname) if (!drw || !dest || !clrname)
return; return;
if (!XftColorAllocName(drw->dpy, drw->visual, drw->cmap, if (!XAllocNamedColor(drw->dpy, drw->cmap, clrname, &color, dest))
clrname, dest))
die("spmenu: cannot allocate color '%s'", clrname); die("spmenu: cannot allocate color '%s'", clrname);
dest->red = color.red;
dest->green = color.green;
dest->blue = color.blue;
dest->pixel = (dest->pixel & 0x00ffffffU) | (alpha << 24); dest->pixel = (dest->pixel & 0x00ffffffU) | (alpha << 24);
} }
@ -255,7 +130,7 @@ Clr * drw_scm_create(Drw *drw, char *clrnames[], unsigned int alphas[], size_t c
Clr *ret; Clr *ret;
/* need at least two colors for a scheme */ /* need at least two colors for a scheme */
if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, sizeof(XftColor)))) if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, sizeof(XColor))))
return NULL; return NULL;
for (i = 0; i < clrcount; i++) for (i = 0; i < clrcount; i++)
@ -316,7 +191,6 @@ int xerrordummy(Display *dpy, XErrorEvent *ee) {
return 0; return 0;
} }
#if USEPANGO
char *parse_utf(char *str, size_t clen) { char *parse_utf(char *str, size_t clen) {
char *ostr = str; char *ostr = str;
char *cnstr = calloc(clen + 1, sizeof(char)); char *cnstr = calloc(clen + 1, sizeof(char));
@ -341,20 +215,18 @@ char *parse_utf(char *str, size_t clen) {
return cnstr; return cnstr;
} }
#endif
int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert, Bool markup) { int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert, Bool markup) {
XSetErrorHandler(xerrordummy);
#if USEPANGO // pango
char buf[1024]; char buf[1024];
int ty; int ty;
unsigned int ew = 0; unsigned int ew = 0;
XftDraw *d = NULL;
size_t i, len; size_t i, len;
int render = x || y || w || h; int render = x || y || w || h;
char *t; char *t;
XSetErrorHandler(xerrordummy);
if (!drw || (render && !drw->scheme) || !text || !drw->font) if (!drw || (render && !drw->scheme) || !text || !drw->font)
return 0; return 0;
@ -363,19 +235,21 @@ int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned in
} else { } else {
XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel); XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel);
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h); XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
d = XftDrawCreate(drw->dpy, drw->drawable, drw->visual, drw->cmap);
drw->surface = cairo_xlib_surface_create(drw->dpy, drw->drawable, drw->visual, drw->w, drw->h);
drw->d = cairo_create(drw->surface);
x += lpad; x += lpad;
w -= lpad; w -= lpad;
} }
len = strlen(text); t = parse_utf(strdup(text), strlen(text));
t = strdup(text); len = strlen(t);
t = parse_utf(t, len);
if (len) { if (len) {
drw_font_getexts(drw->font, t, len, &ew, NULL, markup); drw_font_getexts(drw->font, t, len, &ew, NULL, markup);
/* shorten text if necessary */
// shorten text if necessary
for (len = MIN(len, sizeof(buf) - 1); len && ew > w; drw_font_getexts(drw->font, t, len, &ew, NULL, markup)) for (len = MIN(len, sizeof(buf) - 1); len && ew > w; drw_font_getexts(drw->font, t, len, &ew, NULL, markup))
len--; len--;
@ -384,20 +258,31 @@ int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned in
buf[len] = '\0'; buf[len] = '\0';
if (len < strlen(t)) if (len < strlen(t))
for (i = len; i && i > len - 3; buf[--i] = '.') for (i = len; i && i > len - 3; buf[--i] = '.')
; /* NOP */ ; // NOP
if (!strstr(buf, "</")) if (!strstr(buf, "</")) // must contain </
markup = 0; markup = 0;
if (render) { if (render) {
ty = y + (h - drw->font->h) / 2; ty = y + (h - drw->font->h) / 2;
if(markup)
if (markup) {
pango_layout_set_markup(drw->font->layout, buf, len); pango_layout_set_markup(drw->font->layout, buf, len);
else } else {
pango_layout_set_text(drw->font->layout, buf, len); pango_layout_set_text(drw->font->layout, buf, len);
pango_xft_render_layout(d, &drw->scheme[invert ? ColBg : ColFg], }
drw->font->layout, x * PANGO_SCALE, ty * PANGO_SCALE);
if(markup) /* clear markup attributes */ cairo_save(drw->d);
cairo_set_source_rgb(drw->d, convert_color(drw->scheme->red), convert_color(drw->scheme->green), convert_color(drw->scheme->blue));
cairo_move_to(drw->d, x, ty);
pango_cairo_update_layout(drw->d, drw->font->layout);
pango_cairo_show_layout(drw->d, drw->font->layout);
cairo_restore(drw->d);
if (markup) // clear markup attributes
pango_layout_set_attributes(drw->font->layout, NULL); pango_layout_set_attributes(drw->font->layout, NULL);
} }
@ -405,139 +290,8 @@ int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned in
w -= ew; w -= ew;
} }
} }
if (d)
XftDrawDestroy(d);
return x + (render ? w : 0); return x + (render ? w : 0);
#else // xft
char buf[1024];
int ty;
unsigned int ew = 0;
XftDraw *d = NULL;
Fnt *usedfont, *curfont, *nextfont;
size_t i, len;
int utf8strlen, utf8charlen, render = x || y || w || h;
long utf8codepoint = 0;
const char *utf8str;
FcCharSet *fccharset;
FcPattern *fcpattern;
FcPattern *match;
XftResult result;
int charexists = 0;
if (!drw || (render && !drw->scheme) || !text || !drw->font)
return 0;
if (!render) {
w = ~w;
} else {
XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel);
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
d = XftDrawCreate(drw->dpy, drw->drawable, drw->visual, drw->cmap);
x += lpad;
w -= lpad;
}
usedfont = drw->font;
while (1) {
utf8strlen = 0;
utf8str = text;
nextfont = NULL;
while (*text) {
utf8charlen = utf8decode(text, &utf8codepoint, UTF_SIZ);
for (curfont = drw->font; curfont; curfont = curfont->next) {
charexists = charexists || XftCharExists(drw->dpy, curfont->xfont, utf8codepoint);
if (charexists) {
if (curfont == usedfont) {
utf8strlen += utf8charlen;
text += utf8charlen;
} else {
nextfont = curfont;
}
break;
}
}
if (!charexists || nextfont)
break;
else
charexists = 0;
}
if (utf8strlen) {
drw_font_getexts(usedfont, utf8str, utf8strlen, &ew, NULL, True);
/* shorten text if necessary */
for (len = MIN(utf8strlen, sizeof(buf) - 1); len && ew > w; drw_font_getexts(usedfont, utf8str, len, &ew, NULL, True))
len--;
if (len) {
memcpy(buf, utf8str, len);
buf[len] = '\0';
if (len < utf8strlen)
for (i = len; i && i > len - 3; buf[--i] = '.')
; /* NOP */
if (render) {
ty = y + (h - usedfont->h) / 2 + usedfont->xfont->ascent;
XftDrawStringUtf8(d, &drw->scheme[invert ? ColBg : ColFg],
usedfont->xfont, x, ty, (XftChar8 *)buf, len);
}
x += ew;
w -= ew;
}
}
if (!*text) {
break;
} else if (nextfont) {
charexists = 0;
usedfont = nextfont;
} else {
/* Regardless of whether or not a fallback font is found, the
* character must be drawn. */
charexists = 1;
fccharset = FcCharSetCreate();
FcCharSetAddChar(fccharset, utf8codepoint);
if (!drw->font->pattern) {
/* Refer to the comment in xfont_create for more information. */
die("spmenu: the first font in the cache must be loaded from a font string.");
}
fcpattern = FcPatternDuplicate(drw->font->pattern);
FcPatternAddCharSet(fcpattern, FC_CHARSET, fccharset);
FcPatternAddBool(fcpattern, FC_SCALABLE, FcTrue);
FcConfigSubstitute(NULL, fcpattern, FcMatchPattern);
FcDefaultSubstitute(fcpattern);
match = XftFontMatch(drw->dpy, drw->screen, fcpattern, &result);
FcCharSetDestroy(fccharset);
FcPatternDestroy(fcpattern);
if (match) {
usedfont = xfont_create(drw, NULL, match);
if (usedfont && XftCharExists(drw->dpy, usedfont->xfont, utf8codepoint)) {
for (curfont = drw->font; curfont->next; curfont = curfont->next)
; /* NOP */
curfont->next = usedfont;
} else {
xfont_free(usedfont);
usedfont = drw->font;
}
}
}
}
if (d)
XftDrawDestroy(d);
XSync(drw->dpy, False);
return x + (render ? w : 0);
#endif
XSync(drw->dpy, False);
} }
void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h) { void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h) {
@ -555,37 +309,31 @@ unsigned int drw_font_getwidth(Drw *drw, const char *text, Bool markup) {
} }
void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h, Bool markup) { void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h, Bool markup) {
#if !USEPANGO
XGlyphInfo ext;
#endif
if (!font || !text) if (!font || !text)
return; return;
char *t = strdup(text); char *t = strdup(text);
#if USEPANGO
t = parse_utf(t, len); t = parse_utf(t, len);
if (!strstr(t, "</")) if (!strstr(t, "</"))
markup = 0; markup = 0;
PangoRectangle r; PangoRectangle r;
if(markup)
if (markup)
pango_layout_set_markup(font->layout, t, len); pango_layout_set_markup(font->layout, t, len);
else else
pango_layout_set_text(font->layout, t, len); pango_layout_set_text(font->layout, t, len);
pango_layout_get_extents(font->layout, 0, &r); pango_layout_get_extents(font->layout, 0, &r);
if(markup) // clear markup attributes
if (markup) // clear markup attributes
pango_layout_set_attributes(font->layout, NULL); pango_layout_set_attributes(font->layout, NULL);
#else
XftTextExtentsUtf8(font->dpy, font->xfont, (XftChar8 *)t, len, &ext);
#endif
if (w) if (w)
#if USEPANGO
*w = r.width / PANGO_SCALE; *w = r.width / PANGO_SCALE;
#else
*w = ext.xOff;
#endif
if (h) if (h)
*h = font->h; *h = font->h;
} }

View file

@ -1,29 +1,33 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
#ifndef PANGO #include <cairo/cairo.h>
#define USEPANGO 0 #include <cairo/cairo-ft.h>
#else #include <cairo/cairo-xlib.h>
#define USEPANGO 1 #include <pango/pango.h>
#endif #include <pango/pangocairo.h>
#define convert_color(x) (double)((x) / 65535.0)
typedef struct { typedef struct {
Cursor cursor; Cursor cursor;
} Cur; } Cur;
typedef XColor Clr;
typedef struct Fnt { typedef struct Fnt {
Display *dpy; Display *dpy;
unsigned int h; unsigned int h;
#if USEPANGO FcPattern *pattern;
PangoLayout *layout; PangoLayout *layout;
#else
XftFont *xfont;
FcPattern *pattern;
struct Fnt *next;
#endif
} Fnt; } Fnt;
typedef struct Rgb {
unsigned int r;
unsigned int g;
unsigned int b;
} Rgb;
enum { ColFg, ColBg, ColPwl }; /* Clr scheme index */ enum { ColFg, ColBg, ColPwl }; /* Clr scheme index */
typedef XftColor Clr;
typedef struct { typedef struct {
unsigned int w, h; unsigned int w, h;
@ -37,6 +41,9 @@ typedef struct {
GC gc; GC gc;
Clr *scheme; Clr *scheme;
Fnt *font; Fnt *font;
Rgb *rgb;
cairo_surface_t *surface;
cairo_t *d;
} Drw; } Drw;
/* Drawable abstraction */ /* Drawable abstraction */
@ -60,9 +67,6 @@ Cur *drw_cur_create(Drw *drw, int shape);
void drw_cur_free(Drw *drw, Cur *cursor); void drw_cur_free(Drw *drw, Cur *cursor);
/* Drawing context manipulation */ /* Drawing context manipulation */
#if !USEPANGO
void drw_setfont(Drw *drw, Fnt *set);
#endif
void drw_setscheme(Drw *drw, Clr *scm); void drw_setscheme(Drw *drw, Clr *scm);
/* Drawing functions */ /* Drawing functions */
@ -75,3 +79,6 @@ void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h)
/* Powerline functions */ /* Powerline functions */
void drw_settrans(Drw *drw, Clr *psc, Clr *nsc); void drw_settrans(Drw *drw, Clr *psc, Clr *nsc);
void drw_arrow(Drw* drw, int x, int y, unsigned int w, unsigned int h, int direction, int slash); void drw_arrow(Drw* drw, int x, int y, unsigned int w, unsigned int h, int direction, int slash);
/* UTF-8 functions */
char *parse_utf(char *str, size_t clen);

View file

@ -17,7 +17,10 @@ project_dependencies = [
dependency('x11'), dependency('x11'),
dependency('xrender'), dependency('xrender'),
dependency('freetype2'), dependency('freetype2'),
dependency('xft'), dependency('cairo'),
dependency('pango'),
dependency('pangocairo'),
dependency('fontconfig'),
cc.find_library('m', required : false), cc.find_library('m', required : false),
] ]
@ -53,14 +56,6 @@ if get_option('xinerama')
build_args += [ '-DXINERAMA' ] build_args += [ '-DXINERAMA' ]
endif endif
if get_option('pango') and get_option('pangoxft')
project_dependencies += [ dependency('pango') ]
project_dependencies += [ dependency('pangoxft') ]
build_args += [ '-DPANGO' ]
else
project_dependencies += [ dependency('fontconfig') ]
endif
if get_option('libconfig') if get_option('libconfig')
project_dependencies += [ dependency('libconfig') ] project_dependencies += [ dependency('libconfig') ]
build_args += [ '-DCONFIG' ] build_args += [ '-DCONFIG' ]

View file

@ -33,20 +33,6 @@ option(
description : 'Enable configuration file support' description : 'Enable configuration file support'
) )
option(
'pango',
type : 'boolean',
value : true,
description : 'Enable Pango markup support'
)
option(
'pangoxft',
type : 'boolean',
value : true,
description : 'Enable Pango for libXft'
)
option( option(
'xinerama', 'xinerama',
type : 'boolean', type : 'boolean',

View file

@ -41,8 +41,6 @@ build() {
-Dxinerama="$xinerama" \ -Dxinerama="$xinerama" \
-Dimlib2="$imlib2" \ -Dimlib2="$imlib2" \
-Dopenssl="$openssl" \ -Dopenssl="$openssl" \
-Dpango="$pango" \
-Dpangoxft="$pangoxft" \
-Dlibconfig="$libconfig" \ -Dlibconfig="$libconfig" \
-Dutf8="$utf8" \ -Dutf8="$utf8" \
--prefix "$prefix" \ --prefix "$prefix" \
@ -54,8 +52,6 @@ build() {
-Dxinerama="$xinerama" \ -Dxinerama="$xinerama" \
-Dimlib2="$imlib2" \ -Dimlib2="$imlib2" \
-Dopenssl="$openssl" \ -Dopenssl="$openssl" \
-Dpango="$pango" \
-Dpangoxft="$pangoxft" \
-Dlibconfig="$libconfig" \ -Dlibconfig="$libconfig" \
-Dutf8="$utf8" \ -Dutf8="$utf8" \
--prefix "$prefix" \ --prefix "$prefix" \

View file

@ -94,7 +94,8 @@
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/keysym.h> #include <X11/keysym.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include <X11/Xft/Xft.h> #include <X11/Xproto.h>
#include <X11/extensions/Xrender.h>
// include xresources // include xresources
#if USEXRESOURCES #if USEXRESOURCES

View file

@ -1,10 +0,0 @@
/* This is a sample theme.
* It simply sets the font to Terminus.
*
* Simply copy this to ~/.config/spmenu/theme.conf to apply.
*/
theme = {
text = ( { font = "Terminus 8";
} );
};