[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.javascript

Finding out a fonts height

bit-naughty

4/27/2016 5:18:00 PM

Hi,
How do I query what the max height is for the current font at the current size? Like, say a capital letter like "D" (I guess that would be as maximum a size as anything else...? ). Like, I can obviously set it to whatever I want, but if the user does a CTRL + mousewheel up , then it can change - is there any way to query it?


Thanks.
7 Answers

Evertjan.

4/27/2016 9:18:00 PM

0

bit-naughty@hotmail.com wrote on 27 Apr 2016 in comp.lang.javascript:

> How do I query what the max height is for the current font at the
> current size? Like, say a capital letter like "D" (I guess that would be
> as maximum a size as anything else...? ). Like, I can obviously set it
> to whatever I want, but if the user does a CTRL + mousewheel up , then
> it can change

Not in Chrome, it is the pixel size that changes on Ctrl + mousewheel,
so the size of an element in virtual pixels stays the same.

> - is there any way to query it?

Don't think so.

I would like to be able to measure the print-size of an element in
centimeters [or inches if you are into that].

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Aleksandro

4/28/2016 1:37:00 AM

0

On 27/04/16 14:17, bit-naughty@hotmail.com wrote:
> Hi,
> How do I query what the max height is for the current font at the current size? Like, say a capital letter like "D" (I guess that would be as maximum a size as anything else...? ). Like, I can obviously set it to whatever I want, but if the user does a CTRL + mousewheel up , then it can change - is there any way to query it?

I don't have time to look by myself but take a look at:
* https://developer.mozilla.org/en-US/docs/Web/API/Window/getCom...
*
https://developer.mozilla.org/en-US/docs/Web/API/Element/getBounding...

bit-naughty

4/30/2016 12:46:00 PM

0

Thanks guys.

Is there any way to tell, at a particular font size, and for a particular width, what the HEIGHT of a particular portion of text will be? Like, a "d" will be say, 5 pixels wide, and a "i" say 2 pixels, and so on, so - for a given sentence: "I went up", how do I tell how wide the whole thing will be? Following on from which, if I set a <div> at a width I want, what will be it's height on screen? (assuming it's a good say 10 lines of text etc., of course!)
Is there any way to find out? This REALLY seems tricky!

Thanks.

bit-naughty

4/30/2016 12:47:00 PM

0

On Thursday, April 28, 2016 at 2:48:54 AM UTC+5:30, Evertjan. wrote:

> so the size of an element in virtual pixels stays the same.
>

I have to confess, I'm still pretty new to this stuff, I don't know what "virtual pixels" are- what are they?

Evertjan.

4/30/2016 10:02:00 PM

0

bit-naughty@hotmail.com wrote on 30 Apr 2016 in comp.lang.javascript:

> On Thursday, April 28, 2016 at 2:48:54 AM UTC+5:30, Evertjan. wrote:
>
>> so the size of an element in virtual pixels stays the same.
>
> I have to confess, I'm still pretty new to this stuff, I don't know what
> "virtual pixels" are- what are they?

Such basics you can look up, methinks.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

bit-naughty

5/5/2016 6:04:00 AM

0

Can you tell me what to Google *FOR*, please?

Michael Haufe (\"TNO\")

5/6/2016 1:14:00 AM

0

On Saturday, April 30, 2016 at 7:46:19 AM UTC-5, bit-n...@hotmail.com wrote:
> Thanks guys.
>
> Is there any way to tell, at a particular font size, and for a particular width, what the HEIGHT of a particular portion of text will be? Like, a "d" will be say, 5 pixels wide, and a "i" say 2 pixels, and so on, so - for a given sentence: "I went up", how do I tell how wide the whole thing will be? Following on from which, if I set a <div> at a width I want, what will be it's height on screen? (assuming it's a good say 10 lines of text etc., of course!)
> Is there any way to find out? This REALLY seems tricky!

Take a look at the available length measurements:

<https://developer.mozilla.org/en-US/docs/Web/CSS/length...