OLD | NEW |
| (Empty) |
1 /* Hyphen - hyphenation library using converted TeX hyphenation patterns | |
2 * | |
3 * (C) 1998 Raph Levien | |
4 * (C) 2001 ALTLinux, Moscow | |
5 * (C) 2006, 2007, 2008 László Németh | |
6 * | |
7 * This was part of libHnj library by Raph Levien. | |
8 * | |
9 * Peter Novodvorsky from ALTLinux cut hyphenation part from libHnj | |
10 * to use it in OpenOffice.org. | |
11 * | |
12 * Non-standard and compound word hyphenation support by László Németh. | |
13 * | |
14 * License is the original LibHnj license: | |
15 * | |
16 * LibHnj is dual licensed under LGPL and MPL. Boilerplate for both | |
17 * licenses follows. | |
18 */ | |
19 | |
20 /* LibHnj - a library for high quality hyphenation and justification | |
21 * Copyright (C) 1998 Raph Levien | |
22 * | |
23 * This library is free software; you can redistribute it and/or | |
24 * modify it under the terms of the GNU Library General Public | |
25 * License as published by the Free Software Foundation; either | |
26 * version 2 of the License, or (at your option) any later version. | |
27 * | |
28 * This library is distributed in the hope that it will be useful, | |
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
31 * Library General Public License for more details. | |
32 * | |
33 * You should have received a copy of the GNU Library General Public | |
34 * License along with this library; if not, write to the | |
35 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
36 * Boston, MA 02111-1307 USA. | |
37 */ | |
38 | |
39 /* | |
40 * The contents of this file are subject to the Mozilla Public License | |
41 * Version 1.0 (the "MPL"); you may not use this file except in | |
42 * compliance with the MPL. You may obtain a copy of the MPL at | |
43 * http://www.mozilla.org/MPL/ | |
44 * | |
45 * Software distributed under the MPL is distributed on an "AS IS" basis, | |
46 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the MPL | |
47 * for the specific language governing rights and limitations under the | |
48 * MPL. | |
49 * | |
50 */ | |
51 #ifndef __HYPHEN_H__ | |
52 #define __HYPHEN_H__ | |
53 | |
54 #ifdef __cplusplus | |
55 extern "C" { | |
56 #endif /* __cplusplus */ | |
57 | |
58 typedef struct _HyphenDict HyphenDict; | |
59 typedef struct _HyphenState HyphenState; | |
60 typedef struct _HyphenTrans HyphenTrans; | |
61 #define MAX_CHARS 100 | |
62 #define MAX_NAME 20 | |
63 | |
64 struct _HyphenDict { | |
65 /* user options */ | |
66 char lhmin; /* lefthyphenmin: min. hyph. distance from the left side */ | |
67 char rhmin; /* righthyphenmin: min. hyph. distance from the right side */ | |
68 char clhmin; /* min. hyph. distance from the left compound boundary */ | |
69 char crhmin; /* min. hyph. distance from the right compound boundary */ | |
70 /* system variables */ | |
71 int num_states; | |
72 char cset[MAX_NAME]; | |
73 int utf8; | |
74 HyphenState *states; | |
75 HyphenDict *nextlevel; | |
76 }; | |
77 | |
78 struct _HyphenState { | |
79 char *match; | |
80 char *repl; | |
81 signed char replindex; | |
82 signed char replcut; | |
83 int fallback_state; | |
84 int num_trans; | |
85 HyphenTrans *trans; | |
86 }; | |
87 | |
88 struct _HyphenTrans { | |
89 char ch; | |
90 int new_state; | |
91 }; | |
92 | |
93 #if 0 | |
94 /* DO NOT USE, there are known problems with Unicode on Windows. */ | |
95 HyphenDict *hnj_hyphen_load (const char *fn); | |
96 #endif | |
97 HyphenDict *hnj_hyphen_load_file (FILE *f); | |
98 void hnj_hyphen_free (HyphenDict *dict); | |
99 | |
100 /* obsolete, use hnj_hyphen_hyphenate2() or *hyphenate3() functions) */ | |
101 int hnj_hyphen_hyphenate (HyphenDict *dict, | |
102 const char *word, int word_size, | |
103 char *hyphens); | |
104 | |
105 /* | |
106 | |
107 int hnj_hyphen_hyphenate2(): non-standard hyphenation. | |
108 | |
109 (It supports Catalan, Dutch, German, Hungarian, Norwegian, Swedish | |
110 etc. orthography, see documentation.) | |
111 | |
112 input data: | |
113 word: input word | |
114 word_size: byte length of the input word | |
115 | |
116 hyphens: allocated character buffer (size = word_size + 5) | |
117 hyphenated_word: allocated character buffer (size ~ word_size * 2) or NULL | |
118 rep, pos, cut: pointers (point to the allocated and _zeroed_ buffers | |
119 (size=word_size) or with NULL value) or NULL | |
120 | |
121 output data: | |
122 hyphens: hyphenation vector (hyphenation points signed with odd numbers) | |
123 hyphenated_word: hyphenated input word (hyphens signed with `='), | |
124 optional (NULL input) | |
125 rep: NULL (only standard hyph.), or replacements (hyphenation points | |
126 signed with `=' in replacements); | |
127 pos: NULL, or difference of the actual position and the beginning | |
128 positions of the change in input words; | |
129 cut: NULL, or counts of the removed characters of the original words | |
130 at hyphenation, | |
131 | |
132 Note: rep, pos, cut are complementary arrays to the hyphens, indexed with the | |
133 character positions of the input word. | |
134 | |
135 For example: | |
136 Schiffahrt -> Schiff=fahrt, | |
137 pattern: f1f/ff=f,1,2 | |
138 output: rep[5]="ff=f", pos[5] = 1, cut[5] = 2 | |
139 | |
140 Note: hnj_hyphen_hyphenate2() can allocate rep, pos, cut (word_size | |
141 length arrays): | |
142 | |
143 char ** rep = NULL; | |
144 int * pos = NULL; | |
145 int * cut = NULL; | |
146 char hyphens[MAXWORDLEN]; | |
147 hnj_hyphen_hyphenate2(dict, "example", 7, hyphens, NULL, &rep, &pos, &cut); | |
148 | |
149 See example in the source distribution. | |
150 | |
151 */ | |
152 | |
153 int hnj_hyphen_hyphenate2 (HyphenDict *dict, | |
154 const char *word, int word_size, char * hyphens, | |
155 char *hyphenated_word, char *** rep, int ** pos, int ** cut); | |
156 | |
157 /* like hnj_hyphen_hyphenate2, but with hyphenmin parameters */ | |
158 /* lhmin: lefthyphenmin | |
159 * rhmin: righthyphenmin | |
160 * clhmin: compoundlefthyphemin | |
161 * crhmin: compoundrighthyphenmin | |
162 * (see documentation) */ | |
163 | |
164 int hnj_hyphen_hyphenate3 (HyphenDict *dict, | |
165 const char *word, int word_size, char * hyphens, | |
166 char *hyphword, char *** rep, int ** pos, int ** cut, | |
167 int lhmin, int rhmin, int clhmin, int crhmin); | |
168 | |
169 #ifdef __cplusplus | |
170 } | |
171 #endif /* __cplusplus */ | |
172 | |
173 #endif /* __HYPHEN_H__ */ | |
OLD | NEW |