Home » Archimedes archive » Acorn Computing » 1994 02.adf » 9402 » FontManage/Example4
FontManage/Example4
This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.
Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.
| Tape/disk: | Home » Archimedes archive » Acorn Computing » 1994 02.adf » 9402 |
| Filename: | FontManage/Example4 |
| Read OK: | ✔ |
| File size: | 1112 bytes |
| Load address: | 0000 |
| Exec address: | 0000 |
Duplicates
There is 1 duplicate copy of this file in the archive:
- Archimedes archive » Acorn Computing » 1994 02.adf » 9402 » FontManage/Example4
- Recent acquisitions » Acorn ADFS disks » adfs_AcornComputing_199402.adf » 9402 » FontManage/Example4
File contents
10REM > Example4
20REM Example of Font Manager use - justified text
30REM by Ben Summers
40
50
60REM first check to see if we have the RISC OS 3.1 font manager
70SYS "Font_CacheAddr" TO version%
80IF version% < 300 THEN ERROR 0,"Font Manager too old"
90
100REM find a suitible mode (multisync if possible)
110SYS "OS_CheckModeValid",20 TO ;f%
120IF (f% AND 2) = 2 THEN MODE 12 ELSE MODE 20
130OFF
140
150white% = &FFFFFF00
160black% = &00000000
170
180REM set palette for white on black
190SYS "Font_SetPalette",,0,1,14,black%,white%,&65757254
200
210REM ok, let's find a font...
220size% = 18 * 16
230SYS "Font_FindFont",,"Trinity.Medium",size%,size%,0,0 TO font%
240
250
260REM width of column of text
270width% = 448
280
290REM position of text
300x% = 128
310y% = 768
320
330REM line spacing
340spacing% = -52
350
360
370REM set text to use
380text$ = "This is some text to try some justification. First we'll do a quick left justification, followed by a fully justified bit of text and then finally a right justification... It's really exciting... Why not press any key to see the next bit..."
390REM put text in a block of memory.
400DIM text% 256
410$text% = text$
420
430SYS "ColourTrans_SetFontColours",font%,black%,white%,14
440SYS "Font_Paint",font%,"Left justified text",784,0,960
450PROCdraw_edges
460
470REM length of string
480length% = LEN(text$)
490REM location within string
500loc% = 0
510
520cy% = y%
530
540DIM cb% 64
550
560REPEAT
570 REM this is a coordinate block, the first too entries give additional
580 REM x,y offsets on spaces, then the additional x,y offsets between
590 REM each letter. The bit we're really interested in is the fifth
600 REM entry, which is the character to split lines at. (space)
610 cb%!0 = 0
620 cb%!4 = 0
630 cb%!8 = 0
640 cb%!12 = 0
650 cb%!16 = 32
660
670 REM convert the size of the columns into milli-points for ScanString...
680 REM it doesn't like OS units
690 SYS "Font_Converttopoints",,width%,1024 TO ,jx%,jy%
700
710 REM 800 here is another magic number to find out where to split the string
720 SYS "Font_ScanString",font%,text%+loc%,800,jx%,jy%,cb% TO ,split%
730
740 split% -= text% + loc%
750 REM split% is the number of characters to plot
760
770 REM and paint it onto the screen
780 SYS "Font_Paint",font%,MID$(text$,loc%+1,split%),784,x%,cy%
790
800 loc% += split% + 1
810 cy% += spacing%
820UNTIL loc% >= length%
830
840G = GET
850
860CLS
870
880SYS "Font_Paint",font%,"Fully justified text",784,0,960
890PROCdraw_edges
900
910loc% = 0
920cy% = y%
930
940REPEAT
950 cb%!0 = 0
960 cb%!4 = 0
970 cb%!8 = 0
980 cb%!12 = 0
990 cb%!16 = 32
1000
1010 SYS "Font_Converttopoints",,width%,1024 TO ,jx%,jy%
1020 SYS "Font_ScanString",font%,text%+loc%,800,jx%,jy%,cb% TO ,split%
1030
1040 split% -= text% + loc%
1050 REM split% is the number of characters to plot
1060
1070 REM right, this is where it gets complex. Firstly, we set the far right of
1080 REM the justification using the graphics cursor (the MOVE command). Then,
1090 REM we work out whether we need to justify the particular line ('cos we
1100 REM don't on the last one) and then use the appropriate magic number.
1110 MOVE x%+width%,cy%
1120 IF (loc%+split%+1) <= length% THEN
1130 SYS "Font_Paint",font%,MID$(text$,loc%+1,split%),785,x%,cy%
1140 ELSE
1150 SYS "Font_Paint",font%,MID$(text$,loc%+1,split%),784,x%,cy%
1160 ENDIF
1170
1180 loc% += split% + 1
1190 cy% += spacing%
1200UNTIL loc% >= length%
1210
1220G = GET
1230
1240CLS
1250
1260SYS "Font_Paint",font%,"Right justified text",784,0,960
1270PROCdraw_edges
1280
1290loc% = 0
1300cy% = y%
1310
1320REPEAT
1330 cb%!0 = 0
1340 cb%!4 = 0
1350 cb%!8 = 0
1360 cb%!12 = 0
1370 cb%!16 = 32
1380
1390 SYS "Font_Converttopoints",,width%,1024 TO ,jx%,jy%
1400
1410 REM the new magic number here means 'return the bounding box of the string
1420 REM in the block' which here is cb%.
1430 SYS "Font_ScanString",font%,text%+loc%,&40320,jx%,jy%,cb% TO ,split%
1440
1450 split% -= text% + loc%
1460
1470 REM convert the bounding box returned to absolute sizes in OS units
1480 SYS "Font_ConverttoOS",,cb%!28 - cb%!20,cb%!32 - cb%!24 TO ,text_x%,text_y%
1490
1500 REM split% is the number of characters to plot
1510 SYS "Font_Paint",font%,MID$(text$,loc%+1,split%),784,x% + width% - text_x%,cy%
1520
1530 loc%+=split% + 1
1540 cy% += spacing%
1550UNTIL loc% >= length%
1560
1570REM and finally, lose the font...
1580SYS "Font_LoseFont",font%
1590
1600PRINT '''
1610
1620END
1630
1640DEFPROCdraw_edges
1650 COLOUR 12
1660 RECTANGLEFILL x%,0,-4,y%-spacing%
1670 RECTANGLEFILL x%+width%,0,4,y%-spacing%
1680ENDPROC
� > Example4
2� Example of Font Manager use - justified text
� by Ben Summers
(
2
<@� first check to see if we have the RISC OS 3.1 font manager
F"ș "Font_CacheAddr" � version%
P1� version% < 300 � � 0,"Font Manager too old"
Z
d2� find a suitible mode (multisync if possible)
n#ș "OS_CheckModeValid",20 � ;f%
x � (f% � 2) = 2 � � 12 � � 20
��
�
�white% = &FFFFFF00
�black% = &00000000
�
�$� set palette for white on black
�8ș "Font_SetPalette",,0,1,14,black%,white%,&65757254
�
�� ok, let's find a font...
�size% = 18 * 16
�@ș "Font_FindFont",,"Trinity.Medium",size%,size%,0,0 � font%
�
�
� width of column of text
width% = 448
"� position of text
,x% = 128
6y% = 768
@
J� line spacing
Tspacing% = -52
^
h
r� set text to use
|�text$ = "This is some text to try some justification. First we'll do a quick left justification, followed by a fully justified bit of text and then finally a right justification... It's really exciting... Why not press any key to see the next bit..."
�$� put text in a block of memory.
�� text% 256
�$text% = text$
�
�:ș "ColourTrans_SetFontColours",font%,black%,white%,14
�9ș "Font_Paint",font%,"Left justified text",784,0,960
��draw_edges
�
�� length of string
�length% = �(text$)
�� location within string
�loc% = 0
�
cy% = y%
� cb% 64
&
0�
:I � this is a coordinate block, the first too entries give additional
DH � x,y offsets on spaces, then the additional x,y offsets between
NF � each letter. The bit we're really interested in is the fifth
XB � entry, which is the character to split lines at. (space)
b cb%!0 = 0
l cb%!4 = 0
v cb%!8 = 0
� cb%!12 = 0
� cb%!16 = 32
�
�K � convert the size of the columns into milli-points for ScanString...
�" � it doesn't like OS units
�7 ș "Font_Converttopoints",,width%,1024 � ,jx%,jy%
�
�N � 800 here is another magic number to find out where to split the string
�E ș "Font_ScanString",font%,text%+loc%,800,jx%,jy%,cb% � ,split%
�
� split% -= text% + loc%
�2 � split% is the number of characters to plot
�
$ � and paint it onto the screen
< ș "Font_Paint",font%,�text$,loc%+1,split%),784,x%,cy%
loc% += split% + 1
* cy% += spacing%
4� loc% >= length%
>
H G = �
R
\�
f
p:ș "Font_Paint",font%,"Fully justified text",784,0,960
z�draw_edges
�
�loc% = 0
�cy% = y%
�
��
� cb%!0 = 0
� cb%!4 = 0
� cb%!8 = 0
� cb%!12 = 0
� cb%!16 = 32
�
�7 ș "Font_Converttopoints",,width%,1024 � ,jx%,jy%
�E ș "Font_ScanString",font%,text%+loc%,800,jx%,jy%,cb% � ,split%
split% -= text% + loc%
2 � split% is the number of characters to plot
$
.N � right, this is where it gets complex. Firstly, we set the far right of
8O � the justification using the graphics cursor (the MOVE command). Then,
BM � we work out whether we need to justify the particular line ('cos we
LK � don't on the last one) and then use the appropriate magic number.
V � x%+width%,cy%
`$ � (loc%+split%+1) <= length% �
j> ș "Font_Paint",font%,�text$,loc%+1,split%),785,x%,cy%
t �
~> ș "Font_Paint",font%,�text$,loc%+1,split%),784,x%,cy%
� �
�
� loc% += split% + 1
� cy% += spacing%
�� loc% >= length%
�
� G = �
�
��
�
�:ș "Font_Paint",font%,"Right justified text",784,0,960
��draw_edges
loc% = 0
cy% = y%
(�
2 cb%!0 = 0
< cb%!4 = 0
F cb%!8 = 0
P cb%!12 = 0
Z cb%!16 = 32
d
n7 ș "Font_Converttopoints",,width%,1024 � ,jx%,jy%
x
�N � the new magic number here means 'return the bounding box of the string
�* � in the block' which here is cb%.
�H ș "Font_ScanString",font%,text%+loc%,&40320,jx%,jy%,cb% � ,split%
�
� split% -= text% + loc%
�
�G � convert the bounding box returned to absolute sizes in OS units
�O ș "Font_ConverttoOS",,cb%!28 - cb%!20,cb%!32 - cb%!24 � ,text_x%,text_y%
�
�2 � split% is the number of characters to plot
�O ș "Font_Paint",font%,�text$,loc%+1,split%),784,x% + width% - text_x%,cy%
�
� loc%+=split% + 1
cy% += spacing%
� loc% >= length%
"#� and finally, lose the font...
,ș "Font_LoseFont",font%
6
@ � '''
J
T�
^
h��draw_edges
r
� 12
| ȓȐ x%,0,-4,y%-spacing%
�$ ȓȐ x%+width%,0,4,y%-spacing%
��
� 00000000 0d 00 0a 10 f4 20 3e 20 45 78 61 6d 70 6c 65 34 |..... > Example4|
00000010 0d 00 14 32 f4 20 45 78 61 6d 70 6c 65 20 6f 66 |...2. Example of|
00000020 20 46 6f 6e 74 20 4d 61 6e 61 67 65 72 20 75 73 | Font Manager us|
00000030 65 20 2d 20 6a 75 73 74 69 66 69 65 64 20 74 65 |e - justified te|
00000040 78 74 0d 00 1e 14 f4 20 62 79 20 42 65 6e 20 53 |xt..... by Ben S|
00000050 75 6d 6d 65 72 73 0d 00 28 04 0d 00 32 04 0d 00 |ummers..(...2...|
00000060 3c 40 f4 20 66 69 72 73 74 20 63 68 65 63 6b 20 |<@. first check |
00000070 74 6f 20 73 65 65 20 69 66 20 77 65 20 68 61 76 |to see if we hav|
00000080 65 20 74 68 65 20 52 49 53 43 20 4f 53 20 33 2e |e the RISC OS 3.|
00000090 31 20 66 6f 6e 74 20 6d 61 6e 61 67 65 72 0d 00 |1 font manager..|
000000a0 46 22 c8 99 20 22 46 6f 6e 74 5f 43 61 63 68 65 |F".. "Font_Cache|
000000b0 41 64 64 72 22 20 b8 20 76 65 72 73 69 6f 6e 25 |Addr" . version%|
000000c0 0d 00 50 31 e7 20 76 65 72 73 69 6f 6e 25 20 3c |..P1. version% <|
000000d0 20 33 30 30 20 8c 20 85 20 30 2c 22 46 6f 6e 74 | 300 . . 0,"Font|
000000e0 20 4d 61 6e 61 67 65 72 20 74 6f 6f 20 6f 6c 64 | Manager too old|
000000f0 22 0d 00 5a 04 0d 00 64 32 f4 20 66 69 6e 64 20 |"..Z...d2. find |
00000100 61 20 73 75 69 74 69 62 6c 65 20 6d 6f 64 65 20 |a suitible mode |
00000110 28 6d 75 6c 74 69 73 79 6e 63 20 69 66 20 70 6f |(multisync if po|
00000120 73 73 69 62 6c 65 29 0d 00 6e 23 c8 99 20 22 4f |ssible)..n#.. "O|
00000130 53 5f 43 68 65 63 6b 4d 6f 64 65 56 61 6c 69 64 |S_CheckModeValid|
00000140 22 2c 32 30 20 b8 20 3b 66 25 0d 00 78 20 e7 20 |",20 . ;f%..x . |
00000150 28 66 25 20 80 20 32 29 20 3d 20 32 20 8c 20 eb |(f% . 2) = 2 . .|
00000160 20 31 32 20 8b 20 eb 20 32 30 0d 00 82 05 87 0d | 12 . . 20......|
00000170 00 8c 04 0d 00 96 17 77 68 69 74 65 25 20 20 3d |.......white% =|
00000180 20 26 46 46 46 46 46 46 30 30 0d 00 a0 17 62 6c | &FFFFFF00....bl|
00000190 61 63 6b 25 20 20 3d 20 26 30 30 30 30 30 30 30 |ack% = &0000000|
000001a0 30 0d 00 aa 04 0d 00 b4 24 f4 20 73 65 74 20 70 |0.......$. set p|
000001b0 61 6c 65 74 74 65 20 66 6f 72 20 77 68 69 74 65 |alette for white|
000001c0 20 6f 6e 20 62 6c 61 63 6b 0d 00 be 38 c8 99 20 | on black...8.. |
000001d0 22 46 6f 6e 74 5f 53 65 74 50 61 6c 65 74 74 65 |"Font_SetPalette|
000001e0 22 2c 2c 30 2c 31 2c 31 34 2c 62 6c 61 63 6b 25 |",,0,1,14,black%|
000001f0 2c 77 68 69 74 65 25 2c 26 36 35 37 35 37 32 35 |,white%,&6575725|
00000200 34 0d 00 c8 04 0d 00 d2 1e f4 20 6f 6b 2c 20 6c |4......... ok, l|
00000210 65 74 27 73 20 66 69 6e 64 20 61 20 66 6f 6e 74 |et's find a font|
00000220 2e 2e 2e 0d 00 dc 13 73 69 7a 65 25 20 3d 20 31 |.......size% = 1|
00000230 38 20 2a 20 31 36 0d 00 e6 40 c8 99 20 22 46 6f |8 * 16...@.. "Fo|
00000240 6e 74 5f 46 69 6e 64 46 6f 6e 74 22 2c 2c 22 54 |nt_FindFont",,"T|
00000250 72 69 6e 69 74 79 2e 4d 65 64 69 75 6d 22 2c 73 |rinity.Medium",s|
00000260 69 7a 65 25 2c 73 69 7a 65 25 2c 30 2c 30 20 b8 |ize%,size%,0,0 .|
00000270 20 66 6f 6e 74 25 0d 00 f0 04 0d 00 fa 04 0d 01 | font%..........|
00000280 04 1d f4 20 77 69 64 74 68 20 6f 66 20 63 6f 6c |... width of col|
00000290 75 6d 6e 20 6f 66 20 74 65 78 74 0d 01 0e 10 77 |umn of text....w|
000002a0 69 64 74 68 25 20 3d 20 34 34 38 0d 01 18 04 0d |idth% = 448.....|
000002b0 01 22 16 f4 20 70 6f 73 69 74 69 6f 6e 20 6f 66 |.".. position of|
000002c0 20 74 65 78 74 0d 01 2c 0c 78 25 20 3d 20 31 32 | text..,.x% = 12|
000002d0 38 0d 01 36 0c 79 25 20 3d 20 37 36 38 0d 01 40 |8..6.y% = 768..@|
000002e0 04 0d 01 4a 12 f4 20 6c 69 6e 65 20 73 70 61 63 |...J.. line spac|
000002f0 69 6e 67 0d 01 54 12 73 70 61 63 69 6e 67 25 20 |ing..T.spacing% |
00000300 3d 20 2d 35 32 0d 01 5e 04 0d 01 68 04 0d 01 72 |= -52..^...h...r|
00000310 15 f4 20 73 65 74 20 74 65 78 74 20 74 6f 20 75 |.. set text to u|
00000320 73 65 0d 01 7c fe 74 65 78 74 24 20 3d 20 22 54 |se..|.text$ = "T|
00000330 68 69 73 20 69 73 20 73 6f 6d 65 20 74 65 78 74 |his is some text|
00000340 20 74 6f 20 74 72 79 20 73 6f 6d 65 20 6a 75 73 | to try some jus|
00000350 74 69 66 69 63 61 74 69 6f 6e 2e 20 46 69 72 73 |tification. Firs|
00000360 74 20 77 65 27 6c 6c 20 64 6f 20 61 20 71 75 69 |t we'll do a qui|
00000370 63 6b 20 6c 65 66 74 20 6a 75 73 74 69 66 69 63 |ck left justific|
00000380 61 74 69 6f 6e 2c 20 66 6f 6c 6c 6f 77 65 64 20 |ation, followed |
00000390 62 79 20 61 20 66 75 6c 6c 79 20 6a 75 73 74 69 |by a fully justi|
000003a0 66 69 65 64 20 62 69 74 20 6f 66 20 74 65 78 74 |fied bit of text|
000003b0 20 61 6e 64 20 74 68 65 6e 20 66 69 6e 61 6c 6c | and then finall|
000003c0 79 20 61 20 72 69 67 68 74 20 6a 75 73 74 69 66 |y a right justif|
000003d0 69 63 61 74 69 6f 6e 2e 2e 2e 20 49 74 27 73 20 |ication... It's |
000003e0 72 65 61 6c 6c 79 20 65 78 63 69 74 69 6e 67 2e |really exciting.|
000003f0 2e 2e 20 57 68 79 20 6e 6f 74 20 70 72 65 73 73 |.. Why not press|
00000400 20 61 6e 79 20 6b 65 79 20 74 6f 20 73 65 65 20 | any key to see |
00000410 74 68 65 20 6e 65 78 74 20 62 69 74 2e 2e 2e 22 |the next bit..."|
00000420 0d 01 86 24 f4 20 70 75 74 20 74 65 78 74 20 69 |...$. put text i|
00000430 6e 20 61 20 62 6c 6f 63 6b 20 6f 66 20 6d 65 6d |n a block of mem|
00000440 6f 72 79 2e 0d 01 90 0f de 20 74 65 78 74 25 20 |ory...... text% |
00000450 32 35 36 0d 01 9a 12 24 74 65 78 74 25 20 3d 20 |256....$text% = |
00000460 74 65 78 74 24 0d 01 a4 04 0d 01 ae 3a c8 99 20 |text$.......:.. |
00000470 22 43 6f 6c 6f 75 72 54 72 61 6e 73 5f 53 65 74 |"ColourTrans_Set|
00000480 46 6f 6e 74 43 6f 6c 6f 75 72 73 22 2c 66 6f 6e |FontColours",fon|
00000490 74 25 2c 62 6c 61 63 6b 25 2c 77 68 69 74 65 25 |t%,black%,white%|
000004a0 2c 31 34 0d 01 b8 39 c8 99 20 22 46 6f 6e 74 5f |,14...9.. "Font_|
000004b0 50 61 69 6e 74 22 2c 66 6f 6e 74 25 2c 22 4c 65 |Paint",font%,"Le|
000004c0 66 74 20 6a 75 73 74 69 66 69 65 64 20 74 65 78 |ft justified tex|
000004d0 74 22 2c 37 38 34 2c 30 2c 39 36 30 0d 01 c2 0f |t",784,0,960....|
000004e0 f2 64 72 61 77 5f 65 64 67 65 73 0d 01 cc 04 0d |.draw_edges.....|
000004f0 01 d6 16 f4 20 6c 65 6e 67 74 68 20 6f 66 20 73 |.... length of s|
00000500 74 72 69 6e 67 0d 01 e0 16 6c 65 6e 67 74 68 25 |tring....length%|
00000510 20 3d 20 a9 28 74 65 78 74 24 29 0d 01 ea 1c f4 | = .(text$).....|
00000520 20 6c 6f 63 61 74 69 6f 6e 20 77 69 74 68 69 6e | location within|
00000530 20 73 74 72 69 6e 67 0d 01 f4 0c 6c 6f 63 25 20 | string....loc% |
00000540 3d 20 30 0d 01 fe 04 0d 02 08 0c 63 79 25 20 3d |= 0........cy% =|
00000550 20 79 25 0d 02 12 04 0d 02 1c 0c de 20 63 62 25 | y%......... cb%|
00000560 20 36 34 0d 02 26 04 0d 02 30 05 f5 0d 02 3a 49 | 64..&...0....:I|
00000570 20 20 f4 20 74 68 69 73 20 69 73 20 61 20 63 6f | . this is a co|
00000580 6f 72 64 69 6e 61 74 65 20 62 6c 6f 63 6b 2c 20 |ordinate block, |
00000590 74 68 65 20 66 69 72 73 74 20 74 6f 6f 20 65 6e |the first too en|
000005a0 74 72 69 65 73 20 67 69 76 65 20 61 64 64 69 74 |tries give addit|
000005b0 69 6f 6e 61 6c 0d 02 44 48 20 20 f4 20 20 20 78 |ional..DH . x|
000005c0 2c 79 20 6f 66 66 73 65 74 73 20 6f 6e 20 73 70 |,y offsets on sp|
000005d0 61 63 65 73 2c 20 74 68 65 6e 20 74 68 65 20 61 |aces, then the a|
000005e0 64 64 69 74 69 6f 6e 61 6c 20 78 2c 79 20 6f 66 |dditional x,y of|
000005f0 66 73 65 74 73 20 62 65 74 77 65 65 6e 0d 02 4e |fsets between..N|
00000600 46 20 20 f4 20 20 20 65 61 63 68 20 6c 65 74 74 |F . each lett|
00000610 65 72 2e 20 54 68 65 20 62 69 74 20 77 65 27 72 |er. The bit we'r|
00000620 65 20 72 65 61 6c 6c 79 20 69 6e 74 65 72 65 73 |e really interes|
00000630 74 65 64 20 69 6e 20 69 73 20 74 68 65 20 66 69 |ted in is the fi|
00000640 66 74 68 0d 02 58 42 20 20 f4 20 20 20 65 6e 74 |fth..XB . ent|
00000650 72 79 2c 20 77 68 69 63 68 20 69 73 20 74 68 65 |ry, which is the|
00000660 20 63 68 61 72 61 63 74 65 72 20 74 6f 20 73 70 | character to sp|
00000670 6c 69 74 20 6c 69 6e 65 73 20 61 74 2e 20 28 73 |lit lines at. (s|
00000680 70 61 63 65 29 0d 02 62 0f 20 20 63 62 25 21 30 |pace)..b. cb%!0|
00000690 20 3d 20 30 0d 02 6c 0f 20 20 63 62 25 21 34 20 | = 0..l. cb%!4 |
000006a0 3d 20 30 0d 02 76 0f 20 20 63 62 25 21 38 20 3d |= 0..v. cb%!8 =|
000006b0 20 30 0d 02 80 10 20 20 63 62 25 21 31 32 20 3d | 0.... cb%!12 =|
000006c0 20 30 0d 02 8a 11 20 20 63 62 25 21 31 36 20 3d | 0.... cb%!16 =|
000006d0 20 33 32 0d 02 94 04 0d 02 9e 4b 20 20 f4 20 63 | 32.......K . c|
000006e0 6f 6e 76 65 72 74 20 74 68 65 20 73 69 7a 65 20 |onvert the size |
000006f0 6f 66 20 74 68 65 20 63 6f 6c 75 6d 6e 73 20 69 |of the columns i|
00000700 6e 74 6f 20 6d 69 6c 6c 69 2d 70 6f 69 6e 74 73 |nto milli-points|
00000710 20 66 6f 72 20 53 63 61 6e 53 74 72 69 6e 67 2e | for ScanString.|
00000720 2e 2e 0d 02 a8 22 20 20 f4 20 20 20 69 74 20 64 |....." . it d|
00000730 6f 65 73 6e 27 74 20 6c 69 6b 65 20 4f 53 20 75 |oesn't like OS u|
00000740 6e 69 74 73 0d 02 b2 37 20 20 c8 99 20 22 46 6f |nits...7 .. "Fo|
00000750 6e 74 5f 43 6f 6e 76 65 72 74 74 6f 70 6f 69 6e |nt_Converttopoin|
00000760 74 73 22 2c 2c 77 69 64 74 68 25 2c 31 30 32 34 |ts",,width%,1024|
00000770 20 b8 20 2c 6a 78 25 2c 6a 79 25 0d 02 bc 04 0d | . ,jx%,jy%.....|
00000780 02 c6 4e 20 20 f4 20 38 30 30 20 68 65 72 65 20 |..N . 800 here |
00000790 69 73 20 61 6e 6f 74 68 65 72 20 6d 61 67 69 63 |is another magic|
000007a0 20 6e 75 6d 62 65 72 20 74 6f 20 66 69 6e 64 20 | number to find |
000007b0 6f 75 74 20 77 68 65 72 65 20 74 6f 20 73 70 6c |out where to spl|
000007c0 69 74 20 74 68 65 20 73 74 72 69 6e 67 0d 02 d0 |it the string...|
000007d0 45 20 20 c8 99 20 22 46 6f 6e 74 5f 53 63 61 6e |E .. "Font_Scan|
000007e0 53 74 72 69 6e 67 22 2c 66 6f 6e 74 25 2c 74 65 |String",font%,te|
000007f0 78 74 25 2b 6c 6f 63 25 2c 38 30 30 2c 6a 78 25 |xt%+loc%,800,jx%|
00000800 2c 6a 79 25 2c 63 62 25 20 b8 20 2c 73 70 6c 69 |,jy%,cb% . ,spli|
00000810 74 25 0d 02 da 04 0d 02 e4 1c 20 20 73 70 6c 69 |t%........ spli|
00000820 74 25 20 2d 3d 20 74 65 78 74 25 20 2b 20 6c 6f |t% -= text% + lo|
00000830 63 25 0d 02 ee 32 20 20 f4 20 73 70 6c 69 74 25 |c%...2 . split%|
00000840 20 69 73 20 74 68 65 20 6e 75 6d 62 65 72 20 6f | is the number o|
00000850 66 20 63 68 61 72 61 63 74 65 72 73 20 74 6f 20 |f characters to |
00000860 70 6c 6f 74 0d 02 f8 04 0d 03 02 24 20 20 f4 20 |plot.......$ . |
00000870 61 6e 64 20 70 61 69 6e 74 20 69 74 20 6f 6e 74 |and paint it ont|
00000880 6f 20 74 68 65 20 73 63 72 65 65 6e 0d 03 0c 3c |o the screen...<|
00000890 20 20 c8 99 20 22 46 6f 6e 74 5f 50 61 69 6e 74 | .. "Font_Paint|
000008a0 22 2c 66 6f 6e 74 25 2c c1 74 65 78 74 24 2c 6c |",font%,.text$,l|
000008b0 6f 63 25 2b 31 2c 73 70 6c 69 74 25 29 2c 37 38 |oc%+1,split%),78|
000008c0 34 2c 78 25 2c 63 79 25 0d 03 16 04 0d 03 20 18 |4,x%,cy%...... .|
000008d0 20 20 6c 6f 63 25 20 2b 3d 20 73 70 6c 69 74 25 | loc% += split%|
000008e0 20 2b 20 31 0d 03 2a 16 20 20 63 79 25 20 20 2b | + 1..*. cy% +|
000008f0 3d 20 73 70 61 63 69 6e 67 25 0d 03 34 15 fd 20 |= spacing%..4.. |
00000900 6c 6f 63 25 20 3e 3d 20 6c 65 6e 67 74 68 25 0d |loc% >= length%.|
00000910 03 3e 04 0d 03 48 09 47 20 3d 20 a5 0d 03 52 04 |.>...H.G = ...R.|
00000920 0d 03 5c 05 db 0d 03 66 04 0d 03 70 3a c8 99 20 |..\....f...p:.. |
00000930 22 46 6f 6e 74 5f 50 61 69 6e 74 22 2c 66 6f 6e |"Font_Paint",fon|
00000940 74 25 2c 22 46 75 6c 6c 79 20 6a 75 73 74 69 66 |t%,"Fully justif|
00000950 69 65 64 20 74 65 78 74 22 2c 37 38 34 2c 30 2c |ied text",784,0,|
00000960 39 36 30 0d 03 7a 0f f2 64 72 61 77 5f 65 64 67 |960..z..draw_edg|
00000970 65 73 0d 03 84 04 0d 03 8e 0c 6c 6f 63 25 20 3d |es........loc% =|
00000980 20 30 0d 03 98 0c 63 79 25 20 3d 20 79 25 0d 03 | 0....cy% = y%..|
00000990 a2 04 0d 03 ac 05 f5 0d 03 b6 0f 20 20 63 62 25 |........... cb%|
000009a0 21 30 20 3d 20 30 0d 03 c0 0f 20 20 63 62 25 21 |!0 = 0.... cb%!|
000009b0 34 20 3d 20 30 0d 03 ca 0f 20 20 63 62 25 21 38 |4 = 0.... cb%!8|
000009c0 20 3d 20 30 0d 03 d4 10 20 20 63 62 25 21 31 32 | = 0.... cb%!12|
000009d0 20 3d 20 30 0d 03 de 11 20 20 63 62 25 21 31 36 | = 0.... cb%!16|
000009e0 20 3d 20 33 32 0d 03 e8 04 0d 03 f2 37 20 20 c8 | = 32.......7 .|
000009f0 99 20 22 46 6f 6e 74 5f 43 6f 6e 76 65 72 74 74 |. "Font_Convertt|
00000a00 6f 70 6f 69 6e 74 73 22 2c 2c 77 69 64 74 68 25 |opoints",,width%|
00000a10 2c 31 30 32 34 20 b8 20 2c 6a 78 25 2c 6a 79 25 |,1024 . ,jx%,jy%|
00000a20 0d 03 fc 45 20 20 c8 99 20 22 46 6f 6e 74 5f 53 |...E .. "Font_S|
00000a30 63 61 6e 53 74 72 69 6e 67 22 2c 66 6f 6e 74 25 |canString",font%|
00000a40 2c 74 65 78 74 25 2b 6c 6f 63 25 2c 38 30 30 2c |,text%+loc%,800,|
00000a50 6a 78 25 2c 6a 79 25 2c 63 62 25 20 b8 20 2c 73 |jx%,jy%,cb% . ,s|
00000a60 70 6c 69 74 25 0d 04 06 04 0d 04 10 1c 20 20 73 |plit%........ s|
00000a70 70 6c 69 74 25 20 2d 3d 20 74 65 78 74 25 20 2b |plit% -= text% +|
00000a80 20 6c 6f 63 25 0d 04 1a 32 20 20 f4 20 73 70 6c | loc%...2 . spl|
00000a90 69 74 25 20 69 73 20 74 68 65 20 6e 75 6d 62 65 |it% is the numbe|
00000aa0 72 20 6f 66 20 63 68 61 72 61 63 74 65 72 73 20 |r of characters |
00000ab0 74 6f 20 70 6c 6f 74 0d 04 24 04 0d 04 2e 4e 20 |to plot..$....N |
00000ac0 20 f4 20 72 69 67 68 74 2c 20 74 68 69 73 20 69 | . right, this i|
00000ad0 73 20 77 68 65 72 65 20 69 74 20 67 65 74 73 20 |s where it gets |
00000ae0 63 6f 6d 70 6c 65 78 2e 20 46 69 72 73 74 6c 79 |complex. Firstly|
00000af0 2c 20 77 65 20 73 65 74 20 74 68 65 20 66 61 72 |, we set the far|
00000b00 20 72 69 67 68 74 20 6f 66 0d 04 38 4f 20 20 f4 | right of..8O .|
00000b10 20 20 20 74 68 65 20 6a 75 73 74 69 66 69 63 61 | the justifica|
00000b20 74 69 6f 6e 20 75 73 69 6e 67 20 74 68 65 20 67 |tion using the g|
00000b30 72 61 70 68 69 63 73 20 63 75 72 73 6f 72 20 28 |raphics cursor (|
00000b40 74 68 65 20 4d 4f 56 45 20 63 6f 6d 6d 61 6e 64 |the MOVE command|
00000b50 29 2e 20 54 68 65 6e 2c 0d 04 42 4d 20 20 f4 20 |). Then,..BM . |
00000b60 20 20 77 65 20 77 6f 72 6b 20 6f 75 74 20 77 68 | we work out wh|
00000b70 65 74 68 65 72 20 77 65 20 6e 65 65 64 20 74 6f |ether we need to|
00000b80 20 6a 75 73 74 69 66 79 20 74 68 65 20 70 61 72 | justify the par|
00000b90 74 69 63 75 6c 61 72 20 6c 69 6e 65 20 28 27 63 |ticular line ('c|
00000ba0 6f 73 20 77 65 0d 04 4c 4b 20 20 f4 20 20 20 64 |os we..LK . d|
00000bb0 6f 6e 27 74 20 6f 6e 20 74 68 65 20 6c 61 73 74 |on't on the last|
00000bc0 20 6f 6e 65 29 20 61 6e 64 20 74 68 65 6e 20 75 | one) and then u|
00000bd0 73 65 20 74 68 65 20 61 70 70 72 6f 70 72 69 61 |se the appropria|
00000be0 74 65 20 6d 61 67 69 63 20 6e 75 6d 62 65 72 2e |te magic number.|
00000bf0 0d 04 56 15 20 20 ec 20 78 25 2b 77 69 64 74 68 |..V. . x%+width|
00000c00 25 2c 63 79 25 0d 04 60 24 20 20 e7 20 28 6c 6f |%,cy%..`$ . (lo|
00000c10 63 25 2b 73 70 6c 69 74 25 2b 31 29 20 3c 3d 20 |c%+split%+1) <= |
00000c20 6c 65 6e 67 74 68 25 20 8c 0d 04 6a 3e 20 20 20 |length% ...j> |
00000c30 20 c8 99 20 22 46 6f 6e 74 5f 50 61 69 6e 74 22 | .. "Font_Paint"|
00000c40 2c 66 6f 6e 74 25 2c c1 74 65 78 74 24 2c 6c 6f |,font%,.text$,lo|
00000c50 63 25 2b 31 2c 73 70 6c 69 74 25 29 2c 37 38 35 |c%+1,split%),785|
00000c60 2c 78 25 2c 63 79 25 0d 04 74 07 20 20 cc 0d 04 |,x%,cy%..t. ...|
00000c70 7e 3e 20 20 20 20 c8 99 20 22 46 6f 6e 74 5f 50 |~> .. "Font_P|
00000c80 61 69 6e 74 22 2c 66 6f 6e 74 25 2c c1 74 65 78 |aint",font%,.tex|
00000c90 74 24 2c 6c 6f 63 25 2b 31 2c 73 70 6c 69 74 25 |t$,loc%+1,split%|
00000ca0 29 2c 37 38 34 2c 78 25 2c 63 79 25 0d 04 88 07 |),784,x%,cy%....|
00000cb0 20 20 cd 0d 04 92 04 0d 04 9c 18 20 20 6c 6f 63 | ......... loc|
00000cc0 25 20 2b 3d 20 73 70 6c 69 74 25 20 2b 20 31 0d |% += split% + 1.|
00000cd0 04 a6 16 20 20 63 79 25 20 20 2b 3d 20 73 70 61 |... cy% += spa|
00000ce0 63 69 6e 67 25 0d 04 b0 15 fd 20 6c 6f 63 25 20 |cing%..... loc% |
00000cf0 3e 3d 20 6c 65 6e 67 74 68 25 0d 04 ba 04 0d 04 |>= length%......|
00000d00 c4 09 47 20 3d 20 a5 0d 04 ce 04 0d 04 d8 05 db |..G = ..........|
00000d10 0d 04 e2 04 0d 04 ec 3a c8 99 20 22 46 6f 6e 74 |.......:.. "Font|
00000d20 5f 50 61 69 6e 74 22 2c 66 6f 6e 74 25 2c 22 52 |_Paint",font%,"R|
00000d30 69 67 68 74 20 6a 75 73 74 69 66 69 65 64 20 74 |ight justified t|
00000d40 65 78 74 22 2c 37 38 34 2c 30 2c 39 36 30 0d 04 |ext",784,0,960..|
00000d50 f6 0f f2 64 72 61 77 5f 65 64 67 65 73 0d 05 00 |...draw_edges...|
00000d60 04 0d 05 0a 0c 6c 6f 63 25 20 3d 20 30 0d 05 14 |.....loc% = 0...|
00000d70 0c 63 79 25 20 3d 20 79 25 0d 05 1e 04 0d 05 28 |.cy% = y%......(|
00000d80 05 f5 0d 05 32 0f 20 20 63 62 25 21 30 20 3d 20 |....2. cb%!0 = |
00000d90 30 0d 05 3c 0f 20 20 63 62 25 21 34 20 3d 20 30 |0..<. cb%!4 = 0|
00000da0 0d 05 46 0f 20 20 63 62 25 21 38 20 3d 20 30 0d |..F. cb%!8 = 0.|
00000db0 05 50 10 20 20 63 62 25 21 31 32 20 3d 20 30 0d |.P. cb%!12 = 0.|
00000dc0 05 5a 11 20 20 63 62 25 21 31 36 20 3d 20 33 32 |.Z. cb%!16 = 32|
00000dd0 0d 05 64 04 0d 05 6e 37 20 20 c8 99 20 22 46 6f |..d...n7 .. "Fo|
00000de0 6e 74 5f 43 6f 6e 76 65 72 74 74 6f 70 6f 69 6e |nt_Converttopoin|
00000df0 74 73 22 2c 2c 77 69 64 74 68 25 2c 31 30 32 34 |ts",,width%,1024|
00000e00 20 b8 20 2c 6a 78 25 2c 6a 79 25 0d 05 78 04 0d | . ,jx%,jy%..x..|
00000e10 05 82 4e 20 20 f4 20 74 68 65 20 6e 65 77 20 6d |..N . the new m|
00000e20 61 67 69 63 20 6e 75 6d 62 65 72 20 68 65 72 65 |agic number here|
00000e30 20 6d 65 61 6e 73 20 27 72 65 74 75 72 6e 20 74 | means 'return t|
00000e40 68 65 20 62 6f 75 6e 64 69 6e 67 20 62 6f 78 20 |he bounding box |
00000e50 6f 66 20 74 68 65 20 73 74 72 69 6e 67 0d 05 8c |of the string...|
00000e60 2a 20 20 f4 20 20 20 69 6e 20 74 68 65 20 62 6c |* . in the bl|
00000e70 6f 63 6b 27 20 77 68 69 63 68 20 68 65 72 65 20 |ock' which here |
00000e80 69 73 20 63 62 25 2e 0d 05 96 48 20 20 c8 99 20 |is cb%....H .. |
00000e90 22 46 6f 6e 74 5f 53 63 61 6e 53 74 72 69 6e 67 |"Font_ScanString|
00000ea0 22 2c 66 6f 6e 74 25 2c 74 65 78 74 25 2b 6c 6f |",font%,text%+lo|
00000eb0 63 25 2c 26 34 30 33 32 30 2c 6a 78 25 2c 6a 79 |c%,&40320,jx%,jy|
00000ec0 25 2c 63 62 25 20 b8 20 2c 73 70 6c 69 74 25 0d |%,cb% . ,split%.|
00000ed0 05 a0 04 0d 05 aa 1c 20 20 73 70 6c 69 74 25 20 |....... split% |
00000ee0 2d 3d 20 74 65 78 74 25 20 2b 20 6c 6f 63 25 0d |-= text% + loc%.|
00000ef0 05 b4 04 0d 05 be 47 20 20 f4 20 63 6f 6e 76 65 |......G . conve|
00000f00 72 74 20 74 68 65 20 62 6f 75 6e 64 69 6e 67 20 |rt the bounding |
00000f10 62 6f 78 20 72 65 74 75 72 6e 65 64 20 74 6f 20 |box returned to |
00000f20 61 62 73 6f 6c 75 74 65 20 73 69 7a 65 73 20 69 |absolute sizes i|
00000f30 6e 20 4f 53 20 75 6e 69 74 73 0d 05 c8 4f 20 20 |n OS units...O |
00000f40 c8 99 20 22 46 6f 6e 74 5f 43 6f 6e 76 65 72 74 |.. "Font_Convert|
00000f50 74 6f 4f 53 22 2c 2c 63 62 25 21 32 38 20 2d 20 |toOS",,cb%!28 - |
00000f60 63 62 25 21 32 30 2c 63 62 25 21 33 32 20 2d 20 |cb%!20,cb%!32 - |
00000f70 63 62 25 21 32 34 20 b8 20 2c 74 65 78 74 5f 78 |cb%!24 . ,text_x|
00000f80 25 2c 74 65 78 74 5f 79 25 0d 05 d2 04 0d 05 dc |%,text_y%.......|
00000f90 32 20 20 f4 20 73 70 6c 69 74 25 20 69 73 20 74 |2 . split% is t|
00000fa0 68 65 20 6e 75 6d 62 65 72 20 6f 66 20 63 68 61 |he number of cha|
00000fb0 72 61 63 74 65 72 73 20 74 6f 20 70 6c 6f 74 0d |racters to plot.|
00000fc0 05 e6 4f 20 20 c8 99 20 22 46 6f 6e 74 5f 50 61 |..O .. "Font_Pa|
00000fd0 69 6e 74 22 2c 66 6f 6e 74 25 2c c1 74 65 78 74 |int",font%,.text|
00000fe0 24 2c 6c 6f 63 25 2b 31 2c 73 70 6c 69 74 25 29 |$,loc%+1,split%)|
00000ff0 2c 37 38 34 2c 78 25 20 2b 20 77 69 64 74 68 25 |,784,x% + width%|
00001000 20 2d 20 74 65 78 74 5f 78 25 2c 63 79 25 0d 05 | - text_x%,cy%..|
00001010 f0 04 0d 05 fa 16 20 20 6c 6f 63 25 2b 3d 73 70 |...... loc%+=sp|
00001020 6c 69 74 25 20 2b 20 31 0d 06 04 15 20 20 63 79 |lit% + 1.... cy|
00001030 25 20 2b 3d 20 73 70 61 63 69 6e 67 25 0d 06 0e |% += spacing%...|
00001040 15 fd 20 6c 6f 63 25 20 3e 3d 20 6c 65 6e 67 74 |.. loc% >= lengt|
00001050 68 25 0d 06 18 04 0d 06 22 23 f4 20 61 6e 64 20 |h%......"#. and |
00001060 66 69 6e 61 6c 6c 79 2c 20 6c 6f 73 65 20 74 68 |finally, lose th|
00001070 65 20 66 6f 6e 74 2e 2e 2e 0d 06 2c 1c c8 99 20 |e font.....,... |
00001080 22 46 6f 6e 74 5f 4c 6f 73 65 46 6f 6e 74 22 2c |"Font_LoseFont",|
00001090 66 6f 6e 74 25 0d 06 36 04 0d 06 40 09 f1 20 27 |font%..6...@.. '|
000010a0 27 27 0d 06 4a 04 0d 06 54 05 e0 0d 06 5e 04 0d |''..J...T....^..|
000010b0 06 68 10 dd f2 64 72 61 77 5f 65 64 67 65 73 0d |.h...draw_edges.|
000010c0 06 72 0a 20 20 fb 20 31 32 0d 06 7c 1e 20 20 c8 |.r. . 12..|. .|
000010d0 93 c8 90 20 78 25 2c 30 2c 2d 34 2c 79 25 2d 73 |... x%,0,-4,y%-s|
000010e0 70 61 63 69 6e 67 25 0d 06 86 24 20 20 c8 93 c8 |pacing%...$ ...|
000010f0 90 20 78 25 2b 77 69 64 74 68 25 2c 30 2c 34 2c |. x%+width%,0,4,|
00001100 79 25 2d 73 70 61 63 69 6e 67 25 0d 06 90 05 e1 |y%-spacing%.....|
00001110 0d ff |..|
00001112
.