Problem with giant font sizes in tkinter

S

Steven D'Aprano

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-*'

On one PC (Fedora), the text is displayed fine. Running xlsfonts gives me
this:

$ xlsfonts -fn '-Adobe-Helvetica-Bold-R-Normal-*-140-*'
-adobe-helvetica-bold-r-normal--14-140-75-75-p-82-iso10646-1
-adobe-helvetica-bold-r-normal--14-140-75-75-p-82-iso8859-1
-adobe-helvetica-bold-r-normal--20-140-100-100-p-105-iso10646-1
-adobe-helvetica-bold-r-normal--20-140-100-100-p-105-iso8859-1



On a second PC (Ubuntu), the text is displayed in HUGE letters and I get
this from xlsfonts:

$ xlsfonts -fn '-Adobe-Helvetica-Bold-R-Normal-*-140-*'
-adobe-helvetica-bold-r-normal--14-140-75-75-p-82-iso10646-1
-adobe-helvetica-bold-r-normal--14-140-75-75-p-82-iso10646-1
-adobe-helvetica-bold-r-normal--14-140-75-75-p-82-iso8859-1
-adobe-helvetica-bold-r-normal--14-140-75-75-p-82-iso8859-1
-adobe-helvetica-bold-r-normal--20-140-100-100-p-105-iso10646-1
-adobe-helvetica-bold-r-normal--20-140-100-100-p-105-iso10646-1
-adobe-helvetica-bold-r-normal--20-140-100-100-p-105-iso8859-1
-adobe-helvetica-bold-r-normal--20-140-100-100-p-105-iso8859-1


I don't know how to diagnose or fix the problem. What should I do to fix
this problem?
 
C

Cousin Stanley

Steven said:
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 ?

canv.create_text(
81 , 27 ,
text = ' NTSC Standard ' ,
fill = 'white' ,
font = ( 'Helvetica' , 12 , 'bold' ) )
 
R

rantingrick

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-*'

On one PC (Fedora), the text is displayed fine. Running xlsfonts gives me
this:

$ xlsfonts -fn '-Adobe-Helvetica-Bold-R-Normal-*-140-*'
-adobe-helvetica-bold-r-normal--14-140-75-75-p-82-iso10646-1
-adobe-helvetica-bold-r-normal--14-140-75-75-p-82-iso8859-1
-adobe-helvetica-bold-r-normal--20-140-100-100-p-105-iso10646-1
-adobe-helvetica-bold-r-normal--20-140-100-100-p-105-iso8859-1

On a second PC (Ubuntu), the text is displayed in HUGE letters and I get
this from xlsfonts:

$ xlsfonts -fn '-Adobe-Helvetica-Bold-R-Normal-*-140-*'
-adobe-helvetica-bold-r-normal--14-140-75-75-p-82-iso10646-1
-adobe-helvetica-bold-r-normal--14-140-75-75-p-82-iso10646-1
-adobe-helvetica-bold-r-normal--14-140-75-75-p-82-iso8859-1
-adobe-helvetica-bold-r-normal--14-140-75-75-p-82-iso8859-1
-adobe-helvetica-bold-r-normal--20-140-100-100-p-105-iso10646-1
-adobe-helvetica-bold-r-normal--20-140-100-100-p-105-iso10646-1
-adobe-helvetica-bold-r-normal--20-140-100-100-p-105-iso8859-1
-adobe-helvetica-bold-r-normal--20-140-100-100-p-105-iso8859-1

I don't know how to diagnose or fix the problem. What should I do to fix
this problem?


First let me stop laughing... hold on... yea just a minute... a little
longer please... gawd i am enjoying this... ok i am ready... *pffftt*
ha ha ha ha ha ha ha!

I thought you hated Tkinter Steven? That is what you told this fine
group many times anyway. Also on many occasions you have said that you
have no use for GUI's, period. This is very interesting that know you
cannot even draw text to preferred size.

Oh, and about your problem. READ THE FREAKING MANUAL!
 
S

Steven D'Aprano

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?
 
P

Paul Rubin

Steven D'Aprano said:
Nevertheless, I'd like to learn how to diagnose these sorts of font
issues. Can anyone suggest where I should start?

Is the -140- a font size in points (1 point = 1/72 inch) or something
like that? Try a smaller number.
 
S

Steven D'Aprano

Is the -140- a font size in points (1 point = 1/72 inch) or something
like that? Try a smaller number.

Thanks, but I already know how to make random changes to code until it
works :)

