1 | /* For use with Bidi Reference Implementation |
2 | For more information see the associated file bidi-std.c |
3 | |
4 | Credits: |
5 | ------- |
6 | Written by: Asmus Freytag |
7 | Command line interface by: Rick McGowan |
8 | Verification (v24): Doug Felt |
9 | |
10 | Disclaimer and legal rights: |
11 | --------------------------- |
12 | Copyright (C) 1999-2009, ASMUS, Inc. All Rights Reserved. |
13 | Distributed under the Terms of Use in http://www.unicode.org/copyright.html. |
14 | |
15 | THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
16 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. |
18 | IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE |
19 | BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, |
20 | OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, |
21 | WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, |
22 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE SOFTWARE. |
23 | */ |
24 | |
25 | /* Bidirectional Character Types |
26 | * as defined by the Unicode Bidirectional Algorithm Table 3-7. |
27 | * The list of bidirectional character types here is not grouped the |
28 | * same way as the table 3-7, since the numeric values for the types |
29 | * are chosen to keep the state and action tables compact. |
30 | */ |
31 | enum |
32 | { |
33 | /* input types */ |
34 | /* ON MUST be zero, code relies on ON = N = 0 */ |
35 | BDI_ON = 0, /* Other Neutral */ |
36 | BDI_L, /* Left-to-right Letter */ |
37 | BDI_R, /* Right-to-left Letter */ |
38 | BDI_AN, /* Arabic Number */ |
39 | BDI_EN, /* European Number */ |
40 | BDI_AL, /* Arabic Letter (Right-to-left) */ |
41 | BDI_NSM, /* Non-spacing Mark */ |
42 | BDI_CS, /* Common Separator */ |
43 | BDI_ES, /* European Separator */ |
44 | BDI_ET, /* European Terminator (post/prefix e.g. $ and %) */ |
45 | |
46 | /* resolved types */ |
47 | BDI_BN, /* Boundary neutral (type of RLE etc after explicit levels)*/ |
48 | |
49 | /* input types, */ |
50 | BDI_S, /* Segment Separator (TAB) used only in L1 */ |
51 | BDI_WS, /* White space used only in L1 */ |
52 | BDI_B, /* Paragraph Separator (aka as PS) */ |
53 | |
54 | /* types for explicit controls */ |
55 | BDI_RLO, /* these are used only in X1-X9 */ |
56 | BDI_RLE, |
57 | BDI_LRO, |
58 | BDI_LRE, |
59 | BDI_PDF, |
60 | |
61 | /* resolved types, also resolved directions */ |
62 | BDI_N = BDI_ON /* alias, where ON, WS and S are treated the same */ |
63 | }; |
64 | |
65 | typedef int fz_bidi_level; /* Note: Max level is 125 */ |
66 | typedef uint8_t fz_bidi_chartype; |
67 | |
68 | enum |
69 | { |
70 | BIDI_LEVEL_MAX = 125 /* Updated for 6.3.0 */ |
71 | }; |
72 | |
73 | void fz_bidi_resolve_neutrals(fz_bidi_level baselevel, fz_bidi_chartype *pcls, const fz_bidi_level *plevel, size_t cch); |
74 | void fz_bidi_resolve_implicit(const fz_bidi_chartype *pcls, fz_bidi_level *plevel, size_t cch); |
75 | void fz_bidi_resolve_weak(fz_context *ctx, fz_bidi_level baselevel, fz_bidi_chartype *pcls, fz_bidi_level *plevel, size_t cch); |
76 | void fz_bidi_resolve_whitespace(fz_bidi_level baselevel, const fz_bidi_chartype *pcls, fz_bidi_level *plevel, size_t cch); |
77 | size_t fz_bidi_resolve_explicit(fz_bidi_level level, fz_bidi_chartype dir, fz_bidi_chartype *pcls, fz_bidi_level *plevel, size_t cch, fz_bidi_level nNest); |
78 | int fz_bidi_resolve_paragraphs(fz_bidi_chartype *types, int cch); |
79 | |