473,909 Members | 6,117 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

&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
Feb 29 '08 #1
59 7764
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;
Feb 29 '08 #2
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
http://tobyinkster.co.uk/blog/2008/02/18/bottled-water/
Feb 29 '08 #3
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
http://groups.google.com/groups/sear...Alan.J.Flavell
Feb 29 '08 #4
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.
Feb 29 '08 #5
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/

Feb 29 '08 #6
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
Feb 29 '08 #7
In article <Ko************ ********@reader 1.news.saunalah ti.fi>,
"Jukka K. Korpela" <jk******@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
Feb 29 '08 #8
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
http://tobyinkster.co.uk/blog/2008/02/18/bottled-water/
Mar 1 '08 #9
dorayme wrote:
Jukka K. Korpela <jk******@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
http://tobyinkster.co.uk/blog/2008/02/18/bottled-water/
Mar 1 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1572
by: Mark | last post by:
I'm just after a bit of wisdom here. If I specify something like body { font-size: 1em; } is this really the same as body { font-size: 100%; } ?
3
4529
by: Joseph Gruber | last post by:
Hi all -- I have two questions. First, I'm adding a control to my form at runtime and the control/form seems to ignore the anchor property of the runtime control. Any idea how I can get a runtime control to anchor properly? Second -- the program I'm writting is supposed to look like a dos application (long story). When the application is "Normal" aka a small window then everything looks great. But when I resize the window to...
0
11346
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10919
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11046
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9725
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7248
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5938
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6138
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4774
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3357
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.