1 module pango.bidi_type;
2 
3 import pango.utils;
4 import pango.c.bidi_type;
5 
6 import glib;
7 
8 /**
9  * PangoBidiType:
10  * L: Left-to-Right
11  * LRE: Left-to-Right Embedding
12  * LRO: Left-to-Right Override
13  * R: Right-to-Left
14  * AL: Right-to-Left Arabic
15  * RLE: Right-to-Left Embedding
16  * RLO: Right-to-Left Override
17  * PDF: Pop Directional Format
18  * EN: European Number
19  * ES: European Number Separator
20  * ET: European Number Terminator
21  * AN: Arabic Number
22  * CS: Common Number Separator
23  * NSM: Nonspacing Mark
24  * BN: Boundary Neutral
25  * B: Paragraph Separator
26  * S: Segment Separator
27  * WS: Whitespace
28  * ON: Other Neutrals
29  *
30  * The #PangoBidiType type represents the bidirectional character
31  * type of a Unicode character as specified by the
32  * <ulink url="http://www.unicode.org/reports/tr9/">Unicode bidirectional algorithm</ulink>.
33  *
34  * Since: 1.22
35  **/
36 enum BidiType {
37   /* Strong types */
38   L     = PangoBidiType.PANGO_BIDI_TYPE_L,
39   LRE   = PangoBidiType.PANGO_BIDI_TYPE_LRE,
40   LRO   = PangoBidiType.PANGO_BIDI_TYPE_LRO,
41   R     = PangoBidiType.PANGO_BIDI_TYPE_R,
42   AL    = PangoBidiType.PANGO_BIDI_TYPE_AL,
43   RLE   = PangoBidiType.PANGO_BIDI_TYPE_RLE,
44   RLO   = PangoBidiType.PANGO_BIDI_TYPE_RLO,
45 
46   /* Weak types */
47   PDF   = PangoBidiType.PANGO_BIDI_TYPE_PDF,
48   EN    = PangoBidiType.PANGO_BIDI_TYPE_EN,
49   ES    = PangoBidiType.PANGO_BIDI_TYPE_ES,
50   ET    = PangoBidiType.PANGO_BIDI_TYPE_ET,
51   AN    = PangoBidiType.PANGO_BIDI_TYPE_AN,
52   CS    = PangoBidiType.PANGO_BIDI_TYPE_CS,
53   NSM   = PangoBidiType.PANGO_BIDI_TYPE_NSM,
54   BN    = PangoBidiType.PANGO_BIDI_TYPE_BN,
55 
56   /* Neutral types */
57   B     = PangoBidiType.PANGO_BIDI_TYPE_B,
58   S     = PangoBidiType.PANGO_BIDI_TYPE_S,
59   WS    = PangoBidiType.PANGO_BIDI_TYPE_WS,
60   ON    = PangoBidiType.PANGO_BIDI_TYPE_ON
61 }
62 
63 
64 pure BidiType bidiTypeForUnichar(dchar ch)
65 {
66     return cast(BidiType)pango_bidi_type_for_unichar(ch);
67 }
68 
69 /**
70  * PangoDirection:
71  * LTR: A strong left-to-right direction
72  * RTL: A strong right-to-left direction
73  * TTB_LTR: Deprecated value; treated the
74  *   same as %PANGO_DIRECTION_RTL.
75  * TTB_RTL: Deprecated value; treated the
76  *   same as %PANGO_DIRECTION_LTR
77  * Weak_LTR: A weak left-to-right direction
78  * Weak_RTL: A weak right-to-left direction
79  * Neutral: No direction specified
80  *
81  * The #PangoDirection type represents a direction in the
82  * Unicode bidirectional algorithm; not every value in this
83  * enumeration makes sense for every usage of #PangoDirection;
84  * for example, the return value of pango_unichar_direction()
85  * and pango_find_base_dir() cannot be %PANGO_DIRECTION_WEAK_LTR
86  * or %PANGO_DIRECTION_WEAK_RTL, since every character is either
87  * neutral or has a strong direction; on the other hand
88  * %PANGO_DIRECTION_NEUTRAL doesn't make sense to pass
89  * to pango_itemize_with_base_dir().
90  *
91  * The %PANGO_DIRECTION_TTB_LTR, %PANGO_DIRECTION_TTB_RTL
92  * values come from an earlier interpretation of this
93  * enumeration as the writing direction of a block of
94  * text and are no longer used; See #PangoGravity for how
95  * vertical text is handled in Pango.
96  **/
97 enum Direction {
98   LTR       = PangoDirection.PANGO_DIRECTION_LTR,
99   RTL       = PangoDirection.PANGO_DIRECTION_RTL,
100   TTB_LTR   = PangoDirection.PANGO_DIRECTION_TTB_LTR,
101   TTB_RTL   = PangoDirection.PANGO_DIRECTION_TTB_RTL,
102   Weak_LTR  = PangoDirection.PANGO_DIRECTION_WEAK_LTR,
103   Weak_RTL  = PangoDirection.PANGO_DIRECTION_WEAK_RTL,
104   Neutral   = PangoDirection.PANGO_DIRECTION_NEUTRAL
105 }
106 
107 pure Direction unicharDirection(dchar ch) {
108     return cast(Direction)pango_unichar_direction(ch);
109 }
110 
111 Direction findBaseDir(string text) {
112     return cast(Direction)pango_find_base_dir(text.ptr, cast(int)text.length);
113 }
114 
115 
116 //deprecated("use g_unichar_get_mirror_char")
117 //gboolean       pango_get_mirror_char        (gunichar     ch,
118 //                         gunichar    *mirrored_ch);
119