You are not logged in.

#1 2012-07-03 22:31:19

Simple Boot
Member
Registered: 2012-06-19
Posts: 21

dwm fails to display font glyphs

Good evening, everyone, again smile

echo -e "\n\xDE\n"

Both urxvt ( ok ) and dwm ( not ok ) use the same font line, but dwm fails to show the given glyph and "replaces" it with an invisible space.

What could be wrong ?

My systems locale is set to enUS UTF-8 ( ISO enabled as well ).


Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

Offline

#2 2012-07-03 22:32:28

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: dwm fails to display font glyphs

What is the font you are trying to display in the status bar and how are you loading it in config.h?


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2012-07-03 22:33:49

Simple Boot
Member
Registered: 2012-06-19
Posts: 21

Re: dwm fails to display font glyphs

jasonwryan wrote:

What is the font you are trying to display in the status bar and how are you loading it in config.h?

It's an edited version of Dina ( DinaMedium9 to be specific ).

Font line in config.h looks like this:

static const char font[]            = "-windows-dinacustom-medium-r-normal--0-0-96-96-c-0-iso8859-1";

** If that matters, I'm using dwm 5.9 ( from suckless.org archive ).

Last edited by Simple Boot (2012-07-03 22:35:59)


Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

Offline

#4 2012-07-03 23:03:06

moetunes
Member
From: A comfortable couch
Registered: 2010-10-09
Posts: 1,033

Re: dwm fails to display font glyphs

As a test you can print the character in urxvt and copy/paste it to your dwm script.


You're just jealous because the voices only talk to me.

Offline

#5 2012-07-03 23:03:35

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,571
Website

Re: dwm fails to display font glyphs

I feel like I must be missing something simple ... but why do you START the string with a newline?

Wouldn't that just lop off everything after it?

Or a better way to ask is what actual command(s) are you using to attempt to display something in the status bar?  Are you using xsetroot?  A program/script?  And/or are you trying to use these characters in config.h as desktop names or layout symbols?


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#6 2012-07-03 23:09:20

Simple Boot
Member
Registered: 2012-06-19
Posts: 21

Re: dwm fails to display font glyphs

moetunes wrote:

As a test you can print the character in urxvt and copy/paste it to your dwm script.

Works just fine. Why doesn't it pick up when sent from a script/command ?

Trilby wrote:

I feel like I must be missing something simple ... but why do you START the string with a newline?

Wouldn't that just lop off everything after it?

Or a better way to ask is what actual command(s) are you using to attempt to display something in the status bar?  Are you using xsetroot?  A program/script?  And/or are you trying to use these characters in config.h as desktop names or layout symbols?

Oh, that was just a test in my terminal ( added \n to add some padding ) - those \n aren't in my actual dwm status bar script ( see below ).

#!/bin/bash

echo -e "\xDE $(date +"%B %d, %H:%M:%S")"

The given script is being called every second through xsetroot and I'm only using those glyphs in the status bar part ( not the tags or anything like that ).


Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

Offline

#7 2012-07-03 23:35:08

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,571
Website

Re: dwm fails to display font glyphs

And how is it called by xsetroot?

I suspect there is a problem with escaping the backslash.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#8 2012-07-03 23:41:16

moetunes
Member
From: A comfortable couch
Registered: 2010-10-09
Posts: 1,033

Re: dwm fails to display font glyphs

Simple Boot wrote:

Works just fine. Why doesn't it pick up when sent from a script/command ?

I've no idea on the details but before I changed snapwm to use multibyte fonts, to have glyphs shown in the bar needed a printf, after, no glyphs showed if used in a printf, they had to be copied/pasted. I assume dwm works similarly.


You're just jealous because the voices only talk to me.

Offline

#9 2012-07-04 09:30:13

Simple Boot
Member
Registered: 2012-06-19
Posts: 21

Re: dwm fails to display font glyphs

Trilby wrote:

And how is it called by xsetroot?

I suspect there is a problem with escaping the backslash.

while true; do
	xsetroot -name "$(/home/user/.dwm/status.sh)"
	sleep 1
done &

exec ck-launch-session dbus-launch dwm

Any ideas ?

Last edited by Simple Boot (2012-07-04 09:31:03)


Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

Offline

#10 2012-07-04 12:16:38

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,571
Website

Re: dwm fails to display font glyphs

Hmm.  I can verify that xsetroot behaves that way here too.  'echo' will properly echo that glyph, and when copy and pasted into the xsetroot command it puts the glyph in the status as expected, but the following only prints "name"

xsetroot -name "$(echo -e "\xDE name")"

.

This seems to be an xsetroot issue, not any shell expansion or escaping problem because the following works as expected:

$ echo -e "\uDE hello"
Þ hello
$ export TEMP=`!!`
export TEMP=`echo -e "\uDE hello"`
$ echo $TEMP
Þ hello
$ xsetroot -name "$TEMP"

but the xsetroot at the end just sets the status to "hello".

Sorry that I don't have any solution to this problem ... this is one of the many reasons I'm glad I wrote my statusbar in C.  The Xlib XStoreName function does not have this problem.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#11 2012-07-04 12:51:51

Simple Boot
Member
Registered: 2012-06-19
Posts: 21

Re: dwm fails to display font glyphs

Trilby wrote:

Hmm.  I can verify that xsetroot behaves that way here too.  'echo' will properly echo that glyph, and when copy and pasted into the xsetroot command it puts the glyph in the status as expected, but the following only prints "name"

xsetroot -name "$(echo -e "\xDE name")"

.

This seems to be an xsetroot issue, not any shell expansion or escaping problem because the following works as expected:

$ echo -e "\uDE hello"
Þ hello
$ export TEMP=`!!`
export TEMP=`echo -e "\uDE hello"`
$ echo $TEMP
Þ hello
$ xsetroot -name "$TEMP"

but the xsetroot at the end just sets the status to "hello".

Sorry that I don't have any solution to this problem ... this is one of the many reasons I'm glad I wrote my statusbar in C.  The Xlib XStoreName function does not have this problem.

Nothing to be sorry about. Thank you smile

Actually, regardless of the fact that there's no solution for this, I'm happy to know that this is a software issue, not my lack of experience with dwm and fonts in general.

By saying you have written your status bar in C, do you mean you have somehow altered dwm.c ?


Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

Offline

#12 2012-07-04 13:17:16

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,571
Website

Re: dwm fails to display font glyphs

Nope, I just wrote an xlib program that calls XStorename on the root window.  I have periodically thought about working it into dwm.c but I quickly realized there'd really be no benefit.  As is dwm responds to an event whenever the root window's name changes and that triggers the redraw of the status bar.  If I worked my code into dwm.c it would have to run as an independent thread so it could loop every second (or however often) without interfering with other processes.  As dwm is not currently multithreaded this would really be no benefit over having an independent program that sets the root window name.

But I do find many benefits of the program versus a script calling xsetroot.  Now one more: xsetroot may not handle these glyphs properly.  Other advantages include a massive saving in system resources.  With your set up, you have a bash loop that calls a different bash script (new process) every second.  That other script then calls xsetroot (another new process) every time it is run.  Assuming your script does not create any more processes (which most status scripts DO) you'd have at least two processes starting, running, passing information, and exiting every second.  Within that you'd have xsetroot establishing and closing a connection with X every second.

With a single program I have one process that opens a connection to X when it starts runs in the background updating the root window name every second, and only closing the connection when it ends (aka when  the x session ends).

here's an example.  I've simplified this both in the code and aesthetics  to be more minimal for what I'm using now, but it shows the idea.

edit: for the most basic template:

#include <stdlib.h>
#include <stdio.h>
#include <X11/Xlib.h>

int main() {
	Display *dpy;
	Window root;
	if ( (dpy=XOpenDisplay(NULL)) == NULL) {
		fprintf(stderr, "ERROR: could not open display\n");
		exit(1);
	}
	root = XRootWindow(dpy,DefaultScreen(dpy));

	char status[42]; /* change length (42) as needed */
	/*declare any of your variables here*/
	for (;;) {
		/*
		construct "status" string here
		*/
		XStoreName(dpy,root,status);
		XFlush(dpy);
		sleep(1);
	}
	XCloseDisplay(dpy);
	return 0;
}

and compile with -lX11 flag

Last edited by Trilby (2012-07-04 13:37:15)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#13 2012-07-04 20:45:43

Simple Boot
Member
Registered: 2012-06-19
Posts: 21

Re: dwm fails to display font glyphs

Trilby wrote:

Nope, I just wrote an xlib program that calls XStorename on the root window.  I have periodically thought about working it into dwm.c but I quickly realized there'd really be no benefit.  As is dwm responds to an event whenever the root window's name changes and that triggers the redraw of the status bar.  If I worked my code into dwm.c it would have to run as an independent thread so it could loop every second (or however often) without interfering with other processes.  As dwm is not currently multithreaded this would really be no benefit over having an independent program that sets the root window name.

But I do find many benefits of the program versus a script calling xsetroot.  Now one more: xsetroot may not handle these glyphs properly.  Other advantages include a massive saving in system resources.  With your set up, you have a bash loop that calls a different bash script (new process) every second.  That other script then calls xsetroot (another new process) every time it is run.  Assuming your script does not create any more processes (which most status scripts DO) you'd have at least two processes starting, running, passing information, and exiting every second.  Within that you'd have xsetroot establishing and closing a connection with X every second.

