Introduction
Introduction Statistics Contact Development Disclaimer Help
libsl/x11: add new function drw_fontset_getwidth_clamp - libsl - draw back-ends…
git clone git://git.codemadness.org/libsl
Log
Files
Refs
LICENSE
---
commit 3e27a145b9678dd8c68d2cd71fd78966b215b7c2
parent f33024dd2dbb6471cb2c5c41f901fc19e4c133a8
Author: Hiltjo Posthuma <[email protected]>
Date: Tue, 10 May 2022 19:12:33 +0200
libsl/x11: add new function drw_fontset_getwidth_clamp
Diffstat:
M x11/drw.c | 12 +++++++++---
M x11/drw.h | 1 +
2 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/x11/drw.c b/x11/drw.c
@@ -147,10 +147,7 @@ void
drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled,
int invert)
{
- int dx;
-
XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColBg : ColFg].…
- dx = (drw->fonts->ascent + drw->fonts->descent + 2) / 4;
if (filled)
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w + 1, …
else
@@ -223,6 +220,15 @@ drw_fontset_getwidth(Drw *drw, const char *text)
return drw_font_getexts_width(drw->fonts, text, strlen(text));
}
+unsigned int
+drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n)
+{
+ unsigned int tmp = 0;
+ if (drw && drw->fonts && text && n)
+ tmp = drw_text(drw, 0, 0, 0, 0, 0, text, n);
+ return MIN(n, tmp);
+}
+
void
drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *…
{
diff --git a/x11/drw.h b/x11/drw.h
@@ -36,6 +36,7 @@ void drw_free(Drw *drw);
Fnt *drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount);
void drw_fontset_free(Fnt* set);
unsigned int drw_fontset_getwidth(Drw *drw, const char *text);
+unsigned int drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned i…
void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned …
/* Colorscheme abstraction */
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.