texlanguage.h /size: 4060 b    last modification: 2025-02-21 11:03
1/*
2    See license.txt in the root of this project.
3*/
4
5# ifndef LMT_TEXLANG_H
6# define LMT_TEXLANG_H
7
8/*tex We resolve the properties beforehand and store them in a struct. */
9
10typedef struct language_state_info {
11    struct tex_language **languages;
12    memory_data           language_data;
13    lua_Integer           handler_table_id;
14    int                   handler_count;
15    int                   list_count; 
16    int                   word_count; 
17    int                   checked_count;
18    int                   exceptions_count;
19    int                   hyphenated_count;
20    int                   nothing_count;
21    /*tex We keep thse in the heap instead of on stack: */
22    unsigned char         shared_word_buffer[max_size_of_word_buffer];  /*tex Work buffer for bytes (can be \UTF8): */
23    unsigned              shared_uword_buffer[max_size_of_word_buffer]; /*tex Work buffer for \UNICODE\ (often too large): */
24} language_state_info;
25
26extern language_state_info lmt_language_state;
27
28typedef struct language_variables {
29    halfword pre_hyphen_char;
30    halfword post_hyphen_char;
31    halfword pre_exhyphen_char;
32    halfword post_exhyphen_char;
33} language_variables;
34
35/*tex This is used in: */
36
37typedef struct tex_language {
38    halfword        pre_hyphen_char;
39    halfword        post_hyphen_char;
40    halfword        pre_exhyphen_char;
41    halfword        post_exhyphen_char;
42    halfword        hyphenation_min;
43    halfword        id;
44    hjn_dictionary *patterns;
45    int             exceptions;
46    int             wordhandler;
47    sa_tree         hjcode_head;
48} tex_language;
49
50extern tex_language *tex_new_language           (halfword n);
51extern tex_language *tex_get_language           (halfword n);
52/*     void          tex_free_languages         (void); */
53
54extern void          tex_load_patterns          (struct tex_language *lang, const unsigned char *buf);
55extern void          tex_load_hyphenation       (struct tex_language *lang, const unsigned char *buf);
56
57extern void          tex_handle_hyphenation     (halfword h, halfword t);
58extern void          tex_clear_patterns         (struct tex_language *lang);
59extern void          tex_clear_hyphenation      (struct tex_language *lang);
60extern const char   *tex_clean_hyphenation      (halfword id, const char *buffer, char **cleaned);
61
62extern void          tex_hyphenate_list         (halfword head, halfword tail);
63extern int           tex_collapse_list          (halfword head, halfword c1, halfword c2, halfword c3, halfword c4);
64
65extern void          tex_set_pre_hyphen_char    (halfword lan, halfword val);
66extern void          tex_set_post_hyphen_char   (halfword lan, halfword val);
67extern halfword      tex_get_pre_hyphen_char    (halfword lan);
68extern halfword      tex_get_post_hyphen_char   (halfword lan);
69
70extern void          tex_set_pre_exhyphen_char  (halfword lan, halfword val);
71extern void          tex_set_post_exhyphen_char (halfword lan, halfword val);
72extern halfword      tex_get_pre_exhyphen_char  (halfword lan);
73extern halfword      tex_get_post_exhyphen_char (halfword lan);
74
75extern void          tex_set_hyphenation_min    (halfword lan, halfword val);
76extern halfword      tex_get_hyphenation_min    (halfword lan);
77
78extern void          tex_dump_language_data     (dumpstream f);
79extern void          tex_undump_language_data   (dumpstream f);
80
81/*     char         *tex_get_exception_strings  (struct tex_language *lang); */
82
83extern void          tex_load_tex_patterns      (halfword curlang, halfword head);
84extern void          tex_load_tex_hyphenation   (halfword curlang, halfword head);
85
86extern void          tex_initialize_languages   (void);
87extern int           tex_is_valid_language      (halfword n);
88
89extern halfword      tex_glyph_to_discretionary (halfword glyph, quarterword code, int keepkern);
90
91/*
92void tex_hnj_hyphen_hyphenate(
93    HyphenDict     *dict,
94    halfword        first,
95    halfword        last,
96    int             size,
97    halfword        left,
98    halfword        right,
99    lang_variables *lan
100);
101*/
102
103# endif
104