Wednesday, October 1, 2008

Core Text - CTFontGetUnderlineThickness

[build 0066] I have got the first five effects to work - that is I can open files that have the effect and publish them. My thought of a chance to make some rapid progress by avoiding text was short-lived. Having added text to the test files there were problems to work through.

The effects deal with text as path shapes. That is internally they make a single shape out of the glyphs and then do weird and wonderful things to them. This exercises a section of the text code that I had identified as not being tested and was open on my check-list (I could not generate file that was able to test it). The primary problem was due to incorrectly scaling the glyph shapes as they were generated, but there were a few others.

Working through the bugs the last one was the position of the underline. Below is an effect that transitions a shape my curling it upwards. In the test file je orange text starts exactly over the bluish text and curls off. It is caught part way through transition.

Interestingly a similar problem affected the PC version of Cello - the underline shifted once an effect was applied. The two underlines are calculated in two different place and calculated differently.

The solution was quite nice. CoreText has two functions CTFontGetUnderlineThickness and CTFontGetUnderlinePosition - just call these functions in the two places and the results are identical.

No comments: