Ali Parr
Ali Parr

Reputation: 4787

Uniscribe Kerning

At work, I have been tasked with improving the text rendering of our application to better support text character kerning. Our application generates images that appear on Television, so image quality is paramount. Therefore, even small improvements to the appearance of any output we generate is very useful.

Our current text engine is implemented using Uniscribe, which seems to be an ideal solution. As mentioned here, it supports ligature substitution in a context aware fashion with complex scripts. It also handles right-to-left languages, and BiDi. This is all important as we need to be able to render arabic/cursive languages perfectly.

It therefore seems rather peculiar that Uniscribe doesn't appear to output glyph kerning information. I have attached a screenshot to demonstrate the issue.

alt text http://www.aliparr.net/kerning.jpg

My app performs the same as notepad in that every glyph appears 'monospaced'. Notice how in Photoshop CS2, the bridge at the top of the 'T' nicely overhangs the 'e'. I want to recreate this.

I am aware of other APIs such as Pango/Freetype - but it seems a rather heavyweight solution to include all of that just to do the final 1% of this task, if Uniscribe is so great at everything else.

Am I missing a step using Uniscribe? What is the best solution to this? Can Freetype export kerning information in a lightweight fashion, so that I can integrate it with the existing Uniscribe solution?

N.b. We only need to run on Windows - platform portability is thankfully not an issue I need to worry about right now.

Cheers in advance !

Upvotes: 4

Views: 1167

Answers (3)

HarshG
HarshG

Reputation: 297

By default, ScriptShape/ScriptPlace applies kerning if the selected font supports it. However, in case you want turn it on/off, you should use OpenType Api's of uniscribe.

Upvotes: 0

chowey
chowey

Reputation: 9826

You can manually implement kerning with Uniscribe.

I did this by manually creating the const int *piJustify argument of ScriptTextOut.

// Initially the justification is simply a copy of the advance array
int* piJustify = (int *)malloc(pcGlyphs);
memcpy(piJustify, piAdvance, pcGlyphs);

// Apply kerning to each glyph
for (size_t i = 0; i < pcGlyphs; i++) {
    if (psva[i].fClusterStart) {
        // Only add kerning to the first glyph in each cluster
        piJustify[i] += myKerning;
    }
}

This assumes you already have called ScriptItemize, ScriptShape and ScriptPlace for the pcGlyphs, piAdvance and psva.

Upvotes: 1

tzot
tzot

Reputation: 95901

If you're running on Windows XP, I believe you have to have enabled the following in Control Panel's Regional Options:

  • Install files for complex scripts and right-to-left languages (including Thai)
  • Install files for East Asian Languages

for Uniscribe kerning to work.

Upvotes: 0

Related Questions