Recent

Author Topic: [SOLVED] TLabel height  (Read 7685 times)

Slyde

  • Full Member
  • ***
  • Posts: 152
[SOLVED] TLabel height
« on: December 09, 2020, 02:44:05 am »
For readability, I bumped up the TLabel font size to 11.  Then I saw it was chopping the legs off characters, so I tried to increase the Label height.  But it isn't letting me do that.   The only way it lets me increase the Label height is to increase the font size again.  Not what I'm looking for. 

How can I keep my font size at 11 and increase the Label height?

Here is what it does to y g p
« Last Edit: December 09, 2020, 02:57:32 am by Slyde »
Linux Mint 21.3
Lazarus 3.0

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: TLabel height
« Reply #1 on: December 09, 2020, 02:51:13 am »
Turn the autosize off
The only true wisdom is knowing you know nothing

Slyde

  • Full Member
  • ***
  • Posts: 152
Re: TLabel height
« Reply #2 on: December 09, 2020, 02:57:07 am »
I feel like crawling under a rock.  Thank you, jamie.
Linux Mint 21.3
Lazarus 3.0

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: [SOLVED] TLabel height
« Reply #3 on: December 09, 2020, 06:04:14 am »
The trouble with auto size being off is you had better make sure what ever is going in there, fits.  So, if you write some new text in there during the execution of the programme or, perhaps have it translated to another language. And there are a people out there with poor eyesight who set their default fonts larger.

With autosize on, that clipping should not happen. I have seen this problem somewhere else on my own app and its also reported here https://forum.lazarus.freepascal.org/index.php/topic,52450.msg386611

Me thinks its a bug ....

We need to be able to demonstrate it reliably and log it.
 
Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Slyde

  • Full Member
  • ***
  • Posts: 152
Re: [SOLVED] TLabel height
« Reply #4 on: December 09, 2020, 06:36:47 am »
@dbannon - IMHO, autosize should work for the width only, not the height.  Autosize should only be concerned about the string's width.  Nothing else.  I want to be able to set the height, if necessary, to accommodate the font size.  And pass that ability on to the end-user so they can handle the height too if they need large fonts.

Anyway,  I'll have to make do with what I have. 

Thanks for the input.
Linux Mint 21.3
Lazarus 3.0

wp

  • Hero Member
  • *****
  • Posts: 11856
Re: [SOLVED] TLabel height
« Reply #5 on: December 09, 2020, 10:06:27 am »
Setting AutoSize = false is like driving a car with the eyes shut! Don't do this. Autosizing and anchoring are the most efficient ways to create forms with self-adjusting layouts.

Your wish to autosize only the width, but not the height of a label causes lots of trouble with the Caption is word-wrapped.

When label AutoSize does not work as expected you should give more details: what is your OS? Widgetset? Lazarus and FPC versioms? Which font is showing the issue?

Did you try a TStaticText instead of TLabel? Does it show the same issue?

Slyde

  • Full Member
  • ***
  • Posts: 152
Re: [SOLVED] TLabel height
« Reply #6 on: December 09, 2020, 09:32:54 pm »
OS: Cinnamon 20
Lazarus 2.0.10
Widgetset: standard Lazarus compliment
FPC 3.2.0
Font: Defalt (Sans on my machine)
Font size used: 11
Autosize: true
Wordwrap: false

TStaticText works though.  So all's well that ends well  ;)



« Last Edit: December 09, 2020, 09:41:14 pm by Slyde »
Linux Mint 21.3
Lazarus 3.0

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: [SOLVED] TLabel height
« Reply #7 on: December 09, 2020, 09:47:59 pm »
Hi!

This is a Lazarus bug since ages in Linux.

I don't know about Windows.

The only solution is like you said: Turn of autosize.
As I disable autosize for all components it does not hurt me much.

Really bad it gets with UTF8 symbols where the lower third (or so) is cut off. Try

⨀ ⨌ ⟁ ∫

Autosize also does not react on changing from  font.style := [] to font.style := [fsbold].
The last letter is partly cut off in x direction.

Avoid autosize and you avoid a lot of trouble.

Winni
 

Slyde

  • Full Member
  • ***
  • Posts: 152
Re: [SOLVED] TLabel height
« Reply #8 on: December 09, 2020, 09:56:23 pm »
@winni - agreed.  However, the TStaticText works for me.  Just have to remember to turn on autosizing as it rolls out turned off.  It even changes height based on the font size chosen.  No need for TLabel at all.
Linux Mint 21.3
Lazarus 3.0

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: [SOLVED] TLabel height
« Reply #9 on: December 09, 2020, 10:28:25 pm »
Note, though, that TStaticText wastes more resources than TLabel; not so many more that it always matters, but if you have a lot of them ...
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: [SOLVED] TLabel height
« Reply #10 on: December 09, 2020, 11:23:41 pm »
Hi!

If you want to reduce ressources:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormPaint(Sender: TObject);
  2. begin
  3.    self.Canvas.TextOut(10,10,'I am the great pretender of Label42');
  4.    self.Canvas.TextOut(30,30,'I am the great pretender of StaticText23');
  5. end;


Winni

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: [SOLVED] TLabel height
« Reply #11 on: December 09, 2020, 11:41:40 pm »
does anyone ever use the BorderSpacing properties ?
The only true wisdom is knowing you know nothing

wp

  • Hero Member
  • *****
  • Posts: 11856
Re: [SOLVED] TLabel height
« Reply #12 on: December 09, 2020, 11:49:27 pm »
Always. If you link controls by using the Anchor Editor you can define the spacing between them with the BorderSpacing. I am rather sure that it can help with clipping the label because this is due to incorrect consideration of font metrics.

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: [SOLVED] TLabel height
« Reply #13 on: December 09, 2020, 11:53:26 pm »
does anyone ever use the BorderSpacing properties ?

Yes; I myself use them in almost all programs. Handy little buggers :)
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: [SOLVED] TLabel height
« Reply #14 on: December 10, 2020, 12:23:12 am »
Always. If you link controls by using the Anchor Editor you can define the spacing between them with the BorderSpacing. I am rather sure that it can help with clipping the label because this is due to incorrect consideration of font metrics.

The answer is quiete easy:

Create a new project.

The only component you need is a label.

Resizie your form to 1000 x 1000
Put the label in the center.

Add for the label.caption :

⨀ ⨌ ⟁ ∫

Sit back in amazement and enjoy how the glyphs are cut of.

That was the end of the BorderSpacing theory.

Winni


 

TinyPortal © 2005-2018