Problem with giant font sizes in tkinter

Rhodri James rhodri at wildebst.demon.co.uk
Sun Feb 13 18:42:06 EST 2011


On Fri, 11 Feb 2011 02:08:01 -0000, Steven D'Aprano  
<steve+comp.lang.python at pearwood.info> wrote:

> On Thu, 10 Feb 2011 15:48:47 +0000, Cousin Stanley wrote:
>
>> Steven D'Aprano wrote:
>>
>>> I have a tkinter application under Python 2.6 which is shows text in a
>>> giant font, about twenty(?) times larger than expected.
>>>
>>> The fonts are set using:
>>>
>>> titlefont = '-Adobe-Helvetica-Bold-R-Normal-*-180-*'
>>> buttonfont = '-Adobe-Helvetica-Bold-R-Normal-*-140-*'
>>> labelfont = '-Adobe-Helvetica-Bold-R-Normal-*-140-*'
>>> ....
>>
>>   Although I've been a linux user for several years, that type of font
>>   spec hurts my head .... :-)
>>
>>   Will the more simplistic type of tuple spec not work in your tkinter
>>   application ?
>
> I don't know, but I'll give it a try.
>
> Nevertheless, I'd like to learn how to diagnose these sorts of font
> issues. Can anyone suggest where I should start?

The Linux Cookbook has a fairly comprehensible page on the X Font Names at  
http://dsl.org/cookbook/cookbook_20.html  (The Naming of Fonts.  Hmm.   
Paging T S Eliot...)

In this case I think you're missing a hyphen.  Try

titlefont = '-Adobe-Helvetica-Bold-R-Normal--*-180-*'

This breaks down as:

   Foundry:             Adobe
   Family:              Helvetica
   Weight:              Bold
   Slant:               Roman
   Proportionate Width: Normal
   Additional:          La la, can't hear you
   Size in pixels:      Whatever
   Size in points:      180

Points as far as X is concerned are 1/727.2 of an inch.  Pixels would be,  
oh, maybe twenty times bigger?

-- 
Rhodri James *-* Wildebeest Herder to the Masses



More information about the Python-list mailing list