diff options
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/lang/texlang.w')
-rw-r--r-- | Build/source/texk/web2c/luatexdir/lang/texlang.w | 45 |
1 files changed, 38 insertions, 7 deletions
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); +} |