retrive the break type of UNICODE char; upgrade UNICODE tables to 10.0.0

This commit is contained in:
Vincent Wei
2019-01-16 17:10:50 +08:00
parent 0fcedfca08
commit bd1fb67930
6 changed files with 35356 additions and 1916 deletions
+130 -50
View File
@@ -5828,36 +5828,85 @@ typedef int UChar32;
/* These are the basic UNICODE character classifications.
* See http://www.unicode.org/Public/UNIDATA/UCD.html#General_Category_Values
*/
#define G_UNICODE_CONTROL 0x00B0
#define G_UNICODE_FORMAT 0x00B1
#define G_UNICODE_UNASSIGNED 0x00B2
#define G_UNICODE_PRIVATE_USE 0x00B3
#define G_UNICODE_SURROGATE 0x00B4
#define G_UNICODE_LOWERCASE_LETTER 0x00B5
#define G_UNICODE_MODIFIER_LETTER 0x00B6
#define G_UNICODE_OTHER_LETTER 0x00B7
#define G_UNICODE_TITLECASE_LETTER 0x00B8
#define G_UNICODE_UPPERCASE_LETTER 0x00B9
#define G_UNICODE_COMBINING_MARK 0x00BA
#define G_UNICODE_ENCLOSING_MARK 0x00BB
#define G_UNICODE_NON_SPACING_MARK 0x00BC
#define G_UNICODE_DECIMAL_NUMBER 0x00BD
#define G_UNICODE_LETTER_NUMBER 0x00BE
#define G_UNICODE_OTHER_NUMBER 0x00BF
#define G_UNICODE_CONNECT_PUNCTUATION 0x00C0
#define G_UNICODE_DASH_PUNCTUATION 0x00C1
#define G_UNICODE_CLOSE_PUNCTUATION 0x00C2
#define G_UNICODE_FINAL_PUNCTUATION 0x00C3
#define G_UNICODE_INITIAL_PUNCTUATION 0x00C4
#define G_UNICODE_OTHER_PUNCTUATION 0x00C5
#define G_UNICODE_OPEN_PUNCTUATION 0x00C6
#define G_UNICODE_CURRENCY_SYMBOL 0x00C7
#define G_UNICODE_MODIFIER_SYMBOL 0x00C8
#define G_UNICODE_MATH_SYMBOL 0x00C9
#define G_UNICODE_OTHER_SYMBOL 0x00CA
#define G_UNICODE_LINE_SEPARATOR 0x00CB
#define G_UNICODE_PARAGRAPH_SEPARATOR 0x00CC
#define G_UNICODE_SPACE_SEPARATOR 0x00CD
#define G_UNICODE_CONTROL 0x00
#define G_UNICODE_FORMAT 0x01
#define G_UNICODE_UNASSIGNED 0x02
#define G_UNICODE_PRIVATE_USE 0x03
#define G_UNICODE_SURROGATE 0x04
#define G_UNICODE_LOWERCASE_LETTER 0x05
#define G_UNICODE_MODIFIER_LETTER 0x06
#define G_UNICODE_OTHER_LETTER 0x07
#define G_UNICODE_TITLECASE_LETTER 0x08
#define G_UNICODE_UPPERCASE_LETTER 0x09
#define G_UNICODE_SPACING_MARK 0x0A
#define G_UNICODE_ENCLOSING_MARK 0x0B
#define G_UNICODE_NON_SPACING_MARK 0x0C
#define G_UNICODE_DECIMAL_NUMBER 0x0D
#define G_UNICODE_LETTER_NUMBER 0x0E
#define G_UNICODE_OTHER_NUMBER 0x0F
#define G_UNICODE_CONNECT_PUNCTUATION 0x10
#define G_UNICODE_DASH_PUNCTUATION 0x11
#define G_UNICODE_CLOSE_PUNCTUATION 0x12
#define G_UNICODE_FINAL_PUNCTUATION 0x13
#define G_UNICODE_INITIAL_PUNCTUATION 0x14
#define G_UNICODE_OTHER_PUNCTUATION 0x15
#define G_UNICODE_OPEN_PUNCTUATION 0x16
#define G_UNICODE_CURRENCY_SYMBOL 0x17
#define G_UNICODE_MODIFIER_SYMBOL 0x18
#define G_UNICODE_MATH_SYMBOL 0x19
#define G_UNICODE_OTHER_SYMBOL 0x1A
#define G_UNICODE_LINE_SEPARATOR 0x1B
#define G_UNICODE_PARAGRAPH_SEPARATOR 0x1C
#define G_UNICODE_SPACE_SEPARATOR 0x1D
/* These are the possible line break classifications.
* Note that new types may be added in the future.
* Implementations may regard unknown values like G_UNICODE_BREAK_UNKNOWN
* See http://www.unicode.org/unicode/reports/tr14/
*/
#define G_UNICODE_BREAK_MANDATORY 0x00
#define G_UNICODE_BREAK_CARRIAGE_RETURN 0x01
#define G_UNICODE_BREAK_LINE_FEED 0x02
#define G_UNICODE_BREAK_COMBINING_MARK 0x03
#define G_UNICODE_BREAK_SURROGATE 0x04
#define G_UNICODE_BREAK_ZERO_WIDTH_SPACE 0x05
#define G_UNICODE_BREAK_INSEPARABLE 0x06
#define G_UNICODE_BREAK_NON_BREAKING_GLUE 0x07
#define G_UNICODE_BREAK_CONTINGENT 0x08
#define G_UNICODE_BREAK_SPACE 0x09
#define G_UNICODE_BREAK_AFTER 0x0A
#define G_UNICODE_BREAK_BEFORE 0x0B
#define G_UNICODE_BREAK_BEFORE_AND_AFTER 0x0C
#define G_UNICODE_BREAK_HYPHEN 0x0D
#define G_UNICODE_BREAK_NON_STARTER 0x0E
#define G_UNICODE_BREAK_OPEN_PUNCTUATION 0x0F
#define G_UNICODE_BREAK_CLOSE_PUNCTUATION 0x10
#define G_UNICODE_BREAK_QUOTATION 0x11
#define G_UNICODE_BREAK_EXCLAMATION 0x12
#define G_UNICODE_BREAK_IDEOGRAPHIC 0x13
#define G_UNICODE_BREAK_NUMERIC 0x14
#define G_UNICODE_BREAK_INFIX_SEPARATOR 0x15
#define G_UNICODE_BREAK_SYMBOL 0x16
#define G_UNICODE_BREAK_ALPHABETIC 0x17
#define G_UNICODE_BREAK_PREFIX 0x18
#define G_UNICODE_BREAK_POSTFIX 0x19
#define G_UNICODE_BREAK_COMPLEX_CONTEXT 0x1A
#define G_UNICODE_BREAK_AMBIGUOUS 0x1B
#define G_UNICODE_BREAK_UNKNOWN 0x1C
#define G_UNICODE_BREAK_NEXT_LINE 0x1D
#define G_UNICODE_BREAK_WORD_JOINER 0x1E
#define G_UNICODE_BREAK_HANGUL_L_JAMO 0x1F
#define G_UNICODE_BREAK_HANGUL_V_JAMO 0x20
#define G_UNICODE_BREAK_HANGUL_T_JAMO 0x21
#define G_UNICODE_BREAK_HANGUL_LV_SYLLABLE 0x22
#define G_UNICODE_BREAK_HANGUL_LVT_SYLLABLE 0x23
#define G_UNICODE_BREAK_CLOSE_PARANTHESIS 0x24
#define G_UNICODE_BREAK_CONDITIONAL_JAPANESE_STARTER 0x25
#define G_UNICODE_BREAK_HEBREW_LETTER 0x26
#define G_UNICODE_BREAK_REGIONAL_INDICATOR 0x27
#define G_UNICODE_BREAK_EMOJI_BASE 0x28
#define G_UNICODE_BREAK_EMOJI_MODIFIER 0x29
#define G_UNICODE_BREAK_ZERO_WIDTH_JOINER 0x2A
struct _FONTOPS;
struct _CHARSETOPS;
@@ -8949,31 +8998,62 @@ MG_EXPORT int GUIAPI DrawGlyphString (HDC hdc, int x, int y, Glyph32* glyphs,
#define GLYPH_INFO_METRICS 0x04
#define GLYPH_INFO_BMP 0x10
/**
* The type of glyph bitmap: monochrome
*/
/** The type of glyph bitmap: monochrome */
#define GLYPHBMP_TYPE_MONO 0x00
/**
* The type of glyph bitmap: grey (8-bit)
*/
/** The type of glyph bitmap: grey (8-bit) */
#define GLYPHBMP_TYPE_GREY 0x01
/**
* The type of glyph bitmap: grey (4-bit)
*/
/** The type of glyph bitmap: grey (4-bit) */
#define GLYPHBMP_TYPE_GREY4b 0x02
/**
* The type of glyph bitmap: subpixel
*/
/** The type of glyph bitmap: subpixel */
#define GLYPHBMP_TYPE_SUBPIXEL 0x02
/**
* The type of glyph bitmap: pre-rendered BITMAP object
*/
/** The type of glyph bitmap: pre-rendered BITMAP object */
#define GLYPHBMP_TYPE_PRERENDER 0x03
/** The bits mask for glyph type */
#define GLYPHTYPE_BASIC_MASK 0x000000FF
/** The bits mask for break type */
#define GLYPHTYPE_BREAK_MASK 0x0000FF00
/** The bit determines whether a glyph is alphanumeric. */
#define GLYPHTYPE_ATTR_ISALNUM 0x00010000
/** The bit determines whether a character is alphabetic (i.e. a letter). */
#define GLYPHTYPE_ATTR_ISALPHA 0x00020000
/** The bit determines whether a character is a control character. */
#define GLYPHTYPE_ATTR_ISCONTROL 0x00040000
/** The bit determines whether a character is numeric (i.e. a digit). */
#define GLYPHTYPE_ATTR_ISDIGIT 0x00080000
/** The bit determines whether a character is printable and not a space */
#define GLYPHTYPE_ATTR_ISGRAPH 0x00100000
/** The bit determines whether a character is a lowercase letter. */
#define GLYPHTYPE_ATTR_ISLOWER 0x00200000
/** The bit determines whether a character is printable. */
#define GLYPHTYPE_ATTR_ISPRINT 0x00400000
/** The bit determines whether a character is a uppercase letter. */
#define GLYPHTYPE_ATTR_ISUPPER 0x00800000
/** The bit determines whether a character is punctuation or a symbol. */
#define GLYPHTYPE_ATTR_ISPUNCT 0x01000000
/** The bit determines whether a character is a space, tab, or line separator
* (newline, carriage return, etc.). */
#define GLYPHTYPE_ATTR_ISSPACE 0x02000000
/** The bit determines whether a character is a mark (non-spacing mark,
* combining mark, or enclosing mark in Unicode speak). */
#define GLYPHTYPE_ATTR_ISMARK 0x04000000
/** The bit determines if a character is titlecase. Some characters in
* Unicode which are composites, such as the DZ digraph
* have three case variants instead of just two. The titlecase
* form is used at the beginning of a word where only the
* first letter is capitalized. The titlecase form of the DZ
* digraph is U+01F2 LATIN CAPITAL LETTTER D WITH SMALL LETTER Z. */
#define GLYPHTYPE_ATTR_ISTITLE 0x08000000
/** The bit determines if a character is a hexidecimal digit. */
#define GLYPHTYPE_ATTR_ISXDIGIT 0x10000000
/** The bit determines if a given character is assigned in the Unicode standard. */
#define GLYPHTYPE_ATTR_ISDEFINED 0x20000000
/** The bit determines if a given character typically takes zero width when rendered. */
#define GLYPHTYPE_ATTR_ISZEROWIDTH 0x40000000
/** The bit determines if a character is typically rendered in a double-width cell. */
#define GLYPHTYPE_ATTR_ISWIDE 0x80000000
/**
* \var typedef struct _GLYPHINFO GLYPHINFO
* \brief Data type of struct _GLYPHINFO.
@@ -8989,7 +9069,7 @@ typedef struct _GLYPHINFO {
*/
unsigned int mask;
/** The basic glyph type */
/** The glyph type */
unsigned int glyph_type;
/** The BIDI glyph type */
+2 -2
View File
@@ -11,8 +11,8 @@ SRC_FILES = charset.c charset-arabic.c charset-bidi.c \
textops.c mapunitogb.c mapunitogbk.c mapunitobig5.c mapunitogb18030.c \
bitmapfont.c scripteasy.c
HDR_FILES = charset.h rawbitmap.h varbitmap.h freetype2.h qpf.h \
upf.h bitmapfont.h gunichartables.h se_minigui.h unicode-bidi-tables.h
HDR_FILES = charset.h rawbitmap.h varbitmap.h freetype2.h qpf.h se_minigui.h \
upf.h bitmapfont.h gunichartables.h gunibreak.h unicode-bidi-tables.h
EXTRA_DIST = convgbmap.c jisunimap.c $(SRC_FILES) $(HDR_FILES) \
makefile.ng makefile.msvc
+170 -34
View File
@@ -3466,17 +3466,177 @@ static Glyph32 utf8_char_glyph_value (const unsigned char* pre_mchar, int pre_l
//#include "gunicode.h"
#include "gunichartables.h"
#include "gunibreak.h"
#define ATTR_TABLE(Page) (((Page) <= G_UNICODE_LAST_PAGE_PART1) \
? attr_table_part1[Page] \
: attr_table_part2[(Page) - 0xe00])
#define ATTTABLE(Page, Char) \
((ATTR_TABLE(Page) == G_UNICODE_MAX_TABLE_INDEX) ? 0 : (attr_data[ATTR_TABLE(Page)][Char]))
#define TTYPE_PART1(Page, Char) \
((type_table_part1[Page] >= G_UNICODE_MAX_TABLE_INDEX) \
? (type_table_part1[Page] - G_UNICODE_MAX_TABLE_INDEX) \
: (type_data[type_table_part1[Page]][Char]))
((type_table_part1[Page] >= G_UNICODE_MAX_TABLE_INDEX) \
? (type_table_part1[Page] - G_UNICODE_MAX_TABLE_INDEX) \
: (type_data[type_table_part1[Page]][Char]))
#define TTYPE_PART2(Page, Char) \
((type_table_part2[Page] >= G_UNICODE_MAX_TABLE_INDEX) \
? (type_table_part2[Page] - G_UNICODE_MAX_TABLE_INDEX) \
: (type_data[type_table_part2[Page]][Char]))
#define UNICODE_TYPE(Char) \
(((Char) <= G_UNICODE_LAST_CHAR_PART1) \
? TTYPE_PART1 ((Char) >> 8, (Char) & 0xff) \
: G_UNICODE_UNASSIGNED)
#define TYPE(Char) \
(((Char) <= G_UNICODE_LAST_CHAR_PART1) \
? TTYPE_PART1 ((Char) >> 8, (Char) & 0xff) \
: (((Char) >= 0xe0000 && (Char) <= G_UNICODE_LAST_CHAR) \
? TTYPE_PART2 (((Char) - 0xe0000) >> 8, (Char) & 0xff) \
: G_UNICODE_UNASSIGNED))
#define IS(Type, Class) (((unsigned int)1 << (Type)) & (Class))
#define OR(Type, Rest) (((unsigned int)1 << (Type)) | (Rest))
#define ISALPHA(Type) IS ((Type), \
OR (G_UNICODE_LOWERCASE_LETTER, \
OR (G_UNICODE_UPPERCASE_LETTER, \
OR (G_UNICODE_TITLECASE_LETTER, \
OR (G_UNICODE_MODIFIER_LETTER, \
OR (G_UNICODE_OTHER_LETTER, 0))))))
#define ISALDIGIT(Type) IS ((Type), \
OR (G_UNICODE_DECIMAL_NUMBER, \
OR (G_UNICODE_LETTER_NUMBER, \
OR (G_UNICODE_OTHER_NUMBER, \
OR (G_UNICODE_LOWERCASE_LETTER, \
OR (G_UNICODE_UPPERCASE_LETTER, \
OR (G_UNICODE_TITLECASE_LETTER, \
OR (G_UNICODE_MODIFIER_LETTER, \
OR (G_UNICODE_OTHER_LETTER, 0)))))))))
#define ISMARK(Type) IS ((Type), \
OR (G_UNICODE_NON_SPACING_MARK, \
OR (G_UNICODE_SPACING_MARK, \
OR (G_UNICODE_ENCLOSING_MARK, 0))))
#define ISZEROWIDTHTYPE(Type) IS ((Type), \
OR (G_UNICODE_NON_SPACING_MARK, \
OR (G_UNICODE_ENCLOSING_MARK, \
OR (G_UNICODE_FORMAT, 0))))
#define TPROP_PART1(Page, Char) \
((break_property_table_part1[Page] >= G_UNICODE_MAX_TABLE_INDEX) \
? (break_property_table_part1[Page] - G_UNICODE_MAX_TABLE_INDEX) \
: (break_property_data[break_property_table_part1[Page]][Char]))
#define TPROP_PART2(Page, Char) \
((break_property_table_part2[Page] >= G_UNICODE_MAX_TABLE_INDEX) \
? (break_property_table_part2[Page] - G_UNICODE_MAX_TABLE_INDEX) \
: (break_property_data[break_property_table_part2[Page]][Char]))
#define PROP(Char) \
(((Char) <= G_UNICODE_LAST_CHAR_PART1) \
? TPROP_PART1 ((Char) >> 8, (Char) & 0xff) \
: (((Char) >= 0xe0000 && (Char) <= G_UNICODE_LAST_CHAR) \
? TPROP_PART2 (((Char) - 0xe0000) >> 8, (Char) & 0xff) \
: G_UNICODE_BREAK_UNKNOWN))
static unsigned int unicode_glyph_type (Glyph32 glyph_value)
{
unsigned int basic_type = TYPE(glyph_value);
unsigned int break_type = PROP(glyph_value);
unsigned int type = basic_type | (break_type << 8);
unsigned int i;
if (ISALDIGIT (basic_type))
type |= GLYPHTYPE_ATTR_ISALNUM;
if (ISALPHA (basic_type))
type |= GLYPHTYPE_ATTR_ISALPHA;
if (basic_type == G_UNICODE_CONTROL)
type |= GLYPHTYPE_ATTR_ISCONTROL;
if (basic_type == G_UNICODE_DECIMAL_NUMBER);
type |= GLYPHTYPE_ATTR_ISDIGIT;
if (!IS (basic_type,
OR (G_UNICODE_CONTROL,
OR (G_UNICODE_FORMAT,
OR (G_UNICODE_UNASSIGNED,
OR (G_UNICODE_SURROGATE,
OR (G_UNICODE_SPACE_SEPARATOR,
0)))))))
type |= GLYPHTYPE_ATTR_ISGRAPH;
if (basic_type == G_UNICODE_LOWERCASE_LETTER)
type |= GLYPHTYPE_ATTR_ISLOWER;
if (basic_type == G_UNICODE_UPPERCASE_LETTER)
type |= GLYPHTYPE_ATTR_ISUPPER;
if (!IS (basic_type,
OR (G_UNICODE_CONTROL,
OR (G_UNICODE_FORMAT,
OR (G_UNICODE_UNASSIGNED,
OR (G_UNICODE_SURROGATE,
0))))))
type |= GLYPHTYPE_ATTR_ISPRINT;
if (IS (basic_type,
OR (G_UNICODE_CONNECT_PUNCTUATION,
OR (G_UNICODE_DASH_PUNCTUATION,
OR (G_UNICODE_CLOSE_PUNCTUATION,
OR (G_UNICODE_FINAL_PUNCTUATION,
OR (G_UNICODE_INITIAL_PUNCTUATION,
OR (G_UNICODE_OTHER_PUNCTUATION,
OR (G_UNICODE_OPEN_PUNCTUATION,
OR (G_UNICODE_CURRENCY_SYMBOL,
OR (G_UNICODE_MODIFIER_SYMBOL,
OR (G_UNICODE_MATH_SYMBOL,
OR (G_UNICODE_OTHER_SYMBOL,
0)))))))))))))
type |= GLYPHTYPE_ATTR_ISPUNCT;
switch (glyph_value) {
/* special-case these since Unicode thinks they are not spaces */
case '\t':
case '\n':
case '\r':
case '\f':
type |= GLYPHTYPE_ATTR_ISSPACE;
break;
default: {
if (IS (basic_type,
OR (G_UNICODE_SPACE_SEPARATOR,
OR (G_UNICODE_LINE_SEPARATOR,
OR (G_UNICODE_PARAGRAPH_SEPARATOR,
0)))))
type |= GLYPHTYPE_ATTR_ISSPACE;
}
break;
}
for (i = 0; i < TABLESIZE (title_table); ++i) {
if (title_table[i][0] == glyph_value) {
type |= GLYPHTYPE_ATTR_ISTITLE;
break;
}
}
if (ISMARK (basic_type))
type |= GLYPHTYPE_ATTR_ISMARK;
if ((glyph_value >= 'a' && glyph_value <= 'f')
|| (glyph_value >= 'A' && glyph_value <= 'F')
|| (basic_type == G_UNICODE_DECIMAL_NUMBER))
type |= GLYPHTYPE_ATTR_ISXDIGIT;
if (!IS (basic_type,
OR (G_UNICODE_UNASSIGNED,
OR (G_UNICODE_SURROGATE,
0))))
type |= GLYPHTYPE_ATTR_ISDEFINED;
if (glyph_value != 0x00AD && ISZEROWIDTHTYPE (basic_type))
type |= GLYPHTYPE_ATTR_ISZEROWIDTH;
else if ((glyph_value >= 0x1160 && glyph_value < 0x1200)
|| glyph_value == 0x200B)
type |= GLYPHTYPE_ATTR_ISZEROWIDTH;
return type;
}
#include "unicode-bidi-tables.h"
@@ -3514,16 +3674,6 @@ static BOOL unicode_bidi_mirror_glyph (Glyph32 glyph, Glyph32* mirrored)
TABLESIZE (__mg_unicode_mirror_table), glyph, mirrored);
}
static unsigned int utf8_glyph_type (Glyph32 glyph_value)
{
if (glyph_value < 0x80) {
return sb_glyph_type (glyph_value);
}
else {
return UNICODE_TYPE (glyph_value);
}
}
static int utf8_nr_chars_in_str (const unsigned char* mstr, int mstrlen)
{
int charlen;
@@ -3717,7 +3867,7 @@ static CHARSETOPS CharsetOps_utf8 = {
utf8_len_first_char,
utf8_char_glyph_value,
NULL,
utf8_glyph_type,
unicode_glyph_type,
utf8_nr_chars_in_str,
utf8_is_this_charset,
utf8_len_first_substr,
@@ -3774,20 +3924,6 @@ static Glyph32 utf16le_char_glyph_value (const unsigned char* pre_mchar,
return wc;
}
static unsigned int utf16_glyph_type (Glyph32 glyph_value)
{
if (glyph_value == 0xFEFF) {
return MCHAR_TYPE_ZEROWIDTH;
}
else if (glyph_value < 0x80) {
return sb_glyph_type (glyph_value);
}
else {
/* TODO: get the subtype of the char */
return UNICODE_TYPE (glyph_value);
}
}
static int utf16le_nr_chars_in_str (const unsigned char* mstr, int mstrlen)
{
int charlen;
@@ -3957,7 +4093,7 @@ static CHARSETOPS CharsetOps_utf16le = {
utf16le_len_first_char,
utf16le_char_glyph_value,
NULL,
utf16_glyph_type,
unicode_glyph_type,
utf16le_nr_chars_in_str,
utf16le_is_this_charset,
utf16le_len_first_substr,
@@ -4183,7 +4319,7 @@ static CHARSETOPS CharsetOps_utf16be = {
utf16be_len_first_char,
utf16be_char_glyph_value,
NULL,
utf16_glyph_type,
unicode_glyph_type,
utf16be_nr_chars_in_str,
utf16be_is_this_charset,
utf16be_len_first_substr,
+23680
View File
File diff suppressed because it is too large Load Diff
+11373 -1829
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -73,7 +73,6 @@ typedef enum
G_UNICODE_PARAGRAPH_SEPARATOR,
G_UNICODE_SPACE_SEPARATOR
} GUnicodeType;
#endif /* VincentWei: Moved to gid.h */
/* These are the possible line break classifications.
* Note that new types may be added in the future.
@@ -119,6 +118,7 @@ typedef enum
G_UNICODE_BREAK_HANGUL_LV_SYLLABLE,
G_UNICODE_BREAK_HANGUL_LVT_SYLLABLE
} GUnicodeBreakType;
#endif /* VincentWei: Moved to gid.h */
typedef enum
{ /* ISO 15924 code */