Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XClock -font option syntax

Status
Not open for further replies.

TonyGroves

Programmer
Aug 13, 2003
2,389
IE
I'm trying to construct a command to display a digital XClock using a specific font, but I can't figure out the syntax of the -font argument.

Among other things, I've tried:
[tt] xclock -d -strftime "%a %d %b %H:%M" -font
"-b&h-lucida-medium-r-normal-10-*-*-*-*-*-*-*" &[/tt]
but I get the error "Cannot convert string ... to type FontStruct".

Can anybody tell me the syntax I should be using?
Thanks.
 
Solved the syntax error problem. The font string should have been:
[tt] "-b&h-lucida-medium-r-normal-*-10-*-*-*-*-*-*-*"[/tt]

However, the font setting seems to be ignored in favour of the default font. Has anyone out there got XClock working with a non-default font?

Thanks.
 
Relax; I wrote a little Perl script to do the same thing.
 
How about this (from xclock man page):
[tt]
font (class Font)
Specifies the font to be used for the digital clock. Note that
variable width fonts currently will not always display cor-
rectly. This font is only used when Xrender is not in effect.
[/tt]
I don't know about the Xrender part exactly, but maybe it's that or the variable-width font causing a problem? Have you tried any other fonts with success?

----
JBR
 
I tried fixed-width fonts as well, and they didn't work either. In any event, the Perl script works fine. Here it is:
[tt]
use Tk;
use POSIX qw(strftime);
sub gettime{$d=strftime "%a %d %b\n%H:%M",localtime};
gettime;
$w=MainWindow->new;
$w->repeat(60000,\&gettime);
$w
->Label(-textvariable=>\$d,-anchor=>center)
->place(-relheight=>1,-relwidth=>1);
MainLoop;
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top