Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Set font on ctext widget

36 views
Skip to first unread message

Alexandru

unread,
Dec 9, 2018, 2:49:44 PM12/9/18
to
Hi,

I use next procedure to set the font on all "text" and "ctext" widgets.
Works for "text". Fails for "ctext".
I did add the .t to the widget path of ctext widgets.

proc TextSetFont {w {fontname "Lucida Sans Typewriter"}} {
foreach tagname [$w tag names] {
$w tag configure $tagname -font [list -family $fontname]
}
}

Any idea how to set font on ctext?

Thanks!
Alexandru

briang

unread,
Dec 9, 2018, 4:03:36 PM12/9/18
to
The post does not indicate what the results are from the code above.

I'm not entirely sure how much the ctext widget manages the underlying text widget with respect to fonts, it's possible the ctext wrapper is blocking the change for some reason. If that is the case, then you may need to use the ctext specific configuring commands (e.g. ctext::addHighlightClass) to set the desired font.

Generally speaking about the text widget:

The widget font should be used when setting the font across all text ( $w configure -font $font ).

If a tag has a font value that is empty ( [$w tag cget -font] eq {} ), it should not be blindly changed unless it is intentional to have a different font from the default widget font.

-Brian

Alexandru

unread,
Dec 9, 2018, 4:12:48 PM12/9/18
to
Thanks for the tipp. The issue can be solved by directly setting the font on the widget, not only on the tags.

If $w is the path of the ctext widget, then you can use:

$w.t configure -font [list -family "Lucida Sans Typewriter"]

briang

unread,
Dec 9, 2018, 7:24:48 PM12/9/18
to
Interesting. [$w configure] is supposed to forward the configure to the .t subwidget, so it's not clear why this workaround is necessary. Seems like a bug to me.

-Brian
0 new messages