Recent

Author Topic: Memo - Original height vs stretched height  (Read 8915 times)

GaborBoros

  • New Member
  • *
  • Posts: 21
Memo - Original height vs stretched height
« on: September 26, 2017, 03:49:36 pm »
Hi All,

I have a Memo on a report with Height = 17 and the font is Open Sans with Size = 9. For a simple jjjj text the original height is correct but the stretched not. The one line memo's height on the preview is 17 and the three line memo's height is 44. Why?

The example report and the result is attached.

Gabor

rvk

  • Hero Member
  • *****
  • Posts: 6111
Re: Memo - Original height vs stretched height
« Reply #1 on: September 26, 2017, 04:13:32 pm »
Why?
Because you set Stretched of the memo to true. It will expand the memos height to show all the text or to the band-height (whichever is highest).

(Don't forget to also set the stretched of the band to true but you already did)

GaborBoros

  • New Member
  • *
  • Posts: 21
Re: Memo - Original height vs stretched height
« Reply #2 on: September 26, 2017, 04:38:34 pm »
Sorry if my English is not clear enough...  :) My problem is, the stretched height is not enough to the memo's text. See the bottom of the jjj... in the right hand memo on the attached picture.

rvk

  • Hero Member
  • *****
  • Posts: 6111
Re: Memo - Original height vs stretched height
« Reply #3 on: September 26, 2017, 04:55:17 pm »
What font did you use? (Mine is empty here)

With that empty font I also get some weird cut offs for the letters.
Not only at the bottom but the first J is also cut at the left.
In both stretched and unstretched version.

The cutoff at the bottom also depends on the zoom-factor.
I think a font is used which doesn't correctly give the proper sizes and that's the reason it is cut.

Try another font. Does it happen there too? (if so, what font)

GaborBoros

  • New Member
  • *
  • Posts: 21
Re: Memo - Original height vs stretched height
« Reply #4 on: September 26, 2017, 05:07:53 pm »
As I wrote in the topic starter message, I use Open Sans with Size = 9. For example Form1.Canvas.TextHeight('jjj') return 17 for me with Open Sans - 9. So, height of three lines with the default LineSpacig = 2 is 55 for me, but the Memo stretched to 44.

Thaddy

  • Hero Member
  • *****
  • Posts: 14205
  • Probably until I exterminate Putin.
Re: Memo - Original height vs stretched height
« Reply #5 on: September 26, 2017, 05:17:26 pm »
As I wrote in the topic starter message, I use Open Sans with Size = 9. For example Form1.Canvas.TextHeight('jjj') return 17 for me with Open Sans - 9. So, height of three lines with the default LineSpacig = 2 is 55 for me, but the Memo stretched to 44.
Are you sure you HAVE the font?.... As rvk explained....
Anyway it is not a standard font. You have to install it.
https://fonts.google.com/specimen/Open+Sans
https://www.fontsquirrel.com/fonts/open-sans

