comparison mupdf-source/include/mupdf/fitz/bidi.h @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
1 /**
2 Bidirectional text processing.
3
4 Derived from the SmartOffice code, which is itself derived
5 from the example unicode standard code. Original copyright
6 messages follow:
7
8 Copyright (C) Picsel, 2004-2008. All Rights Reserved.
9
10 Processes Unicode text by arranging the characters into an order
11 suitable for display. E.g. Hebrew text will be arranged from
12 right-to-left and any English within the text will remain in the
13 left-to-right order.
14
15 This is an implementation of the Unicode Bidirectional Algorithm
16 which can be found here: http://www.unicode.org/reports/tr9/ and
17 is based on the reference implementation found on Unicode.org.
18 */
19
20 #ifndef FITZ_BIDI_H
21 #define FITZ_BIDI_H
22
23 #include "mupdf/fitz/system.h"
24 #include "mupdf/fitz/context.h"
25
26 /* Implementation details: subject to change. */
27
28 typedef enum
29 {
30 FZ_BIDI_LTR = 0,
31 FZ_BIDI_RTL = 1,
32 FZ_BIDI_NEUTRAL = 2
33 }
34 fz_bidi_direction;
35
36 typedef enum
37 {
38 FZ_BIDI_CLASSIFY_WHITE_SPACE = 1,
39 FZ_BIDI_REPLACE_TAB = 2
40 }
41 fz_bidi_flags;
42
43 /**
44 Prototype for callback function supplied to fz_bidi_fragment_text.
45
46 @param fragment first character in fragment
47 @param fragmentLen number of characters in fragment
48 @param bidiLevel The bidirectional level for this text.
49 The bottom bit will be set iff block
50 should concatenate with other blocks as
51 right-to-left
52 @param script the script in use for this fragment (other
53 than common or inherited)
54 @param arg data from caller of Bidi_fragmentText
55 */
56 typedef void (fz_bidi_fragment_fn)(const uint32_t *fragment,
57 size_t fragmentLen,
58 int bidiLevel,
59 int script,
60 void *arg);
61
62 /**
63 Partitions the given Unicode sequence into one or more
64 unidirectional fragments and invokes the given callback
65 function for each fragment.
66
67 For example, if directionality of text is:
68 0123456789
69 rrlllrrrrr,
70 we'll invoke callback with:
71 &text[0], length == 2
72 &text[2], length == 3
73 &text[5], length == 5
74
75 @param[in] text start of Unicode sequence
76 @param[in] textlen number of Unicodes to analyse
77 @param[in] baseDir direction of paragraph (specify FZ_BIDI_NEUTRAL to force auto-detection)
78 @param[in] callback function to be called for each fragment
79 @param[in] arg data to be passed to the callback function
80 @param[in] flags flags to control operation (see fz_bidi_flags above)
81 */
82 void fz_bidi_fragment_text(fz_context *ctx,
83 const uint32_t *text,
84 size_t textlen,
85 fz_bidi_direction *baseDir,
86 fz_bidi_fragment_fn *callback,
87 void *arg,
88 int flags);
89
90 #endif