summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtkread18
1 files changed, 12 insertions, 6 deletions
diff --git a/tkread b/tkread
index b14204a..b4f9f2e 100755
--- a/tkread
+++ b/tkread
@@ -13,9 +13,9 @@
# - if window width is small, reduce padx space
# - make scrolling using mouse work even when text area isn't hovered over (also note this sort of scrolling doesn't update the title); integrate the MouseWheel event with scroll. this *should* also fix the issue of dragging and then leaving the window, as the strange scrolling is likely caused by related default behaviour
# - add more markdown processing
-# - use font create / configure to name a font to simplify changing its size
-set fontsize 15
+set fontfamily {Linux Libertine O}
+set fontsize 16
set textcolour #443322
set bgcolour #eeeeee
set outercolour #f8f8f5
@@ -49,6 +49,7 @@ proc rewrap {text} {
# deleted without affecting the position for formatting.
proc markup {widget} {
global surroundfmt
+ global fontfamily
global fontsize
global tagnum
@@ -86,22 +87,23 @@ proc markup {widget} {
$widget tag add tag_$tagnum markon_$x markoff_$x
}
- $widget tag configure tag_$tagnum -font "Times $fontsize $fmtstring"
+ $widget tag configure tag_$tagnum -font "{$fontfamily} $fontsize $fmtstring"
incr tagnum
}
}
proc changeFontSize {change} {
+ global fontfamily
global fontsize
global surroundfmt
global tagnum
set newsize [expr $fontsize $change]
if {$newsize > 0} {
set fontsize $newsize
- .t configure -font "Times $fontsize" -padx [expr $fontsize * 3]
+ .t configure -font "{$fontfamily} $fontsize" -padx [expr $fontsize * 3]
for {set x 0} {$x < $tagnum} {incr x} {
set fmtstring [lindex [lindex $surroundfmt $x] 1]
- .t tag configure tag_$x -font "Times $fontsize $fmtstring"
+ .t tag configure tag_$x -font "{$fontfamily} $fontsize $fmtstring"
}
}
}
@@ -136,8 +138,12 @@ proc doMotion {ypos} {
set lasty $ypos
}
+if { [lsearch [font families] "$fontfamily"] == -1 } {
+ # A font called "Times" is guaranteed by Tk to be available
+ set fontfamily Times
+}
. configure -bg $outercolour
-text .t -font "Times $fontsize" -wrap word -width 64 -padx [expr $fontsize * 3] -bg $bgcolour -fg $textcolour -relief flat -inactiveselectbackground {} -cursor {}
+text .t -font "{$fontfamily} $fontsize" -wrap word -width 64 -padx [expr $fontsize * 3] -bg $bgcolour -fg $textcolour -relief flat -inactiveselectbackground {} -cursor {}
pack .t -expand yes -fill y
set text [read stdin]
foreach arg $::argv {