Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #30365 > unrolled thread

Finding out a fonts height

Started bybit-naughty@hotmail.com
First post2016-04-27 10:17 -0700
Last post2016-05-05 18:13 -0700
Articles 8 — 4 participants

Back to article view | Back to comp.lang.javascript


Contents

  Finding out a fonts height bit-naughty@hotmail.com - 2016-04-27 10:17 -0700
    Re: Finding out a fonts height "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-04-27 23:18 +0200
      Re: Finding out a fonts height bit-naughty@hotmail.com - 2016-04-30 05:47 -0700
        Re: Finding out a fonts height "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-05-01 00:01 +0200
          Re: Finding out a fonts height bit-naughty@hotmail.com - 2016-05-04 23:04 -0700
    Re: Finding out a fonts height Aleksandro <aleksandro@gmx.com> - 2016-04-27 22:36 -0300
    Re: Finding out a fonts height bit-naughty@hotmail.com - 2016-04-30 05:46 -0700
      Re: Finding out a fonts height "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-05-05 18:13 -0700

#30365 — Finding out a fonts height

Frombit-naughty@hotmail.com
Date2016-04-27 10:17 -0700
SubjectFinding out a fonts height
Message-ID<b0b36ce1-96a3-4556-912d-c385336e82c5@googlegroups.com>
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.

[toc] | [next] | [standalone]


#30375

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2016-04-27 23:18 +0200
Message-ID<XnsA5F7ED129B298eejj99@194.109.6.166>
In reply to#30365
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)

[toc] | [prev] | [next] | [standalone]


#30381

Frombit-naughty@hotmail.com
Date2016-04-30 05:47 -0700
Message-ID<99ec6a45-fd45-459a-ad76-83db73747a5c@googlegroups.com>
In reply to#30375
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?

[toc] | [prev] | [next] | [standalone]


#30383

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2016-05-01 00:01 +0200
Message-ID<XnsA5FB4AB6CDFeejj99@194.109.6.166>
In reply to#30381
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)

[toc] | [prev] | [next] | [standalone]


#30395

Frombit-naughty@hotmail.com
Date2016-05-04 23:04 -0700
Message-ID<225102c8-4a27-497c-a5d9-c2bdef1d898d@googlegroups.com>
In reply to#30383
Can you tell me what to Google *FOR*, please?

[toc] | [prev] | [next] | [standalone]


#30379

FromAleksandro <aleksandro@gmx.com>
Date2016-04-27 22:36 -0300
Message-ID<nfrp98$5f1$1@dont-email.me>
In reply to#30365
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/getComputedStyle
*
https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect

[toc] | [prev] | [next] | [standalone]


#30380

Frombit-naughty@hotmail.com
Date2016-04-30 05:46 -0700
Message-ID<6b0ea745-c983-407e-8bc9-ca76ca61f2cd@googlegroups.com>
In reply to#30365
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.

[toc] | [prev] | [next] | [standalone]


#30399

From"Michael Haufe (TNO)" <tno@thenewobjective.com>
Date2016-05-05 18:13 -0700
Message-ID<7b3dcbc5-3105-4401-b3e9-54ca6fea7535@googlegroups.com>
In reply to#30380
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#Units>

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web