swap fonts' size

C

Cartel

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?
 
R

Randy Webb

Cartel said:
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.
 
C

Cartel

Randy Webb said:
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?
 
L

Lasse Reichstein Nielsen

Cartel said:
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>
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
 
C

Cartel

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.
 
C

Cartel

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.
 
C

Cartel

ps.: doesn't work; maybe 'cause the pages where it is enbedded, are
dynamically generated?
 
C

Cartel

ps.: doesn't work; maybe 'cause the pages where it is enbedded, are
dynamically generated?
 
N

Noozer

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.
 
L

Lasse Reichstein Nielsen

Cartel said:
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
 
C

Cartel

Noozer said:
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"?
 
A

Adam Ness

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
 
A

Adam Ness

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.
 
R

Randy Webb

Adam said:
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top