aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Geerken <devnull@localhost>2012-12-05 10:32:59 +0100
committerSebastian Geerken <devnull@localhost>2012-12-05 10:32:59 +0100
commit9931f73e91bde579357365a3e089834cf23839a3 (patch)
treeb4f1c10d2dcd4d031a4e27ea5a50d4e4f01a1217
parent7ecf0501bb1439c77255ad0808abbe3141cf4bc7 (diff)
Added non-breakable space to division characters, so that hyphenation works correctly.
-rw-r--r--dw/textblock.cc9
-rw-r--r--dw/textblock.hh4
-rw-r--r--test/hyphenate-nbsp.html4
-rw-r--r--test/liang.cc1
4 files changed, 14 insertions, 4 deletions
diff --git a/dw/textblock.cc b/dw/textblock.cc
index 20ac7fa5..226b5ab6 100644
--- a/dw/textblock.cc
+++ b/dw/textblock.cc
@@ -48,7 +48,10 @@ Textblock::DivChar Textblock::divChars[NUM_DIV_CHARS] = {
{ "\xe2\x80\x90", false, true, true, -1, PENALTY_HYPHEN },
// em dash (U+2014): breaks on both sides are allowed (but see below).
{ "\xe2\x80\x94", false, true, false,
- PENALTY_EM_DASH_LEFT, PENALTY_EM_DASH_RIGHT }
+ PENALTY_EM_DASH_LEFT, PENALTY_EM_DASH_RIGHT },
+ // non-breakable space
+ { "\xc2\xa0", false, true, true,
+ PENALTY_PROHIBIT_BREAK_I, PENALTY_PROHIBIT_BREAK_I }
};
// Standard values are defined here. The values are already multiplied
@@ -74,7 +77,9 @@ int Textblock::penalties[PENALTY_NUM][2] = {
// so that a break on the *right* side is preferred.
{ 800, 800 },
// Penalties for a break point *right* of an em-dash: like hyphens.
- { 100, 800 }
+ { 100, 800 },
+ // Prohibit: added here to have a defined index in divChars[].
+ { INT_MAX, INT_MAX }
};
/**
diff --git a/dw/textblock.hh b/dw/textblock.hh
index b1ad3ee8..f448cda3 100644
--- a/dw/textblock.hh
+++ b/dw/textblock.hh
@@ -217,8 +217,8 @@ private:
};
enum { PENALTY_HYPHEN, PENALTY_EM_DASH_LEFT, PENALTY_EM_DASH_RIGHT,
- PENALTY_NUM };
- enum { NUM_DIV_CHARS = 4 };
+ PENALTY_PROHIBIT_BREAK_I, PENALTY_NUM };
+ enum { NUM_DIV_CHARS = 5 };
typedef struct
{
diff --git a/test/hyphenate-nbsp.html b/test/hyphenate-nbsp.html
new file mode 100644
index 00000000..1e9bf379
--- /dev/null
+++ b/test/hyphenate-nbsp.html
@@ -0,0 +1,4 @@
+<div style="font-size:10em" lang=de>
+Weiß
+kurz&nbsp;und&nbsp;knapp
+</div>
diff --git a/test/liang.cc b/test/liang.cc
index 71ed6210..4ed717ee 100644
--- a/test/liang.cc
+++ b/test/liang.cc
@@ -49,6 +49,7 @@ int main (int argc, char *argv[])
"carbonsäure-7²-(Z)-(O-methyloxim)");
hyphenateWord (&p, "Abtei-Stadt");
hyphenateWord (&p, "Nordrhein-Westfalen");
+ hyphenateWord (&p, "kurz\xc2\xa0und\xc2\xa0knapp");
return 0;
}