Quite a long saga but as an FYI this is what I have learned from tech support:
Firstly the documentation for ItemSize
, under more information, says
In Grid, w is measured in ems, and h in line heights.
I'd overlooked that. With that information some control should be possible:
magicRatio = CurrentValue["FontMWidth"]/CurrentValue["FontLineHeight"];
itemSize = {5, magicRatio*5};
Grid[
{{x, x, x, x, x}, {x, x,
Framed[Pane[x,
ImageSize ->
Dynamic[itemSize*{CurrentValue["FontMWidth"],
CurrentValue["FontLineHeight"]}],
ImageMargins -> 0,
FrameMargins -> 0,
Alignment -> Center],
FrameMargins -> 0,
ImageMargins -> 0], x, x}, {x, x, x, x, x}},
Background -> {None, None, {{2, 3} -> Red}}, ItemSize -> itemSize,
Frame -> All, Spacings -> {0, 0}, Alignment -> {Center, Center}]
On Mac 10.6.8 Mma V8.0.4
This is close -- may be good enough in most cases -- but no cigar. The problem is that even if this is close enough for someones usage requirements it only works when notebook magnification is set to 100%. For example
125%
50%
In theory you would think you could correct for this by getting the magnification
CurrentValue[EvaluationNotebook[], Magnification] /. Inherited -> 1
and you can as long as you don't make the image size Dynamic
because if you do adding the magnification correction breaks the Pane
image size:
dynamic image size, magnification 75%
static image size, magnification 75%
And an added note/FYI is that the line height is different within a Dynamic
In the end tech support have said that the developers don't see any easy way around this sort of problem.
see also this Q&A though note that even allowing for frame line width I couldn't get the pane to fit precisely in the grid cell.