Code: Select all
type Font
w as long
h as long
d as any ptr
end type
enum
FB_FONT_8 = 0,
FB_FONT_14
FB_FONT_16
end enum
extern Fonts(2) alias "__fb_font" as Font
sub EditChar cdecl (byref f as Font, c as ubyte, ...)
Dim As cva_list args
cva_start(args,c)
dim as long y,yend,code
dim row as ubyte ptr
yend=f.h
code=c:code*=f.h:row=f.d+code
for y = 1 to yend
*row=cva_arg(args, ubyte)
row+=1
next
end sub
'screenres 640,480 ',32
screen 12
editchar (Fonts(FB_FONT_16),asc("e"), 60, 66, 66, 129, 129, 66, 24, 24, 126, 24, 24, 24, 36, 36, 195)
dim a as string
print "Type something:"
input a
This approach is not related with the custom fonts that can be used with DRAW STRING. The main differences are:
1) Using DRAW STRING doesn't affect the character attribute map: so it's impossible to check the character later with the SCREEN function
2) Custom fonts used by DRAW STRING must be in the same format of the screen mode they are used on (if they are created in indexed 8 bit screen mode they can't be used on 32 bit real color mode, for example). This approach, instead, works on any screen mode
3) DRAW doesn't control scrolling. PRINT does. Also, as shown in the example, this approach allows to use custom fonts with INPUT as well
4) Fonts used with DRAW STRING contain color information in the font itself, so it is not possible to use the same font in different colors, you would need a new font for each color you want to use. The approach I used, instead, allows to use the COLOR command normally
I think this trick could be useful to port some basic programs written for old home computers (Commodore 64, Vic 20, Sinclair Spectrum, Amstrad CPC), since they often used character redefinition (as far as I know they all used 8x8 characters).