I want to understand what I'm doing and why. Why does the same piece of
code work perfectly fine on one PC, and blow up to the size of a house on
another? This surprises me, particularly since the not-working PC has the
same fonts as the working one (plus extras).
 
R

rantingrick

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?


I am *seriously* worried about comrade D'Aprano! Either his little
sister is using his account or he has completely lost his marbles!
Either way i am worried! SERIOUSLY!

Steven, are you seriously telling this group that with all your
knowledge of Python, CPython, C and many other languages you cannot
solve a simple "attack of the Tkinter giant font" bug? You cannot read
a tutorial or a manual to find the answer? You cannot use Google?
 
C

Chris Jones

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?

First of all, you need to know precisely what the above font name coding
means.

Chapter 6 of O'Reilly's ‘The X Window System's User Guide’, provides
a brief but fairly thorough introduction.

In relation to your problem, see in particular the discussion of the use
of wild cards and such aspects as pixel size and vertical/horizontal
resolution.

You can download a scanned pdf of this book free of charge here:

http://www.archive.org/details/xwindowsytemosf03querarch

Have fun,

cj
 
S

Stephen Hansen

I am *seriously* ...blah

You are a child.

This is your second pointless response to this thread.

Part of me wants to say, stop behaving like a 13 year old; only you're
behaving worse then several 13 year olds I know. It would be an insult
to their maturity to compare you to them.

"Grow up" doesn't quite do it. You're usually a troll, everyone gets
that. Its all you do, troll here and there, but this is all worse then
even what you spew out usually.

It's just... kinda, sad.

You can't even manage a point anymore. It's kinda funny, really. You've
proven yourself incapable of supporting position after position in
actual argument-- so now you're just not even able to rant. Once upon a
time you would seize upon this and find some reason to rant about--
something, to call to arms the silent majority, to declare you the
spokesman for all that is holy and proper and good, none of which can be
found here.

Now.. this? Lol.

Time to change your name. You're no longer Ranting Rick.
Congratulations! You're now Blabbering Rick.

--

Stephen Hansen
... Also: Ixokai
... Mail: me+list/python (AT) ixokai (DOT) io
... Blog: http://meh.ixokai.io/


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.10 (Darwin)

iQEcBAEBAgAGBQJNVPTLAAoJEKcbwptVWx/l+dMH/0Q1w0DduVmTaR6o0F9yH2WU
UY1sC2vcJImAx0zooz/teYcoxwPp4VT83vIt75ouwG/JNxOUpm30uQq4fYPP7IpP
rxYMx8hZbPGrbOjRu5xFSAY7jSeIMnZcD8GcUv8JZUOnUImaPGeAaWI4wzP3p2em
yqKggWkm555y41eYTrSubYMGsZ4n92yOQBzXD5r4juMnnwnhj3efNx3bhe9WSIKr
BQL7zavC2fFekskkqQAeiPcuSIAEhz1zli+PXGlrkWh95TSios+haGb+e+rCEYh/
wWUWaIpQS5LKBTdRxe2sxslzfMKyVPmFvtCkFovfq9z78d2wDAMx8XPBHMfCEp8=
=IIs9
-----END PGP SIGNATURE-----
 
A

Arndt Roger Schneider

Steven said:
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?

Those adobe helveticas are bitmap fonts.
Tk 8.5 uses freetype to render fonts under X11,
if you wish to use outdated bitmap fonts under X11,
then disable-xft when building Tk 8.5.

I do assume there are different tk versions on your
various platforms, and the troubling one is with
version 8.5 --8.5 uses anti-aliasing hence freetype.

Recommendation: Get rid of bitmap fonts under X11.

BTW the default fonts under Linux are:
bitstream vera sans (for helvetica)
bitstream vera (for times)
and bitstream vera sans mono (for courier).

In my opion those bitstream fonts are much better
than the mentioned Adobe fonts.

-roger
 
C

Chris Jones

labelfont = '-Adobe-Helvetica-Bold-R-Normal-*-140-*'
[...]
First of all, you need to know precisely what the above font name coding
means.

Thanks for the link, that's incredibly useful (although the PDF
doesn't render correctly in any of the five different PDF viewers
I tried, but I was able to read it).

The O'Reilly X admin guide is also available at the same address and has
a few more pieces of the puzzle.

Should've mentioned that you should download the (much smaller) *.djvu
files rather than the pdf's. Much smaller files, and render considerably
faster. The ‘evince’ viewer on GNU/Linux appears to understand the djvu
format.

cj
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top