-
Notifications
You must be signed in to change notification settings - Fork 2
/
Font.tcl
67 lines (48 loc) · 1.22 KB
/
Font.tcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Toolbox Ref Volume 2, 16-41
little_endian
proc pstr { n name } {
set p [pos]
set len [uint8]
if { $n == 0 } { set n [expr $len + 1 ]}
if { $len == 0 } {
move -1
entry $name "" $n
bytes $n
return ""
}
if { $len >= $n } { set len [expr $n - 1] }
set str [ascii $len]
goto $p
entry $name $str $n ;# [expr $len + 1]
bytes $n
return $str
}
pstr 0 "Name"
set start [pos]
set offset [uint16 "Offset"]
int16 "Family"
uint16 "Style"
uint16 "Point Size"
uint16 -hex "Version"
uint16 "Font Bounds Rectangle Extent"
# additional fields, if any, would go here.
goto [expr $start + $offset * 2]
uint16 "Font Type (ignored)"
set firstChar [uint16 -hex "First Char"]
set lastChar [uint16 -hex "Last Char"]
uint16 "Max Width"
int16 "Max Kern"
int16 "Max Descent"
uint16 "Font Width Rectangle"
set fHeight [uint16 "Font Height Rectangle"]
set owTLoc [uint16 "Offset to Offset/Width Table"]
set owOffset [expr [pos] + $owTLoc * 2 - 2]
uint16 "Font Ascent"
uint16 "Font Descent"
uint16 "Leading"
set row [uint16 "Width of Font Strike"]
bytes [expr $row * 2 * $fHeight] "Font Strike Data"
set tsize [expr ($lastChar - $firstChar + 3) * 2]
goto [expr $owOffset - $tsize]
bytes $tsize "Location Table"
bytes $tsize "Offset/Width Table"