Home » Recent acquisitions » Acorn ADFS disks » adfs_AcornComputing_199402.adf » 9402 » FontManage/Example2

FontManage/Example2

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 » Recent acquisitions » Acorn ADFS disks » adfs_AcornComputing_199402.adf » 9402
Filename: FontManage/Example2
Read OK:
File size: 07D6 bytes
Load address: 0000
Exec address: 0000
File contents
   10REM > Example2
   20REM Example of Font Manager use - show different colours
   30REM by Ben Summers
   40
   50
   60ONERROR REPORT:PRINT" at line "ERL:PROCend:END
   70
   80REM first check to see if we have the RISC OS 3.1 font manager
   90SYS "Font_CacheAddr" TO version%
  100IF version% < 300 THEN ERROR 0,"Font Manager too old"
  110
  120REM find a suitible mode (multisync if possible)
  130SYS "OS_CheckModeValid",21 TO ;f%
  140IF (f% AND 2) = 2 THEN MODE 15 ELSE MODE 21
  150OFF
  160
  170REM ok, let's find a font or two...
  180size% = 24 * 16
  190SYS "Font_FindFont",,"Homerton.Bold",size%,size%,0,0 TO font%
  200SYS "Font_FindFont",,"Homerton.Medium",size%,size%,0,0 TO font2%
  210
  220REM and set up the screen...
  230FOR c = 0 TO 255
  240  SYS "ColourTrans_SetGCOL",c<<8,,,256,0
  250  RECTANGLEFILL 0,c*4,64,4
  260NEXT
  270FOR c = 0 TO 255
  280  SYS "ColourTrans_SetGCOL",c<<16,,,256,0
  290  RECTANGLEFILL 1184,832-c*3,32,4
  300NEXT
  310FOR c = 0 TO 255
  320  SYS "ColourTrans_SetGCOL",c<<24,,,256,0
  330  RECTANGLEFILL c*4+128,32,4,32
  340NEXT
  350SYS "ColourTrans_SetFontColours",font2%,0,&FFFFFF00,14
  360SYS "Font_Paint",font2%,"Click on the red bar to set the red",784,128,960
  370SYS "Font_Paint",font2%,"component or press [ESCAPE] to exit",784,128,896
  380*Pointer 1
  390
  400
  410REM right then, plot some text in different colours...
  420red% = 255
  430REPEAT
  440  SYS "ColourTrans_SetGCOL",0,,,0,0
  450  RECTANGLEFILL 70,64,1088,800
  460  FOR green% = 0 TO 255 STEP 32
  470    FOR blue% = 0 TO 255 STEP 32
  480
  490      REM set the font colour using ColourTrans
  500      REM red%, green% and blue% are the components of the colour,
  510      REM ranging from 0 (off) to 255 (full on)
  520      SYS "ColourTrans_SetFontColours",font%,0,(red%<<8) + (green%<<16) + (blue%<<24),14
  530
  540      REM pop it on the screen at the appropriate place
  550      SYS "Font_Paint",font%,"font",784,128 + blue%*4,768 - green%*3
  560
  570    NEXT blue%
  580  NEXT green%
  590
  600  REM get a new value for the red component
  610  REPEAT
  620    MOUSE x%,y%,z%
  630  UNTIL z% <> 0 AND x% <= 64
  640  red% = y%/4
  650UNTILFALSE
  660
  670DEFPROCend
  680REM and finally, lose the fonts...
  690SYS "Font_LoseFont",font%
  700SYS "Font_LoseFont",font2%
  710ENDPROC
  720
  730
  740

