swap fonts' size

Discussion in 'Javascript' started by Cartel, Jun 7, 2005.

  1. Cartel

    Cartel Guest

    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?
     
    Cartel, Jun 7, 2005
    #1
    1. Advertising

  2. Cartel

    Randy Webb Guest

    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
     
    Randy Webb, Jun 7, 2005
    #2
    1. Advertising

  3. Cartel

    Cartel Guest

    "Randy Webb" <> ha scritto nel messaggio
    news:...
    > 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?
     
    Cartel, Jun 7, 2005
    #3
  4. "Cartel" <> 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 -
    DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
    'Faith without judgement merely degrades the spirit divine.'
     
    Lasse Reichstein Nielsen, Jun 7, 2005
    #4
  5. Cartel

    Cartel Guest

    "Lasse Reichstein Nielsen" <> ha scritto nel messaggio
    news:eek:...

    > 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.
     
    Cartel, Jun 7, 2005
    #5
  6. Cartel

    Cartel Guest

    "Lasse Reichstein Nielsen" <> ha scritto nel messaggio
    news:eek:...

    > 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.
     
    Cartel, Jun 7, 2005
    #6
  7. Cartel

    Cartel Guest

    ps.: doesn't work; maybe 'cause the pages where it is enbedded, are
    dynamically generated?
     
    Cartel, Jun 7, 2005
    #7
  8. Cartel

    Cartel Guest

    ps.: doesn't work; maybe 'cause the pages where it is enbedded, are
    dynamically generated?
     
    Cartel, Jun 7, 2005
    #8
  9. Cartel

    Noozer Guest

    > 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.
     
    Noozer, Jun 7, 2005
    #9
  10. "Cartel" <> writes:

    > "Lasse Reichstein Nielsen" <> ha scritto nel messaggio
    > news:eek:...
    >
    >> 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 -
    DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
    'Faith without judgement merely degrades the spirit divine.'
     
    Lasse Reichstein Nielsen, Jun 7, 2005
    #10
  11. Cartel

    Cartel Guest

    "Noozer" <> 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"?
     
    Cartel, Jun 7, 2005
    #11
  12. Cartel

    Adam Ness Guest

    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
     
    Adam Ness, Jun 10, 2005
    #12
  13. Cartel

    Adam Ness Guest

    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.
     
    Adam Ness, Jun 10, 2005
    #13
  14. Cartel

    Randy Webb Guest

    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?
     
    Randy Webb, Jun 11, 2005
    #14
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Otto Meijer

    Swap space size in C

    Otto Meijer, Dec 12, 2003, in forum: C Programming
    Replies:
    14
    Views:
    559
    glen herrmannsfeldt
    Dec 17, 2003
  2. Niels Dekker (no reply address)

    What swap is called when using std::swap?

    Niels Dekker (no reply address), Jul 19, 2006, in forum: C++
    Replies:
    4
    Views:
    1,013
    Niels Dekker (no reply address)
    Jul 20, 2006
  3. Adrienne Boswell

    Another reason to not use micro-size fonts

    Adrienne Boswell, Aug 2, 2008, in forum: HTML
    Replies:
    23
    Views:
    918
    dorayme
    Aug 7, 2008
  4. Chris F.A. Johnson

    Re: Preferred way to size fonts

    Chris F.A. Johnson, Nov 5, 2008, in forum: HTML
    Replies:
    19
    Views:
    778
    Sherm Pendley
    Nov 8, 2008
  5. sam
    Replies:
    0
    Views:
    453
Loading...

Share This Page