I've made several corrections to enhance compatibility with TEXTOUT_P (I'm attaching version 1.01 below). A few days ago, I also sent you my description proposal for review. Have you had time to take a look at it?
Code:
// Custom Text Formatting Library v1.01 by Tyann & Komame
ICON buffer 89504E470D0A1A0A0000000D494844520000014B0000001F010000000046A4D2660000000274524E5300010194FDAE0000001E494441547801EDCA310100000C0220FBA75C9359C10070935F9DAAAAAA5ADAB10D75F21D64EC0000000049454E44AE426082;
EXPORT ATEXTSIZE(s,p,a)
BEGIN
LOCAL h,l,f;
{'l','h'}:=TEXTSIZE(s,p);
IF BITAND(a,8) THEN
l:=l+CEILING(h/3);
END;
IF BITAND(a,16) THEN
l:=l+1;f:=1;
END;
IF BITAND(a,32) THEN
l:=l+1-f;h:=h+1;
END;
{l,h};
END;
EXPORT ATEXTOUT_P(...l)
BEGIN
LOCAL d,f;
IF TYPE(l(2))≠8 THEN l(−2):=G0;END;
d:=SIZE(l);
IF d<7 THEN
f:=STRING(l);
f:="TEXTOUT_P("+SUPPRESS(f,{1,DIM(f)});
RETURN EXPR(f);
END;
IF d<10 THEN
l:=CONCAT(l,SUB({0,320,−1},d-6,3));
ELSE
IF d>10 THEN Err(0);END;
IF l(10)<0 THEN Err(2);END;
END;
IF l(2)≠8 THEN Err(2);END;
atextout(l(1),l(2),l(3),l(4),l(5),l(6),l(7),l(8),l(9),l(10));
END;
atextout(s,g,x,y,p,c,a,t,l,f)
BEGIN
LOCAL i,j,k,fi,fr;
LOCAL ii,h;
IF 63<a OR a<0 OR 255<t OR t<0 THEN
Err(2);
END;
fr:=(f≥0); t:=255-t;
{'k','h'}:=ATEXTSIZE(s,p,a);
l:=MIN(l,k);
BLIT_P("buffer",10,0,g,x-1,y-4,x+l+3,y+h+4);
IF fr THEN
RECT_P("buffer",10,2,11+k+2,3+h-1,f,f);
END;
i:=1;
REPEAT
IF i==16 THEN
TEXTOUT_P(s,"buffer",11,3,p,c,l);
END;
IF BITAND(a,i) THEN
CASE
if i==1 then //barré / strikethrough
j:=CEILING(h-p-2);
LINE_P("buffer",11,j,11+l,j,c);
end;
if i==2 then //sous ligné / underline
LINE_P("buffer",11,h-2+3,11+l,h-2+3,c);
end;
if i==4 then //encadré / frame
RECT_P("buffer",10,1,11+l,h-1+4,c,{0,255});
end;
if i==8 then //italique / italic
j:=11;
FOR ii:=h+3 DOWNTO -2 STEP 3 DO
BLIT_P("buffer",j-1,ii,"buffer",10,ii,11+l+1,ii+3);
j:=j-1;
END;
fi:=1;
end
if BITAND(a,16) then //gras / bold
TEXTOUT_P(s,"buffer",12,3,p,c,l);
end;
if BITAND(a,32) then //relief
TEXTOUT_P(s,"buffer",12,4,p,c,l);
end;
END;//CASE
END;//BITAND
i:=i*2;
UNTIL i==64;
IF fi THEN
j:=11;
FOR ii:=h+3 DOWNTO -2 STEP 3 DO
BLIT_P(g,x-1,y+ii-4,"buffer",j-1,ii,j+l+1,ii+3,{0,255},t);
j:=j-1;
END;
ELSE
BLIT_P(g,x-1,y-4,"buffer",10,0,l+12,h+6,{0,255},t);
END;
END;
Err(n)
BEGIN
LOCAL l:={};
CASE
if n==0 then EXPR(":"); end;
if n==1 then UPPER(1); end;
if n==2 then l(1); end;
if n==3 then l+{1,2}; end;
if n==4 then CROSS([1],[1,1]);end;
END;
END;