Луди у меня почти безгеморойный способ
файл конфига:
/fonts/dos_font_10.png
rus_dos
10
33
а код модуля вот:
unit fon;
interface
var fnt_im:image;
symbols_cnt,hw_font:Integer;
file_font,numer_file:resource;
font_type,numer_file_str:string;
numeration:array[0..1000]of string;
procedure load_font(fnt_ini:string);
procedure draw_char(num,x,y:integer);
function get_font_HW:INTEGER;
function get_font_type:string;
procedure draw_text(text:string;x,y:integer);
function get_text_width(text:string):integer;
function get_text_height(text:string):integer;
function numeration_fnc(chr:char):integer;
implementation
{ тела функций }
procedure load_font(fnt_ini:string);
begin
file_font:=openResource('/'+fnt_ini);
if (resourceAvailable(file_font)) then begin
fnt_im:=loadimage(readline(file_font));
font_type:=readline(file_font);
numer_file_str:=readline(file_font);
hw_font:=stringtointeger(readline(file_font));
symbols_cnt:=stringtointeger(readline(file_font));
end;
closeResource(file_font);
end;
procedure draw_char(num,x,y:integer);
begin
drawimage(ImageFromImage(fnt_im,num*hw_font,0,hw_font,hw_font),x,y);
end;
function get_font_HW:integer;
begin
get_font_HW:=hw_font;
end;
function get_font_type:string;
begin
get_font_type:=font_type;
end;
procedure unload_font;
begin
fnt_im:=loadimage('/icon.png');
font_type:='';
hw_font:=0;
symbols_cnt:=0;
end;
procedure draw_text(text:string;x,y:integer;);
var i:integer;
num:integer;
begin
text:=upcase(text);
for i:=0 to length(text)-1 do begin
if getchar(text,i)<>' ' then begin
num:=numeration_fnc(getchar(text,i));
draw_char(num,x+i*hw_font,y);
end;
end;
end;
function get_text_width(text:string):integer;
begin
get_text_width:=length(text)*hw_font;
end;
function get_text_Height(text:string):integer;
begin
get_text_height:=hw_font;
end;
function numeration_fnc(chr:char):integer;
begin
if chr='А' then numeration_fnc:=0;
if chr='Б' then numeration_fnc:=1;
if chr='В' then numeration_fnc:=2;
if chr='Г' then numeration_fnc:=3;
if chr='Д' then numeration_fnc:=4;
if chr='Е' then numeration_fnc:=5;
if chr='Ё' then numeration_fnc:=6;
if chr='Ж' then numeration_fnc:=7;
if chr='З' then numeration_fnc:=8;
if chr='И' then numeration_fnc:=9;
if chr='Й' then numeration_fnc:=10;
if chr='К' then numeration_fnc:=11;
if chr='Л' then numeration_fnc:=12;
if chr='М' then numeration_fnc:=13;
if chr='Н' then numeration_fnc:=14;
if chr='О' then numeration_fnc:=15;
if chr='П' then numeration_fnc:=16;
if chr='Р' then numeration_fnc:=17;
if chr='С' then numeration_fnc:=18;
if chr='Т' then numeration_fnc:=19;
if chr='У' then numeration_fnc:=20;
if chr='Ф' then numeration_fnc:=21;
if chr='Х' then numeration_fnc:=22;
if chr='Ц' then numeration_fnc:=23;
if chr='Ч' then numeration_fnc:=24;
if chr='Ш' then numeration_fnc:=25;
if chr='Щ' then numeration_fnc:=26;
if chr='Ъ' then numeration_fnc:=27;
if chr='Ы' then numeration_fnc:=28;
if chr='Ь' then numeration_fnc:=29;
if chr='Э' then numeration_fnc:=30;
if chr='Ю' then numeration_fnc:=31;
if chr='Я' then numeration_fnc:=32;
if chr='!' then numeration_fnc:=33;
if chr='@' then numeration_fnc:=34;
if chr='#' then numeration_fnc:=35;
if chr='$' then numeration_fnc:=36;
if chr='%' then numeration_fnc:=37;
if chr='?' then numeration_fnc:=38;
if chr='.' then numeration_fnc:=39;
if chr=',' then numeration_fnc:=40;
if chr='*' then numeration_fnc:=41;
if chr='=' then numeration_fnc:=42;
if chr='-' then numeration_fnc:=43;
if chr=''''' then numeration_fnc:=44;
if chr=':' then numeration_fnc:=45;
if chr='A' then numeration_fnc:=42+4;
if chr='B' then numeration_fnc:=43+4;
if chr='C' then numeration_fnc:=44+4;
if chr='D' then numeration_fnc:=45+4;
if chr='E' then numeration_fnc:=46+4;
if chr='F' then numeration_fnc:=47+4;
if chr='G' then numeration_fnc:=48+4;
if chr='H' then numeration_fnc:=49+4;
if chr='I' then numeration_fnc:=50+4;
if chr='J' then numeration_fnc:=51+4;
if chr='K' then numeration_fnc:=52+4;
if chr='L' then numeration_fnc:=53+4;
if chr='M' then numeration_fnc:=54+4;
if chr='N' then numeration_fnc:=55+4;
if chr='O' then numeration_fnc:=56+4;
if chr='P' then numeration_fnc:=57+4;
if chr='Q' then numeration_fnc:=58+4;
if chr='R' then numeration_fnc:=59+4;
if chr='S' then numeration_fnc:=60+4;
if chr='T' then numeration_fnc:=61+4;
if chr='U' then numeration_fnc:=62+4;
if chr='V' then numeration_fnc:=63+4;
if chr='W' then numeration_fnc:=64+4;
if chr='X' then numeration_fnc:=65+4;
if chr='Y' then numeration_fnc:=66+4;
if chr='Z' then numeration_fnc:=67+4;
if chr='0' then numeration_fnc:=68+4;
if chr='1' then numeration_fnc:=69+4;
if chr='2' then numeration_fnc:=70+4;
if chr='3' then numeration_fnc:=71+4;
if chr='4' then numeration_fnc:=72+4;
if chr='5' then numeration_fnc:=73+4;
if chr='6' then numeration_fnc:=74+4;
if chr='7' then numeration_fnc:=75+4;
if chr='8' then numeration_fnc:=76+4;
if chr='9' then numeration_fnc:=77+4;
end;
initialization
{ инициализация }
end.
но есть малое условие:
1)симфолы шрифта не должны вылазить за грани описаные в строке номер 3
2)прозрачность ставим через MP а в grc Редакторе цвет фона делаем <> цвету символоф шрефта!