� > Example2
:� Example of Font Manager use - show different colours
� by Ben Summers
(
2
<� �:�" at line "�:�end:�
F
P@� first check to see if we have the RISC OS 3.1 font manager
Z"ș "Font_CacheAddr" � version%
d1� version% < 300 � � 0,"Font Manager too old"
n
x2� find a suitible mode (multisync if possible)
�#ș "OS_CheckModeValid",21 � ;f%
� � (f% � 2) = 2 � � 15 � � 21
��
�
�%� ok, let's find a font or two...
�size% = 24 * 16
�?ș "Font_FindFont",,"Homerton.Bold",size%,size%,0,0 � font%
�Bș "Font_FindFont",,"Homerton.Medium",size%,size%,0,0 � font2%
�
�� and set up the screen...
�� c = 0 � 255
�+  ș "ColourTrans_SetGCOL",c<<8,,,256,0
�  ȓȐ 0,c*4,64,4
�
� c = 0 � 255
,  ș "ColourTrans_SetGCOL",c<<16,,,256,0
"  ȓȐ 1184,832-c*3,32,4
,�
6� c = 0 � 255
@,  ș "ColourTrans_SetGCOL",c<<24,,,256,0
J  ȓȐ c*4+128,32,4,32
T�
^9ș "ColourTrans_SetFontColours",font2%,0,&FFFFFF00,14
hLș "Font_Paint",font2%,"Click on the red bar to set the red",784,128,960
rLș "Font_Paint",font2%,"component or press [ESCAPE] to exit",784,128,896
|*Pointer 1
�
�
�8� right then, plot some text in different colours...
�red% = 255
��
�&  ș "ColourTrans_SetGCOL",0,,,0,0
�  ȓȐ 70,64,1088,800
�  � green% = 0 � 255 � 32
�    � blue% = 0 � 255 � 32
�
�1      � set the font colour using ColourTrans
�D      � red%, green% and blue% are the components of the colour,
�1      � ranging from 0 (off) to 255 (full on)
[      ș "ColourTrans_SetFontColours",font%,0,(red%<<8) + (green%<<16) + (blue%<<24),14

9      � pop it on the screen at the appropriate place
&G      ș "Font_Paint",font%,"font",784,128 + blue%*4,768 - green%*3
0
:    � blue%
D  � green%
N
X-  � get a new value for the red component
b  �
l    ȗ x%,y%,z%
v  � z% <> 0 � x% <= 64
�  red% = y%/4
���
�
�	��end
�$� and finally, lose the fonts...
�ș "Font_LoseFont",font%
�ș "Font_LoseFont",font2%
��
�
�
�
�
00000000  0d 00 0a 10 f4 20 3e 20  45 78 61 6d 70 6c 65 32  |..... > Example2|
00000010  0d 00 14 3a f4 20 45 78  61 6d 70 6c 65 20 6f 66  |...:. 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 73 68 6f 77  20 64 69 66 66 65 72 65  |e - show differe|
00000040  6e 74 20 63 6f 6c 6f 75  72 73 0d 00 1e 14 f4 20  |nt colours..... |
00000050  62 79 20 42 65 6e 20 53  75 6d 6d 65 72 73 0d 00  |by Ben Summers..|
00000060  28 04 0d 00 32 04 0d 00  3c 1d ee 85 20 f6 3a f1  |(...2...<... .:.|
00000070  22 20 61 74 20 6c 69 6e  65 20 22 9e 3a f2 65 6e  |" at line ".:.en|
00000080  64 3a e0 0d 00 46 04 0d  00 50 40 f4 20 66 69 72  |d:...F...P@. fir|
00000090  73 74 20 63 68 65 63 6b  20 74 6f 20 73 65 65 20  |st check to see |
000000a0  69 66 20 77 65 20 68 61  76 65 20 74 68 65 20 52  |if we have the R|
000000b0  49 53 43 20 4f 53 20 33  2e 31 20 66 6f 6e 74 20  |ISC OS 3.1 font |
000000c0  6d 61 6e 61 67 65 72 0d  00 5a 22 c8 99 20 22 46  |manager..Z".. "F|
000000d0  6f 6e 74 5f 43 61 63 68  65 41 64 64 72 22 20 b8  |ont_CacheAddr" .|
000000e0  20 76 65 72 73 69 6f 6e  25 0d 00 64 31 e7 20 76  | version%..d1. v|
000000f0  65 72 73 69 6f 6e 25 20  3c 20 33 30 30 20 8c 20  |ersion% < 300 . |
00000100  85 20 30 2c 22 46 6f 6e  74 20 4d 61 6e 61 67 65  |. 0,"Font Manage|
00000110  72 20 74 6f 6f 20 6f 6c  64 22 0d 00 6e 04 0d 00  |r too old"..n...|
00000120  78 32 f4 20 66 69 6e 64  20 61 20 73 75 69 74 69  |x2. find a suiti|
00000130  62 6c 65 20 6d 6f 64 65  20 28 6d 75 6c 74 69 73  |ble mode (multis|
00000140  79 6e 63 20 69 66 20 70  6f 73 73 69 62 6c 65 29  |ync if possible)|
00000150  0d 00 82 23 c8 99 20 22  4f 53 5f 43 68 65 63 6b  |...#.. "OS_Check|
00000160  4d 6f 64 65 56 61 6c 69  64 22 2c 32 31 20 b8 20  |ModeValid",21 . |
00000170  3b 66 25 0d 00 8c 20 e7  20 28 66 25 20 80 20 32  |;f%... . (f% . 2|
00000180  29 20 3d 20 32 20 8c 20  eb 20 31 35 20 8b 20 eb  |) = 2 . . 15 . .|
00000190  20 32 31 0d 00 96 05 87  0d 00 a0 04 0d 00 aa 25  | 21............%|
000001a0  f4 20 6f 6b 2c 20 6c 65  74 27 73 20 66 69 6e 64  |. ok, let's find|
000001b0  20 61 20 66 6f 6e 74 20  6f 72 20 74 77 6f 2e 2e  | a font or two..|
000001c0  2e 0d 00 b4 13 73 69 7a  65 25 20 3d 20 32 34 20  |.....size% = 24 |
000001d0  2a 20 31 36 0d 00 be 3f  c8 99 20 22 46 6f 6e 74  |* 16...?.. "Font|
000001e0  5f 46 69 6e 64 46 6f 6e  74 22 2c 2c 22 48 6f 6d  |_FindFont",,"Hom|
000001f0  65 72 74 6f 6e 2e 42 6f  6c 64 22 2c 73 69 7a 65  |erton.Bold",size|
00000200  25 2c 73 69 7a 65 25 2c  30 2c 30 20 b8 20 66 6f  |%,size%,0,0 . fo|
00000210  6e 74 25 0d 00 c8 42 c8  99 20 22 46 6f 6e 74 5f  |nt%...B.. "Font_|
00000220  46 69 6e 64 46 6f 6e 74  22 2c 2c 22 48 6f 6d 65  |FindFont",,"Home|
00000230  72 74 6f 6e 2e 4d 65 64  69 75 6d 22 2c 73 69 7a  |rton.Medium",siz|
00000240  65 25 2c 73 69 7a 65 25  2c 30 2c 30 20 b8 20 66  |e%,size%,0,0 . f|
00000250  6f 6e 74 32 25 0d 00 d2  04 0d 00 dc 1e f4 20 61  |ont2%......... a|
00000260  6e 64 20 73 65 74 20 75  70 20 74 68 65 20 73 63  |nd set up the sc|
00000270  72 65 65 6e 2e 2e 2e 0d  00 e6 11 e3 20 63 20 3d  |reen........ c =|
00000280  20 30 20 b8 20 32 35 35  0d 00 f0 2b 20 20 c8 99  | 0 . 255...+  ..|
00000290  20 22 43 6f 6c 6f 75 72  54 72 61 6e 73 5f 53 65  | "ColourTrans_Se|
000002a0  74 47 43 4f 4c 22 2c 63  3c 3c 38 2c 2c 2c 32 35  |tGCOL",c<<8,,,25|
000002b0  36 2c 30 0d 00 fa 15 20  20 c8 93 c8 90 20 30 2c  |6,0....  .... 0,|
000002c0  63 2a 34 2c 36 34 2c 34  0d 01 04 05 ed 0d 01 0e  |c*4,64,4........|
000002d0  11 e3 20 63 20 3d 20 30  20 b8 20 32 35 35 0d 01  |.. c = 0 . 255..|
000002e0  18 2c 20 20 c8 99 20 22  43 6f 6c 6f 75 72 54 72  |.,  .. "ColourTr|
000002f0  61 6e 73 5f 53 65 74 47  43 4f 4c 22 2c 63 3c 3c  |ans_SetGCOL",c<<|
00000300  31 36 2c 2c 2c 32 35 36  2c 30 0d 01 22 1c 20 20  |16,,,256,0..".  |
00000310  c8 93 c8 90 20 31 31 38  34 2c 38 33 32 2d 63 2a  |.... 1184,832-c*|
00000320  33 2c 33 32 2c 34 0d 01  2c 05 ed 0d 01 36 11 e3  |3,32,4..,....6..|
00000330  20 63 20 3d 20 30 20 b8  20 32 35 35 0d 01 40 2c  | c = 0 . 255..@,|
00000340  20 20 c8 99 20 22 43 6f  6c 6f 75 72 54 72 61 6e  |  .. "ColourTran|
00000350  73 5f 53 65 74 47 43 4f  4c 22 2c 63 3c 3c 32 34  |s_SetGCOL",c<<24|
00000360  2c 2c 2c 32 35 36 2c 30  0d 01 4a 1a 20 20 c8 93  |,,,256,0..J.  ..|
00000370  c8 90 20 63 2a 34 2b 31  32 38 2c 33 32 2c 34 2c  |.. c*4+128,32,4,|
00000380  33 32 0d 01 54 05 ed 0d  01 5e 39 c8 99 20 22 43  |32..T....^9.. "C|
00000390  6f 6c 6f 75 72 54 72 61  6e 73 5f 53 65 74 46 6f  |olourTrans_SetFo|
000003a0  6e 74 43 6f 6c 6f 75 72  73 22 2c 66 6f 6e 74 32  |ntColours",font2|
000003b0  25 2c 30 2c 26 46 46 46  46 46 46 30 30 2c 31 34  |%,0,&FFFFFF00,14|
000003c0  0d 01 68 4c c8 99 20 22  46 6f 6e 74 5f 50 61 69  |..hL.. "Font_Pai|
000003d0  6e 74 22 2c 66 6f 6e 74  32 25 2c 22 43 6c 69 63  |nt",font2%,"Clic|
000003e0  6b 20 6f 6e 20 74 68 65  20 72 65 64 20 62 61 72  |k on the red bar|
000003f0  20 74 6f 20 73 65 74 20  74 68 65 20 72 65 64 22  | to set the red"|
00000400  2c 37 38 34 2c 31 32 38  2c 39 36 30 0d 01 72 4c  |,784,128,960..rL|
00000410  c8 99 20 22 46 6f 6e 74  5f 50 61 69 6e 74 22 2c  |.. "Font_Paint",|
00000420  66 6f 6e 74 32 25 2c 22  63 6f 6d 70 6f 6e 65 6e  |font2%,"componen|
00000430  74 20 6f 72 20 70 72 65  73 73 20 5b 45 53 43 41  |t or press [ESCA|
00000440  50 45 5d 20 74 6f 20 65  78 69 74 22 2c 37 38 34  |PE] to exit",784|
00000450  2c 31 32 38 2c 38 39 36  0d 01 7c 0e 2a 50 6f 69  |,128,896..|.*Poi|
00000460  6e 74 65 72 20 31 0d 01  86 04 0d 01 90 04 0d 01  |nter 1..........|
00000470  9a 38 f4 20 72 69 67 68  74 20 74 68 65 6e 2c 20  |.8. right then, |
00000480  70 6c 6f 74 20 73 6f 6d  65 20 74 65 78 74 20 69  |plot some text i|
00000490  6e 20 64 69 66 66 65 72  65 6e 74 20 63 6f 6c 6f  |n different colo|
000004a0  75 72 73 2e 2e 2e 0d 01  a4 0e 72 65 64 25 20 3d  |urs.......red% =|
000004b0  20 32 35 35 0d 01 ae 05  f5 0d 01 b8 26 20 20 c8  | 255........&  .|
000004c0  99 20 22 43 6f 6c 6f 75  72 54 72 61 6e 73 5f 53  |. "ColourTrans_S|
000004d0  65 74 47 43 4f 4c 22 2c  30 2c 2c 2c 30 2c 30 0d  |etGCOL",0,,,0,0.|
000004e0  01 c2 19 20 20 c8 93 c8  90 20 37 30 2c 36 34 2c  |...  .... 70,64,|
000004f0  31 30 38 38 2c 38 30 30  0d 01 cc 1d 20 20 e3 20  |1088,800....  . |
00000500  67 72 65 65 6e 25 20 3d  20 30 20 b8 20 32 35 35  |green% = 0 . 255|
00000510  20 88 20 33 32 0d 01 d6  1e 20 20 20 20 e3 20 62  | . 32....    . b|
00000520  6c 75 65 25 20 3d 20 30  20 b8 20 32 35 35 20 88  |lue% = 0 . 255 .|
00000530  20 33 32 0d 01 e0 04 0d  01 ea 31 20 20 20 20 20  | 32.......1     |
00000540  20 f4 20 73 65 74 20 74  68 65 20 66 6f 6e 74 20  | . set the font |
00000550  63 6f 6c 6f 75 72 20 75  73 69 6e 67 20 43 6f 6c  |colour using Col|
00000560  6f 75 72 54 72 61 6e 73  0d 01 f4 44 20 20 20 20  |ourTrans...D    |
00000570  20 20 f4 20 72 65 64 25  2c 20 67 72 65 65 6e 25  |  . red%, green%|
00000580  20 61 6e 64 20 62 6c 75  65 25 20 61 72 65 20 74  | and blue% are t|
00000590  68 65 20 63 6f 6d 70 6f  6e 65 6e 74 73 20 6f 66  |he components of|
000005a0  20 74 68 65 20 63 6f 6c  6f 75 72 2c 0d 01 fe 31  | the colour,...1|
000005b0  20 20 20 20 20 20 f4 20  72 61 6e 67 69 6e 67 20  |      . ranging |
000005c0  66 72 6f 6d 20 30 20 28  6f 66 66 29 20 74 6f 20  |from 0 (off) to |
000005d0  32 35 35 20 28 66 75 6c  6c 20 6f 6e 29 0d 02 08  |255 (full on)...|
000005e0  5b 20 20 20 20 20 20 c8  99 20 22 43 6f 6c 6f 75  |[      .. "Colou|
000005f0  72 54 72 61 6e 73 5f 53  65 74 46 6f 6e 74 43 6f  |rTrans_SetFontCo|
00000600  6c 6f 75 72 73 22 2c 66  6f 6e 74 25 2c 30 2c 28  |lours",font%,0,(|
00000610  72 65 64 25 3c 3c 38 29  20 2b 20 28 67 72 65 65  |red%<<8) + (gree|
00000620  6e 25 3c 3c 31 36 29 20  2b 20 28 62 6c 75 65 25  |n%<<16) + (blue%|
00000630  3c 3c 32 34 29 2c 31 34  0d 02 12 04 0d 02 1c 39  |<<24),14.......9|
00000640  20 20 20 20 20 20 f4 20  70 6f 70 20 69 74 20 6f  |      . pop it o|
00000650  6e 20 74 68 65 20 73 63  72 65 65 6e 20 61 74 20  |n the screen at |
00000660  74 68 65 20 61 70 70 72  6f 70 72 69 61 74 65 20  |the appropriate |
00000670  70 6c 61 63 65 0d 02 26  47 20 20 20 20 20 20 c8  |place..&G      .|
00000680  99 20 22 46 6f 6e 74 5f  50 61 69 6e 74 22 2c 66  |. "Font_Paint",f|
00000690  6f 6e 74 25 2c 22 66 6f  6e 74 22 2c 37 38 34 2c  |ont%,"font",784,|
000006a0  31 32 38 20 2b 20 62 6c  75 65 25 2a 34 2c 37 36  |128 + blue%*4,76|
000006b0  38 20 2d 20 67 72 65 65  6e 25 2a 33 0d 02 30 04  |8 - green%*3..0.|
000006c0  0d 02 3a 0f 20 20 20 20  ed 20 62 6c 75 65 25 0d  |..:.    . blue%.|
000006d0  02 44 0e 20 20 ed 20 67  72 65 65 6e 25 0d 02 4e  |.D.  . green%..N|
000006e0  04 0d 02 58 2d 20 20 f4  20 67 65 74 20 61 20 6e  |...X-  . get a n|
000006f0  65 77 20 76 61 6c 75 65  20 66 6f 72 20 74 68 65  |ew value for the|
00000700  20 72 65 64 20 63 6f 6d  70 6f 6e 65 6e 74 0d 02  | red component..|
00000710  62 07 20 20 f5 0d 02 6c  13 20 20 20 20 c8 97 20  |b.  ...l.    .. |
00000720  78 25 2c 79 25 2c 7a 25  0d 02 76 1a 20 20 fd 20  |x%,y%,z%..v.  . |
00000730  7a 25 20 3c 3e 20 30 20  80 20 78 25 20 3c 3d 20  |z% <> 0 . x% <= |
00000740  36 34 0d 02 80 11 20 20  72 65 64 25 20 3d 20 79  |64....  red% = y|
00000750  25 2f 34 0d 02 8a 06 fd  a3 0d 02 94 04 0d 02 9e  |%/4.............|
00000760  09 dd f2 65 6e 64 0d 02  a8 24 f4 20 61 6e 64 20  |...end...$. and |
00000770  66 69 6e 61 6c 6c 79 2c  20 6c 6f 73 65 20 74 68  |finally, lose th|
00000780  65 20 66 6f 6e 74 73 2e  2e 2e 0d 02 b2 1c c8 99  |e fonts.........|
00000790  20 22 46 6f 6e 74 5f 4c  6f 73 65 46 6f 6e 74 22  | "Font_LoseFont"|
000007a0  2c 66 6f 6e 74 25 0d 02  bc 1d c8 99 20 22 46 6f  |,font%...... "Fo|
000007b0  6e 74 5f 4c 6f 73 65 46  6f 6e 74 22 2c 66 6f 6e  |nt_LoseFont",fon|
000007c0  74 32 25 0d 02 c6 05 e1  0d 02 d0 04 0d 02 da 04  |t2%.............|
000007d0  0d 02 e4 04 0d ff                                 |......|
000007d6