If it is not installed you can not use it. Simple as that. If it doesn't support scaling, same thing...
(btw it is ugly  >:D >:( :D )
« Last Edit: September 26, 2017, 05:22:42 pm by Thaddy »
Specialize a type, not a var.

rvk

  • Hero Member
  • *****
  • Posts: 6111
Re: Memo - Original height vs stretched height
« Reply #6 on: September 26, 2017, 05:28:13 pm »
I think Open Sans is standard on Windows 10 (but the OS/version isn't mentioned yet).

Anyway, if you look at the space above the J, you see a lot more space then above the second row J.
So it's not 17 + 2 + 17 + 2 + 17 because that 17 also included a lot of space above which isn't visible in the second row.
It's more like 2 { extra space? } + 2 + 12 + 2 + 12 + 2 + 12

But i'm puzzled by the large space above that J.
If you take Arial for example the space above and below is much more even.

If you increase the font the problem gets much more clear.
So my guess that the calculations of the sizes aren't that accurate or based on the wrong thing.
(Maybe the space above isn't used in calculating the rectangle for the box)

The cutoff at the left is anoying too. And Arial has the same problem at large size.

Maybe with LazReport knowledge can clarify this.
« Last Edit: September 26, 2017, 05:33:56 pm by rvk »

Thaddy

  • Hero Member
  • *****
  • Posts: 14205
  • Probably until I exterminate Putin.
Re: Memo - Original height vs stretched height
« Reply #7 on: September 26, 2017, 05:41:10 pm »
I don't have open sans on windows, any windows, including dev previews.. Maybe I need to install some additional software which causes it to install? Like the software that misses a day every four years?
« Last Edit: September 26, 2017, 05:42:52 pm by Thaddy »
Specialize a type, not a var.

rvk

  • Hero Member
  • *****
  • Posts: 6111
Re: Memo - Original height vs stretched height
« Reply #8 on: September 26, 2017, 06:13:18 pm »
Mmm, not sure which software installed open sans for me then.

But anyway... the problem is also visible with Arial (which I'm sure is standard installed :D)
Both the cutoff at the left and sometimes (depending on spacing and fontsize) cutoff at the bottom.

Change open sans to Arial, choose 16 points and set linespacing to 0, you see the same problem.
LazReport does some wrong size-calculation there.
« Last Edit: September 26, 2017, 06:15:29 pm by rvk »

GaborBoros

  • New Member
  • *
  • Posts: 21
Re: Memo - Original height vs stretched height
« Reply #9 on: September 26, 2017, 08:05:23 pm »
LazReport does some wrong size-calculation there.

Yes, something wrong somewhere. :( See the attached images.

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Memo - Original height vs stretched height
« Reply #10 on: September 26, 2017, 09:59:48 pm »
there are a number of factors that have a role in the final outcome, eg integer sizes, constant rounding between calculations the fact that vector fonts are not very size stable by their nature even a device's drivers might add its own calculating errors to the mix. IF you want to see if there is anything you can do fix it then take a look on the unit lr_Class specifically the TfrCustomMemoView.CalcHeight and TfrCustomMemoView.WrapMemo methods. You will find code like y := Round(y* ScaleY)+OffsY; or InternalGapY := wy2 div 2 + 1 + FGapY; etc.

I wasn't able to test your attached report it raises an error when loading the file that isn't very helpful and I'd rather not debug it at this time, but a quick test that I made produces acceptable results in my windows 7 with arial font. I have no idea if it is the font, the device (printer, screen etc) or the constant rounding but as far as I can tell this is expected behaviour in all the vector fonts and preview/print procedures. they are not that accurate.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

rvk

  • Hero Member
  • *****
  • Posts: 6111
Re: Memo - Original height vs stretched height
« Reply #11 on: September 26, 2017, 10:05:15 pm »
... but a quick test that I made produces acceptable results in my windows 7 with arial font.
taazz, what happens if you make the linespacing 0. Is the bottom still correct for you?

And if I look very closely to your image I can see that the lower curl of the first j is cut off the left. So that's not correct either.
It's very small but the cutoff is definitely there.

(even for the single row j's)
« Last Edit: September 26, 2017, 10:07:50 pm by rvk »

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Memo - Original height vs stretched height
« Reply #12 on: September 26, 2017, 10:28:30 pm »
taazz, what happens if you make the linespacing 0. Is the bottom still correct for you?

There you go linespacing = 0 and stretched = true for both memos as you can see the height looks pixel perfect.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

rvk

  • Hero Member
  • *****
  • Posts: 6111
Re: Memo - Original height vs stretched height
« Reply #13 on: September 26, 2017, 10:34:24 pm »
There you go linespacing = 0 and stretched = true for both memos as you can see the height looks pixel perfect.
Yes, but you can see that with linespacing = 0 the bottom margin is already a lot smaller (almost non existing). Make the font size = 26 and I'm sure you'll get the cutoff at the bottom too.

And the left is also still cut off.

So I'm not calling this pixel perfect  %)

GaborBoros

  • New Member
  • *
  • Posts: 21
Re: Memo - Original height vs stretched height
« Reply #14 on: September 27, 2017, 09:20:58 am »
I wasn't able to test your attached report it raises an error when loading the file that isn't very helpful...

It's created with actual LazReport from Lazarus trunk.

 

TinyPortal © 2005-2018