473,386 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

getting the font size in pixels

I am working on a kiosk system. It is packaged software (I am a
ISV). I know my customers are going to be running on a number of
different resolutions and I want the kiosk to have the same
proportional layout. In other words, if at 1024x768 the font takes up
7% of the height, I want it to be 7% when at 1600x1200. I have
learned from a html newsgroup that there is no easy way to do this in
a browser so I am figuring that I will have to do it the hard way, via
JavaScript. Here is what I am assuming the steps are:

* First get the base percentage:

1.1: Find a font that looks good on my monitor
1.2: Somehow find out the height of the font (I know that height is a
relative term depending on the character), which height I should be
using I don't know.
1.3: Find out what percentage of the screen I want the text.

* Set the font size in the web page:

2.1: Determine the screen size/window size .
2.2: Use the percentage from step 1.3 to find out how many pixels on
this screen.
2.3: Somehow set the standard font size to the result of 2.2.

Is this the best way to achieve my goal? If so, how does one code up
step 1.2 and 2.3? I am targeting all the browsers, right now the
kiosk is IE7 but that will be changing to either Firefox or Safari
(WebKit) in the near future. Also in future versions, the system will
be running over a WiFi so that folks can use their personal laptops to
access it. In a perfect world, I would love to see things size as the
user adjusts the size of the browser!

The back end is Apache with both PHP and a custom Apache Module, so I
have lots of flexibility there, too.

Cartoper

Sep 8 '07 #1
3 2463
Cartoper :
I have learned from a html newsgroup that there is no easy way to do
this in a browser
True enough, but there is an easy way to do it the other way round:
express the heights, widths, etc of all non-text elements in percentage of
the font height, IOW, in ems. (Yes, image sizes can be expressed in ems.)

In addition to being straightforward, this approach allows users with
sight problems or unusual screen resolutions to choose their font size,
e.g., in the View menu. Images etc zoom in or out proportionally.

Mind you, it only works if you are prepared to allow some flexibility in
your layout. But if you are not, I suggest PDF, not (X)HTML... Screens are
not paper, therefore the Web cannot be WYSYWIG.

However, this is OT here. Try comp.infosystems.www.authoring.stylesheets

--
Johannes
"Quand on dit c'est un Johannes, cela vaut autant que ce que maintenant
on appelle un pédant" (H. Estienne, in É. Littré, /Dictionnaire de la
langue française/, art. PÉDANT)
Sep 8 '07 #2
On Sep 8, 7:50 am, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
However, there are media formats where everything can be scaled
automagically: SVG and PDF (standardized), and Flash (proprietary), to name
just a few. All of the former can also be scripted with ECMAScript
implementations: SVG with ECMAScript, PDF with Adobe PDF Script (if used
with Adobe Reader), and Flash with built-in ActionScript.
I find this very interesting, fore I have been playing around with SVG
in the project to display the next/previous/up arrows. I have not
been able to get them to position correctly in a div. I did
contemplate moving the whole thing to SVG, which sounds like what you
are suggesting. I have a couple issues with that, which you might be
able to solve:

1: Lack of information: I can find some stuff on the web about SVG,
but it just seems like is a very new technology (I don't think it is,
I think it is just isn't real popular). Do you have any suggestions
on good SVG forums to ask questions when/if I run into issues?

2: IE support: Right now the kiosk is using IE6/IE7, depending on
what my customer has installed on his/her kiosk machines. I guess I
should simply check to see if they have the Adobe plugin and install
it if they don't. Then there is the issue of when the system goes
"public" so that folks can use their personal computer to view the
site, I believe I am going to run into problems because the Internet
will more then likely not be avaiable. I don't know, maybe I just
say: deal with it;)

Cartoper

Sep 8 '07 #3
Cartoper wrote:
On Sep 8, 7:50 am, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
>However, there are media formats where everything can be scaled
automagically: SVG and PDF (standardized), and Flash (proprietary), to name
just a few. All of the former can also be scripted with ECMAScript
implementations: SVG with ECMAScript, PDF with Adobe PDF Script (if used
with Adobe Reader), and Flash with built-in ActionScript.

I find this very interesting, fore I have been playing around with SVG
in the project to display the next/previous/up arrows. I have not
been able to get them to position correctly in a div.
That would be a problem to be best discussed in
comp.infosystems.www.authoring.stylesheets.
I did contemplate moving the whole thing to SVG, which sounds like what
you are suggesting. I have a couple issues with that, which you might be
able to solve:

1: Lack of information: I can find some stuff on the web about SVG,
but it just seems like is a very new technology (I don't think it is,
I think it is just isn't real popular). Do you have any suggestions
on good SVG forums to ask questions when/if I run into issues?
For general questions, the newsgroup comp.text.xml would be my first
choice in the Big 8. adobe.svg and netscape.public.mozilla.svg might
also provide some insight.

http://groups.google.com/groups/dir?...ch+for+a+group

Scripting issues with SVG are on-topic here in comp.lang.javascript.
2: IE support: Right now the kiosk is using IE6/IE7, depending on
what my customer has installed on his/her kiosk machines. I guess I
should simply check to see if they have the Adobe plugin and install
it if they don't. Then there is the issue of when the system goes
"public" so that folks can use their personal computer to view the
site, I believe I am going to run into problems because the Internet
will more then likely not be avaiable. I don't know, maybe I just
say: deal with it;)
Or move to Firefox or another XUL application where partial SVG support
is built-in (since Firefox 1.1a1, Gecko 1.8, 2005-05-31), and is apparently
going to be completed per Firefox 3.0, Gecko 1.9 (AIUI).
PointedEars
--
"Use any version of Microsoft Frontpage to create your site. (This won't
prevent people from viewing your source, but no one will want to steal it.)"
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Sep 8 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

55
by: Haines Brown | last post by:
I've been setting font-size 1em; as the default in my style sheets. Until now, that seemed to be ok. But now I'm beginning to wonder. My aim is to have an easily readable, but not overly large...
21
by: James Moe | last post by:
Hello, I just joined this group and saw the discussion "What do you think of resizing 1em to 10px?" I am somewhat confused by what y'all think should be used as a reference size. I was surprised...
60
by: deko | last post by:
As I understand it, most browser manufacturers have agreed on 16px for their default font size. So, this should be an accurate conversion for percentages: px % 16 = 100 14 = 87.5 13 =...
12
by: Laphan | last post by:
Hi All Strange question this, but could somebody tell me what the old size=1, size=2 .... to size=7 font parameters are in pixels and points. I thought it was: size 1 = 7 pt size 2 = 14...
7
by: carterweb | last post by:
This is how I do it now. 1. Determine the dimensions of the rectangle. 2. Set a my font size to a fixed maximum size. 3. Apply the font my string and measure the string using the graphics...
30
by: Takehiko Abe | last post by:
I have a <pelement with <ttinside: ;;; <p>A paragraph contains <tt>tt element</tt>.</p> I would like to set the font-size of the TT to the same as the containing <p>. This does not seem to...
71
by: Mark | last post by:
Sorry if the question is a bit basic. I generally express my font sizes in pixels, originally to handle the Macintosh/Windows font size differences (though I believe that they both now treat...
11
by: Ram | last post by:
Hey, I've got the following code: <font font-size="7">Hello</font> How can I calculate the font-size int the actual size in pixels? Thanks ahead! --sternr
1
by: Oron.Morad | last post by:
Hello, I develop C#.NET (WinForm) over 2003server. I am looking for a way to adjust a component size (width pixels) according to a given text of a certain font (i.e font family, size and style)...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.