📄 thai-shaper.c
字号:
thai_make_glyph_tis (font_info, ucs2tis (cluster[1])); return n; } break; case 3: if (is_char_type (cluster[0], NoTailCons|BotTailCons|SpltTailCons) && is_char_type (cluster[1], Tone) && is_char_type (cluster[2], SaraAm)) { glyph_lists[0] = thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); glyph_lists[1] = thai_make_glyph_tis (font_info, shaping_table->AmComp[0]); glyph_lists[2] = thai_make_glyph_tis (font_info, ucs2tis (cluster[1])); glyph_lists[3] = thai_make_glyph_tis (font_info, shaping_table->AmComp[1]); return 4; } else if (is_char_type (cluster[0], UpTailCons) && is_char_type (cluster[1], Tone) && is_char_type (cluster[2], SaraAm)) { glyph_lists[0] = thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); glyph_lists[1] = thai_make_glyph_tis (font_info, shiftleft_tone_ad (shaping_table->AmComp[0], shaping_table)); glyph_lists[2] = thai_make_glyph_tis (font_info, shiftleft_tone_ad (ucs2tis (cluster[1]), shaping_table)); glyph_lists[3] = thai_make_glyph_tis (font_info, shaping_table->AmComp[1]); return 4; } else if (is_char_type (cluster[0], UpTailCons) && is_char_type (cluster[1], AboveVowel) && is_char_type (cluster[2], AboveDiac|Tone)) { glyph_lists[0] = thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); glyph_lists[1] = thai_make_glyph_tis (font_info, shiftleft_av (ucs2tis (cluster[1]), shaping_table)); glyph_lists[2] = thai_make_glyph_tis (font_info, shiftleft_tone_ad (ucs2tis (cluster[2]), shaping_table)); return 3; } else if (is_char_type (cluster[0], UpTailCons) && is_char_type (cluster[1], BelowVowel) && is_char_type (cluster[2], AboveDiac|Tone)) { glyph_lists[0] = thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); glyph_lists[1] = thai_make_glyph_tis (font_info, ucs2tis (cluster[1])); glyph_lists[2] = thai_make_glyph_tis (font_info, shiftdownleft_tone_ad (ucs2tis (cluster[2]), shaping_table)); return 3; } else if (is_char_type (cluster[0], NoTailCons) && is_char_type (cluster[1], BelowVowel) && is_char_type (cluster[2], AboveDiac|Tone)) { glyph_lists[0] = thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); glyph_lists[1] = thai_make_glyph_tis (font_info, ucs2tis (cluster[1])); glyph_lists[2] = thai_make_glyph_tis (font_info, shiftdown_tone_ad (ucs2tis (cluster[2]), shaping_table)); return 3; } else if (is_char_type (cluster[0], SpltTailCons) && is_char_type (cluster[1], BelowVowel) && is_char_type (cluster[2], AboveDiac|Tone)) { glyph_lists[0] = thai_make_glyph_tis (font_info, tailcutcons (ucs2tis (cluster[0]), shaping_table)); glyph_lists[1] = thai_make_glyph_tis (font_info, ucs2tis (cluster[1])); glyph_lists[2] = thai_make_glyph_tis (font_info, shiftdown_tone_ad (ucs2tis (cluster[2]), shaping_table)); return 3; } else if (is_char_type (cluster[0], BotTailCons) && is_char_type (cluster[1], BelowVowel) && is_char_type (cluster[2], AboveDiac|Tone)) { glyph_lists[0] = thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); glyph_lists[1] = thai_make_glyph_tis (font_info, shiftdown_bv_bd (ucs2tis (cluster[1]), shaping_table)); glyph_lists[2] = thai_make_glyph_tis (font_info, shiftdown_tone_ad (ucs2tis (cluster[2]), shaping_table)); return 3; } else { glyph_lists[0] = thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); glyph_lists[1] = thai_make_glyph_tis (font_info, ucs2tis (cluster[1])); glyph_lists[2] = thai_make_glyph_tis (font_info, ucs2tis (cluster[2])); return 3; } break; default: /* e.g. Lao cluster with below cons + upper/lower vowel + tone */ { gint i; for (i = 0; i < num_chrs; i++) glyph_lists[i] = thai_make_glyph_tis (font_info, ucs2tis (cluster[i])); return num_chrs; } } return 0;}static gintget_glyphs_list (ThaiFontInfo *font_info, PangoScript script, gunichar *cluster, gint num_chrs, PangoGlyph *glyph_lists){ gint i; switch (script) { case PANGO_SCRIPT_THAI: switch (font_info->font_set) { default: case THAI_FONT_NONE: for (i=0; i < num_chrs; i++) glyph_lists[i] = thai_make_unknown_glyph (font_info, cluster[i]); return num_chrs; case THAI_FONT_TIS: /* TIS620-0 + Wtt2.0 Extension */ return get_adjusted_glyphs_list (font_info, cluster, num_chrs, glyph_lists, &tis620_0_shape_table); case THAI_FONT_TIS_MAC: /* MacIntosh Extension */ return get_adjusted_glyphs_list (font_info, cluster, num_chrs, glyph_lists, &Mac_shape_table); case THAI_FONT_TIS_WIN: /* Microsoft Extension */ return get_adjusted_glyphs_list (font_info, cluster, num_chrs, glyph_lists, &Win_shape_table); } break; case PANGO_SCRIPT_LAO: return get_adjusted_glyphs_list (font_info, cluster, num_chrs, glyph_lists, &Lao_shape_table); default: for (i=0; i < num_chrs; i++) glyph_lists[i] = thai_make_unknown_glyph (font_info, cluster[i]); return num_chrs; } return 0; /* Quiet GCC */}static voidadd_cluster (ThaiFontInfo *font_info, PangoScript script, PangoGlyphString *glyphs, gint cluster_start, gunichar *cluster, gint num_chrs){ PangoGlyph glyphs_list[MAX_GLYPHS]; gint num_glyphs; gint i; if (isthai (cluster[0])) { num_glyphs = get_glyphs_list(font_info, script, cluster, num_chrs, glyphs_list); for (i=0; i<num_glyphs; i++) add_glyph (font_info, glyphs, cluster_start, glyphs_list[i], i == 0 ? FALSE : TRUE); } else if (islao (cluster[0])) { num_glyphs = get_glyphs_list(font_info, script, cluster, num_chrs, glyphs_list); for (i=0; i<num_glyphs; i++) add_glyph (font_info, glyphs, cluster_start, glyphs_list[i], i == 0 ? FALSE : TRUE); } else { g_assert (num_chrs == 1); add_glyph (font_info, glyphs, cluster_start, thai_make_glyph_uni (font_info, cluster[0]), FALSE); }}static gbooleanis_wtt_composible (gunichar cur_wc, gunichar nxt_wc){ switch (TAC_compose_input(cur_wc, nxt_wc)) { case 'A': case 'S': case 'R': case 'X': return FALSE; case 'C': return TRUE; } g_assert_not_reached (); return FALSE;}static const char *get_next_cluster(const char *text, gint length, gunichar *cluster, gint *num_chrs){ PangoScript cluster_script = PANGO_SCRIPT_INVALID_CODE, cur_script; const char *p; gint n_chars = 0; gunichar current; for (p = text; p < text + length; p = g_utf8_next_char (p)) { current = g_utf8_get_char (p); cur_script = pango_script_for_unichar (current); if (cluster_script == PANGO_SCRIPT_INVALID_CODE) cluster_script = cur_script; if (cur_script != cluster_script || (n_chars > 0 && !is_wtt_composible (cluster[n_chars - 1], current))) break; cluster[n_chars++] = current; } *num_chrs = n_chars; return p;}voidthai_set_glyphs (ThaiFontInfo *font_info, const char *text, gint length, PangoScript script, PangoGlyphString *glyphs){ gint n_chars; const char *p; const char *log_cluster; gunichar cluster[MAX_CLUSTER_CHRS]; pango_glyph_string_set_size (glyphs, 0); p = text; while (p < text + length) { log_cluster = p; p = get_next_cluster (p, text + length - p, cluster, &n_chars); add_cluster (font_info, script, glyphs, log_cluster - text, cluster, n_chars); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -