2010-01-06 19:37:16 +00:00
|
|
|
/*
|
|
|
|
* GRUB -- GRand Unified Bootloader
|
|
|
|
* Copyright (C) 2010 Free Software Foundation, Inc.
|
|
|
|
*
|
|
|
|
* GRUB is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* GRUB is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GRUB_BIDI_HEADER
|
|
|
|
#define GRUB_BIDI_HEADER 1
|
|
|
|
|
|
|
|
#include <grub/types.h>
|
2010-03-15 21:12:34 +00:00
|
|
|
#include <grub/mm.h>
|
|
|
|
#include <grub/misc.h>
|
2010-01-06 19:37:16 +00:00
|
|
|
|
2010-03-16 20:57:34 +00:00
|
|
|
struct grub_unicode_bidi_pair
|
|
|
|
{
|
|
|
|
grub_uint32_t key;
|
|
|
|
grub_uint32_t replace;
|
|
|
|
};
|
|
|
|
|
2010-01-07 15:37:53 +00:00
|
|
|
struct grub_unicode_compact_range
|
2010-01-06 19:37:16 +00:00
|
|
|
{
|
2010-01-07 15:37:53 +00:00
|
|
|
grub_uint32_t start:21;
|
|
|
|
grub_uint32_t end:21;
|
|
|
|
grub_uint8_t bidi_type:5;
|
|
|
|
grub_uint8_t comb_type;
|
2010-01-07 20:25:56 +00:00
|
|
|
grub_uint8_t bidi_mirror:1;
|
2010-01-06 19:37:16 +00:00
|
|
|
} __attribute__ ((packed));
|
|
|
|
|
|
|
|
enum grub_bidi_type
|
|
|
|
{
|
|
|
|
GRUB_BIDI_TYPE_L = 0,
|
|
|
|
GRUB_BIDI_TYPE_LRE,
|
|
|
|
GRUB_BIDI_TYPE_LRO,
|
|
|
|
GRUB_BIDI_TYPE_R,
|
|
|
|
GRUB_BIDI_TYPE_AL,
|
|
|
|
GRUB_BIDI_TYPE_RLE,
|
|
|
|
GRUB_BIDI_TYPE_RLO,
|
|
|
|
GRUB_BIDI_TYPE_PDF,
|
|
|
|
GRUB_BIDI_TYPE_EN,
|
|
|
|
GRUB_BIDI_TYPE_ES,
|
|
|
|
GRUB_BIDI_TYPE_ET,
|
|
|
|
GRUB_BIDI_TYPE_AN,
|
|
|
|
GRUB_BIDI_TYPE_CS,
|
|
|
|
GRUB_BIDI_TYPE_NSM,
|
|
|
|
GRUB_BIDI_TYPE_BN,
|
|
|
|
GRUB_BIDI_TYPE_B,
|
|
|
|
GRUB_BIDI_TYPE_S,
|
|
|
|
GRUB_BIDI_TYPE_WS,
|
|
|
|
GRUB_BIDI_TYPE_ON
|
|
|
|
};
|
|
|
|
|
2010-01-07 15:37:53 +00:00
|
|
|
enum grub_comb_type
|
|
|
|
{
|
2010-03-15 20:14:11 +00:00
|
|
|
GRUB_UNICODE_COMB_NONE = 0,
|
2010-01-07 23:46:42 +00:00
|
|
|
GRUB_UNICODE_COMB_OVERLAY = 1,
|
|
|
|
GRUB_UNICODE_STACK_ATTACHED_BELOW = 202,
|
|
|
|
GRUB_UNICODE_STACK_ATTACHED_ABOVE = 214,
|
2010-01-08 17:48:41 +00:00
|
|
|
GRUB_UNICODE_COMB_ATTACHED_ABOVE_RIGHT = 216,
|
2010-01-07 15:37:53 +00:00
|
|
|
GRUB_UNICODE_STACK_BELOW = 220,
|
|
|
|
GRUB_UNICODE_STACK_ABOVE = 230,
|
2010-01-08 17:48:41 +00:00
|
|
|
GRUB_UNICODE_COMB_ABOVE_RIGHT = 232,
|
2010-02-08 00:44:06 +00:00
|
|
|
GRUB_UNICODE_COMB_YPOGEGRAMMENI = 240,
|
2010-01-07 15:37:53 +00:00
|
|
|
/* If combining nature is indicated only by class and
|
|
|
|
not "combining type". */
|
|
|
|
GRUB_UNICODE_COMB_ME = 253,
|
|
|
|
GRUB_UNICODE_COMB_MC = 254,
|
|
|
|
GRUB_UNICODE_COMB_MN = 255,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* This structure describes a glyph as opposed to character. */
|
|
|
|
struct grub_unicode_glyph
|
|
|
|
{
|
|
|
|
grub_uint32_t base;
|
2010-01-07 20:25:56 +00:00
|
|
|
grub_uint16_t variant:9;
|
|
|
|
grub_uint8_t attributes:1;
|
2010-01-07 15:37:53 +00:00
|
|
|
grub_size_t ncomb;
|
2010-03-15 21:12:34 +00:00
|
|
|
struct grub_unicode_combining {
|
|
|
|
grub_uint32_t code;
|
|
|
|
enum grub_comb_type type;
|
|
|
|
} *combining;
|
2010-03-16 18:55:09 +00:00
|
|
|
/* Hint by unicode subsystem how wide this character usually is.
|
|
|
|
Real width is determined by font. Set only in UTF-8 stream. */
|
|
|
|
int estimated_width;
|
2010-01-07 15:37:53 +00:00
|
|
|
};
|
|
|
|
|
2010-01-07 20:25:56 +00:00
|
|
|
#define GRUB_UNICODE_GLYPH_ATTRIBUTE_MIRROR 0x1
|
2010-02-08 01:01:10 +00:00
|
|
|
#define GRUB_UNICODE_COMBINING_GRAPHEME_JOINER 0x34f
|
2010-01-07 15:37:53 +00:00
|
|
|
#define GRUB_UNICODE_VARIATION_SELECTOR_1 0xfe00
|
|
|
|
#define GRUB_UNICODE_VARIATION_SELECTOR_16 0xfe0f
|
|
|
|
#define GRUB_UNICODE_VARIATION_SELECTOR_17 0xe0100
|
|
|
|
#define GRUB_UNICODE_VARIATION_SELECTOR_256 0xe01ef
|
|
|
|
|
|
|
|
extern struct grub_unicode_compact_range grub_unicode_compact[];
|
2010-03-16 20:57:34 +00:00
|
|
|
extern struct grub_unicode_bidi_pair grub_unicode_bidi_pairs[];
|
2010-01-06 19:37:16 +00:00
|
|
|
|
2010-01-07 15:37:53 +00:00
|
|
|
#define GRUB_UNICODE_MAX_CACHED_CHAR 0x20000
|
2010-01-06 19:37:16 +00:00
|
|
|
/* Unicode mandates an arbitrary limit. */
|
|
|
|
#define GRUB_BIDI_MAX_EXPLICIT_LEVEL 61
|
|
|
|
|
2010-03-15 20:14:11 +00:00
|
|
|
grub_ssize_t
|
|
|
|
grub_bidi_logical_to_visual (const grub_uint32_t *logical,
|
|
|
|
grub_size_t logical_len,
|
|
|
|
struct grub_unicode_glyph **visual_out,
|
|
|
|
grub_ssize_t (*getcharwidth) (const struct grub_unicode_glyph *visual),
|
2010-03-16 09:55:06 +00:00
|
|
|
grub_size_t max_width,
|
|
|
|
grub_size_t start_width);
|
2010-03-15 20:14:11 +00:00
|
|
|
|
|
|
|
enum grub_comb_type
|
|
|
|
grub_unicode_get_comb_type (grub_uint32_t c);
|
|
|
|
grub_size_t
|
|
|
|
grub_unicode_aglomerate_comb (const grub_uint32_t *in, grub_size_t inlen,
|
|
|
|
struct grub_unicode_glyph *out);
|
2010-03-15 21:12:34 +00:00
|
|
|
|
|
|
|
static inline struct grub_unicode_glyph *
|
|
|
|
grub_unicode_glyph_dup (const struct grub_unicode_glyph *in)
|
|
|
|
{
|
|
|
|
struct grub_unicode_glyph *out = grub_malloc (sizeof (*out));
|
|
|
|
if (!out)
|
|
|
|
return NULL;
|
|
|
|
grub_memcpy (out, in, sizeof (*in));
|
2010-03-16 22:03:08 +00:00
|
|
|
if (in->combining)
|
2010-03-15 21:12:34 +00:00
|
|
|
{
|
2010-03-16 22:03:08 +00:00
|
|
|
out->combining = grub_malloc (in->ncomb * sizeof (*in));
|
|
|
|
if (!out->combining)
|
|
|
|
{
|
|
|
|
grub_free (out);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
grub_memcpy (out->combining, in->combining, in->ncomb * sizeof (*in));
|
2010-03-15 21:12:34 +00:00
|
|
|
}
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct grub_unicode_glyph *
|
|
|
|
grub_unicode_glyph_from_code (grub_uint32_t code)
|
|
|
|
{
|
|
|
|
struct grub_unicode_glyph *ret;
|
2010-03-16 18:55:09 +00:00
|
|
|
ret = grub_zalloc (sizeof (*ret));
|
2010-03-15 21:12:34 +00:00
|
|
|
if (!ret)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
ret->base = code;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2010-03-15 20:14:11 +00:00
|
|
|
|
2010-01-06 19:37:16 +00:00
|
|
|
#endif
|