Ticket #169 (new bug)

Opened 3 years ago

Last modified 2 months ago

[Registrar] Shutdown Status window isn't font sensitive (easy)

Reported by: diver Owned by: bonefish
Priority: normal Milestone: R1
Component: Servers/registrar Version:
Cc: Blocked By:
Platform: All Blocking:

Description (last modified by nielx) (diff)

Shutdown Status window isn't font sensetive (see screenshot). Tested with rev16399.

Attachments

shutdown.PNG (10.5 kB) - added by diver 3 years ago.
Shutdown Status window
FontBig.png (11.1 kB) - added by pieterpan 2 months ago.
FontNormal.png (9.3 kB) - added by pieterpan 2 months ago.

Change History

Changed 3 years ago by diver

Shutdown Status window

Changed 2 years ago by axeld

  • owner changed from sikosis to bonefish

Changed 2 years ago by korli

  • bug_group set to developers

Changed 2 years ago by diver

  • summary changed from Shutdown Status window isn't font sensetive to [Registrar] Shutdown Status window isn't font sensetive

Changed 2 years ago by diver

  • summary changed from [Registrar] Shutdown Status window isn't font sensetive to [Registrar] Shutdown Status window isn't font sensitive

Changed 9 months ago by nielx

  • platform set to All
  • component changed from - Applications to Servers/registrar
  • description modified (diff)
  • summary changed from [Registrar] Shutdown Status window isn't font sensitive to [Registrar] Shutdown Status window isn't font sensitive (easy)

Move to the correct component.

This also qualifies as an 'easy' bug.

Changed 2 months ago by pieterpan

Ok, so I figured, this one is easy. But I can't figure it out at all... The code in ShutDownProcess.cpp seems fine:

fTextView->SetText("two\nlines");
int textHeight = (int)fTextView->TextHeight(0, 1) + 1;

This is then used to position the elements below the textview. This works with font size in the fonts preflet is 12 (default). Now when I change the font size to 18 (biggest) and reboot, all of a sudden only one text line appears instead of two. (Which is the original problem of this ticket) So to see what is going on, I have modified it in such a way that it also prints the size returned by TextHeight to the resulting string in SetText. The strange part is that TextHeight(0,1) returns a SMALLER value for a larger font! See both screenshots attached. (please ignore the second 0. I looked at TextHeight, but I can't see the problem. It must be in there somewhere... Also, try font size 13 and the window becomes infinitely big... Probably TextHeight returns something strange there... The code there is a little over my head, and it is late.

Changed 2 months ago by pieterpan

Changed 2 months ago by pieterpan

Changed 2 months ago by anevilyak

One thing that does immediately seem odd from looking at TextHeight()'s implementation is it seems to reference an out of bounds line:

float height = (*fLines)[endLine + 1]->origin

  • (*fLines)[startLine]->origin;

Unless there's some trick I'm missing, that will only work if endLine is not in fact the last line in the view, which it is here. If that's the case it's entirely possible it's getting back a garbage value, though I'm somewhat surprised it's not crashing if that's true.

Changed 2 months ago by pieterpan

I looked at the way that I think the whole fLines is set up, I think it actually stores an extra line, maybe for code simplification. Say you have 2 lines: line 0 and line 1. It will actually store line 0, line 1 and line 2. Now the total text height is the origin of line 0 to the origin of line 2. However, this does not explain the strange values we get. Anyway, that code is rather involved, perhaps someone who worked on it could examine it?

One of the problems with this code is that it assumes that the text will fit inside the window (determined by the width of the buttons etc, and that it will do so in 2 lines... Probably for a long app name and big font this does not apply. So it should probably also factor in the width of the textview. Or just use the layout system.

Note: See TracTickets for help on using tickets.