Forum How do I...?

Is there a variable-width non-breaking space?

dauwhe
Due to house typographic styles, I need to construct ellipses from periods and non-breaking spaces. However, it seems that Prince treat the non-breaking space U+00A0 as being of fixed width when justifying text (at least in the common OTF fonts I've tried). Is there a non-breaking space that is not fixed-width?
mikeday
No I don't think so, unless you wrapped up some normal spaces in a span and applied "white-space: pre".
jim_albright
No-break thin space, known in Unicode as "NARROW NO-BREAK SPACE" (U+202F). This is required for French punctuation (before ?, ! or ;).

This may be of help to you.

Jim Albright
Wycliffe Bible Translators

thomas
dauwhe wrote:
Is there a non-breaking space that is not fixed-width?


Sort of:
<span style="white-space:nowrap">&#xFEFF &#xFEFF</span>
neochief
pjrm
Use of nbsp prevents breaking at that space, but still allows hyphenation or breaking around certain punctuation such as slashes, so one would more commonly wrap a whole phrase in a span marked up with white-space:nowrap; a <nobr> element is commonly used for this purpose (and Prince and some web browsers have a

nobr { white-space: nowrap }

rule in their user-agent style sheet), though note that the html spec does not mention such an element, so it is technically not valid html.

The main use of nbsp is around punctuation characters, where one really does only wish to prevent breaking at that space itself.

Strangely, I haven't found any guidance in either w3c or unicode specs on the justification behaviour of u+00a0 no-break space; does anyone else have any pointers? Word processors do not stretch it, but both Chromium and Firefox do. Of the first two French books I pulled from my bookshelf, one (printed in 1948, i.e. before widespread use of computers in publishing) stretches the space before colon, the other (printed in 2000) does not.

I am currently leaning towards preferring to stretch nbsp, but the variation in user expectations and absence of spec guidance on the matter (that I've found so far) do at least make me delay changing things.
dauwhe
CSS Text 3 seems to imply that U+00A0 should adjust:

A justification opportunity is a point where the justification algorithm may alter spacing within the text. A justification opportunity can be provided by a single typographic character unit (such as a word separator),



Word-separator characters are typographic character units whose purpose and general usage is to separate words. In [UNICODE] this includes the space (U+0020), the no-break space (U+00A0), the Ethiopic word space (U+1361), the Aegean word separators (U+10100,U+10101), the Ugaritic word divider (U+1039F), and the Phoenician Word Separator (U+1091F).

If there are no word-separator characters, or if a word-separating character has a zero advance width (such as the zero width space U+200B) then the user agent must not create an additional spacing between words.

General punctuation and fixed-width spaces (such as U+3000 and U+2000 through U+200A) are not considered word-separator characters.


I'd be happy to seek clarification from the working group if that would help.
pjrm
I now believe this is what css-text-3 wants. (I was tripped up by some text about not needing to justify non-collapsible white space, which I now believe was not intended to include no-break space.)

I have accordingly been working on making this change, and am just consulting with a colleague on some matters related to handling of nbsp for tagged pdf and similar before submitting for inclusion in future builds.
bea41659
I was looking for a solution to this problem and I figured out such a hack:

in html file find & replace:

&nbsp;

with

<span class="nobr"></span>


in css file add this:

.nobr:after {
content: "\20\2060";
white-space: nowrap;
}