473,324 Members | 2,002 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,324 software developers and data experts.

swap fonts' size

Hello, I wish to modify the dimension of the font within a given table (that
is, not yet in the whole page); when I hit a button, the font's size
increases by 1 point; another button decreases it by 1 point (starting from
the default size), and a last button will reset it to the original size.

Pratically, whichever might be the default size (which I set from three css,
swapped accordingly to the screen's res), the text inside that table it
should be resized only by step of +1 or -1 point from the default size. Any
ideas?

Jul 23 '05 #1
14 1465
Cartel wrote:
Hello, I wish to modify the dimension of the font within a given table (that
is, not yet in the whole page); when I hit a button, the font's size
increases by 1 point; another button decreases it by 1 point (starting from
the default size), and a last button will reset it to the original size.

Pratically, whichever might be the default size (which I set from three css,
swapped accordingly to the screen's res), the text inside that table it
should be resized only by step of +1 or -1 point from the default size. Any
ideas?


Yeah, I have an idea or two. Let the user use the built-in mechanism for
adjusting font sizes. Thats what it is there for.

Second idea: What has my screen resolution got to do with anything?
Well, anything other than my resolution. I promise you that 600X800 on
my 19" monitor does *not* look/perform the same as 600X800 on a 15 inch
monitor. Nor does it matter when it comes to the size of my browser
window. If I have a 600x800 browser window on a 2560x960 dual monitor
desktop, what in the world makes you think I want some huge monster font
on the page?

Stop f**king with the fonts - end of problem.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Jul 23 '05 #2
"Randy Webb" <Hi************@aol.com> ha scritto nel messaggio
news:Mp********************@comcast.com...
Yeah, I have an idea or two. Let the user use the built-in mechanism for
adjusting font sizes. Thats what it is there for.
I've asked for ideas, not yet for "opinions".
Second idea: What has my screen resolution got to do with anything? Well,
anything other than my resolution. I promise you that 600X800 on my 19"
monitor does *not* look/perform the same as 600X800 on a 15 inch monitor.
Nor does it matter when it comes to the size of my browser window. If I
have a 600x800 browser window on a 2560x960 dual monitor desktop, what in
the world makes you think I want some huge monster font on the page?
UH? Sorry..... Are you ok?
Stop f**king with the fonts - end of problem.


Feeling lonely? Or just kinda philosophical?

(repeat)

Some serious scripts?

Jul 23 '05 #3
"Cartel" <bm*****@hotmail.com> writes:
Hello, I wish to modify the dimension of the font within a given table (that
is, not yet in the whole page); when I hit a button, the font's size
increases by 1 point; another button decreases it by 1 point (starting from
the default size), and a last button will reset it to the original size.
That's hard if you don't know the original size. If you want the button
to increase the font size by 10%, then it's much easier. E.g.:

----
<script type="text/javascript">
var size = 0;
var delta = 10;
function fontSize(n) {
if (n == 0) {
size = 0;
} else {
size += n;
}
document.getElementById("tableId").style.fontSize =
(100 + size * delta) + "%";
}
</script>

<input type="button" value="A-" onclick="fontSize(-1);">
<input type="button" value="A!" onclick="fontSize(0);">
<input type="button" value="A+" onclick="fontSize(+1);">
<table id="tableId">
<tr><td>Test</td><tr>
</table>
---
Pratically, whichever might be the default size (which I set from three css,
swapped accordingly to the screen's res),
Bad idea. The screen resolution tells you nothing about the actual
size of either browser or screen. I have a laptop with an extra CRT
screen attached. The larger CRT screen has the lower resolution (and I
can only begin to guess what you would think the screen resolution is
:).

Just go with the user's configured default font size.
the text inside that table it should be resized only by step of +1
or -1 point from the default size. Any ideas?


If it is imperative that the steps are 1 point, then you have to find
the current size *in points*. That might not even be possible, if you
don't have it provided to your script by whoever choses the style
sheet. What you can find, in some browsers, is the computed value of
the font size, which is probably in pixels, and there is no way to go
from pixels to points.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #4
"Lasse Reichstein Nielsen" <lr*@hotpop.com> ha scritto nel messaggio
news:oe**********@hotpop.com...
If it is imperative that the steps are 1 point,
sorry, **pixels** :(

then you have to find the current size *in points*. That might not even be possible, if you
don't have it provided to your script by whoever choses the style
sheet.


Indeed, in order to avoid these probs (I guess), I arranged the thing so
that the three css's are swapped by a javascript accordingly to the user's
resolution :) (800x600, 1024x768 and 1280x1024 and above).

It isn't the user who choses the css's manually.

I use three css 'cause nowaday many people have screens which run over
1680.....

My fault, I didn't mentioned this. So that's why I found feasible a script
which swaps the size by 1 px step.


Jul 23 '05 #5
ps.: doesn't work; maybe 'cause the pages where it is enbedded, are
dynamically generated?

Jul 23 '05 #6
ps.: doesn't work; maybe 'cause the pages where it is enbedded, are
dynamically generated?

Jul 23 '05 #7
> Indeed, in order to avoid these probs (I guess), I arranged the thing so
that the three css's are swapped by a javascript accordingly to the user's
resolution :) (800x600, 1024x768 and 1280x1024 and above).


Why???

A properly written site works on ALL monitors. If you have to specify
different CSS for different (and always incorrect) browser sizes you haven't
developed a good site.
Jul 23 '05 #8
"Cartel" <bm*****@hotmail.com> writes:
"Lasse Reichstein Nielsen" <lr*@hotpop.com> ha scritto nel messaggio
news:oe**********@hotpop.com...
If it is imperative that the steps are 1 point,
sorry, **pixels** :(


Ah, probably much easier :)
Indeed, in order to avoid these probs (I guess), I arranged the thing so
that the three css's are swapped by a javascript accordingly to the user's
resolution :) (800x600, 1024x768 and 1280x1024 and above).
I hope you are not going for exact matches for the first two. My
screens at work are currently 1152px and 1440px wide. Put together,
that gives a desktop that is 2592px wide, and a varying number of
pixels high :). However, I normally run the browser on the screen
with the lower resolution, so if you choose style sheet based on
screen.width, I would get the wrong one.

