🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.x
Article #36666

Re: Finding name of installed font

#36666
From: der Mouse
Date: Sun, 11 Feb 1990 04:29
39 lines
2048 bytes
> How does one determine the name of the currently-loaded font?

There is no "the" currently-loaded font.  My server at the moment, for
example, has (at least) four fonts loaded; I've got that many different
fonts in use in various windows.

> Specifically, what I'm trying to do is set up a sequence of Xw
> widgets as follows:  statictext statictext valuator, all inside a
> rowcol.  The width of each statictext is to be determined by the
> length of certain strings.

A string has a length (in pixels) only when associated with a font.
The string "foo", for example, does not have a length in pixels,
whereas the thing <"foo" in font "fixed"> does (18 pixels, I think it
is, on the system I'm using to type this).

> To do this, it looks like I have to:

> [...]
>     o  find out the fontstruct using
>            fontstruct = XLoadQueryFont (display, fontname)
>        for which I need to

>     o  learn the name of the installed font.

You can get an XFontStruct that way, yes.  However, you can also use
XQueryFont, for which you need only the font ID, or even a graphics
context ID (obtainable from the GC with XGContextFromGC).

I don't know enough about widgets (of any sort) to more than guess what
font your statictext widget is going to use, but if you can get it to
tell you the graphics context it will use for drawing, you can use
that.  If all else fails, you might be able to get away with using the
default GC for the screen, but I doubt that'd work properly.

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu
Technical Details
Message-ID: <9002110429.AA02515@Larry.McRCIM.McGill.EDU>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!tut.cis.ohio-state.edu!snorkelwacker!bloom-beacon!LARRY.MCRCIM.MCGILL.EDU!mouse

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!tut.cis.ohio-state.edu!snorkelwacker!bloom-beacon!LARRY.MCRCIM.MCGILL.EDU!mouse
From: mouse@LARRY.MCRCIM.MCGILL.EDU (der Mouse)
Newsgroups: comp.windows.x
Subject: Re:  Finding name of installed font
Message-ID: <9002110429.AA02515@Larry.McRCIM.McGill.EDU>
Date: 11 Feb 90 04:29:47 GMT
Sender: daemon@athena.mit.edu (Mr Background)
Organization: The Internet
Lines: 39