Font character width?

The place to discuss creating, porting and modifying Celestia's source code.
Topic author
maxim
Posts: 1036
Joined: 13.11.2003
With us: 21 years
Location: N?rnberg, Germany

Font character width?

Post #1by maxim » 27.03.2005, 17:51

Is there any tool for examining txf-files?

OR

Can anybody tell the width of default (and other?) cel font characters in pixel?

maxim

Christophe
Developer
Posts: 944
Joined: 18.07.2002
With us: 22 years 4 months
Location: Lyon (France)

Post #2by Christophe » 27.03.2005, 18:14

The tools available on Mark Kilgard's site don't work with Celestia's txf files. But I'm working on getting a working version to add a preview to the font generator.
Christophe

Christophe
Developer
Posts: 944
Joined: 18.07.2002
With us: 22 years 4 months
Location: Lyon (France)

Post #3by Christophe » 28.03.2005, 13:57

A txf file preview is now available here.
Christophe

Avatar
dirkpitt
Developer
Posts: 674
Joined: 24.10.2004
With us: 20 years 1 month

Post #4by dirkpitt » 29.03.2005, 00:48

Christophe wrote:A txf file preview is now available here.


Cool, seems to work for small TXF's. Jumbo (2k+) TXF's containing lots of CJK characters
seem to break it. I suppose though that this is just further proof that Celestia itself
needs a more scalable font system that can handle 2k+ CJK fonts. Something that
doesn't require loading one giant font texture at once. I've been thinking along the lines of
Celestia storing the texture as little strips, might be a little slower to render but should
be much more scalable.

Christophe
Developer
Posts: 944
Joined: 18.07.2002
With us: 22 years 4 months
Location: Lyon (France)

Post #5by Christophe » 29.03.2005, 08:18

Well, I wasn't particularly cautious with the memory handling, so that may explain why the preview doesn't work with large textures.

The solution to rendering CJK fonts might be to use a different library like FTGL which can render TTF fonts directly. But I don't know how it performs with fonts with a large number of glyphs.
Christophe

patesi
Posts: 5
Joined: 31.10.2003
With us: 21 years
Location: Hungary

Post #6by patesi » 29.03.2005, 16:45

Merci Christophe, pour cet outil g?©nial! :P

Enfin un program qui permet la conversion des txf sous windows.

(il y a quelques semaines il fallait encore installer un Linux, apprendre a manipuler ttf2txf etc. -une bonne journ?©e-, maintenant voici en 10 secondes le txf qui me faut, pas mal!)

Zolt??n

Topic author
maxim
Posts: 1036
Joined: 13.11.2003
With us: 21 years
Location: N?rnberg, Germany

Post #7by maxim » 30.03.2005, 08:12

Thanks Christophe - I'll give it a try.

No one who knows the dimensions of the characters? I mean - they have to be cut out to display them on the screen. There must be an information about the sizes anywhere for that.

maxim

Christophe
Developer
Posts: 944
Joined: 18.07.2002
With us: 22 years 4 months
Location: Lyon (France)

Post #8by Christophe » 30.03.2005, 09:21

Yes, the font geometry information is stored in the txf along the texture.

Have a look at the src/celtxf/texturefont.cpp source file. TextureFont::load should make it clear how to retreive that information.
Christophe

Topic author
maxim
Posts: 1036
Joined: 13.11.2003
With us: 21 years
Location: N?rnberg, Germany

Post #9by maxim » 30.03.2005, 16:10

Ok, I see.

So no ready-to-use default charsize table for use in a lua-textprocessing-function - beside writing my own tool to retrieve one?

maxim

Christophe
Developer
Posts: 944
Joined: 18.07.2002
With us: 22 years 4 months
Location: Lyon (France)

Post #10by Christophe » 30.03.2005, 19:30

Well, making TextureFont::getWidth available to Lua scripts doesn't seem all that difficult if that's all you need.
Christophe

Topic author
maxim
Posts: 1036
Joined: 13.11.2003
With us: 21 years
Location: N?rnberg, Germany

Post #11by maxim » 30.03.2005, 19:35

In fact that would be the optimal solution.

maxim :)

Christophe
Developer
Posts: 944
Joined: 18.07.2002
With us: 22 years 4 months
Location: Lyon (France)

Post #12by Christophe » 30.03.2005, 20:45

OK, I'll see what I can do. Do you compile your own version from cvs or do you use the pre-release?
Christophe

Topic author
maxim
Posts: 1036
Joined: 13.11.2003
With us: 21 years
Location: N?rnberg, Germany

Post #13by maxim » 31.03.2005, 07:27

Both. Depends if I am testing, or creating mainstream stuff.

maxim

Christophe
Developer
Posts: 944
Joined: 18.07.2002
With us: 22 years 4 months
Location: Lyon (France)

Post #14by Christophe » 04.04.2005, 20:49

I've added a celestia:gettextwidth(string) method.

It returns the width of the string in pixels, you need to divide that by celestia:gettextwidth("M") to get the em units used by celestia:print.
Christophe


Return to “Development”