OpenGL and Uniscribe

Hi,

Does anybody know any tutorial, demo or library that shows how to use the Uniscribe library or some other library with similar capabilities to create 3D font outline under Windows?

I ask this, because the WGL font outline library, freetype and other utilities doesn’t support special kerning and alignment facilities that are required for some character sets like that of arabic one.

If anybody read about this or have already tried it, please help. Any idea is appreciated.

FreeType and WGL font outline are ways to get glyphs. How you arrange those glyphs is up you you. FreeType does provide all of the information necessary to do complex layout, such as for arabic. But it is not a layout library; it is a glyph library.

Layout libraries that (unlike Uniscribe) are not directly tied to rendering (and thus would be appropriate for OpenGL use) include the ICU layout library and Pango. ICU is under the MIT License, while Pango is LGPL, if that matters to you.

Yes, btw that’s my problem, as even though Uniscribe handles the layout, it still returns just an array of glyphs that I don’t know how to use for rendering. Any articles on the topic of getting the geometry behind the glyphs?

Thanks, these may come handy, but I’m pretty unsure whether these libraries support the layout facilities I need. E.g. arabic font with justified text alignment should result in a glyph array that contains some filling characters to make the text alignment justified. Anyway, I will check them out if they know such thing or not.

Btw, just to clarify my problem:

I need to create a library that has a unicode paragraph as input and results in the geometric data of the representation of the input string in a similar style like WGL font outline does, just it should take care of kerning and other layout related issues.

Does anybody have an idea what to use and how to implement?

I know how to create the font outline based on a list of control points for the text as it would be only a geometry related issue, but I’m not really familiar with these layout libraries.

I need to create a library that has a unicode paragraph as input and results in the geometric data of the representation of the input string in a similar style like WGL font outline does, just it should take care of kerning and other layout related issues.

I don’t think such a thing exists. Layout libraries tell you where to draw each glyph. The specific “geometric data” is up to you. You have to convert these glyph locations into whatever geometry your glyphs are in. If you’re blitting glyphs from a texture(s), you have to convert each glyph location into a quad. If you’re drawing glyphs as glyph outlines, you have to offset each glyph based on the glyph location the layout library gives you.

Use FreeType.

  1. InitFreeTypeLib();
  2. Create face: FT_New_Face( library, fontname, 0, &face );
  3. Set char size: FT_Set_Char_Size (it is 26.6 fixed numbers)
  4. for each letter in paragraph find its glyph index:
    FT_UInt glyph_index = FT_Get_Char_Index( face, character );
  5. Load glyph
    FT_Load_Glyph( face, glyph_index, FT_LOAD_DEFAULT );
    FT_GlyphSlot slot = face->glyph;
    FT_Outline outline = slot->outline;
    use data from slot & outline to build shape.
    Do you want polygons or just lines? If you want lines, you need to process each contour in outline. Contours is made of lines and curves. If you want polygone you need to use some tesselation lib and take case of multiple contour surface. (like chars O, R, B, D, 8, 9, i, j, …

A lot of usefull code you can see in FTGL project. It supports outline fonts.

I know this, that’s why I have to create such one that uses some layout library. The problem is that I don’t know how to generate outline geometry from a glyph.

I actually would be able to do that but it’s critical to not use rasterized font but font outlines.

Offsetting the glyphs actually won’t be a problem, so with generating the outline, but I don’t know how to get geometric information (i.e. control points or whatever) from a glyph. Glyphs seem to me like some mystical entities. I don’t know what information can I get about them.

Well actually that’s my problem. I cannot simply get the glyph based on character index as this way I don’t take into account kerning, paragraph alignment and other layout specific parameters. This is simply unacceptable for arabic languages.

Anyway, I would be very interested how to get geometry data based on glyph identifiers as with Uniscribe I’m already able to get the glyph indices and offsets, just I need to make geometry from that and that’s the only equation missing from the formula.

Anyway, I would be very interested how to get geometry data based on glyph identifiers as with Uniscribe I’m already able to get the glyph indices and offsets, just I need to make geometry from that and that’s the only equation missing from the formula.

If all you need is the ability to draw an arbitrary glyph, you need to investigate FreeType. What you’re wanting to do is very much not simple (one of the reasons I prefer rasterized fonts is that working with them is a lot less effort), and it isn’t cross-platform. Each font system has its own quirks about what the basic glyph curves look like, how they do hinting, and so forth. So you’re going to have to pick through the details of what all of this data means.

Font rasterization is non-trivial, and getting it to work decently well will not simply be a matter of getting some control-points and rendering a few triangles based on them.

You may want to ask how to go about doing this in the FreeType mailing list.

Glyph is just character shape description. If you want to do any drawings on screen you need glyphs. Kerning pairs is described in font, but layout, paragraphs, etc is not… you have to do it by yourself.