Can i get a list of glyph mappings from a Font ?

I’m writing a simple java.awt.Font wrapper for my jogl application which renders all characters to a texture and maps these to quads in runtime. Unfortunately I can’t figure out how to get a complete list of available glyph mappings from my font object. Isn’t this possible?

For now, as a cheesy alternative, my wrapper class only support the 256 ascii characters by doing a simple for-loop like this

for( int i = 0; i < 256; i++ ) {
  if( font.canDisplay( (char)i ) ) {
    // render character to backbuffer and record texture coordinates
  }
}

This works fine, but i really want to support unicodes aswell (without having to go through all 64k characters). Hope someone has some insight :slight_smile:

lazy loading ? wait till a character is required to render it and add it to your cache.
(faster startup, less texture memory required)

my 2 cents

Lilian :slight_smile:

Except then your going to have 256 seperate textures, which adds more looksups to the hashmap lookup values in the driver leading to crapper performance…

Besides, why dont you pre-render the texture and store it as a TGA?

DP

There’s nothing implementation related in my post :slight_smile:

for example, you can use a set or 512*512 texture objects to render glyphs (allocating a new one earytime the last is filled). no texture change involved while every glyph is in the same block.

adding a new glyph is just a batch update of the texture object.

my 1 cent

Lilian :slight_smile:

My english may be getting worse, but I don’t think that’s what the OP asked…

Anyway, in my understanding, you can find what you need in the zShapes source. See the package gr.zdimensions.zshapes.editor.font, classes: UnicodeRange, UnicodeListModel and FontMap. You can also see how rendering works in the gr.zdimensions.zshapes.viewer.font package (although not with textures). Even supplementary (>16bit) characters are supported. :wink:

hehe, I was just suggestion another approach to the problem : instead of finding and prerendering every glyph, just looking for the glyphs requested at runtime.

Apologies for thread hijacking…

Lilian :slight_smile:

Hehe no problem Lilian.

I was considering your approach aswell, but i was afraid i might run into “jaggy” framerates in runtime because I never know when I need to expand my font texture. Imagine a rather big font rendered on a 512x512 texture that you suddenly need to expand to 1024x1024 in runtime and re-render all glyphs. I’m not sure but I imagine it would make a noticable sudden drop in framerate.

Thanks Spasi, i’ll take a look at that when i get off work

I want to deploy my application with webstart, and hence size is a factor. Let’s say I’m using a font in three different sizes, pre calculating these maps would probably take up a megabyte or so? compared to a 50k truetype font. It’s not like it takes more than a fraction of a second to generate these maps during initialization anyway.