Domanda

How can I get "--courier--*--..." like name if I have the font name like "Courier New"? I'm interested in the first two sections - manufacturer and family.

Thank you.

P.S. I can use standard Xlib functions. I don't want to depend on any other library.

È stato utile?

Soluzione

Unfortunately, font handling is fragmented in X11 and what you want is not possible.

The Xlib function XListFonts() will returns the list of 'old', fixed-sized fonts like '-adobe-courier-bold-o-normal--0-0-100-100-m-iso10464-1'. And that's all the information there is; just a name and a bunch of parameters.

What you are seeking are the functions from Freetype like XftFontOpenName(), where you can supply a pattern like "Courier New-14:bold:slant=italic,oblique". But it is a completely different way of rendering fonts and there is no connection between the two font systems.

You can query the Xft library for a list of fonts using XftFontMatch(), perhaps that will give you the information you seek. But you will have to use the freetype library (a small price to pay, I think).

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top