&ensp in a monospaced font

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andy Fish

    &ensp in a monospaced font

    Hi,

    I am trying to output some html in monospaced font, and I want spaces to
    take up the same width as any other character. i thought this would be easy
    for monospaced fonts - surely   and   would both be the same
    width?

    unfortunately not -   is narrower than other characters and   is
    wider :-(

    so how do i generate a sequence of normal width spaces?

    I can't use the <pretag because there is HTML markup in the output - it's
    not only plain text

    Andy


  • tech578

    #2
    Re: &amp;ensp in a monospaced font

    On Feb 29, 9:38 am, "Andy Fish" <ajf...@blueyon der.co.ukwrote:
    Hi,
    >
    I am trying to output some html in monospaced font, and I want spaces to
    take up the same width as any other character. i thought this would be easy
    for monospaced fonts - surely &ensp; and &emsp; would both be the same
    width?
    >
    unfortunately not - &ensp; is narrower than other characters and &emsp; is
    wider :-(
    >
    so how do i generate a sequence of normal width spaces?
    >
    I can't use the <pretag because there is HTML markup in the output - it's
    not only plain text
    >
    Andy
    maybe &nbsp;

    Comment

    • Toby A Inkster

      #3
      Re: &amp;ensp in a monospaced font

      Andy Fish wrote:
      I can't use the <pretag because there is HTML markup in the output -
      it's not only plain text
      You can use markup within <pre>.

      --
      Toby A Inkster BSc (Hons) ARCS
      [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
      [OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 30 days, 22:37.]

      Bottled Water

      Comment

      • Andreas Prilop

        #4
        Re: &amp;ensp in a monospaced font

        On Fri, 29 Feb 2008, Andy Fish wrote:
        I am trying to output some html in monospaced font, and I want spaces to
        take up the same width as any other character. i thought this would be easy
        for monospaced fonts - surely &ensp; and &emsp; would both be the same
        width?
        Some things are meaningless in monospaced fonts. Think of all the
        characters that have "zero-width" in their names.
        unfortunately not - &ensp; is narrower than other characters and &emsp;
        is wider :-(
        In *which* font?
        It is also possible that the browser takes ensp and emsp
        from some other font.

        --
        In memoriam Alan J. Flavell

        Comment

        • C A Upsdell

          #5
          Re: &amp;ensp in a monospaced font

          Andy Fish wrote:
          I am trying to output some html in monospaced font, and I want spaces to
          take up the same width as any other character. i thought this would be easy
          for monospaced fonts - surely &ensp; and &emsp; would both be the same
          width?
          Why would you think that?
          unfortunately not - &ensp; is narrower than other characters and &emsp; is
          wider :-(
          Of course.
          so how do i generate a sequence of normal width spaces?
          Something I have done on occasion is user '0' characters where I want
          spaces, but with the colour the same as the background, so they look
          like spaces.


          Comment

          • Jukka K. Korpela

            #6
            Re: &amp;ensp in a monospaced font

            Scripsit Andy Fish:
            I am trying to output some html in monospaced font,
            Do you mean you wish to present HTML markup visibly or audibly on the
            page? Then a monospace font would normally be a good idea. I would
            suggest using <codemarkup together with a style sheet like
            code { font-family: Consolas, "Courier New"; }
            to reduce the risk that some poor default monospace font is used.
            and I want spaces
            to take up the same width as any other character.
            A normal space, as well as a no-break space, has the same width as other
            characters, when the font is monospace
            i thought this
            would be easy for monospaced fonts - surely &ensp; and &emsp; would
            both be the same width?
            What? Why would you use specific-width space characters (which are
            poorly supported in fonts) _and_ ask them to have the same width as
            other characters? Why would you use them at all?
            so how do i generate a sequence of normal width spaces?
            By using the SPACE character U+0020 as everyone else.
            I can't use the <pretag because there is HTML markup in the output
            - it's not only plain text
            You have misunderstood the meaning of <pre>, and what else?

            The real problem is probably very different from the picture we've got
            so far. To avoid wasting more of everyone's time, post the URL.

            --
            Jukka K. Korpela ("Yucca")


            Comment

            • Bergamot

              #7
              Re: &amp;ensp in a monospaced font

              Jukka K. Korpela wrote:
              >
              suggest using <codemarkup together with a style sheet like
              code { font-family: Consolas, "Courier New"; }
              to reduce the risk that some poor default monospace font is used.
              I suggest font-family:monospac e; and let the user decide whether their
              default is "poor". Mine isn't by a long shot.

              --
              Berg

              Comment

              • dorayme

                #8
                Re: &amp;ensp in a monospaced font

                In article <KoXxj.304103$u Q5.46024@reader 1.news.saunalah ti.fi>,
                "Jukka K. Korpela" <jkorpela@cs.tu t.fiwrote:
                I would
                suggest using <codemarkup together with a style sheet like
                code { font-family: Consolas, "Courier New"; }
                to reduce the risk that some poor default monospace font is used.
                Whenever I have tried this, at least on my Mac, the code looks
                too faint (setting a font-weight can fix, but this might make
                other alternative fonts for code too bold). It is the 'Courier
                New' that is the trouble on my machine at least. The default
                'Courier' does not do this. Courier looks fine.

                --
                dorayme

                Comment

                • Toby A Inkster

                  #9
                  Re: &amp;ensp in a monospaced font

                  C A Upsdell wrote:
                  Something I have done on occasion is user '0' characters where I want
                  spaces, but with the colour the same as the background, so they look
                  like spaces.
                  That must be fun to copy-paste!

                  --
                  Toby A Inkster BSc (Hons) ARCS
                  [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
                  [OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 31 days, 22:46.]

                  Bottled Water

                  Comment

                  • Toby A Inkster

                    #10
                    Re: &amp;ensp in a monospaced font

                    dorayme wrote:
                    Jukka K. Korpela <jkorpela@cs.tu t.fiwrote:
                    >
                    >I would
                    >suggest using <codemarkup together with a style sheet like code {
                    >font-family: Consolas, "Courier New"; } to reduce the risk that some
                    >poor default monospace font is used.
                    >
                    Whenever I have tried this, at least on my Mac, the code looks too faint
                    (setting a font-weight can fix, but this might make other alternative
                    fonts for code too bold). It is the 'Courier New' that is the trouble on
                    my machine at least. The default 'Courier' does not do this. Courier
                    looks fine.
                    Agreed. Courier New is a horrible font -- very lightweight and hard to
                    read unless there is a lot of contrast between the font colour and
                    background colour. The serifs are too pronounced and there is very little
                    visual difference between l/1 and O/0.

                    Courier is slightly better -- it's a reasonable weight -- but still not
                    fantastic for reading as it suffers from Courier New's glyph shape
                    problems.

                    In my stylesheets, I'm now specifying:

                    font-family: "Consolas", "Bitstream Vera Sans Mono", "Andale Mono",
                    "Monaco", "Lucida Console", monospace;

                    for monospaced fonts. Virtually all Mac OS 9/X machines will have Andale
                    Mono or Monoco. Windows Vista machines will have Consolas; earlier Windows
                    will have Andale Mono or Lucida Console. Most Linux machines should have
                    Bitstream Vera Sans Mono these days.

                    Each of those fonts are very readable, smart-looking, sans serif mono
                    fonts. They all have good visual distinction between 0/O and I/l/1 (except
                    Lucida Console where there is little difference between 0/O) which makes
                    them very suitable for reading code.

                    --
                    Toby A Inkster BSc (Hons) ARCS
                    [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
                    [OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 31 days, 22:48.]

                    Bottled Water

                    Comment

                    • Bergamot

                      #11
                      Re: &amp;ensp in a monospaced font

                      C A Upsdell wrote:
                      >
                      Something I have done on occasion is user '0' characters where I want
                      spaces, but with the colour the same as the background, so they look
                      like spaces.
                      I bet it sounds great in a screen reader. :-\

                      --
                      Berg

                      Comment

                      • Jonathan N. Little

                        #12
                        Re: &amp;ensp in a monospaced font

                        Bergamot wrote:
                        C A Upsdell wrote:
                        >Something I have done on occasion is user '0' characters where I want
                        >spaces, but with the colour the same as the background, so they look
                        >like spaces.
                        >
                        I bet it sounds great in a screen reader. :-\
                        >
                        Bad, very bad idea...'zero zero zero zero one two three'...

                        --
                        Take care,

                        Jonathan
                        -------------------
                        LITTLE WORKS STUDIO

                        Comment

                        • Bergamot

                          #13
                          Re: &amp;ensp in a monospaced font

                          Els wrote:
                          Bergamot wrote:
                          >
                          >Why don't you just let the user decide what's most readable in a
                          >monospace font?
                          >
                          By your logic, we shouldn't add any background or text colour either,
                          By your logic, we should set absolute font sizes to go with those fonts.
                          as the user can set that themselves too - what if your webpage is
                          black on white, while they would have preferred red on blue?
                          Now we're getting carried away. :)

                          Don't you get tired of every other web page insisting you use Arial or
                          Verdana or whatever? Why don't more authors just use the generic
                          families instead of over specifying everything?

                          We all make such a big deal about user controlled font sizes, but
                          default fonts are pretty much totally ignored. :(

                          --
                          Berg

                          Comment

                          • Els

                            #14
                            Re: &amp;ensp in a monospaced font

                            Bergamot wrote:
                            Els wrote:
                            >Bergamot wrote:
                            >>
                            >>Why don't you just let the user decide what's most readable in a
                            >>monospace font?
                            >>
                            >By your logic, we shouldn't add any background or text colour either,
                            >
                            By your logic, we should set absolute font sizes to go with those fonts.
                            Nope, I'd set relative font-sizes that I think go with the rest of the
                            page and the purpose, and the user can still resize them, *and* force
                            their own user stylesheet over mine :-)
                            >as the user can set that themselves too - what if your webpage is
                            >black on white, while they would have preferred red on blue?
                            >
                            Now we're getting carried away. :)
                            Really :-)
                            Don't you get tired of every other web page insisting you use Arial or
                            Verdana or whatever? Why don't more authors just use the generic
                            families instead of over specifying everything?
                            No, I don't get tired of that at all.
                            Have a look at these pages. Each of them please:
                            Designer by day, designer by night. I live and work in Philadelphia under a pile of books.

                            The owner of this domain has not yet uploaded their website.


                            Original thoughts on web trends, issues, and usability by Aidan Henry.


                            See how each has a different font?
                            If you have them on your system, you should have seen Georgia, Lucida
                            Grande, Verdana and Trebuchet MS.

                            I'd get tired of seeing my own preferred font on every webpage while I
                            could be looking at diversity in typography.

                            And I don't get your "insisting we use Arial or Verdana or whatever".
                            They don't insist, they suggest. If you really want to have your
                            internet pages all in Verdana, just write your own stylesheet.
                            We all make such a big deal about user controlled font sizes, but
                            default fonts are pretty much totally ignored. :(
                            Which is a good thing :-)

                            --
                            Els http://locusmeus.com/

                            Comment

                            • ajfish@blueyonder.co.uk

                              #15
                              Re: &amp;ensp in a monospaced font

                              ok maybe I didn't make myself clear

                              i am using a monospaced font. on one line of the output i have
                              'abcde'; on the next line I have 'a' followed by 3 spaces followed by
                              'e'

                              I want the 'e' in the second line to appear underneath the 'e' in the
                              first line

                              if I use a normal space, the 3 spaces are collapsed into one; if I use
                              an m-width or n-width space, the spaces aren't the same width as
                              letters; if I use a non-breaking space, this stops the line breaking
                              (which is not the behaviour I want)

                              however, you (ant other posters) are right - I didn't realise you can
                              put other html codes inside a <preblock - so that looks like the
                              best option to me

                              Andy


                              On 29 Feb, 17:36, "Jukka K. Korpela" <jkorp...@cs.tu t.fiwrote:
                              Scripsit Andy Fish:
                              >
                              I am trying to output some html in monospaced font,
                              >
                              Do you mean you wish to present HTML markup visibly or audibly on the
                              page? Then a monospace font would normally be a good idea. I would
                              suggest using <codemarkup together with a style sheet like
                              code { font-family: Consolas, "Courier New"; }
                              to reduce the risk that some poor default monospace font is used.
                              >
                              and I want spaces
                              to take up the same width as any other character.
                              >
                              A normal space, as well as a no-break space, has the same width as other
                              characters, when the font is monospace
                              >
                              i thought this
                              would be easy for monospaced fonts - surely &ensp; and &emsp; would
                              both be the same width?
                              >
                              What? Why would you use specific-width space characters (which are
                              poorly supported in fonts) _and_ ask them to have the same width as
                              other characters? Why would you use them at all?
                              >
                              so how do i generate a sequence of normal width spaces?
                              >
                              By using the SPACE character U+0020 as everyone else.
                              >
                              I can't use the <pretag because there is HTML markup in the output
                              - it's not only plain text
                              >
                              You have misunderstood the meaning of <pre>, and what else?
                              >
                              The real problem is probably very different from the picture we've got
                              so far. To avoid wasting more of everyone's time, post the URL.
                              >
                              --
                              Jukka K. Korpela ("Yucca")http://www.cs.tut.fi/~jkorpela/

                              Comment

                              Working...