You cannot expect to predict the possible resolutions. There are
browsers in mobile phones these days. Some of them might reach 800
pixels width, but not all. Some 19' monitors run at 1280x1024. Some
14' monitors run at 1440x1050. The resolution doesn't tell you the
size of the pixels, only their number.

Trying to guess what a readable font is for the user, even based on
screen.width, is impossible, and bound to give problems for some
people. It is better to just stick to the user's default font size and
not try to be smart.
It isn't the user who choses the css's manually.
I was guessing a server side script, but a client side one is just as
good. In the branches that selects the style sheet, you can set a variable
to the font size that is used, so you have it for your script.
I use three css 'cause nowaday many people have screens which run over
1680.....
I would if my screen allowed it. At home I am stuck at 1600x1200
.... but I never run my browser full screen, so the resolution really
isn't important. The browser size is.
My fault, I didn't mentioned this. So that's why I found feasible a script
which swaps the size by 1 px step.


I would still let the script deciding the style also set a variable
with the original font size. Then just use a simple script similar to
the one I gave earlier to increase it in steps of one at a time.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #9
Cartel wrote:
"Randy Webb" <Hi************@aol.com> ha scritto nel messaggio
news:Mp********************@comcast.com...
Yeah, I have an idea or two. Let the user use the built-in mechanism for
adjusting font sizes. Thats what it is there for.

I've asked for ideas, not yet for "opinions".


And I gave you an idea. Its not my fault you missed the idea.
Second idea: What has my screen resolution got to do with anything? Well,
anything other than my resolution. I promise you that 600X800 on my 19"
monitor does *not* look/perform the same as 600X800 on a 15 inch monitor.
Nor does it matter when it comes to the size of my browser window. If I
have a 600x800 browser window on a 2560x960 dual monitor desktop, what in
the world makes you think I want some huge monster font on the page?

UH? Sorry..... Are you ok?


Just fine. But wondering what makes you think screen resolution has to
do with any of this.
Stop f**king with the fonts - end of problem.

Feeling lonely? Or just kinda philosophical?


Some of both, none of both, or maybe just some of none.
Some serious scripts?


If what you are wanting to do even made sense (It doesn't to me, for
many of the reasons that Lasse already pointed out) then someone would
probably have already written one.

The problem, even if you can determine the font size to start with, is
that if the user does indeed change IE settings from Medium to Largest,
then your script just got canned before it even got started. There is no
way for script to know if I did that or not.

But, you are going on the assumption that if the resolution of my
monitor is in a certain range, then I need fonts a certain size. My
point is that the screen resolution is irrelevant. And a simple scenario
can give you a good thought about it.

Right now I am sitting at a 19" dual monitor system. Now, when I sit at
my desk, I have font sizes set to small so that I don't have to read
huge letters up close. But when I start getting tired (or lazy), I back
away and recline in my desk chair. Thats after I change the font size to
Largest so I don't strain to see it anymore.

