1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/hyphenation/src/hyphen.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,172 @@ 1.4 +/* Hyphen - hyphenation library using converted TeX hyphenation patterns 1.5 + * 1.6 + * (C) 1998 Raph Levien 1.7 + * (C) 2001 ALTLinux, Moscow 1.8 + * (C) 2006, 2007, 2008 László Németh 1.9 + * 1.10 + * This was part of libHnj library by Raph Levien. 1.11 + * 1.12 + * Peter Novodvorsky from ALTLinux cut hyphenation part from libHnj 1.13 + * to use it in OpenOffice.org. 1.14 + * 1.15 + * Non-standard and compound word hyphenation support by László Németh. 1.16 + * 1.17 + * License is the original LibHnj license: 1.18 + * 1.19 + * LibHnj is dual licensed under LGPL and MPL. Boilerplate for both 1.20 + * licenses follows. 1.21 + */ 1.22 + 1.23 +/* LibHnj - a library for high quality hyphenation and justification 1.24 + * Copyright (C) 1998 Raph Levien 1.25 + * 1.26 + * This library is free software; you can redistribute it and/or 1.27 + * modify it under the terms of the GNU Library General Public 1.28 + * License as published by the Free Software Foundation; either 1.29 + * version 2 of the License, or (at your option) any later version. 1.30 + * 1.31 + * This library is distributed in the hope that it will be useful, 1.32 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 1.33 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1.34 + * Library General Public License for more details. 1.35 + * 1.36 + * You should have received a copy of the GNU Library General Public 1.37 + * License along with this library; if not, write to the 1.38 + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 1.39 + * Boston, MA 02111-1307 USA. 1.40 +*/ 1.41 + 1.42 +/* 1.43 + * The contents of this file are subject to the Mozilla Public License 1.44 + * Version 1.0 (the "MPL"); you may not use this file except in 1.45 + * compliance with the MPL. You may obtain a copy of the MPL at 1.46 + * http://www.mozilla.org/MPL/ 1.47 + * 1.48 + * Software distributed under the MPL is distributed on an "AS IS" basis, 1.49 + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the MPL 1.50 + * for the specific language governing rights and limitations under the 1.51 + * MPL. 1.52 + * 1.53 + */ 1.54 +#ifndef __HYPHEN_H__ 1.55 +#define __HYPHEN_H__ 1.56 + 1.57 +#ifdef __cplusplus 1.58 +extern "C" { 1.59 +#endif /* __cplusplus */ 1.60 + 1.61 +typedef struct _HyphenDict HyphenDict; 1.62 +typedef struct _HyphenState HyphenState; 1.63 +typedef struct _HyphenTrans HyphenTrans; 1.64 +#define MAX_CHARS 100 1.65 +#define MAX_NAME 20 1.66 + 1.67 +struct _HyphenDict { 1.68 + /* user options */ 1.69 + char lhmin; /* lefthyphenmin: min. hyph. distance from the left side */ 1.70 + char rhmin; /* righthyphenmin: min. hyph. distance from the right side */ 1.71 + char clhmin; /* min. hyph. distance from the left compound boundary */ 1.72 + char crhmin; /* min. hyph. distance from the right compound boundary */ 1.73 + char * nohyphen; /* comma separated list of characters or character 1.74 + sequences with forbidden hyphenation */ 1.75 + int nohyphenl; /* count of elements in nohyphen */ 1.76 + /* system variables */ 1.77 + int num_states; 1.78 + char cset[MAX_NAME]; 1.79 + int utf8; 1.80 + HyphenState *states; 1.81 + HyphenDict *nextlevel; 1.82 +}; 1.83 + 1.84 +struct _HyphenState { 1.85 + char *match; 1.86 + char *repl; 1.87 + signed char replindex; 1.88 + signed char replcut; 1.89 + int fallback_state; 1.90 + int num_trans; 1.91 + HyphenTrans *trans; 1.92 +}; 1.93 + 1.94 +struct _HyphenTrans { 1.95 + char ch; 1.96 + int new_state; 1.97 +}; 1.98 + 1.99 +HyphenDict *hnj_hyphen_load (const char *fn); 1.100 +void hnj_hyphen_free (HyphenDict *dict); 1.101 + 1.102 +/* obsolete, use hnj_hyphen_hyphenate2() or *hyphenate3() functions) */ 1.103 +int hnj_hyphen_hyphenate (HyphenDict *dict, 1.104 + const char *word, int word_size, 1.105 + char *hyphens); 1.106 + 1.107 +/* 1.108 + 1.109 + int hnj_hyphen_hyphenate2(): non-standard hyphenation. 1.110 + 1.111 + (It supports Catalan, Dutch, German, Hungarian, Norwegian, Swedish 1.112 + etc. orthography, see documentation.) 1.113 + 1.114 + input data: 1.115 + word: input word 1.116 + word_size: byte length of the input word 1.117 + 1.118 + hyphens: allocated character buffer (size = word_size + 5) 1.119 + hyphenated_word: allocated character buffer (size ~ word_size * 2) or NULL 1.120 + rep, pos, cut: pointers (point to the allocated and _zeroed_ buffers 1.121 + (size=word_size) or with NULL value) or NULL 1.122 + 1.123 + output data: 1.124 + hyphens: hyphenation vector (hyphenation points signed with odd numbers) 1.125 + hyphenated_word: hyphenated input word (hyphens signed with `='), 1.126 + optional (NULL input) 1.127 + rep: NULL (only standard hyph.), or replacements (hyphenation points 1.128 + signed with `=' in replacements); 1.129 + pos: NULL, or difference of the actual position and the beginning 1.130 + positions of the change in input words; 1.131 + cut: NULL, or counts of the removed characters of the original words 1.132 + at hyphenation, 1.133 + 1.134 + Note: rep, pos, cut are complementary arrays to the hyphens, indexed with the 1.135 + character positions of the input word. 1.136 + 1.137 + For example: 1.138 + Schiffahrt -> Schiff=fahrt, 1.139 + pattern: f1f/ff=f,1,2 1.140 + output: rep[5]="ff=f", pos[5] = 1, cut[5] = 2 1.141 + 1.142 + Note: hnj_hyphen_hyphenate2() can allocate rep, pos, cut (word_size 1.143 + length arrays): 1.144 + 1.145 + char ** rep = NULL; 1.146 + int * pos = NULL; 1.147 + int * cut = NULL; 1.148 + char hyphens[MAXWORDLEN]; 1.149 + hnj_hyphen_hyphenate2(dict, "example", 7, hyphens, NULL, &rep, &pos, &cut); 1.150 + 1.151 + See example in the source distribution. 1.152 + 1.153 +*/ 1.154 + 1.155 +int hnj_hyphen_hyphenate2 (HyphenDict *dict, 1.156 + const char *word, int word_size, char * hyphens, 1.157 + char *hyphenated_word, char *** rep, int ** pos, int ** cut); 1.158 + 1.159 +/* like hnj_hyphen_hyphenate2, but with hyphenmin parameters */ 1.160 +/* lhmin: lefthyphenmin 1.161 + * rhmin: righthyphenmin 1.162 + * clhmin: compoundlefthyphemin 1.163 + * crhmin: compoundrighthyphenmin 1.164 + * (see documentation) */ 1.165 + 1.166 +int hnj_hyphen_hyphenate3 (HyphenDict *dict, 1.167 + const char *word, int word_size, char * hyphens, 1.168 + char *hyphword, char *** rep, int ** pos, int ** cut, 1.169 + int lhmin, int rhmin, int clhmin, int crhmin); 1.170 + 1.171 +#ifdef __cplusplus 1.172 +} 1.173 +#endif /* __cplusplus */ 1.174 + 1.175 +#endif /* __HYPHEN_H__ */