I have a little design issue, which I cannot seem to get my head around. Maybe I can find some creative minds here who can point me into a direction - I believe I have a creativity blockade right now :(
Please have a look at the following example, before I explain. That makes things easier: http://jsfiddle.net/DV9SE/3/
<canvas id="mycanvas" width="100" height="20"></canvas>
<div id="mydiv">ASDqpjy</div>
#mycanvas {
position:absolute;
left:20px;
top:20px;
border:1px solid #999999;
}
#mydiv {
position:absolute;
height:20px;
width:100px;
left:20px;
top:50px;
border:1px solid #999999;
font-family:arial;
font-size:14px;
line-height:2.2;
}
var canvas = $('#mycanvas')[0];
var ctx = canvas.getContext('2d');
ctx.font = '14px arial';
ctx.fillText('ASDqpjy', 0, canvas.height);
As you can see, it is very easy to put the baseline of a text at the very bottom of a canvas element. Which is precisely what I need for a project. The baseline must be at the bottom of an element (which I can later render movable through JQuery). The problem though: the text is cut off, as, evidently, the lower parts would be outside of the canvas and can thus not be rendered.
An alternative - or so I thought - was to put everything in a DIV, which makes rendering parts of the text possible, that is outside of the actual border/margin. The problem here though: I have to adjust the baseline by using css line-height. That is not an issue when it comes to one or two fonts. But since the project will allow for a font-selection with tens of fonts, it would be a complete nut-job to create a pixel-precise line-height rule for every single font.
Does anybody have an Idea how to work around this problem? How to possibly move the baseline of fonts consistently to the bottom of a DIV element, or a creative solution, how to display parts in a canvas, that are actually "outside" of it? ;)
Thanks a ton SO!