Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | \ ========== Copyright Header Begin ========================================== |
2 | \ | |
3 | \ Hypervisor Software File: font.fth | |
4 | \ | |
5 | \ Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
6 | \ | |
7 | \ - Do no alter or remove copyright notices | |
8 | \ | |
9 | \ - Redistribution and use of this software in source and binary forms, with | |
10 | \ or without modification, are permitted provided that the following | |
11 | \ conditions are met: | |
12 | \ | |
13 | \ - Redistribution of source code must retain the above copyright notice, | |
14 | \ this list of conditions and the following disclaimer. | |
15 | \ | |
16 | \ - Redistribution in binary form must reproduce the above copyright notice, | |
17 | \ this list of conditions and the following disclaimer in the | |
18 | \ documentation and/or other materials provided with the distribution. | |
19 | \ | |
20 | \ Neither the name of Sun Microsystems, Inc. or the names of contributors | |
21 | \ may be used to endorse or promote products derived from this software | |
22 | \ without specific prior written permission. | |
23 | \ | |
24 | \ This software is provided "AS IS," without a warranty of any kind. | |
25 | \ ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, | |
26 | \ INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A | |
27 | \ PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN | |
28 | \ MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR | |
29 | \ ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR | |
30 | \ DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN | |
31 | \ OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR | |
32 | \ FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE | |
33 | \ DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, | |
34 | \ ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF | |
35 | \ SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. | |
36 | \ | |
37 | \ You acknowledge that this software is not designed, licensed or | |
38 | \ intended for use in the design, construction, operation or maintenance of | |
39 | \ any nuclear facility. | |
40 | \ | |
41 | \ ========== Copyright Header End ============================================ | |
42 | id: @(#)font.fth 2.11 95/04/19 | |
43 | purpose: FCode interface to default font | |
44 | copyright: Copyright 1990 Sun Microsystems, Inc. All Rights Reserved | |
45 | ||
46 | decimal | |
47 | headers | |
48 | 0 termemu-value font-base \ Base address of font | |
49 | ||
50 | 0 termemu-value char-width \ FCode character width in pixels | |
51 | 0 termemu-value char-height \ FCode character height in pixels (scan lines) | |
52 | 0 termemu-value fontbytes \ FCode distance in bytes from one scan line of | |
53 | \ a glyph to the next | |
54 | 0 termemu-value glyph-bytes \ distance between glyphs | |
55 | headerless | |
56 | 0 termemu-value min-char \ The lowest character in the font | |
57 | 0 termemu-value #glyphs \ The number of glyphs in the font | |
58 | ||
59 | headers | |
60 | termemu-defer font \ "open" method of terminal emulator does ' romfont is font | |
61 | ||
62 | headerless | |
63 | : decode-font ( hdr-adr -- bits-adr width height advance min-char #glyphs ) | |
64 | dup d# 24 + swap ( bits-adr hdr-adr ) | |
65 | d# 24 ( bits-adr hdr-adr hdr-len ) | |
66 | 4 decode-bytes " font" $= 0= abort" Not a font" ( bits-adr str ) | |
67 | 5 0 do decode-int -rot loop ( bits-adr width height advance min #gl str ) | |
68 | 2drop ( bits-adr width height advance min-char #glyphs ) | |
69 | ; | |
70 | headers | |
71 | also forth definitions | |
72 | \ There are no glyphs for control characters, so the font bitmaps actually | |
73 | \ begin with the glyph for the space (blank) character. | |
74 | ||
75 | \ The 1- after char-height is due to the way that the PROM stores character | |
76 | \ bitmaps. Since the top and bottom scan lines of the character are both 0, | |
77 | \ only char-height 1- scan-lines are actually stored, and the bottom zero | |
78 | \ scan line of a glyph is overlapped with the top zero scan line of the | |
79 | \ next glyph. This is probably a bad idea in the long run. | |
80 | ||
81 | : >font ( char -- adr ) \ FCode | |
82 | min-char - 0 max #glyphs min ( char# ) \ Clip the glyph number | |
83 | glyph-bytes * font-base + | |
84 | ; | |
85 | ||
86 | headerless | |
87 | : character-set ( -- ) | |
88 | " character-set" 2dup get-my-property if ( adr,len ) | |
89 | " ISO8859-1" encode-string 2swap property ( ) | |
90 | else ( adr,len adr,len' ) | |
91 | 2drop 2drop ( ) | |
92 | then ( ) | |
93 | ; | |
94 | headers | |
95 | : default-font ( -- adr width height advance min-char #glyphs ) \ FCode | |
96 | character-set font decode-font | |
97 | ; | |
98 | ||
99 | : set-font ( adr width +-height advance min-char #glyphs -- ) \ FCode | |
100 | is #glyphs is min-char | |
101 | is fontbytes | |
102 | dup >r abs is char-height is char-width ( r: +-height ) | |
103 | is font-base | |
104 | ||
105 | \ If +-height is positive, then we use the original packed font | |
106 | \ storage format in which the last scan line of one glyph overlaps | |
107 | \ the first scan line of the next. If +-height is negative, we | |
108 | \ use an unpacked format in which each glyph is self-contained. | |
109 | r> dup 0> if 1- else negate then fontbytes * to glyph-bytes | |
110 | ; | |
111 | previous definitions |