![]() |
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? |
Re: swap fonts' size
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 |
Re: swap fonts' size
"Randy Webb" <HikksNotAtHome@aol.com> ha scritto nel messaggio
news:MpednYCV7rzbUDjfRVn-3w@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? |
Re: swap fonts' size
"Cartel" <bm_acme@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 - lrn@hotpop.com DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html> 'Faith without judgement merely degrades the spirit divine.' |
Re: swap fonts' size
"Lasse Reichstein Nielsen" <lrn@hotpop.com> ha scritto nel messaggio
news:oeairq1p.fsf@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. |
Re: swap fonts' size
"Lasse Reichstein Nielsen" <lrn@hotpop.com> ha scritto nel messaggio
news:oeairq1p.fsf@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. |
Re: swap fonts' size
ps.: doesn't work; maybe 'cause the pages where it is enbedded, are
dynamically generated? |
Re: swap fonts' size
ps.: doesn't work; maybe 'cause the pages where it is enbedded, are
dynamically generated? |
Re: swap fonts' size
> 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. |
Re: swap fonts' size
"Cartel" <bm_acme@hotmail.com> writes:
> "Lasse Reichstein Nielsen" <lrn@hotpop.com> ha scritto nel messaggio > news:oeairq1p.fsf@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 - lrn@hotpop.com DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html> 'Faith without judgement merely degrades the spirit divine.' |
| All times are GMT. The time now is 05:08 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.