Re: Proposed: new support for vertical anchor value of 'baseline in addition to n,s,c



It's not a dumb idea, it just needs a TIP and some accompanying source
code.

In the meantime, you can accomplish your objective in one of two ways,
exemplified by procs alignAnchorN (for text items anchored n) and
alignAnchorS (for text items anchored s):

proc alignAnchorN {font baselineY} {
return [expr {$baselineY - [font metrics $font -ascent]}]
}

proc alignAnchorS {font baselineY} {
return [expr {$baselineY + [font metrics $font -descent]}]
}


# test code

font create font1 -family {Times New Roman} -size 24
font create font2 -family {Times New Roman} -size 18

set text1 "Text 1"
set text2 "Text 2"

toplevel .test
set c [canvas .test.c]
grid $c -sticky nsew

set baseline 100
$c create line 0 $baseline [winfo reqwidth $c] $baseline
$c create text 0 [alignAnchorN font1 $baseline] \
-anchor nw -font font1 -text $text1
$c create text [font measure font1 $text1] [alignAnchorS font2
$baseline] \
-anchor sw -font font2 -text $text2

.