I've got to develop an auto scaling arrivals and departures board at work.
It's started out easily enough with me creating a table with percentage based column widths (and the overall table being 100% width).
For now, I've got a small piece of JQuery letting me change the scale of my text but its only to prove the concept.
I'm really after being able to automatically scale the font and table cell sizes according to the available screen width and height. I do know the maximum string length allowed for each column cell so I could, potentally, automatically set the em/px size based on some calculation.
However, I'm a bit stuck as where to start. I'm actively developing this now but my initial thoughts are:
scale = maxstringwidth_inpx / currentcellwidth_inpx
Where I'd calculate maxstringwidth by having a lookup table and the font metrics for a character 1em in size on the screen.
The cells are all assigned screen percentages so I should be able to read those directly.
Then I can set the font size, ie:
$("body").css("font-size", currentfontsize_px * scale);
Does this sound a feasible approach? It also raises questions about the padding above and below each string in each cell but I'm sure I can do someting similar there too.
To qualify where I'm stuck:
- Are there examples of this kind of thing out in the wild (I couldn't find any)
- Does my approach have pitfalls?
- Have you done it before and can share wisdom/techniques?
- Have I shot myself in the foot already and should consider a different approach?
I have mentioned using Flash to the PM as a means of autoscaling the text as we can then do a lot of the font metrics in ActionScript. However, I'm only just starting out with that using the .NET flash IDE so I'd be limited to that as a development platform.
Thanks for any tips, examples and advice!
Simon