Tk Source Code

View Ticket
Login
Ticket UUID: 502026
Title: Font scale incorrect in postscript
Type: Bug Version: obsolete: 8.3.4
Submitter: nobody Created on: 2002-01-10 20:42:34
Subsystem: 06. Canvas Postscript Assigned To: hobbs
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2026-10-22 17:22:37
Resolution: Fixed Closed By: serhiy.storchaka
    Closed on: 2026-09-21 14:29:29
Description:
In the tk8.3.4 (and all earlier distributions) the 
Tk_PostscriptFontName routine returns the size of the 
font. It may (in principle) be either in points or 
pixels. In practice it has been converted to points by 
this time.

The postscript file contains a postscript scale 
command at the start of the file that defines all the 
canvas pixel coordinates be converted to points so 
that points are the "postcript unit". The scalefont 
command goes further and scales the font to be scaled 
by the number of points.

If you:
1. place on the canvas a font of size 40 with the 
text "This is some text"
2. get the bounding box of the text and draw a box 
around the text using this.
3. generate a postscript file of the canvas with a -
pageheight of 8i
4. Look at the results in Ghostscript or on a printer

Notice that the bounding box is larger than the text.

I believe that the points must be scaled to pixels 
before calling "scalefont" so that they are converted 
back to points as a result of the "scale" command. 
This should be done after the call to 
Tk_PostscriptFontName in Tk_PostscriptFont in 
tkCanvPs.c.
User Comments: serhiy.storchaka added on 2026-09-21 14:29:29:

Fixed in 8.5.6 by [d63b555adc] (see [2107938]): the font size is converted from pixels to points with the same factor as the canvas coordinates, as proposed here. Verified with 8.6 and 9.1 at tk scaling 1.0, 2.0 and 0.75: the text in the Postscript output has the same size relative to the other items as on the screen.