Post Reply 
Custom Text Formatting (Previously: Getting long results in a program)
04-17-2024, 08:42 PM
Post: #91
RE: Custom Text Formatting (Previously: Getting long results in a program)
Hé komame

J'ai une version qui semble fonctionnelle et que je vous soumet pour améliorations et contrôle.
Quelques points à souligner :
Le buffer n'est pas à la bonne taille dans le listing, je pense que 29 pixels devraient aller (mes calculs se font sur cette valeur : hauteur de police n°7 + 3).
Pour BLIT_P en mode transparence, j'avais mis au départ comme couleur avant l'alpha 0 (noir) mais cela donne un résultat bizarre, en mettant comme couleur la même valeur que l'alpha cela fonctionne correctement, je ne sais pas trop pourquoi.
Si vous le souhaitez vous pouvez modifier les modes gras et relief (16 et 32) ou en rajouter .
Peut être enfin le temps de la publication ?

Hey komame

I've got a version that seems to work and that I'm submitting to you for improvement and checking.
A few points to highlight:
The buffer is not at the right size in the listing, I think 29 pixels should fit (my calculations are based on this value: font height n°7 + 3).
For BLIT_P in transparency mode, I had initially set the front colour to alpha 0 (black) but this gives a strange result. Setting the colour to the same value as the alpha works correctly, I'm not sure why.
If you like, you can change the bold and relief modes (16 and 32) or add more.
Maybe it's finally time to publish?

Code:
ICON buffer 89504E470D0A1A0A0000000D494844520000014A0000001C01000000002FF2CBF6000000027​4524E5300007693CD3800000018494441547801EDC10109000000C3A0F54FFD1C073580230304B40​001D69772FE0000000049454E44AE426082;
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 l(10)<0 THEN Err(2);END;
 END;
 IF l(2)≠8 THEN Err(2);END;
 IF d>10 THEN Err(0);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,n,fi,fr,ft;
 LOCAL ii,h,hh,d;
 IF (63<a  OR a<0)  OR (255<t  OR t<0) THEN
  Err(2);
 END;
 fr:=(f≥0);ft:=(t>0);t:=255-t;
 {'k','h'}:=ATEXTSIZE(s,p,a);
 hh:=h;l:=MIN(l,k);
 IF fr THEN
  RECT_P("buffer",0,0,330,29,f);
 ELSE
  BLIT_P("buffer",10,0,g,x,y-3,x+l,y+h); 
 END;
 i:=1;
 REPEAT 
  IF i==16 THEN
   TEXTOUT_P(s,"buffer",10,3,p,c,l);
  END;
  IF BITAND(a,i) THEN
   CASE
    if i==1 then //barré
     j:=CEILING(h/2)+3; 
     LINE_P("buffer",10,j,10+l,j,c);
    end;
    if i==2 then //sous ligné
      LINE_P("buffer",10,h-2+3,10+l,h-2+3,c);  
    end;
    if i==4 then //encadré
     RECT_P("buffer",10,0,10+l-1,h-1+3,c,{0,255}); 
    end; 
    if i==8 then //italique 
     n:=CEILING(h/3);j:=10;d:=3;
     FOR ii FROM 1 TO n DO
      BLIT_P("buffer",j-1,h-d,"buffer",10,h-d,10+l,h);
      j:=j-1;h:=h-3;d:=MIN(h,3);
     END;
     fi:=1;
    end
    if BITAND(a,16) then //gras
     TEXTOUT_P(s,"buffer",11,3,p,c,l);
    end;
    if BITAND(a,32) then //relief
     TEXTOUT_P(s,"buffer",11,4,p,c,l);
    end;
   END;//CASE
  END;//BITAND
  i:=i*2;
 UNTIL i==64;
 IF fi THEN
  h:=hh+3;j:=10;d:=3;
  n:=CEILING(h/3);y:=y+h;
  FOR ii FROM 1 TO n DO
   EXPR("BLIT_P(g,x,y-d,\"buffer\",j,h-d,j+l,h"+IFTE(ft,",t,t)",")"));
   j:=j-1;y:=y-3;h:=h-3;d:=MIN(h,3);
  END;
 ELSE
  EXPR("BLIT_P(g,x,y-3,\"buffer\",10,0,l+10,h"+IFTE(ft,",t,t)",")"));
 END;
END;
P.S
Félicitations pour vôtre nouveau statut sur ce forum.
Congratulations on your new status on this forum.

Sorry for my english
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Custom Text Formatting - Tyann - 04-15-2024, 06:55 PM
RE: Custom Text Formatting - komame - 04-15-2024, 07:42 PM
RE: Custom Text Formatting - Tyann - 04-16-2024, 04:38 AM
RE: Custom Text Formatting - komame - 04-16-2024, 06:02 AM
RE: Custom Text Formatting (Previously: Getting long results in a program) - Tyann - 04-17-2024 08:42 PM



User(s) browsing this thread: