< prev index next >

src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ucdn/ucdn.c

Print this page

        

*** 21,31 **** typedef struct { unsigned char category; unsigned char combining; unsigned char bidi_class; - unsigned char mirrored; unsigned char east_asian_width; unsigned char script; unsigned char linebreak_class; } UCDRecord; --- 21,30 ----
*** 41,51 **** typedef struct { unsigned int start; short count, index; } Reindex; ! #include "unicodedata_db.h" /* constants required for Hangul (de)composition */ #define SBASE 0xAC00 #define LBASE 0x1100 #define VBASE 0x1161 --- 40,50 ---- typedef struct { unsigned int start; short count, index; } Reindex; ! #include "ucdn_db.h" /* constants required for Hangul (de)composition */ #define SBASE 0xAC00 #define LBASE 0x1100 #define VBASE 0x1161
*** 89,111 **** } return &decomp_data[index]; } ! static int get_comp_index(uint32_t code, const Reindex *idx) { ! int i; ! for (i = 0; idx[i].start; i++) { ! const Reindex *cur = &idx[i]; ! if (code < cur->start) return -1; ! if (code <= cur->start + cur->count) { ! return cur->index + (code - cur->start); ! } ! } return -1; } static int compare_mp(const void *a, const void *b) { --- 88,120 ---- } return &decomp_data[index]; } ! static int compare_reindex(const void *a, const void *b) { ! Reindex *ra = (Reindex *)a; ! Reindex *rb = (Reindex *)b; ! if (ra->start < rb->start) return -1; ! else if (ra->start > (rb->start + rb->count)) ! return 1; ! else ! return 0; ! } ! ! static int get_comp_index(uint32_t code, const Reindex *idx, size_t len) ! { ! Reindex *res; ! Reindex r = {0, 0, 0}; ! r.start = code; ! res = (Reindex *) bsearch(&r, idx, len, sizeof(Reindex), compare_reindex); + if (res != NULL) + return res->index + (code - res->start); + else return -1; } static int compare_mp(const void *a, const void *b) {
*** 125,136 **** { BracketPair bp = {0,0,2}; BracketPair *res; bp.from = code; ! res = bsearch(&bp, bracket_pairs, BIDI_BRACKET_LEN, sizeof(BracketPair), ! compare_bp); return res; } static int hangul_pair_decompose(uint32_t code, uint32_t *a, uint32_t *b) { --- 134,145 ---- { BracketPair bp = {0,0,2}; BracketPair *res; bp.from = code; ! res = (BracketPair *) bsearch(&bp, bracket_pairs, BIDI_BRACKET_LEN, ! sizeof(BracketPair), compare_bp); return res; } static int hangul_pair_decompose(uint32_t code, uint32_t *a, uint32_t *b) {
*** 152,186 **** } } static int hangul_pair_compose(uint32_t *code, uint32_t a, uint32_t b) { ! if (b < VBASE || b >= (TBASE + TCOUNT)) ! return 0; ! ! if ((a < LBASE || a >= (LBASE + LCOUNT)) ! && (a < SBASE || a >= (SBASE + SCOUNT))) ! return 0; ! ! if (a >= SBASE) { /* LV,T */ *code = a + (b - TBASE); return 3; ! } else { /* L,V */ int li = a - LBASE; int vi = b - VBASE; *code = SBASE + li * NCOUNT + vi * TCOUNT; return 2; } } static uint32_t decode_utf16(const unsigned short **code_ptr) { const unsigned short *code = *code_ptr; ! if ((code[0] & 0xd800) != 0xd800) { *code_ptr += 1; return (uint32_t)code[0]; } else { *code_ptr += 2; return 0x10000 + ((uint32_t)code[1] - 0xdc00) + --- 161,190 ---- } } static int hangul_pair_compose(uint32_t *code, uint32_t a, uint32_t b) { ! if (a >= SBASE && a < (SBASE + SCOUNT) && b >= TBASE && b < (TBASE + TCOUNT)) { /* LV,T */ *code = a + (b - TBASE); return 3; ! } else if (a >= LBASE && a < (LBASE + LCOUNT) && b >= VBASE && b < (VBASE + VCOUNT)) { /* L,V */ int li = a - LBASE; int vi = b - VBASE; *code = SBASE + li * NCOUNT + vi * TCOUNT; return 2; + } else { + return 0; } } static uint32_t decode_utf16(const unsigned short **code_ptr) { const unsigned short *code = *code_ptr; ! if (code[0] < 0xd800 || code[0] > 0xdc00) { *code_ptr += 1; return (uint32_t)code[0]; } else { *code_ptr += 2; return 0x10000 + ((uint32_t)code[1] - 0xdc00) +
*** 213,223 **** return get_ucd_record(code)->bidi_class; } int ucdn_get_mirrored(uint32_t code) { ! return get_ucd_record(code)->mirrored; } int ucdn_get_script(uint32_t code) { return get_ucd_record(code)->script; --- 217,227 ---- return get_ucd_record(code)->bidi_class; } int ucdn_get_mirrored(uint32_t code) { ! return ucdn_mirror(code) != code; } int ucdn_get_script(uint32_t code) { return get_ucd_record(code)->script;
*** 262,277 **** uint32_t ucdn_mirror(uint32_t code) { MirrorPair mp = {0}; MirrorPair *res; - if (get_ucd_record(code)->mirrored == 0) - return code; - mp.from = code; ! res = bsearch(&mp, mirror_pairs, BIDI_MIRROR_LEN, sizeof(MirrorPair), ! compare_mp); if (res == NULL) return code; else return res->to; --- 266,278 ---- uint32_t ucdn_mirror(uint32_t code) { MirrorPair mp = {0}; MirrorPair *res; mp.from = code; ! res = (MirrorPair *) bsearch(&mp, mirror_pairs, BIDI_MIRROR_LEN, ! sizeof(MirrorPair), compare_mp); if (res == NULL) return code; else return res->to;
*** 324,335 **** int l, r, index, indexi, offset; if (hangul_pair_compose(code, a, b)) return 1; ! l = get_comp_index(a, nfc_first); ! r = get_comp_index(b, nfc_last); if (l < 0 || r < 0) return 0; indexi = l * TOTAL_LAST + r; --- 325,336 ---- int l, r, index, indexi, offset; if (hangul_pair_compose(code, a, b)) return 1; ! l = get_comp_index(a, nfc_first, sizeof(nfc_first) / sizeof(Reindex)); ! r = get_comp_index(b, nfc_last, sizeof(nfc_last) / sizeof(Reindex)); if (l < 0 || r < 0) return 0; indexi = l * TOTAL_LAST + r;
< prev index next >