How might I construct a function called EmToPX[p] such that the following 2 InputFields would be the same width. If not please explain why doing such isn't possible.
InputField["a", ImageSize -> 100]
InputField["a", FieldSize -> EmToPX[100]]
After some trial an error ~7.2 appears to be the proper number of EMs above( InputField["a", FieldSize -> 7.2]), but after trying to convert to a function using proper ratios it appears such technique doesn't work very well.
EmToPX[p_] := (N[
p (1.888888 + CurrentValue[EvaluationNotebook[], "FontSize"]) ]);
Manipulate[
Column[{
InputField["a", ImageSize -> EmToPX[a]],
InputField["a", FieldSize -> a],
EmToPX[7.2]
}]
, {a, 1, 100}
]
Background: Ultimately I am working with Grid elements and would like an easy way to switch back and froth between CellSize,ImageSize,ItemSize,FieldSize.
Grid, then for the love of all that is good and holy, don't do it this way. UsePaneto define your constraints, and letGridjust snap itself to thePaneelements. – John Fultz Sep 17 '13 at 05:17In traditional typography it is. In CSS, however, it is the font height.I could be wrong but Mathematica is quit tied to the web's creation, and Wolfram did so many things so clean and elegantly that I doubt that he ignored the current web standard. – William Sep 17 '13 at 11:32FieldSize: it seems you just have to figure out what the line height is and you're done. MMA has its own definition for em. They're not real ems. – C. E. Sep 17 '13 at 11:38