In the end, you let the user handle it and you don't have the headaches
that go along with trying to determine things like this.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Jul 23 '05 #10
"Lasse Reichstein Nielsen" <lr*@hotpop.com> ha scritto nel messaggio
news:oe**********@hotpop.com...
If it is imperative that the steps are 1 point,
sorry, **pixels** :(

then you have to find the current size *in points*. That might not even be possible, if you
don't have it provided to your script by whoever choses the style
sheet.


Indeed, in order to avoid these probs (I guess), I arranged the thing so
that the three css's are swapped by a javascript accordingly to the user's
resolution :) (800x600, 1024x768 and 1280x1024 and above).

It isn't the user who choses the css's manually.

I use three css 'cause nowaday many people have screens which run over
1680.....

My fault, I didn't mentioned this. So that's why I found feasible a script
which swaps the size by 1 px step.

Jul 23 '05 #11
"Noozer" <do*******@me.here> ha scritto nel messaggio
news:tGmpe.1591605$Xk.1184550@pd7tw3no...
Why???

A properly written site works on ALL monitors. If you have to specify
different CSS for different (and always incorrect) browser sizes you
haven't
developed a good site.


Still "philosophy"?

Jul 23 '05 #12
Well, if you're designing a web site, and not a web-based application
that might be a convincing argument. I develop a lot of web based
applications, and it's useful to swap font sizes when people are
presenting web based material and the 50+ year olds in the back of the
room can't read the tiny fonts on our grainy projectors.

Adam Ness

Jul 23 '05 #13
Recently, I developed a cold-fusion backed system to automatically
generate web-based presentations, mimicing powerpoint in a lot of ways.
For that application it was necessary to write a lot of javascript to
dynamically resize the fonts and tables. It's valuable from a
presentation standpoint to say "This font should be 5% of the screen
height" rather than "This font should be 12px tall"

This should obviously not be done within the web paradigm, but if
you're using a web application to emulate a different paradigm (
PowerPoint for example, or PDF ) then it could be pretty valuable.

Jul 23 '05 #14
Adam Ness wrote:
Recently, I developed a cold-fusion backed system to automatically
generate web-based presentations, mimicing powerpoint in a lot of ways.
So far, so good.
For that application it was necessary to write a lot of javascript to
dynamically resize the fonts and tables. It's valuable from a
presentation standpoint to say "This font should be 5% of the screen
height" rather than "This font should be 12px tall"
Then use percentages in your CSS.
This should obviously not be done within the web paradigm, but if
you're using a web application to emulate a different paradigm (
PowerPoint for example, or PDF ) then it could be pretty valuable.


Agreed.

Now, if we could just teach you to quote what you are replying to.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
Jul 23 '05 #15

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

Similar topics

21
by: Jay Levitt | last post by:
I'm just starting to play around with CSS and MovableType. My home page (http://www.jay.fm) now validates on both the CSS and the XHTML. However, the Google cached version shows the wrong font in...
258
by: Terry Andersen | last post by:
If I have: struct one_{ unsigned int one_1; unsigned short one_2; unsigned short one_3; }; struct two_{ unsigned int two_1;
14
by: Otto Meijer | last post by:
Hi everyone, for one of my projects I need to figure out the size of the swap file(s) of a certain system. The problem is I need to do this on a host of platforms like: HP_UX, Solaris, Linux,...
8
by: Jason Heyes | last post by:
Does the STL have a function like this one? template <typename T> void remove(std::vector<T> &v, std::vector<T>::size_type index) { std::swap(v, v.back()); v.resize(index); } Unlike...
8
by: traditore | last post by:
Hello. I'm trying to load fonts in a web page using "style" tag. The TTF files are in other page whose URL is, for example, "http://myURL/fonts". The HTML code is something like: <html>...
70
by: axlq | last post by:
I'm trying to design my style sheets such that my pages have similar-looking fonts different platforms (Linux, Mac, Adobe, X-Windows, MS Windows, etc). The problem is, a font on one platform...
1
by: aaron | last post by:
Output of "top" prior to initiation of mysql: load averages: 0.60, 0.97, 1.05 19:03:45 44 processes: 43 sleeping, 1 on cpu CPU states: 97.1% idle, 0.0% user, 0.8% kernel, 2.1% iowait, ...
19
by: Viken Karaguesian | last post by:
Hello everyone, Just an observation here: the CSS newsgroup (comp.infosystems.www.authoring.stylesheets) is totally dead. Why?... Anyway here's my discussion point: What is the most versatile...
11
by: Dennis Jones | last post by:
Hi all, 1) Let's say you have two char 's of the same size. How would you write a no-fail swap method for them? For example: class Test { char s; void swap( Test &rhs ) {
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.