11-03-2011, 11:41 PM
Many proportional fonts look much better when hyphenated words use a true hyphen U+2010 rather than the US keyboard 'minus-hyphen' character. This is particularly the case in German text containing a great many hyphenated neologisms.
In the code below, if the font-family is not specified or is set to a generic "serif", the hyphen may appear as an overstrike of an unprintable character (the unsightly super-imposed empty rectangle.)
A complete list of your available fonts is part of the test page below:
{curl 7.0,8.0 applet}
{curl-file-attributes character-encoding="utf8"}
{set-document-properties
font-family="DejaVu Serif, Lucida Sans Unicode, Arial Unicode MS, DejaVu, serif, sans-serif",
||
|| font-family = "serif",
|| setting to "serif" ONLY or NOT setting will fail to display \u2010 correctly as a hyphen
||
font-size=14pt,
background={Background.from-string "linen"}
}
|| true hyphen ‐
|| dash –
|| true minus sign −
|| US kybd 'minus' -
{title heading?=false, Font Hyphen Test}
|| http://de.wikipedia.org/wiki/Gradiva
|| http://www.freud.org.uk/photo-library/detail/67734/
{heading level=1, Font Hyphen Test}
{def tb={TextFlowBox {text
{def tb={TextFlowBox {text
with hyphen-minus U+002D {center e-h} {br}
with true‐hyphen U+2010 {center e\u2010h} {br}
with soft hyphen U+00AD {center e\u00ADh} {br}
with hard hyphen U+2011 {center e\u2011h} {br}
with ndash U+2013 {center e\u2013h} {br}}}}
{def dc= {tb.get-display-context}}
{def arr = {dc.get-font-names} }
{for n:String in arr do
{tb.add {value n}}
{tb.add {br} }
}
{let fnt:Font = {Font "Lucida Sans Unicode", 14pt } }
{let correct:bool = {dc.font-can-display-char? fnt, '\u2010' } }
{if correct then
{tb.add
{paragraph Hyphen tests as test\u2010test }
}}
{set correct = {dc.font-can-display-char? fnt, '\u2011' } }
{if correct then
{tb.add
{paragraph Hyphen tests as test\u2011test }
}}
{set correct = {dc.font-can-display-char? fnt, '\u00AD' } }
{if correct then
{tb.add
{paragraph Hyphen tests as test\u00ADtest }
}}
{set correct = {dc.font-can-display-char? fnt, '\u002D' } }
{if correct then
{tb.add
{paragraph Hyphen tests as test\u002Dtest }
}}
{value tb}
|| end of font tests
|| NOTE: setting to "serif" ONLY in the doc properties may result in \u2010 \u2011 and \u00AD not displaying correctly as hyphens even with the character encoding set to utf8.
|| The font-can-display-char? test is of no help. A bug?
|| When 00AD displays, I leave 002D (the - key) for Curl code and use 002D in place of 2010 or 2011 in the literary text which I am formatting for display. The display may be the same, but the text remains ready for an upgrade to hard- and soft-hyphens in the future.
In the code below, if the font-family is not specified or is set to a generic "serif", the hyphen may appear as an overstrike of an unprintable character (the unsightly super-imposed empty rectangle.)
A complete list of your available fonts is part of the test page below:
{curl 7.0,8.0 applet}
{curl-file-attributes character-encoding="utf8"}
{set-document-properties
font-family="DejaVu Serif, Lucida Sans Unicode, Arial Unicode MS, DejaVu, serif, sans-serif",
||
|| font-family = "serif",
|| setting to "serif" ONLY or NOT setting will fail to display \u2010 correctly as a hyphen
||
font-size=14pt,
background={Background.from-string "linen"}
}
|| true hyphen ‐
|| dash –
|| true minus sign −
|| US kybd 'minus' -
{title heading?=false, Font Hyphen Test}
|| http://de.wikipedia.org/wiki/Gradiva
|| http://www.freud.org.uk/photo-library/detail/67734/
{heading level=1, Font Hyphen Test}
{def tb={TextFlowBox {text
{def tb={TextFlowBox {text
with hyphen-minus U+002D {center e-h} {br}
with true‐hyphen U+2010 {center e\u2010h} {br}
with soft hyphen U+00AD {center e\u00ADh} {br}
with hard hyphen U+2011 {center e\u2011h} {br}
with ndash U+2013 {center e\u2013h} {br}}}}
{def dc= {tb.get-display-context}}
{def arr = {dc.get-font-names} }
{for n:String in arr do
{tb.add {value n}}
{tb.add {br} }
}
{let fnt:Font = {Font "Lucida Sans Unicode", 14pt } }
{let correct:bool = {dc.font-can-display-char? fnt, '\u2010' } }
{if correct then
{tb.add
{paragraph Hyphen tests as test\u2010test }
}}
{set correct = {dc.font-can-display-char? fnt, '\u2011' } }
{if correct then
{tb.add
{paragraph Hyphen tests as test\u2011test }
}}
{set correct = {dc.font-can-display-char? fnt, '\u00AD' } }
{if correct then
{tb.add
{paragraph Hyphen tests as test\u00ADtest }
}}
{set correct = {dc.font-can-display-char? fnt, '\u002D' } }
{if correct then
{tb.add
{paragraph Hyphen tests as test\u002Dtest }
}}
{value tb}
|| end of font tests
|| NOTE: setting to "serif" ONLY in the doc properties may result in \u2010 \u2011 and \u00AD not displaying correctly as hyphens even with the character encoding set to utf8.
|| The font-can-display-char? test is of no help. A bug?
|| When 00AD displays, I leave 002D (the - key) for Curl code and use 002D in place of 2010 or 2011 in the literary text which I am formatting for display. The display may be the same, but the text remains ready for an upgrade to hard- and soft-hyphens in the future.