[PD-dev] pd.tk confusion regarding fonts

Andre Schmidt andre at vju-tv.net
Mon Sep 9 20:51:11 CEST 2002


hi,

yes, its me again with font problems :)
ok, here are some lines from original pd.tk (0.35-1) file that i assume are used/needed for setting fonts:


<snip1>
    radiobutton $name.radiof.radio8 -value 8 -variable fontsize -text "8"
    radiobutton $name.radiof.radio10 -value 10 -variable fontsize -text "10"
    radiobutton $name.radiof.radio12 -value 12 -variable fontsize -text "12"
    radiobutton $name.radiof.radio16 -value 16 -variable fontsize -text "16"
    radiobutton $name.radiof.radio24 -value 24 -variable fontsize -text "24"
    radiobutton $name.radiof.radio36 -value 36 -variable fontsize -text "36"
    pack $name.radiof.radio8 -side top -anchor w
    pack $name.radiof.radio10 -side top -anchor w
    pack $name.radiof.radio12 -side top -anchor w
    pack $name.radiof.radio16 -side top -anchor w
    pack $name.radiof.radio24 -side top -anchor w
    pack $name.radiof.radio36 -side top -anchor w
</snip1>

<snip2>
############ pdtk_text_new -- create a new text object #2###########
proc pdtk_text_new {canvasname myname x y text font color} {
#    if {$font < 13} {set fontname [format -*-courier-bold----%d-* $font]}
#    if {$font >= 13} {set fontname [format -*-courier-----%d-* $font]}
    $canvasname create text $x $y \
     -font [format -*-courier-bold--normal--%d-* $font] \
     -tags $myname -text $text -fill $color  -anchor nw 
#    pd [concat $myname size [$canvasname bbox $myname] \;]
}
</snip2>

<snip3>
proc pdtk_pd_startup {version} {
    global pd_myversion
    set pd_myversion $version

    set width1 [font measure  -*-courier-bold--normal--8-* x]
    set height1 [lindex [font metrics -*-courier-bold--normal--8-*] 5]

    set width2 [font measure  -*-courier-bold--normal--10-* x]
    set height2 [lindex [font metrics -*-courier-bold--normal--10-*] 5]

    set width3 [font measure  -*-courier-bold--normal--12-* x]
    set height3 [lindex [font metrics -*-courier-bold--normal--12-*] 5]

    set width4 [font measure  -*-courier-bold--normal--14-* x]
    set height4 [lindex [font metrics -*-courier-bold--normal--14-*] 5]

    set width5 [font measure  -*-courier-bold--normal--16-* x]
    set height5 [lindex [font metrics -*-courier-bold--normal--16-*] 5]

    set width6 [font measure  -*-courier-bold--normal--24-* x]
    set height6 [lindex [font metrics -*-courier-bold--normal--24-*] 5]

    set width7 [font measure  -*-courier-bold--normal--36-* x]
    set height7 [lindex [font metrics -*-courier-bold--normal--36-*] 5]

    pd [concat pd init [pdtk_enquote [pwd]] \
     8 $width1 $height1 \
     10 $width2 $height2 \
     12 $width3 $height3 \
     14 $width4 $height4 \
     16 $width5 $height5 \
     24 $width6 $height6 \
     36 $width7 $height7 \
     \;];
}
</snip3>

not tragic but i see theres a size calculated for 14pt but is not used in <snip1> reason/error?

and then a test with this original pd.tk.
i open 14.more.tabread.pd and test the sizes with "fontbomb"
8 : all sizes are changed
10 : diddo
12 : diddo
16 : diddo
24 : only the array name text size is changed (others stay @ 16)?!
36 : all sizes changed
nothing tragic ?! just wanted to report...


then to my font. i change only this

<snip2b>
############ pdtk_text_new -- create a new text object #2###########
proc pdtk_text_new {canvasname myname x y text font color} {
    if {$font < 13} {set fontname [format -*-pufo-----%d-* $font]}
    if {$font >= 13} {set fontname [format -*-courier-bold----%d-* $font]}
    $canvasname create text $x $y \
     -font $fontname \
     -tags $myname -text $text -fill $color  -anchor nw 
#    pd [concat $myname size [$canvasname bbox $myname] \;]
}
</snip2b>

and then a test with this modified pd.tk.
i open 14.more.tabread.pd and test the sizes with "fontbomb"
8 : selects my font at 5pt (5x7pix)
10 : selects my font at 7pt (6x9pix)
12 : selects courier !? (see <snip2b> if(s))
and so on...

and then i tried to get the sizes right and changed still this

<snip3b>
proc pdtk_pd_startup {version} {
    global pd_myversion
    set pd_myversion $version

    set width1 [font measure  -*-pufo---normal--8-* x]
    set height1 [lindex [font metrics -*-pufo---normal--8-*] 5]

    set width2 [font measure  -*-pufo---normal--10-* x]
    set height2 [lindex [font metrics -*-pufo---normal--10-*] 5]
</snip3b>

or this (because its a bitmap font)
</snip3c>
proc pdtk_pd_startup {version} {
    global pd_myversion
    set pd_myversion $version

    set width1 5
    set height1 7

    set width2 6
    set height2 9
</snip3c>
 
and then a test with this modified pd.tk.
i open 14.more.tabread.pd and test the sizes with "fontbomb"
8 : selects my font at 7pt (6x9pix) ?! see test before...
10 : selects my font at 7pt (6x9pix)
and so on...

the object sizes are correct but SOME number boxes are couple pixels too small but NOT ALL ?!?!?!


i'm frustated... dunno what i can do... it's all so unlogical to me... but i hope i've just overseen something important...

on a text editor i get the right sizes
6pt selects 5x7pix (program says 5pt is too small for the prog. [5pt would be the right size but 6pt goes too])
7pt selects 6x9pix
8pt selects 8x11pix


but i wont give up. well, maybe 4 today :)

but this is a tcl/tk problem, right?!
so maybe i should ask in tcl/tk forums or so...


cheers
-andre
ps. i'm on win2k...
pss. yes, i made a new font 5x7pix. but i wont let it out before i get it to work in pd..
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-dev/attachments/20020909/d0667125/attachment.htm>


More information about the Pd-dev mailing list