Ram wrote:
>>Hey,
I've got the following code:
<font font-size="7">Hello</font>
I think here is a typo. The font element has no attribute "font-size".
Correct is "size":
<font size="7">Hello</font>
>>How can I calculate the font-size int the actual size in pixels?
>>Thanks ahead!
>>--sternr
You can try next approach.
Create in runtime a font element, set it font size to known value in
pixels and compare this element with the font element which size you
want to define. Increase the size in series and at some point of time
you will get required value.
Short example:
<html>
<script type="text/javascript">
function checkSize()
{
var fonts = document.getEle mentsByTagName( "font");
var checkedElem = fonts[0];
var height = checkedElem.off setHeight;
for(var i = 0; i < 100; i++)
{
var tempFont = document.create Element("font") ;
tempFont.style. fontSize = i + "px";
tempFont.innerH TML = checkedElem.inn erHTML;
document.body.a ppendChild(temp Font);
var tempHeight = tempFont.offset Height;
document.body.r emoveChild(temp Font);
if (tempHeight >= height)
{
alert("Font size = " + i + "px");
break;
}
}
}
</script>
<body onload="checkSi ze()">
<font size="7">Hello</font>
</body>
</html>