2
$\begingroup$

The documentation says FontSize specifies the vertical size of a font, in printer's points, and that Spacer specifies a spacer as wide as the number provided in its argument, also in printer's points.

Why then the following two do not have the same width?:

Rotate[Style["X", FontSize -> 50], Pi/2]

what outputs (after rasterization)

Rasterized output1

and

Framed@Spacer@50

what outputs

Rasterized output2

I am using this to control gaps for some elements in some plots (namely axes labels, after having set them manually using this) but this is preventing me from adding the amount of space in an automatic way so that everything fits nicely for any plot generated.

Maybe I am missing something very obvious but cannot understand that.

$\endgroup$
2
  • $\begingroup$ Might have been introduced in an update a cleaner and more direct way to specify the position of the axes labels in a plot other than the linked method (which is quite hacky)? $\endgroup$
    – abcd
    Sep 1, 2020 at 4:36
  • 2
    $\begingroup$ perhaps you can do Framed@Style[Invisible@"X", FontSize -> 50] or Framed@Spacer[Rasterize[Style["X", FontSize -> 50], "RasterSize"]]? $\endgroup$
    – kglr
    Sep 1, 2020 at 5:18

1 Answer 1

1
$\begingroup$

On my screen at 150% magnification, your spacer seems to be about 50 printer's points in width. Your rotated capital letter "x" is a bit short.

The documentation article ref/FontSize says:

The size of a font is typically taken to be the distance from the top of the highest character to the bottom of the lowest character.

Your capital "x" goes as high as any character but it doesn't go as low as some. That's because it has no descender. So let's look at how things look if we use text with characters occupying the whole vertical space and see how that shows compared to the 50-pt spacer.

Column[{Framed @ Rotate[Style["ly", 50, "TR"], Pi/2], Framed @ Spacer@50}]

The output looks like so:

demo

The two frames now are very close in width—maybe differing by a printer's point. The small difference may result from rounding that happened during the calculation of the fram size, but that is pure conjecture on my part.enter code here

$\endgroup$
2
  • 1
    $\begingroup$ Try it with CurrentValue["FontLineHeight"]. You'll have to reorg the example a bit and wrap the Spacer in Dynamic. $\endgroup$
    – ihojnicki
    Sep 1, 2020 at 12:49
  • $\begingroup$ I've also learnt the options FrameMargins and ContentPadding apparently also play a role in this issue. $\endgroup$
    – abcd
    Sep 5, 2020 at 22:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.