Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(225)

Unified Diff: third_party/harfbuzz-ng/src/hb-ot-shape-complex-misc.cc

Issue 10915172: harfbuzz-ng roll (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/harfbuzz-ng/src/hb-ot-shape-complex-misc.cc
diff --git a/third_party/harfbuzz-ng/src/hb-ot-shape-complex-misc.cc b/third_party/harfbuzz-ng/src/hb-ot-shape-complex-misc.cc
index d93d4c672d7e6d6aaab5d1e45789e6ee8124c294..13bc22b4da9a9be1d299f91630a5a821beaff77e 100644
--- a/third_party/harfbuzz-ng/src/hb-ot-shape-complex-misc.cc
+++ b/third_party/harfbuzz-ng/src/hb-ot-shape-complex-misc.cc
@@ -1,5 +1,5 @@
/*
- * Copyright © 2010 Google, Inc.
+ * Copyright © 2010,2012 Google, Inc.
*
* This is part of HarfBuzz, a text shaping library.
*
@@ -29,101 +29,105 @@
/* TODO Add kana, and other small shapers here */
-/* When adding trivial shapers, eg. kana, hangul, etc, we can either
- * add a full shaper enum value for them, or switch on the script in
- * the default complex shaper. The former is faster, so I think that's
- * what we would do, and hence the default complex shaper shall remain
- * empty.
- */
-
-void
-_hb_ot_shape_complex_collect_features_default (hb_ot_map_builder_t *map HB_UNUSED,
- const hb_segment_properties_t *props HB_UNUSED)
-{
-}
-
-hb_ot_shape_normalization_mode_t
-_hb_ot_shape_complex_normalization_preference_default (void)
-{
- return HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS;
-}
-void
-_hb_ot_shape_complex_setup_masks_default (hb_ot_map_t *map HB_UNUSED,
- hb_buffer_t *buffer HB_UNUSED,
- hb_font_t *font HB_UNUSED)
-{
-}
-
-
-
-/* Hangul shaper */
+/* The default shaper *only* adds additional per-script features.*/
static const hb_tag_t hangul_features[] =
{
HB_TAG('l','j','m','o'),
HB_TAG('v','j','m','o'),
HB_TAG('t','j','m','o'),
+ HB_TAG_NONE
};
-void
-_hb_ot_shape_complex_collect_features_hangul (hb_ot_map_builder_t *map,
- const hb_segment_properties_t *props HB_UNUSED)
+static const hb_tag_t tibetan_features[] =
{
- for (unsigned int i = 0; i < ARRAY_LENGTH (hangul_features); i++)
- map->add_bool_feature (hangul_features[i]);
-}
+ HB_TAG('a','b','v','s'),
+ HB_TAG('b','l','w','s'),
+ HB_TAG('a','b','v','m'),
+ HB_TAG('b','l','w','m'),
+ HB_TAG_NONE
+};
-hb_ot_shape_normalization_mode_t
-_hb_ot_shape_complex_normalization_preference_hangul (void)
+static void
+collect_features_default (hb_ot_shape_planner_t *plan)
{
- return HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_FULL;
+ const hb_tag_t *script_features = NULL;
+
+ switch ((hb_tag_t) plan->props.script)
+ {
+ /* Unicode-1.1 additions */
+ case HB_SCRIPT_HANGUL:
+ script_features = hangul_features;
+ break;
+
+ /* Unicode-2.0 additions */
+ case HB_SCRIPT_TIBETAN:
+ script_features = tibetan_features;
+ break;
+ }
+
+ for (; script_features && *script_features; script_features++)
+ plan->map.add_bool_feature (*script_features);
}
-void
-_hb_ot_shape_complex_setup_masks_hangul (hb_ot_map_t *map HB_UNUSED,
- hb_buffer_t *buffer HB_UNUSED,
- hb_font_t *font HB_UNUSED)
+static hb_ot_shape_normalization_mode_t
+normalization_preference_default (const hb_ot_shape_plan_t *plan)
{
+ switch ((hb_tag_t) plan->props.script)
+ {
+ /* Unicode-1.1 additions */
+ case HB_SCRIPT_HANGUL:
+ return HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_FULL;
+ }
+ return HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS;
}
+const hb_ot_complex_shaper_t _hb_ot_complex_shaper_default =
+{
+ "default",
+ collect_features_default,
+ NULL, /* override_features */
+ NULL, /* data_create */
+ NULL, /* data_destroy */
+ NULL, /* preprocess_text */
+ normalization_preference_default,
+ NULL, /* setup_masks */
+ true, /* zero_width_attached_marks */
+};
/* Thai / Lao shaper */
-void
-_hb_ot_shape_complex_collect_features_thai (hb_ot_map_builder_t *map HB_UNUSED,
- const hb_segment_properties_t *props HB_UNUSED)
-{
-}
-
-hb_ot_shape_normalization_mode_t
-_hb_ot_shape_complex_normalization_preference_thai (void)
-{
- return HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_FULL;
-}
-
-void
-_hb_ot_shape_complex_setup_masks_thai (hb_ot_map_t *map HB_UNUSED,
- hb_buffer_t *buffer,
- hb_font_t *font HB_UNUSED)
+static void
+preprocess_text_thai (const hb_ot_shape_plan_t *plan HB_UNUSED,
+ hb_buffer_t *buffer,
+ hb_font_t *font HB_UNUSED)
{
/* The following is NOT specified in the MS OT Thai spec, however, it seems
* to be what Uniscribe and other engines implement. According to Eric Muller:
*
- * When you have a sara am, decompose it in nikhahit + sara a, *and* mode the
- * nihka hit backwards over any *tone* mark (0E48-0E4B).
+ * When you have a SARA AM, decompose it in NIKHAHIT + SARA AA, *and* move the
+ * NIKHAHIT backwards over any tone mark (0E48-0E4B).
*
* <0E14, 0E4B, 0E33> -> <0E14, 0E4D, 0E4B, 0E32>
*
- * This reordering is legit only when the nikhahit comes from a sara am, not
+ * This reordering is legit only when the NIKHAHIT comes from a SARA AM, not
* when it's there to start with. The string <0E14, 0E4B, 0E4D> is probably
- * not what a u↪ser wanted, but the rendering is nevertheless nikhahit above
+ * not what a user wanted, but the rendering is nevertheless nikhahit above
* chattawa.
*
* Same for Lao.
+ *
+ * Note:
+ *
+ * Uniscribe also does so below-marks reordering. Namely, it positions U+0E3A
+ * after U+0E38 and U+0E39. We do that by modifying the ccc for U+0E3A.
+ * See unicode->modified_combining_class (). Lao does NOT have a U+0E3A
+ * equivalent.
*/
+
/*
* Here are the characters of significance:
*
@@ -132,9 +136,9 @@ _hb_ot_shape_complex_setup_masks_thai (hb_ot_map_t *map HB_UNUSED,
* SARA AA: U+0E32 U+0EB2
* Nikhahit: U+0E4D U+0ECD
*
- * Tone marks:
- * Thai: <0E48..0E4B> CCC=107
- * Lao: <0EC8..0ECB> CCC=122
+ * Testing shows that Uniscribe reorder the following marks:
+ * Thai: <0E31,0E34..0E37,0E47..0E4E>
+ * Lao: <0EB1,0EB4..0EB7,0EC7..0ECE>
*
* Note how the Lao versions are the same as Thai + 0x80.
*/
@@ -144,7 +148,7 @@ _hb_ot_shape_complex_setup_masks_thai (hb_ot_map_t *map HB_UNUSED,
#define IS_SARA_AM(x) (((x) & ~0x0080) == 0x0E33)
#define NIKHAHIT_FROM_SARA_AM(x) ((x) - 0xE33 + 0xE4D)
#define SARA_AA_FROM_SARA_AM(x) ((x) - 1)
-#define IS_TONE_MARK(x) (((x) & ~0x0083) == 0x0E48)
+#define IS_TONE_MARK(x) (hb_in_ranges<hb_codepoint_t> ((x) & ~0x0080, 0x0E34, 0x0E37, 0x0E47, 0x0E4E, 0x0E31, 0x0E31))
buffer->clear_output ();
unsigned int count = buffer->len;
@@ -169,25 +173,36 @@ _hb_ot_shape_complex_setup_masks_thai (hb_ot_map_t *map HB_UNUSED,
while (start > 0 && IS_TONE_MARK (buffer->out_info[start - 1].codepoint))
start--;
- /* Move Nikhahit (end-2) to the beginning */
- hb_glyph_info_t t = buffer->out_info[end - 2];
- memmove (buffer->out_info + start + 1,
- buffer->out_info + start,
- sizeof (buffer->out_info[0]) * (end - start - 2));
- buffer->out_info[start] = t;
-
- /* XXX Make this easier! */
- /* Make cluster */
- for (; start > 0 && buffer->out_info[start - 1].cluster == buffer->out_info[start].cluster; start--)
- ;
- for (; buffer->idx < count;)
- if (buffer->cur().cluster == buffer->prev().cluster)
- buffer->next_glyph ();
- else
- break;
- end = buffer->out_len;
-
- buffer->merge_out_clusters (start, end);
+ if (start + 2 < end)
+ {
+ /* Move Nikhahit (end-2) to the beginning */
+ buffer->merge_out_clusters (start, end);
+ hb_glyph_info_t t = buffer->out_info[end - 2];
+ memmove (buffer->out_info + start + 1,
+ buffer->out_info + start,
+ sizeof (buffer->out_info[0]) * (end - start - 2));
+ buffer->out_info[start] = t;
+ }
+ else
+ {
+ /* Since we decomposed, and NIKHAHIT is combining, merge clusters with the
+ * previous cluster. */
+ if (start)
+ buffer->merge_out_clusters (start - 1, end);
+ }
}
buffer->swap_buffers ();
}
+
+const hb_ot_complex_shaper_t _hb_ot_complex_shaper_thai =
+{
+ "thai",
+ NULL, /* collect_features */
+ NULL, /* override_features */
+ NULL, /* data_create */
+ NULL, /* data_destroy */
+ preprocess_text_thai,
+ NULL, /* normalization_preference */
+ NULL, /* setup_masks */
+ true, /* zero_width_attached_marks */
+};

Powered by Google App Engine
This is Rietveld 408576698