With a single program I have one process that opens a connection to X when it starts runs in the background updating the root window name every second, and only closing the connection when it ends (aka when  the x session ends).

here's an example.  I've simplified this both in the code and aesthetics  to be more minimal for what I'm using now, but it shows the idea.

edit: for the most basic template:

#include <stdlib.h>
#include <stdio.h>
#include <X11/Xlib.h>

int main() {
	Display *dpy;
	Window root;
	if ( (dpy=XOpenDisplay(NULL)) == NULL) {
		fprintf(stderr, "ERROR: could not open display\n");
		exit(1);
	}
	root = XRootWindow(dpy,DefaultScreen(dpy));

	char status[42]; /* change length (42) as needed */
	/*declare any of your variables here*/
	for (;;) {
		/*
		construct "status" string here
		*/
		XStoreName(dpy,root,status);
		XFlush(dpy);
		sleep(1);
	}
	XCloseDisplay(dpy);
	return 0;
}

and compile with -lX11 flag

Thank you smile

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include <X11/Xlib.h>

int main(int argc, char *argv[])
{
	Display *display;
	Window root;

	if ((display = XOpenDisplay(NULL)) == NULL) {
		fprintf(stderr, "ERROR: could not open display!\n");
		return 1;
	}

	root = XRootWindow(display, DefaultScreen(display));

	char *statusMessage = "\xDE ";

	for (;;)
	{
		XStoreName(display, root, statusMessage);
		XFlush(display);
		sleep(1);
	}

	XCloseDisplay(display);

	return 0;
}

This still procude an empty space instead of the actual character ( glyph ).

What am I missing here ?


Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

Offline

#14 2012-07-04 21:30:29

moetunes
Member
From: A comfortable couch
Registered: 2010-10-09
Posts: 1,033

Re: dwm fails to display font glyphs

It is because of XmbDrawText that you can't echo the glyph and have it show in dwm's bar, not due to xsetroot. Change dwm to not use XmbDrawText if you want that.
Echo always adds a new line and the bar takes one line so I'd recommend using printf.


You're just jealous because the voices only talk to me.

Offline

#15 2012-07-04 22:31:14

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,571
Website

Re: dwm fails to display font glyphs

If you do this in C, don't try to escape the character like that, just use the actual character or set somestring[num] = 0xDE.

Moetunes, I don't get your point.  If echo was the problem, it wouldn't work with other characters.  Also, I have not needed to change dwm's code to have various glphs drawn when I set the root window name via XSetRoot.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#16 2012-07-04 22:40:18

Simple Boot
Member
Registered: 2012-06-19
Posts: 21

Re: dwm fails to display font glyphs

Trilby wrote:

If you do this in C, don't try to escape the character like that, just use the actual character or set somestring[num] = 0xDE.

Moetunes, I don't get your point.  If echo was the problem, it wouldn't work with other characters.  Also, I have not needed to change dwm's code to have various glphs drawn when I set the root window name via XSetRoot.

Now it doesn't show an empty space, but random and weird characters, which aren't the ones I was expecting. More even, adding new characters to the array change ( visually ) the previous ones.

Hm!


Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

Offline

#17 2012-07-04 22:49:37

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,571
Website

Re: dwm fails to display font glyphs

Sorry, I'm a bit lost then.  It works fine here.

To check I took your code exactly as above and compiled it.  It did not work - but as soon as I changed the "\xDE" for the actual character, it worked perfectly and produced the expected gyph.

I do have a couple patches applied.  The statuscolors patch affects the drawbar and drawtext functions, but I have made no other changes to them.

Last edited by Trilby (2012-07-04 22:55:03)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#18 2012-07-04 22:57:53

moetunes
Member
From: A comfortable couch
Registered: 2010-10-09
Posts: 1,033

Re: dwm fails to display font glyphs

The bar shows one line of text so why would you want a new line anywhere, but ignore the bit about echo, that's me being oc.
I said the problem wasn't with xsetroot but with dwm using XmbDrawText. Using the XmbDraw functions if you have e.g. \xDE in an echo then you will only get a blank space but if you use the XDraw functions the glyph will show. I found that out while working on snapwm, as I said earlier. I gather you print the glyphs you want in a terminal and copy/paste them to the text you want shown which is the only way I've found to work when the XmbDraw functions are used. I don't know everything tho.


You're just jealous because the voices only talk to me.

Offline

#19 2012-07-04 23:04:20

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,571
Website

Re: dwm fails to display font glyphs

Ah, that makes more sense.

I don't copy and paste them - but I do one of two methods for using "special" characters.  Either 1) use vim's ctrl-v,x,<hexcode> method, which I'm sure has a proper name that I am unaware of; or 2) set individual characters to the hex codes like

myStatusString[32] = 0xDE;

or some variant of that.  I use former much more often.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

Board footer

Powered by FluxBB