Version 3 of fontmap

Updated 2015-12-07 20:32:29 by arw

arw (Dec 2015): here is an example of a fontmap when exporting the canvas content to a postscript. The fontmap is an array with the keys being the font as specified in the -font option of the text canvas items and the array values being the postscript font specifications. You can find the postscript font names in a file called Fontmap.GS on your system.

package require Tk

canvas .c
pack .c -fill both -expand TRUE

set txt "Lorem ipsum dolor sit amet..."

set f1 "*-Helvetica-Medium-R-Normal-*-12-*"
set f2 [font create -family "DejaVu Sans" -size 14]
set f3 TkDefaultFont
set f4 [font create -family [lindex [font families] 9] -weight bold]


set y 40
foreach f [list $f1 $f2 $f3 $f4] {
    .c create text 50 $y -text $txt -anchor w -font $f 
    incr y 40
}

set fm($f1) [list Helvetica 12]
set fm($f2) [list Times 13]
set fm($f3) [list Courier 14]
set fm($f4) [list Bookman-Demi 15]

.c postscript -file test.ps -fontmap fm