[solved] Prevent Canvas.TextOut from erasing everything behind the text lazarus / 21-General ---------------------------------------------------------------------- PunyDog · 2023-04-18 05:39 I wanted to put a text over a picture, but when I used Canvas.TextOut, there was a white square block around the text. I tried to look for anything about transparency or something like that but unable to find any. Can anyone help? ---------------------------------------------------------------------- dsiders · 2023-04-18 05:50 Quote from: PunyDog on April 18, 2023, 07:39:20 amI wanted to put a text over a picture, but when I used Canvas.TextOut, there was a white square block around the text. I tried to look for anything about transparency or something like that but unable to find any. Can anyone help? Did you try setting TCanvas.TextStyle.Opaque to False before calling TextOut? https://lazarus-ccr.sourceforge.io/docs/lcl/graphics/ttextstyle.html ---------------------------------------------------------------------- PunyDog · 2023-04-18 07:18 I tried that, but it gave error : Argument cannot be assigned to ---------------------------------------------------------------------- AlexTP · 2023-04-18 07:31 Run:         Canvas.Brush.Style:= bsClear; Before Canvas.TextOut. ---------------------------------------------------------------------- PunyDog · 2023-04-18 07:35 Quote from: AlexTP on April 18, 2023, 09:31:34 amRun:         Canvas.Brush.Style:= bsClear; Before Canvas.TextOut. Hey, it works. Thank you! Wonder why they put it with brushstyle, though ---------------------------------------------------------------------- paweld · 2023-04-18 08:30 An example of using TTextStyleCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Button2Click(Sender: TObject);var  ts: TTextStyle;  s: String;begin  s := 'Sample text' + LineEnding + 'in a' + LineEnding + 'few lines';  ts.Opaque := False;  ts.Wordbreak := True;  ts.SingleLine := False;  ts.Alignment := taLeftJustify;  ts.Layout := tlTop;  Canvas.TextRect(ClientRect, 100, 100, s, ts);end; ---------------------------------------------------------------------- wp · 2023-04-18 09:02 Quote from: PunyDog on April 18, 2023, 09:35:37 amWonder why they put it with brushstyle, though    Well, I think it's quite logical. Brush defines the fill of the background. Why shouldn't this apply to the text as well? ---------------------------------------------------------------------- PunyDog · 2023-04-18 09:19 Quote from: wp on April 18, 2023, 11:02:54 amQuote from: PunyDog on April 18, 2023, 09:35:37 amWonder why they put it with brushstyle, though    Well, I think it's quite logical. Brush defines the fill of the background. Why shouldn't this apply to the text as well? At least, it's not so *clear* to me