PDA

View Full Version : Feature request: "baseline" parameter in fonts



Dima Litvinov
08-04-2013, 10:27 AM
Hi!
In my Proton-based application I need a component that renders rich text (bold, italic, different font size + pictures). The basic thing that I need for this is a possibility to change font "on the fly" - i.e. render half of line with one font and continue with another font. Basically, this is not very hard when you have access to RTFont class :)

But when you do such trick, these two fonts might have different sizes - and the problem of vertical aligning of two strings rendered with different fonts appears. You cannot position these two strings giving the same y-coordinate neither to "top" of the characters nor to their "bottoms". Instead, their "baselines" (i.e. places where we underline the text) must have the same y-coordinates. Here is an illustration:

small string big string
I've found the "baseline" parameter in .fnt file, which is used to assemble .rtfont file. But in .rtfont itself it disappears - and there are no ways to get the baseline position in RTFont class.

So, I plan to implement this using "reserved" field in rtfont_header struct. For this I need to modify RTFont-related classes as well as RTPack utility.

Now questions:
1. Did I describe the situation with baseline parameter right? Is it really present in .fnt and absent in .rtfont?
2. The way I described - is it right way to implement this?
3. Wouldn't it be more correct to do these changes in official branch of Proton instead of my own "fork"? Maybe this functionality will be useful for others?

I think, if this functionaity could be useful for others we could discuss with Seth (and others) how to implement it the best way - and I could follow these advices so we could include the changes in official release.

Looking forward for the response(s)!

Seth
08-09-2013, 12:56 AM
Hey, well, it sounds fine to me as long as any change is 100% compatible with old stuff. (For instance, you could add 1 to the font format version, so fonts created with the older rtpack still display perfectly on the new font code, etc)

Dima Litvinov
08-09-2013, 06:56 AM
OK, I'll try, test and let you know. Thanks for the advice.