[mythtv-users] MythArchive - blank title text

Paul Harrison mythtv at dsl.pipex.com
Sat Jul 14 17:56:43 UTC 2007


Michael T. Dean wrote:
> On 07/06/2007 01:38 PM, Paul Harrison wrote:
>   
>> I've also just started to see some font scaling problem after updating
>> to current svn. I've not had time to look at the issue properly but the
>> chap who posted this
>> http://www.gossamer-threads.com/lists/mythtv/dev/277106 seems to think
>> it's something to do with the new fonts that where updated in [13588] by
>> stuartm.
>>     
>
> As requested by me.  (Oops.  But, in my defense, who would have thought
> a font upgrade would break a program?)
>
>   
>>  Try reverting back to the old fonts and see if that fixes it
>> for you.
>>     
>
> I finally got a chance to look into it.  The problem is with the
> superscript/subscript "set asides" in the font (verified with testing as
> described below and by comparing the fonts in FontForge).  In the old
> font, not enough space was provided for the specified height/width of
> the sub/superscripts.  That meant if you used the old font in a
> text-layout program that used the font-specified values, the lines with
> sub/superscripts would have to be "bumped" to make room for the
> sub/superscripts.  (I.e. "normal" line spacing until you include a
> superscript, then there's a big gap between the above line and the one
> with the superscript--unless, of course, the app were really lazy, in
> which case the superscript would overlap the above line.)  Most
> text-layout programs (like OpenOffice.org, for example) don't tend to
> use the font-specified values, though (they calculate their own sizes
> and set asides or allow users to specify them or both).
>
> The new font was changed so that rather than specify values for
> sub/superscript size/set asides, it allowed the font creator program to
> calculate them.  In so doing, the sub/superscripts became bigger and the
> set aside became bigger by the amount the previous version's set aside
> was lacking plus the difference in size of the sub/superscripts. 
> Therefore, the font's metrics now indicate that a line of text is nearly
> twice as tall as before.
>
> Since PIL uses the font-specified height, rather than the actual glyph
> height, MythArchive is now getting a value almost twice what it
> previously got.  Since it seems MythArchive specifies "text box" sizes
> that worked with the old height value in the font, it thinks the text
> will no longer fit (in fact the text is the exact same size, but there's
> blank space above and below it).
>
> While I can create new fonts that specify the same font height as the
> previous-version fonts, in doing so, we'll end up with fonts that differ
> from upstream (and, perhaps, the same issue in the future--but that time
> because we forgot to modify the font again).  However, my recommendation
> would be to adjust the height (and probably position) of the "text
> boxes" that are affected by the changed font.
>
> Another option is to modify PIL to allow retrieving per-character size
> information using FreeType's height member of the FT_Glyph_Metrics
> structure (which, TTBOMK, is not currently possible), push that change
> upstream, change MythArchive to find the height of the tallest glyph in
> the text string using the new function, and get everyone to upgrade to
> PIL 1.1.7; but I think you'll agree that won't work. :)  I've also heard
> that aggdraw ( http://effbot.org/zone/pythondoc-aggdraw.htm ) does
> better at font sizing/positioning, but I haven't tested it and don't
> even know if it would work for what you're doing (and it would create a
> new dependency, so it's probably not worth trying).
>
> As I haven't yet used MythArchive (I watch and delete shows--never
> archive any), I'm not volunteering to make the modifications I'm
> recommending we make to the text boxes.  If no one else is willing to
> fix the text positioning and fixing the problem falls on me (because I
> encouraged the upgrade of the fonts), I'll just make custom versions of
> the fonts (because doing so will only take minutes).
>
> I'm guessing that fixing it properly would simply require someone's
> modifying MythArchive's theme.xml files.  If so, this would be a great
> job for someone who wants to contribute but who's not a coder.  :)
>
> Mike
>
>   
>

Thanks for looking into this Mike.

If you are confident the new fonts are correct and consistent with the
way other fonts would work then I suggest we keep them as they are and I
will somehow work around the problem in MythArchive.

It would be nice to get this fixed in PIL but I don't think its being
actively developed any more, there hasn't been any updates in quite a
while. In any case it would be months before the changes filter down
into all the distributions.

Moving and resizing the text boxes would be the easiest solution but
isn't ideal because it means having to have some of them overlapping
each other and if a user where to use another font it would probably
require changing them all again so things line up properly. Also PIL
doesn't have any way to draw multi line text so MythArchive has to split
the text up into lines and draw each line individually. It uses the text
height returned by textsize() to position the text which worked quite
well with the old font but the spacing is going to be to big with the
new font. I'd probably have to calculate the line spacing based on the
font size + a fixed % or something like that.

Another alternative would be to find a way to get the actual text size
not including these extra areas above and below the text. That would
allow the script to position the text exactly where the theme files want
for all fonts.

Anyway I've got something to work on now, thanks again.


Paul H.




More information about the mythtv-users mailing list