2

Until now I thought justify meant that the text will start and end at the same pixel, but i was surprised a few hours ago, when I saw this:

justify bug

I got similar results in 2 computers (win7+chrome, ubuntu+firefox), and not just at this place, there are more similar bugs on the same site.

After my second chec I thought this is general and I just haven't noticed yet, but other sites don't show this strange behaviour. Also refreshing the site and restarting the browser didn't solved it.

Has anybody else noticed this? What causes this?

4
  • I'm guessing that's a free font embedded with @font-face?
    – mVChr
    Feb 3, 2011 at 10:14
  • It's pixel perfect in IE8/Vista, but not Chrome 8/Vista
    – Andy E
    Feb 3, 2011 at 10:15
  • 3
    You're kidding, right? That you think this is a real problem? @Andy E: Try selecting the text in IE 8; it quivers around and ends up displaying the same lack of pixel-perfect justification that Chrome shows. Feb 3, 2011 at 10:30
  • 1
    @Cody: it's not doing it for me right now, but I have seen IE quiver text before. I agree that developers have more to worry about than a single pixel difference between lines of justified text.
    – Andy E
    Feb 3, 2011 at 10:33

3 Answers 3

2

Actually that could well be intended behaviour. As with kerning it's about the appearance, rather than being pixel perfect. With justification the appearance that's trying to be achieved is of a straight edge on both sides of the text column.

Letting a letterform with an uneven right edge like "k" stick out past the straight edge of a letter like "n" helps to give that appearance visually. This is because of Gestalt psychology, which deals with how we perceive shapes, and you can see it happening at the start of lines as well:

enter image description here

It wouldn't surprise me if Webkit handles the nuances of text reproduction like this better than IE's engine—it's a feature in desktop publishing software like Adobe InDesign.

2
  • It definitely looks straighter in IE 8, which is the point of justification. I think the idea of it being a rounding issue sounds more likely.
    – Andy E
    Feb 3, 2011 at 14:34
  • Updated the post with a screenshot which seems to suggest otherwise (from Chrome 10, OS X).
    – quis
    Feb 3, 2011 at 16:24
1

It should be because of the character width is variable, a pixel is the smallest unit here, and fill the spaces, with, spaces can sometimes compute a float which is rounded.

Anyway, you should really not worry about this as the main reason would readability and not a design vagary.

0

The points previously made about this being a perceptual issue are valid, but also a bit accepting of a best-case scenario where the justification is being done right/well in the first place. It's worth nothing that proper text justification is actually rather hard, and the algorithms used by browsers just aren't that great. This Hacker News thread has a bunch of notes and links that should be of interest.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.