update Unicode bidi tables

This commit is contained in:
Vincent Wei
2019-03-07 17:31:15 +08:00
parent 90e4ee91fe
commit e6cb8f272b
6 changed files with 2040 additions and 473 deletions
+55 -55
View File
@@ -9666,28 +9666,29 @@ MG_EXPORT Uint32 GUIAPI GetACharType (LOGFONT* logfont, Achar32 chv);
#define BIDI_MASK_RTL 0x0001 /* Is right to left */
#define BIDI_MASK_ARABIC 0x0002 /* Is arabic */
#define BIDI_MASK_NSM 0x0004
#define BIDI_MASK_BN 0x0008
#define BIDI_MASK_FIRST 0x0004 /* Whether direction is determined by first strong */
#define BIDI_MASK_BN 0x0008 /* flag for BN */
/* Each char can be only one of the three following. */
#define BIDI_SWN_MASK 0x0030
#define BIDI_MASK_STRONG 0x0010 /* Is strong */
#define BIDI_MASK_WEAK 0x0020 /* Is weak */
#define BIDI_MASK_NEUTRAL 0x0030 /* Is neutral */
#define BIDI_MASK_STRONG 0x0000 /* Is strong */
#define BIDI_MASK_WEAK 0x0010 /* Is weak */
#define BIDI_MASK_NEUTRAL 0x0020 /* Is neutral */
#define BIDI_MASK_WS 0x0040
#define BIDI_MASK_SENTINEL 0x0080 /* Is sentinel: SOT, EOT */
/* Each char can be only one of the five following. */
/* Each char can be only one of the seven following. */
#define BIDI_TYPE_MASK 0x0F00
#define BIDI_MASK_LETTER 0x0100 /* Is letter: L, R, AL */
#define BIDI_MASK_NUMBER 0x0200 /* Is number: EN, AN */
#define BIDI_MASK_NUMSEPTER 0x0300 /* Is number separator or terminator: ES, ET, CS */
#define BIDI_MASK_SPACE 0x0400 /* Is space: BN, BS, SS, WS */
#define BIDI_MASK_EXPLICIT 0x0500 /* Is expilict mark: LRE, RLE, LRO, RLO, PDF */
#define BIDI_MASK_ISOLATE 0x0600 /* Is isolate mark: LRI, RLI, FSI, PDI */
#define BIDI_MASK_NSM 0x0700 /* Is non spacing mark: NSM */
/* Can be on only if BIDI_MASK_SPACE is also on. */
#define BIDI_MASK_SEPARATOR 0x0800 /* Is test separator: BS, SS */
#define BIDI_MASK_SEPARATOR 0x0800 /* Is separator: BS, SS */
/* Can be on only if BIDI_MASK_EXPLICIT is also on. */
#define BIDI_MASK_OVERRIDE 0x8000 /* Is explicit override: LRO, RLO */
@@ -9711,121 +9712,108 @@ MG_EXPORT Uint32 GUIAPI GetACharType (LOGFONT* logfont, Achar32 chv);
* \def BIDI_TYPE_LTR
* \brief Strong left to right
*/
#define BIDI_TYPE_LTR (BIDI_MASK_STRONG + BIDI_MASK_LETTER)
#define BIDI_TYPE_LTR (BIDI_MASK_STRONG | BIDI_MASK_LETTER)
/**
* \def BIDI_TYPE_RTL
* \brief Right to left characters
*/
#define BIDI_TYPE_RTL (BIDI_MASK_STRONG + BIDI_MASK_LETTER \
+ BIDI_MASK_RTL)
#define BIDI_TYPE_RTL (BIDI_MASK_STRONG | BIDI_MASK_LETTER | BIDI_MASK_RTL)
/**
* \def BIDI_TYPE_AL
* \brief Arabic characters
*/
#define BIDI_TYPE_AL (BIDI_MASK_STRONG + BIDI_MASK_LETTER \
+ BIDI_MASK_RTL + BIDI_MASK_ARABIC)
#define BIDI_TYPE_AL (BIDI_MASK_STRONG | BIDI_MASK_LETTER | BIDI_MASK_RTL | BIDI_MASK_ARABIC)
/**
* \def BIDI_TYPE_LRE
* \brief Left-To-Right embedding
*/
#define BIDI_TYPE_LRE (BIDI_MASK_STRONG + BIDI_MASK_EXPLICIT)
#define BIDI_TYPE_LRE (BIDI_MASK_STRONG | BIDI_MASK_EXPLICIT)
/**
* \def BIDI_TYPE_RLE
* \brief Right-To-Left embedding
*/
#define BIDI_TYPE_RLE (BIDI_MASK_STRONG + BIDI_MASK_EXPLICIT \
+ BIDI_MASK_RTL)
#define BIDI_TYPE_RLE (BIDI_MASK_STRONG | BIDI_MASK_EXPLICIT | BIDI_MASK_RTL)
/**
* \def BIDI_TYPE_LRO
* \brief Left-To-Right override
*/
#define BIDI_TYPE_LRO (BIDI_MASK_STRONG + BIDI_MASK_EXPLICIT \
+ BIDI_MASK_OVERRIDE)
#define BIDI_TYPE_LRO (BIDI_MASK_STRONG | BIDI_MASK_EXPLICIT | BIDI_MASK_OVERRIDE)
/**
* \def BIDI_TYPE_RLO
* \brief Right-To-Left override
*/
#define BIDI_TYPE_RLO (BIDI_MASK_STRONG + BIDI_MASK_EXPLICIT \
+ BIDI_MASK_RTL + BIDI_MASK_OVERRIDE)
#define BIDI_TYPE_RLO (BIDI_MASK_STRONG | BIDI_MASK_EXPLICIT | BIDI_MASK_RTL | BIDI_MASK_OVERRIDE)
/**
* \def BIDI_TYPE_PDF
* \brief Pop directional override
*/
#define BIDI_TYPE_PDF (BIDI_MASK_WEAK + BIDI_MASK_EXPLICIT)
#define BIDI_TYPE_PDF (BIDI_MASK_WEAK | BIDI_MASK_EXPLICIT)
/**
* \def BIDI_TYPE_EN
* \brief European digit
*/
#define BIDI_TYPE_EN (BIDI_MASK_WEAK + BIDI_MASK_NUMBER)
#define BIDI_TYPE_EN (BIDI_MASK_WEAK | BIDI_MASK_NUMBER)
/**
* \def BIDI_TYPE_AN
* \brief Arabic digit
*/
#define BIDI_TYPE_AN (BIDI_MASK_WEAK + BIDI_MASK_NUMBER \
+ BIDI_MASK_ARABIC)
#define BIDI_TYPE_AN (BIDI_MASK_WEAK | BIDI_MASK_NUMBER | BIDI_MASK_ARABIC)
/**
* \def BIDI_TYPE_ES
* \brief European number separator
*/
#define BIDI_TYPE_ES (BIDI_MASK_WEAK + BIDI_MASK_NUMSEPTER \
+ BIDI_MASK_ES)
#define BIDI_TYPE_ES (BIDI_MASK_WEAK | BIDI_MASK_NUMSEPTER | BIDI_MASK_ES)
/**
* \def BIDI_TYPE_ET
* \brief European number terminator
*/
#define BIDI_TYPE_ET (BIDI_MASK_WEAK + BIDI_MASK_NUMSEPTER \
+ BIDI_MASK_ET)
#define BIDI_TYPE_ET (BIDI_MASK_WEAK | BIDI_MASK_NUMSEPTER | BIDI_MASK_ET)
/**
* \def BIDI_TYPE_CS
* \brief Common Separator
*/
#define BIDI_TYPE_CS (BIDI_MASK_WEAK + BIDI_MASK_NUMSEPTER \
+ BIDI_MASK_CS)
#define BIDI_TYPE_CS (BIDI_MASK_WEAK | BIDI_MASK_NUMSEPTER | BIDI_MASK_CS)
/**
* \def BIDI_TYPE_NSM
* \brief Non spacing mark
*/
#define BIDI_TYPE_NSM (BIDI_MASK_WEAK + BIDI_MASK_NSM)
#define BIDI_TYPE_NSM (BIDI_MASK_WEAK | BIDI_MASK_NSM)
/**
* \def BIDI_TYPE_BN
* \brief Boundary neutral
*/
#define BIDI_TYPE_BN (BIDI_MASK_WEAK + BIDI_MASK_SPACE \
+ BIDI_MASK_BN)
#define BIDI_TYPE_BN (BIDI_MASK_WEAK | BIDI_MASK_SPACE | BIDI_MASK_BN)
/**
* \def BIDI_TYPE_BS
* \brief Block separator
* \brief Block separator (Paragraph separator)
*/
#define BIDI_TYPE_BS (BIDI_MASK_NEUTRAL + BIDI_MASK_SPACE \
+ BIDI_MASK_SEPARATOR + BIDI_MASK_BS)
#define BIDI_TYPE_BS (BIDI_MASK_NEUTRAL | BIDI_MASK_SPACE | BIDI_MASK_SEPARATOR | BIDI_MASK_BS)
/**
* \def BIDI_TYPE_SS
* \brief Segment separator
*/
#define BIDI_TYPE_SS (BIDI_MASK_NEUTRAL + BIDI_MASK_SPACE \
+ BIDI_MASK_SEPARATOR + BIDI_MASK_SS)
#define BIDI_TYPE_SS (BIDI_MASK_NEUTRAL | BIDI_MASK_SPACE | BIDI_MASK_SEPARATOR | BIDI_MASK_SS)
/**
* \def BIDI_TYPE_WS
* \brief Whitespace
*/
#define BIDI_TYPE_WS (BIDI_MASK_NEUTRAL + BIDI_MASK_SPACE \
+ BIDI_MASK_WS)
#define BIDI_TYPE_WS (BIDI_MASK_NEUTRAL | BIDI_MASK_SPACE | BIDI_MASK_WS)
/**
* \def BIDI_TYPE_ON
@@ -9833,20 +9821,32 @@ MG_EXPORT Uint32 GUIAPI GetACharType (LOGFONT* logfont, Achar32 chv);
*/
#define BIDI_TYPE_ON (BIDI_MASK_NEUTRAL)
/**
* \def BIDI_TYPE_LRI
* \brief Left-to-Right Isolate
*/
#define BIDI_TYPE_LRI (BIDI_MASK_NEUTRAL | BIDI_MASK_ISOLATE)
/**
* \def BIDI_TYPE_RLI
* \brief Right-to-Left Isolate
*/
#define BIDI_TYPE_RLI (BIDI_MASK_NEUTRAL | BIDI_MASK_ISOLATE | BIDI_MASK_RTL)
/**
* \def BIDI_TYPE_FSI
* \brief First Strong Isolate
*/
#define BIDI_TYPE_FSI (BIDI_MASK_NEUTRAL | BIDI_MASK_ISOLATE | BIDI_MASK_FIRST)
/**
* \def BIDI_TYPE_PDI
* \brief Pop Directional Isolate
*/
#define BIDI_TYPE_PDI (BIDI_MASK_NEUTRAL | BIDI_MASK_WEAK | BIDI_MASK_ISOLATE)
/** @} end of glyph_bidi_types */
/* The following are used to identify the paragraph direction,
types L, R, N are not used internally anymore, and recommended to use
LTR, RTL and ON instead, didn't removed because of compatability. */
#define BIDI_TYPE_L (BIDI_TYPE_LTR)
#define BIDI_TYPE_R (BIDI_TYPE_RTL)
#define BIDI_TYPE_N (BIDI_TYPE_ON)
/* Weak left to right */
#define BIDI_TYPE_WL (BIDI_MASK_WEAK)
/* Weak right to left */
#define BIDI_TYPE_WR (BIDI_MASK_WEAK + BIDI_MASK_RTL)
/* The following are only used internally */
/* Start of text */
@@ -9871,11 +9871,11 @@ MG_EXPORT Uint32 GUIAPI GetACharType (LOGFONT* logfont, Achar32 chv);
#define BIDI_IS_ARABIC(p) ((p) & BIDI_MASK_ARABIC)
/* Is strong? */
#define BIDI_IS_STRONG(p) (((p) & BIDI_SWN_MASK) == BIDI_MASK_STRONG)
#define BIDI_IS_STRONG(p) (!((p) & BIDI_SWN_MASK))
/* Is weak? */
#define BIDI_IS_WEAK(p) (((p) & BIDI_SWN_MASK) == BIDI_MASK_WEAK)
#define BIDI_IS_WEAK(p) ((p) & BIDI_MASK_WEAK)
/* Is neutral? */
#define BIDI_IS_NEUTRAL(p) (((p) & BIDI_SWN_MASK) == BIDI_MASK_NEUTRAL)
#define BIDI_IS_NEUTRAL(p) ((p) & BIDI_MASK_NEUTRAL)
/* Is sentinel? */
#define BIDI_IS_SENTINEL(p) ((p) & BIDI_MASK_SENTINEL)
+26 -25
View File
@@ -1,39 +1,39 @@
/*
* This file is part of MiniGUI, a mature cross-platform windowing
* This file is part of MiniGUI, a mature cross-platform windowing
* and Graphics User Interface (GUI) support system for embedded systems
* and smart IoT devices.
*
*
* Copyright (C) 2002~2018, Beijing FMSoft Technologies Co., Ltd.
* Copyright (C) 1998~2002, WEI Yongming
*
*
* This program 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.
*
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*
*
* Or,
*
*
* As this program is a library, any link to this program must follow
* GNU General Public License version 3 (GPLv3). If you cannot accept
* GPLv3, you need to be licensed from FMSoft.
*
*
* If you have got a commercial license of this program, please use it
* under the terms and conditions of the commercial license.
*
*
* For more information about the commercial license, please refer to
* <http://www.minigui.com/en/about/licensing-policy/>.
*/
/*
** charset-bidi.c: The charset Bidirectional Algorithm.
**
**
** Created by houhuihua at 2008/01/23
*/
#include <stdio.h>
@@ -63,14 +63,14 @@ struct _TYPERUN
struct _TYPERUN *prev;
struct _TYPERUN *next;
Uint32 type; /* char type. */
int pos, len; /* run start position、run len.*/
BYTE level; /* Embedding level. */
int pos, len; /* run start position, run len.*/
Uint16 type; /* char type. */
BYTE level; /* embedding level. */
};
#ifdef BIDI_DEBUG
static char bidi_type_name(Uint32 c)
static char bidi_type_name(Uint16 c)
{
switch (c){
case BIDI_TYPE_LTR: return 'L';
@@ -126,12 +126,12 @@ static void print_run_types(TYPERUN *pp)
}
else sprintf(level_str, "%c", bidi_level[(int)pp->level]);
fprintf(stderr, "pos:%d:len:%d(%c)[level:%s] || ", pp->pos, pp->len,
fprintf(stderr, "pos:%d:len:%d(%c)[level:%s] || ", pp->pos, pp->len,
bidi_type_name(pp->type), level_str);
pp = pp->next;
}
fprintf (stderr, "\n");
}
}
static void print_hexstr(Achar32* str, int len, BOOL reorder_state)
{
@@ -286,7 +286,7 @@ static void bidi_resolveExplicit (TYPERUN **ptype_rl_list, Uint32 base_dir)
}
/* 3.Resolving weak types */
static void bidi_resolveWeak(TYPERUN **ptype_rl_list, Uint32 base_dir)
static void bidi_resolveWeak(TYPERUN **ptype_rl_list, Uint32 base_dir)
{
TYPERUN *type_rl_list = *ptype_rl_list, *pp = NULL;
Uint32 last_strong, prev_type_org;
@@ -328,7 +328,7 @@ static void bidi_resolveWeak(TYPERUN **ptype_rl_list, Uint32 base_dir)
last_strong = base_dir;
/* Resolving dependency of loops for rules W4 and W5, W5 may
want to prevent W4 to take effect in the next turn, do this
want to prevent W4 to take effect in the next turn, do this
through "w4". */
w4 = TRUE;
/* Resolving dependency of loops for rules W4 and W5 with W7,
@@ -427,8 +427,8 @@ static void bidi_resolveNeutrals(TYPERUN **ptype_rl_list, Uint32 base_bir)
if (BIDI_IS_NEUTRAL (this_type))
TYPE (pp) = (prev_type == next_type) ?
prev_type : /* N1. */
BIDI_EMBEDDING_DIR(pp); /* N2. */
prev_type : /* N1. */
BIDI_EMBEDDING_DIR(pp); /* N2. */
}
compact_list (type_rl_list);
#ifdef BIDI_DEBUG
@@ -472,8 +472,8 @@ static int bidi_resolveImplicit(TYPERUN **ptype_rl_list, int base_level)
}
/* 6.Resolving Mirrored Char. */
static void
bidi_resolveMirrorChar (const CHARSETOPS* charset_ops, Achar32* achars, int len,
static void
bidi_resolveMirrorChar (const CHARSETOPS* charset_ops, Achar32* achars, int len,
TYPERUN **ptype_rl_list, int base_level)
{
TYPERUN *type_rl_list = *ptype_rl_list, *pp = NULL;
@@ -487,7 +487,8 @@ bidi_resolveMirrorChar (const CHARSETOPS* charset_ops, Achar32* achars, int len,
for (i = POS (pp); i < POS (pp) + LEN (pp); i++)
{
Achar32 mirrored_ch;
if (charset_ops->bidi_mirror_char && charset_ops->bidi_mirror_char (achars[i], &mirrored_ch))
if (charset_ops->bidi_mirror_char &&
charset_ops->bidi_mirror_char (achars[i], &mirrored_ch))
achars[i] = mirrored_ch;
}
}
@@ -501,7 +502,7 @@ static void bidi_resolve_string (const CHARSETOPS* charset_ops,
TYPERUN **ptype_rl_list, BYTE *pmax_level)
{
BYTE base_level = 0;
Uint32 base_dir = BIDI_TYPE_L;
Uint32 base_dir = BIDI_TYPE_LTR;
TYPERUN *type_rl_list = NULL;
/* split the text to some runs. */
@@ -736,7 +737,7 @@ Uint32 __mg_charset_bidi_str_base_dir (const CHARSETOPS* charset_ops,
Achar32* achars, int len)
{
BYTE base_level = 0;
Uint32 base_dir = BIDI_TYPE_L;
Uint32 base_dir = BIDI_TYPE_LTR;
TYPERUN *type_rl_list = NULL;
/* split the text to some runs. */
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1,7 +1,7 @@
#!/bin/bash
url='https://www.unicode.org/Public/11.0.0/ucd/'
files='Scripts.txt UnicodeData.txt LineBreak.txt SpecialCasing.txt CaseFolding.txt CompositionExclusions.txt IndicPositionalCategory.txt IndicSyllabicCategory.txt ArabicShaping.txt BidiBrackets.txt BidiMirroring.txt Blocks.txt extracted/DerivedEastAsianWidth.txt'
files='Scripts.txt UnicodeData.txt LineBreak.txt SpecialCasing.txt CaseFolding.txt CompositionExclusions.txt IndicPositionalCategory.txt IndicSyllabicCategory.txt ArabicShaping.txt BidiBrackets.txt BidiMirroring.txt Blocks.txt extracted/DerivedEastAsianWidth.txt extracted/DerivedBidiClass.txt'
if test ! -d ucd/extracted; then
mkdir -p ucd/extracted
+267
View File
@@ -0,0 +1,267 @@
#!/usr/bin/env python
# Wrotten by Vincent Wei for MiniGUI 3.4
# Create on 2019-03-07
from __future__ import print_function, division, absolute_import
import io, sys
NR_UNICODE_CHARS = 0x10FFFF + 1
#if len (sys.argv) != 4:
# print ("usage: ./gen-bidi-tables.py", file=sys.stderr)
# sys.exit (1)
filenames = ['ucd/extracted/DerivedBidiClass.txt', 'ucd/BidiBrackets.txt', 'ucd/BidiMirroring.txt']
files = [io.open (x, encoding='utf-8') for x in filenames]
headers = [[f.readline () for i in range (2)] for f in files]
headers.insert (0, ["UnicodeData.txt does not have a header."])
# Read fileds[] in UnicodeData.txt to data
data = [{} for f in files]
values = [{} for f in files]
for i, f in enumerate (files):
for line in f:
j = line.find ('#')
if j >= 0:
line = line[:j]
fields = [x.strip () for x in line.split (';')]
if len (fields) == 1:
continue
uu = fields[0].split ('..')
start = int (uu[0], 16)
if len (uu) == 1:
end = start
else:
end = int (uu[1], 16)
if i == 1:
t = fields[2]
else:
t = fields[1]
for u in range (start, end + 1):
data[i][u] = t
values[i][t] = values[i].get (t, 0) + end - start + 1
# The unassigned code points that default to AL are in the ranges:
# [\u0600-\u07BF \u0860-\u086F \u08A0-\u08FF \uFB50-\uFDCF \uFDF0-\uFDFF \uFE70-\uFEFF
# \U00010D00-\U00010D3F \U00010F30-\U00010F6F \U0001EC70-\U0001ECBF \U0001EE00-\U0001EEFF]
#
# This includes code points in the Arabic, Syriac, and Thaana blocks, among others.
#
# The unassigned code points that default to R are in the ranges:
# [\u0590-\u05FF \u07C0-\u085F \u0870-\u089F \uFB1D-\uFB4F \U00010800-\U00010CFF \U00010D40-\U00010F2F
# \U00010F70-\U00010FFF \U0001E800-\U0001EC6F \U0001ECC0-\U0001EDFF \U0001EF00-\U0001EFFF]
#
# This includes code points in the Hebrew, NKo, and Phoenician blocks, among others.
#
# The unassigned code points that default to ET are in the range:
# [\u20A0-\u20CF]
#
# This consists of code points in the Currency Symbols block.
#
# The unassigned code points that default to BN have one of the following properties:
# Default_Ignorable_Code_Point
# Noncharacter_Code_Point
#
# For all other cases:
# All code points not explicitly listed for Bidi_Class
# have the value Left_To_Right (L).
# @missing: 0000..10FFFF; Left_To_Right
# Initialize bidi_types list with the default Bidi class
bidi_types = ["BIDI_TYPE_LTR" for i in range(NR_UNICODE_CHARS)]
for i in range(0x0590, 0x0600):
bidi_types[i] = "BIDI_TYPE_RTL"
for i in range(0x07C0, 0x0900):
bidi_types[i] = "BIDI_TYPE_RTL"
for i in range(0xFB1D, 0xFB50):
bidi_types[i] = "BIDI_TYPE_RTL"
for i in range(0x0600, 0x07C0):
bidi_types[i] = "BIDI_TYPE_AL"
for i in range(0xFB50, 0xFDD0):
bidi_types[i] = "BIDI_TYPE_AL"
for i in range(0xFDF0, 0xFE00):
bidi_types[i] = "BIDI_TYPE_AL"
for i in range(0xFE70, 0xFF00):
bidi_types[i] = "BIDI_TYPE_AL"
for i in range(0x2060, 0x2070):
bidi_types[i] = "BIDI_TYPE_BN"
for i in range(0x20A0, 0x20D0):
bidi_types[i] = "BIDI_TYPE_ET"
for i in range(0xFDD0, 0xFDF0):
bidi_types[i] = "BIDI_TYPE_BN"
for i in range(0xFFF0, 0xFFF9):
bidi_types[i] = "BIDI_TYPE_BN"
for i in range(0xFFFF, NR_UNICODE_CHARS, 0x10000):
bidi_types[i - 1] = bidi_types[i] = "BIDI_TYPE_BN"
for i in range(0x10800, 0x10D00):
bidi_types[i] = "BIDI_TYPE_RTL"
for i in range(0x10D40, 0x10F30):
bidi_types[i] = "BIDI_TYPE_RTL"
for i in range(0x10F70, 0x11000):
bidi_types[i] = "BIDI_TYPE_RTL"
for i in range(0x1E800, 0x1EC70):
bidi_types[i] = "BIDI_TYPE_RTL"
for i in range(0x1ECC0, 0x1EE00):
bidi_types[i] = "BIDI_TYPE_RTL"
for i in range(0x1EF00, 0x1F000):
bidi_types[i] = "BIDI_TYPE_RTL"
for i in range(0xE0000, 0xE1000):
bidi_types[i] = "BIDI_TYPE_BN"
# Fill bidi_types
d = data[0]
for u, v in d.items():
v = v.strip()
if cmp(v, 'L') == 0:
bidi_types[u] = 'BIDI_TYPE_LTR'
elif cmp(v, 'R') == 0:
bidi_types[u] = 'BIDI_TYPE_RTL'
elif cmp(v, 'EN') == 0:
bidi_types[u] = 'BIDI_TYPE_EN'
elif cmp(v, 'ES') == 0:
bidi_types[u] = 'BIDI_TYPE_ES'
elif cmp(v, 'ET') == 0:
bidi_types[u] = 'BIDI_TYPE_ET'
elif cmp(v, 'AN') == 0:
bidi_types[u] = 'BIDI_TYPE_AN'
elif cmp(v, 'CS') == 0:
bidi_types[u] = 'BIDI_TYPE_CS'
elif cmp(v, 'B') == 0:
bidi_types[u] = 'BIDI_TYPE_BS'
elif cmp(v, 'S') == 0:
bidi_types[u] = 'BIDI_TYPE_SS'
elif cmp(v, 'WS') == 0:
bidi_types[u] = 'BIDI_TYPE_WS'
elif cmp(v, 'ON') == 0:
bidi_types[u] = 'BIDI_TYPE_ON'
elif cmp(v, 'BN') == 0:
bidi_types[u] = 'BIDI_TYPE_BN'
elif cmp(v, 'NSM') == 0:
bidi_types[u] = 'BIDI_TYPE_NSM'
elif cmp(v, 'AL') == 0:
bidi_types[u] = 'BIDI_TYPE_AL'
elif cmp(v, 'LRO') == 0:
bidi_types[u] = 'BIDI_TYPE_LRO'
elif cmp(v, 'RLO') == 0:
bidi_types[u] = 'BIDI_TYPE_RLO'
elif cmp(v, 'LRE') == 0:
bidi_types[u] = 'BIDI_TYPE_LRE'
elif cmp(v, 'RLE') == 0:
bidi_types[u] = 'BIDI_TYPE_RLE'
elif cmp(v, 'PDF') == 0:
bidi_types[u] = 'BIDI_TYPE_PDF'
elif cmp(v, 'LRI') == 0:
bidi_types[u] = 'BIDI_TYPE_LRI'
elif cmp(v, 'RLI') == 0:
bidi_types[u] = 'BIDI_TYPE_RLI'
elif cmp(v, 'FSI') == 0:
bidi_types[u] = 'BIDI_TYPE_FSI'
elif cmp(v, 'PDI') == 0:
bidi_types[u] = 'BIDI_TYPE_PDI'
else:
print ("Unknown BIDI type: %s" % v)
print ("/* == Start of generated table == */")
print ("/*")
print (" * The following table is generated by running:")
print (" *")
print (" * ./gen-bidi-tables.py")
print (" *")
print (" * on ucd/extracted/DerivedBidiClass.txt, ucd/BidiBrackets.txt, and ucd/BidiMirroring.txt files with these headers:")
print (" *")
for h in headers:
for l in h:
print (" * %s" % (l.strip()))
print (" */")
print ()
print ("#ifndef _UNICODE_BIDI_TABLES_H")
print ("#define _UNICODE_BIDI_TABLES_H")
print ("")
print ("static const BIDICHAR_TYPE_MAP __mg_unicode_bidi_char_type_map[] =")
print ("{")
cur_chv = 0
cur_count = 1
cur_type = bidi_types[0]
for i in range(1, NR_UNICODE_CHARS):
if bidi_types[i] is not cur_type:
if cur_count == 0:
cur_count = 1
print (" { 0x%06X, 0x%04X, %s }," % (cur_chv, cur_count, cur_type, ))
cur_chv = i
cur_count = 1
cur_type = bidi_types[i]
else:
cur_count += 1
print ("};")
print ("")
print ("static const BIDICHAR_BRACKET __mg_unicode_bracket_table[] =")
print ("{")
d = data[1]
uu = sorted (d.keys())
for u in uu:
v = d[u]
v = v.strip()
if cmp(v, 'o') == 0:
bracket_type = "BIDICHAR_BRACKET_OPEN"
elif cmp(v, 'c') == 0:
bracket_type = "BIDICHAR_BRACKET_CLOSE"
else:
bracket_type = "BIDICHAR_BRACKET_NONE"
print (" { 0x%06X, %s }," % (u, bracket_type, ))
print ("};")
print ("")
print ("static const BIDICHAR_MIRROR_MAP __mg_unicode_mirror_table[] =")
print ("{")
d = data[2]
uu = sorted (d.keys())
for u in uu:
v = d[u]
mirrored = int (v, 16)
print (" { 0x%06X, 0x%06X }," % (u, mirrored, ))
print ("};")
print ()
print ("#endif /* !_UNICODE_BIDI_TABLES_H */")
print ()
print ("/* == End of generated table == */")
+19 -2
View File
@@ -59,11 +59,28 @@ extern "C" {
#define DBGLOG4(s, t1, t2, t3)
#endif
typedef struct _BIDICHAR_TYPE_MAP {
Uchar32 chv; // Starting code point of Unicode character
Uint16 count; // Total number of Unicode characters of same type starting from chv
Uint16 type; // Type of Unicode characters
} BIDICHAR_TYPE_MAP;
typedef struct _TYPERUN TYPERUN;
#define BIDICHAR_BRACKET_NONE 0
#define BIDICHAR_BRACKET_OPEN 1
#define BIDICHAR_BRACKET_CLOSE 2
// NOTE: It is enough to use Uint16 for Unicode bracket table
typedef struct _BIDICHAR_BRACKET {
Uint16 chv;
Uint8 type;
} BIDICHAR_BRACKET;
// NOTE: It is enough to use Uint16 for Unicode mirror map
typedef struct _BIDICHAR_MIRROR_MAP {
Achar32 chv;
Achar32 mirrored;
Uint16 chv;
Uint16 mirrored;
} BIDICHAR_MIRROR_MAP;
Achar32* __mg_charset_bidi_achars_reorder (const CHARSETOPS* charset_ops,