Recent

Author Topic: Richmemo add text with font  (Read 319 times)

eldonfsr

  • Sr. Member
  • ****
  • Posts: 327
Richmemo add text with font
« on: September 29, 2022, 08:44:23 pm »
Hi i have a question how i can add text or line richmemo with font or textstyle


paweld

  • Hero Member
  • *****
  • Posts: 523
Re: Richmemo add text with font
« Reply #1 on: September 29, 2022, 09:19:33 pm »
Code: Pascal  [Select][+][-]
  1. uses
  2.   LazUTF8;
  3.            
  4. procedure TForm1.Button1Click(Sender: TObject);
  5. const
  6.   colorarr: array [0..4] of TColor = (clBlack, clRed, clGreen, clGray, clBlue);
  7.   fontstylearr: array [0..3] of TFontStyle = (fsBold, fsItalic, fsUnderLine, fsStrikeOut);
  8.   fontsizearr: array [0..5] of Integer = (10, 14, 16, 24, 32, 48);
  9.   fontnamearr: array [0..2] of String = ('Arial', 'Courier', 'Times New Roman');
  10. var
  11.   m, l: Integer;
  12.   s: String;
  13. begin
  14.   s := 'zażółć gęślą jaźń';
  15.   s := UTF8Copy(s, 1, Random(UTF8Length(s)) + 1);
  16.   m := UTF8Length(RichMemo1.Lines.Text);
  17.   l := UTF8Length(s);
  18.   RichMemo1.Lines.Add(s); //Add line
  19.   RichMemo1.SetRangeParams(m, l, [tmm_Color, tmm_Styles, tmm_Name, tmm_Size], //tmm_Color - set font color, tmm_Styles - set font style, tmm_Size - set font size, tmm_Name - set font name
  20.     fontnamearr[l mod 3], fontsizearr[l mod 6], colorarr[l mod 5], [fontstylearr[l mod 4]], []);
  21. end;    
Best regards
paweld

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2763
    • havefunsoft.com

eldonfsr

  • Sr. Member
  • ****
  • Posts: 327
Re: Richmemo add text with font
« Reply #3 on: September 29, 2022, 10:51:32 pm »
Ok Thanks....

 

TinyPortal © 2005-2018