SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Wizard
    Join Date
    Apr 2002
    Posts
    2,292
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    fractions with 3 and 5 as the denominator characters in ie?

    ½ like encodings work fine in ie but & # 8532; (without spaces), which is 2/3, ones don't.

    is there a way to have ie display fraction characters like 1/3 and 4/5 (i'm after the x/3's and x/5's) in ie without having to have separate individual characters and styling them?

    thanks.

  2. #2
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You have the U+2153 to U+215E character range in Unicode to play with, but you need to use a font that contains glyphs for those characters and your visitors need to have that font installed.

    The only other options, as far as I know, are to use images (bad) or to use three separate characters and some CSS (okay).
    Birnam wood is come to Dunsinane

  3. #3
    SitePoint Wizard
    Join Date
    Apr 2002
    Posts
    2,292
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    ok thanks.

    when you say

    > You have the U+2153 to U+215E character range in Unicode to play with

    do you mean using a unicode encoding for the page (by php headers say), and include the fraction characters literally?

  4. #4
    Resident curmudgeon bronze trophy gary.turner's Avatar
    Join Date
    Jan 2009
    Location
    Dallas
    Posts
    990
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    View this page, and select block 21. Switch your browser's default font family through the safe fonts until you find those that will render the glyphs.

    I've pasted the group below. See which will render them.

    ⅓ ⅔ ⅕ ⅖ ⅗ ⅘ ⅙ ⅚ ⅛ ⅜ ⅝ ⅞

    cheers,

    gary
    Anyone can build a usable website. It takes a graphic
    designer to make it slow, confusing, and painful to use.

    Simple minded html & css demos and tutorials

  5. #5
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by johnyboy View Post
    do you mean using a unicode encoding for the page (by php headers say), and include the fraction characters literally?
    You can do it that way, or you can use numeric character references (⅓⅞).

    What I mean is that those characters, which Gary posted, are the available fraction characters (in addition to , , – U+00BC to U+00BE). Anything else you'll have to use separate characters for.

    The problem is that not all fonts have glyphs for these characters, in which case they'll render as, e.g., an empty box.

    The safest way is problably to use separate characters:
    Code HTML4Strict:
    <span class="fraction"><span>1</span>/<span class="denominator">3</span></span>
    Code CSS:
    .fraction {letter-spacing:-2px}
    .fraction span {font-size:smaller; vertical-align:1ex}
    .fraction span.denominator {vertical-align:-1ex}
    Birnam wood is come to Dunsinane

  6. #6
    SitePoint Wizard
    Join Date
    Apr 2002
    Posts
    2,292
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    > Switch your browser's default font family through the safe fonts until you find those that will render the glyphs.

    and

    > You can do it that way, or you can use numeric character references (& # 8531; & # 8542; ).

    i see, so when i used & # 8532; and it didn't work in ie, that was only because the font being used in ie didn't have such a character. if it had it would have worked. i thought it might have been something more fundmantal than that; ie can't use &#xxxx; type encoding full stop or something.

    when i tested it i tested it with both font-family:sans-serif and font-family:serif, and in ie the fractions using that kind of encoding with base 3 and 5 failed but not on a few other windows browsers (only very minimally tested though -- tiny number of other browsers). maybe the default typefaces the non ie browsers were set to use happenend to be typefaces with those characters. or maybe those browsers automatically switch font to ensure the right glyph gets displayed regardless of typeface (i think mac safari might do this).

    anyway, obviously it's all a bit hit and miss. i should probably forget trying to use just one character and use the css method you suggest AutisticCuckoo.

    thanks for the replies.

  7. #7
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Named entity references, e.g., &Sigma;, can be unsafe to use because not all browsers support all of the entities declared in HTML4. Numeric character references should be safe inasmuch as browsers should support them. But you still have the font issue to deal with, of course.

    Try Arial Unicode for Windows systems. It seems to have decent support for lots of odd characters, although I'm on Linux right now so I can't check.
    Birnam wood is come to Dunsinane

  8. #8
    SitePoint Wizard
    Join Date
    Apr 2002
    Posts
    2,292
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    ok great, thanks.

  9. #9
    Resident curmudgeon bronze trophy gary.turner's Avatar
    Join Date
    Jan 2009
    Location
    Dallas
    Posts
    990
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AutisticCuckoo View Post
    Named entity references, e.g., [samp]
    Try Arial Unicode for Windows systems. It seems to have decent support for lots of odd characters, although I'm on Linux right now so I can't check.
    Don't you have msttcorefonts installed? The package includes Arial*, Verdana, Trebuchet, Georgia, Times New Roman, and a couple more. I think these are fairly complete, other than for the oriental language glyphs. Further, this set of Microsoft TrueType fonts is widely installed; thus reasonably safe to declare.

    cheers,

    gary

    * Though not the big set, which is huge. I'm not sure it's readily available any more.
    Anyone can build a usable website. It takes a graphic
    designer to make it slow, confusing, and painful to use.

    Simple minded html & css demos and tutorials

  10. #10
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by gary.turner View Post
    Don't you have msttcorefonts installed?
    No, I don't. I tried installing it on my old computer (Red Hat 9) but couldn't get the system to recognise those fonts. I haven't tried in on my newer machine (Fedora 8).

    Quote Originally Posted by gary.turner View Post
    I'm not sure it's readily available any more.
    I think I've read somewhere that Microsoft withdrew it for some reason.
    Birnam wood is come to Dunsinane


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •