2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 2010 Free Software Foundation, Inc.
5 * GRUB is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * GRUB is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef GRUB_BIDI_HEADER
20 #define GRUB_BIDI_HEADER 1
22 #include <grub/types.h>
24 #include <grub/misc.h>
26 struct grub_unicode_compact_range
28 grub_uint32_t start
:21;
30 grub_uint8_t bidi_type
:5;
31 grub_uint8_t comb_type
;
32 grub_uint8_t bidi_mirror
:1;
33 } __attribute__ ((packed
));
60 GRUB_UNICODE_COMB_NONE
= 0,
61 GRUB_UNICODE_COMB_OVERLAY
= 1,
62 GRUB_UNICODE_STACK_ATTACHED_BELOW
= 202,
63 GRUB_UNICODE_STACK_ATTACHED_ABOVE
= 214,
64 GRUB_UNICODE_COMB_ATTACHED_ABOVE_RIGHT
= 216,
65 GRUB_UNICODE_STACK_BELOW
= 220,
66 GRUB_UNICODE_STACK_ABOVE
= 230,
67 GRUB_UNICODE_COMB_ABOVE_RIGHT
= 232,
68 GRUB_UNICODE_COMB_YPOGEGRAMMENI
= 240,
69 /* If combining nature is indicated only by class and
70 not "combining type". */
71 GRUB_UNICODE_COMB_ME
= 253,
72 GRUB_UNICODE_COMB_MC
= 254,
73 GRUB_UNICODE_COMB_MN
= 255,
76 /* This structure describes a glyph as opposed to character. */
77 struct grub_unicode_glyph
80 grub_uint16_t variant
:9;
81 grub_uint8_t attributes
:1;
83 struct grub_unicode_combining
{
85 enum grub_comb_type type
;
89 #define GRUB_UNICODE_GLYPH_ATTRIBUTE_MIRROR 0x1
90 #define GRUB_UNICODE_COMBINING_GRAPHEME_JOINER 0x34f
91 #define GRUB_UNICODE_VARIATION_SELECTOR_1 0xfe00
92 #define GRUB_UNICODE_VARIATION_SELECTOR_16 0xfe0f
93 #define GRUB_UNICODE_VARIATION_SELECTOR_17 0xe0100
94 #define GRUB_UNICODE_VARIATION_SELECTOR_256 0xe01ef
96 extern struct grub_unicode_compact_range grub_unicode_compact
[];
98 #define GRUB_UNICODE_MAX_CACHED_CHAR 0x20000
99 /* Unicode mandates an arbitrary limit. */
100 #define GRUB_BIDI_MAX_EXPLICIT_LEVEL 61
103 grub_bidi_logical_to_visual (const grub_uint32_t
*logical
,
104 grub_size_t logical_len
,
105 struct grub_unicode_glyph
**visual_out
,
106 grub_ssize_t (*getcharwidth
) (const struct grub_unicode_glyph
*visual
),
107 grub_size_t max_width
,
108 grub_size_t start_width
);
111 grub_unicode_get_comb_type (grub_uint32_t c
);
113 grub_unicode_aglomerate_comb (const grub_uint32_t
*in
, grub_size_t inlen
,
114 struct grub_unicode_glyph
*out
);
116 static inline struct grub_unicode_glyph
*
117 grub_unicode_glyph_dup (const struct grub_unicode_glyph
*in
)
119 struct grub_unicode_glyph
*out
= grub_malloc (sizeof (*out
));
122 grub_memcpy (out
, in
, sizeof (*in
));
123 out
->combining
= grub_malloc (in
->ncomb
* sizeof (*in
));
129 grub_memcpy (out
->combining
, in
->combining
, in
->ncomb
* sizeof (*in
));
133 static inline struct grub_unicode_glyph
*
134 grub_unicode_glyph_from_code (grub_uint32_t code
)
136 struct grub_unicode_glyph
*ret
;
137 ret
= grub_malloc (sizeof (*ret
));