summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/luatexdir/lang
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2015-10-07 02:16:02 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2015-10-07 02:16:02 +0000
commita021762e6ccc1101fefbac38abb168b69a11f0ca (patch)
treebaf31827b9c7c7af518a3f4aa58ccba0de18b640 /Build/source/texk/web2c/luatexdir/lang
parent4ca2692153042a0c2f7db8d681e190b867ae2faf (diff)
web2c/luatexdir: Sync with the upstream trunk.
git-svn-id: svn://tug.org/texlive/trunk@38575 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/lang')
-rw-r--r--Build/source/texk/web2c/luatexdir/lang/texlang.h8
-rw-r--r--Build/source/texk/web2c/luatexdir/lang/texlang.w45
2 files changed, 45 insertions, 8 deletions
diff --git a/Build/source/texk/web2c/luatexdir/lang/texlang.h b/Build/source/texk/web2c/luatexdir/lang/texlang.h
index 0fdff82d81a..9a8534b3996 100644
--- a/Build/source/texk/web2c/luatexdir/lang/texlang.h
+++ b/Build/source/texk/web2c/luatexdir/lang/texlang.h
@@ -1,5 +1,5 @@
/* texlang.h
-
+
Copyright 2009 Taco Hoekwater <taco@luatex.org>
This file is part of LuaTeX.
@@ -38,6 +38,7 @@ struct tex_language {
int post_hyphen_char;
int pre_exhyphen_char;
int post_exhyphen_char;
+ int hyphenation_min;
};
# define MAX_WORD_LEN 65536 /* in chars */
@@ -64,6 +65,10 @@ extern void set_pre_exhyphen_char(int lan, int val);
extern void set_post_exhyphen_char(int lan, int val);
extern int get_pre_exhyphen_char(int lan);
extern int get_post_exhyphen_char(int lan);
+
+extern void set_hyphenation_min(int lan, int val);
+extern int get_hyphenation_min(int lan);
+
extern halfword compound_word_break(halfword t, int clang);
extern void dump_language_data(void);
@@ -76,6 +81,7 @@ extern void new_pre_hyphen_char(void);
extern void new_post_hyphen_char(void);
extern void new_pre_exhyphen_char(void);
extern void new_post_exhyphen_char(void);
+extern void new_hyphenation_min(void);
#endif
diff --git a/Build/source/texk/web2c/luatexdir/lang/texlang.w b/Build/source/texk/web2c/luatexdir/lang/texlang.w
index 2053220d2c4..438cf794137 100644
--- a/Build/source/texk/web2c/luatexdir/lang/texlang.w
+++ b/Build/source/texk/web2c/luatexdir/lang/texlang.w
@@ -61,6 +61,7 @@ struct tex_language *new_language(int n)
lang->post_hyphen_char = 0;
lang->pre_exhyphen_char = 0;
lang->post_exhyphen_char = 0;
+ lang->hyphenation_min = -1;
return lang;
} else {
return NULL;
@@ -144,6 +145,22 @@ int get_post_exhyphen_char(int n)
return (int) l->post_exhyphen_char;
}
+
+void set_hyphenation_min(int n, int v)
+{
+ struct tex_language *l = get_language((int) n);
+ if (l != NULL)
+ l->hyphenation_min = (int) v;
+}
+
+int get_hyphenation_min(int n)
+{
+ struct tex_language *l = get_language((int) n);
+ if (l == NULL)
+ return -1;
+ return (int) l->hyphenation_min;
+}
+
@ @c
void load_patterns(struct tex_language *lang, const unsigned char *buff)
{
@@ -314,11 +331,12 @@ void load_tex_hyphenation(int curlang, halfword head)
@c
halfword insert_discretionary(halfword t, halfword pre, halfword post,
- halfword replace)
+ halfword replace, int penalty)
{
halfword g, n;
int f;
n = new_node(disc_node, syllable_disc);
+ disc_penalty(n) = penalty;
try_couple_nodes(n, vlink(t));
couple_nodes(t, n);
if (replace != null)
@@ -364,6 +382,7 @@ halfword insert_syllable_discretionary(halfword t, lang_variables * lan)
{
halfword g, n;
n = new_node(disc_node, syllable_disc);
+ disc_penalty(n) = int_par(hyphen_penalty_code);
couple_nodes(n, vlink(t));
couple_nodes(t, n);
delete_attribute_ref(node_attr(n));
@@ -409,7 +428,7 @@ halfword insert_word_discretionary(halfword t, lang_variables * lan)
pre = insert_character(null, lan->pre_exhyphen_char);
if (lan->post_exhyphen_char > 0)
pos = insert_character(null, lan->post_exhyphen_char);
- return insert_discretionary(t, pre, pos, null);
+ return insert_discretionary(t, pre, pos, null,int_par(ex_hyphen_penalty_code));
}
@ @c
@@ -429,7 +448,7 @@ halfword insert_complex_discretionary(halfword t, lang_variables * lan,
halfword replace)
{
(void) lan;
- return insert_discretionary(t, pre, pos, replace);
+ return insert_discretionary(t, pre, pos, replace,int_par(hyphen_penalty_code));
}
@@ -617,7 +636,7 @@ static void do_exception(halfword wordstart, halfword r, char *replacement)
try_couple_nodes(t, vlink(q));
vlink(q) = null;
}
- t = insert_discretionary(t, gg, hh, replace);
+ t = insert_discretionary(t, gg, hh, replace,int_par(hyphen_penalty_code));
t = vlink(t); /* skip the new disc */
} else {
t = vlink(t);
@@ -732,7 +751,7 @@ static halfword find_next_wordstart(halfword r)
/* -- or --- ligature in which case we can in a worse case usage get bad */
/* node lists later on due to messed up ligature building as these dashes */
/* ligatures in base fonts. This is a side effect of the separating the */
- /* hyphenation, ligaturing and kerning steps. A test is cmr with ------. */
+ /* hyphenation, ligaturing and kerning steps. A test is cmr with ------. */
t = vlink(r) ;
if ((start_ok > 0) && (t!=null) && (type(t) == glyph_node) && (character(t) != ex_hyphen_char)) {
t = compound_word_break(r, char_lang(r));
@@ -818,7 +837,7 @@ void hnj_hyphenation(halfword head, halfword tail)
couple_nodes(tail, s);
while (r != null) { /* could be while(1), but let's be paranoid */
- int clang, lhmin, rhmin;
+ int clang, lhmin, rhmin, hmin;
halfword hyf_font;
halfword end_word = r;
wordstart = r;
@@ -829,6 +848,7 @@ void hnj_hyphenation(halfword head, halfword tail)
clang = char_lang(wordstart);
lhmin = char_lhmin(wordstart);
rhmin = char_rhmin(wordstart);
+ hmin = get_hyphenation_min(clang);
langdata.pre_hyphen_char = get_pre_hyphen_char(clang);
langdata.post_hyphen_char = get_post_hyphen_char(clang);
while (r != null && type(r) == glyph_node && is_simple_character(r) && clang == char_lang(r) &&
@@ -842,7 +862,7 @@ void hnj_hyphenation(halfword head, halfword tail)
end_word = r;
r = vlink(r);
}
- if (valid_wordend(r) && wordlen >= lhmin + rhmin
+ if (valid_wordend(r) && wordlen >= lhmin + rhmin && (hmin <= 0 || wordlen >= hmin)
&& (hyf_font != 0) && clang >=0 && (lang = tex_languages[clang]) != NULL) {
*hy = 0;
if (lang->exceptions != 0 &&
@@ -963,6 +983,7 @@ static void dump_one_language(int i)
dump_int(lang->post_hyphen_char);
dump_int(lang->pre_exhyphen_char);
dump_int(lang->post_exhyphen_char);
+ dump_int(lang->hyphenation_min);
if (lang->patterns != NULL) {
s = (char *) hnj_serialize(lang->patterns);
}
@@ -1010,6 +1031,8 @@ static void undump_one_language(int i)
lang->pre_exhyphen_char = x;
undump_int(x);
lang->post_exhyphen_char = x;
+ undump_int(x);
+ lang->hyphenation_min = x;
/* patterns */
undump_int(x);
if (x > 0) {
@@ -1102,3 +1125,11 @@ void new_post_exhyphen_char(void)
scan_int();
set_post_exhyphen_char(int_par(language_code), cur_val);
}
+
+
+void new_hyphenation_min(void)
+{
+ scan_optional_equals();
+ scan_int();
+ set_hyphenation_min(int_par(language_code), cur_val);
+}