Author Topic: [SOLVED]SpeedButton Font  (Read 731 times)

Petrus Vorster

  • Sr. Member
  • ****
  • Posts: 261
[SOLVED]SpeedButton Font
« on: August 06, 2026, 04:35:00 pm »
Hi All

I am playing with the transparency on the Speedbutton.
It works great, but the application has a background that varies and loads the current Windows background for a backdrop.

That renders the text part of the button almost useless since the varying of the background makes some text hard to read.
Microsoft has a black shadow/background on the text which is not part of the font. I tried some outlined fonts but that did not help.

I assume its going to be a lot of work to make a back background for the text?

This is a learning exercise, not really critical, but I would like to know how to do that.

-Thanks for all the help.

Peter

« Last Edit: August 07, 2026, 10:29:28 am by Petrus Vorster »

jamie

  • Hero Member
  • *****
  • Posts: 7937
Re: SpeedButton Font
« Reply #1 on: August 06, 2026, 11:52:01 pm »
AI created example, well part it. It was quicker for me to copy and paste.

Code: Pascal  [Select][+][-]
  1.  // Calculate center position
  2.   X := (ClientWidth - Canvas.TextWidth(TextStr)) div 2;
  3.   Y := (ClientHeight - Canvas.TextHeight(TextStr)) div 2;
  4.  
  5.   // Draw shadow (darker, bottom-right)
  6.   Canvas.Font.Color := clGray;
  7.   Canvas.TextOut(X + 2, Y + 2, TextStr);
  8.  
  9.   // Draw highlight (lighter, top-left)
  10.   Canvas.Font.Color := clWhite;
  11.   Canvas.TextOut(X, Y, TextStr);
  12. end;
  13.  

DO that in the OnPaint event of the speed button and also disable the Show caption in the OI so you don't get a double print.

The TextStr would be replaced with the CAPTION of the button.

Jamie

The only true wisdom is knowing you know nothing

Petrus Vorster

  • Sr. Member
  • ****
  • Posts: 261
Re: SpeedButton Font
« Reply #2 on: August 07, 2026, 09:04:29 am »
Thank you for trying.

This just paints a white block somewhere on the screen.
I tried a few AI options myself.
One of them got the text and shadow right , but it wont draw the text below the Glyph.

There is another option, but its very hard to find free. Adobe has a solid white font with a black border.
In other words a SOLID outlined font that will do the trick, but getting it has proven quite challenging.

Oh well, this is not critical, its just a learning exercise.

-Peter

Xenno

  • Full Member
  • ***
  • Posts: 201
    • BS Programs
Re: SpeedButton Font
« Reply #3 on: August 07, 2026, 09:31:39 am »
Do you have to use TSpeedButton?
How about an image and plain text as my reply (https://forum.lazarus.freepascal.org/index.php/topic,74527.msg588055.html#msg588055) in your other thread?
Lazarus 4.6, Windows 10, Website, YouTube channel
If I want to share, I give. If I want money, I sell. I don't set traps.

Petrus Vorster

  • Sr. Member
  • ****
  • Posts: 261
Re: SpeedButton Font
« Reply #4 on: August 07, 2026, 10:29:10 am »
Thank you.

This is a much simpler approach.

-Peter

 

TinyPortal © 2005-2018