[mythtv] mytharchive: Font scaling weirdness

Russell Mora rd.mora at gmail.com
Fri Jun 29 04:16:44 UTC 2007

Hi All,

I'm experiencing some font scaling problems with mytharhive that I've not
been able to find any information on.  Basically the python imaging library
(PIL) is reporting rendered font sizes much bigger than what they actually
are - this extra debug statement illustrates the problem:

Index: mytharchive/mythburn/scripts/mythburn.py
--- mytharchive/mythburn/scripts/mythburn.py    (revision 13754)
+++ mytharchive/mythburn/scripts/mythburn.py    (working copy)
@@ -819,6 +819,7 @@
         fontsize = getScaledAttribute(nodefont, "size")
         write( "Loading font %s, %s size %s" %
(fontnumber,getFontPathName(fontname),fontsize) )
+        write( "Font actual size (for \"Test\") is %s by %s" %
themeFonts[fontnumber].getsize("Test") )

 def getFileInformation(file, folder):

Results in this in the output log:

Loading font 0, /usr/local/share/mythtv/FreeSans.ttf size 19
Font actual size (for "Test") is 38 by 36
Loading font 1, /usr/local/share/mythtv/FreeSans.ttf size 15
Font actual size (for "Test") is 29 by 28
Loading font 2, /usr/local/share/mythtv/FreeSans.ttf size 14
Font actual size (for "Test") is 28 by 26

As you can see the height of the rendered text is just under twice (~1.875)
of what (I would have) expected.  The end result of this is that when
mythburn tries to render some text it decides it is too big to fit into the
allowed area and truncates it - down to zero characters.  Unfortunately this
includes all of the menu buttons, i.e. titles, chapter times, etc, which
makes the DVD image almost unplayable.  This happens on all of the DVD

To see what size the rendered text would be I hacked mythburn not to
truncate the text (by hard-coding the returned height from intelliDraw to be
the same as the requested size from when the font is loaded) - surprisingly
enough the rendered text looks about the right size, however it does look
like it has been rendered into a area about the size reported, i.e. ~1.875
the normal size, and aligned to the bottom of the "rendered" area.  Thus the
end results is that the layout does not look right...

I've searched for any information about this wrt PIL and the freetype
library but could not find anything.  This only started happening after a
system upgrade so I tried downgrading freetype and PIL, but no luck.  If
anyone has any insight into this problem (I know next to nothing about
python) I would appreciate it.  Otherwise I think I'll have to start
debugging the python imaging library (sounds like fun :-( ).


Some system details:
2.6.20-gentoo-r8 x86_64
MythTV - SVN Revision: 13754
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mythtv.org/pipermail/mythtv-dev/attachments/20070629/f2bf3eff/attachment.htm 

More information about the mythtv-dev mailing list