From 89a2bc9ba674e7e57fec1fd8ce7648a44f3aab63 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 31 May 2011 15:18:13 -0400 Subject: [PATCH] [Vertical] Apply vertical features We apply all of vert, vrt2, vkrn, valt, and vpal. --- TODO | 7 ------- src/hb-ot-shape.cc | 50 +++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 41 insertions(+), 16 deletions(-) diff --git a/TODO b/TODO index a03923f..b7d8e71 100644 --- a/TODO +++ b/TODO @@ -11,13 +11,6 @@ General fixes: - Do proper rounding when scaling from font space? -- Adjust default features for vertical text: - - * vrt2 preferred over vert; but if user selects vert, turn vrt2 off? - * vkrn (enables vpal? vpal anyone???); - * valt: "This feature is mutually exclusive with all other glyph-height features (e.g. vhal and vpal), - which should be turned off when it's applied. It deactivates the kern." - API issues to fix before 1.0: ============================ diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 4b66dd1..9df92a3 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -34,18 +34,36 @@ HB_BEGIN_DECLS -/* XXX vertical */ -hb_tag_t default_features[] = { - HB_TAG('c','a','l','t'), +hb_tag_t early_features[] = { HB_TAG('c','c','m','p'), + HB_TAG('l','o','c','l'), +}; + +hb_tag_t common_features[] = { + HB_TAG('m','a','r','k'), + HB_TAG('m','k','m','k'), + HB_TAG('r','l','i','g'), +}; + +hb_tag_t horizontal_features[] = { + HB_TAG('c','a','l','t'), HB_TAG('c','l','i','g'), HB_TAG('c','u','r','s'), HB_TAG('k','e','r','n'), HB_TAG('l','i','g','a'), - HB_TAG('l','o','c','l'), - HB_TAG('m','a','r','k'), - HB_TAG('m','k','m','k'), - HB_TAG('r','l','i','g') +}; + +/* Note: + * Technically speaking, vrt2 and vert are mutually exclusive. + * According to the spec, valt and vpal are also mutually exclusive. + * But we apply them all for now. + */ +hb_tag_t vertical_features[] = { + HB_TAG('v','a','l','t'), + HB_TAG('v','e','r','t'), + HB_TAG('v','k','r','n'), + HB_TAG('v','p','a','l'), + HB_TAG('v','r','t','2'), }; static void @@ -70,11 +88,25 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner, break; } - for (unsigned int i = 0; i < ARRAY_LENGTH (default_features); i++) - planner->map.add_bool_feature (default_features[i]); +#define ADD_FEATURES(array) \ + HB_STMT_START { \ + for (unsigned int i = 0; i < ARRAY_LENGTH (array); i++) \ + planner->map.add_bool_feature (array[i]); \ + } HB_STMT_END + + ADD_FEATURES (early_features); hb_ot_shape_complex_collect_features (planner, props); + ADD_FEATURES (common_features); + + if (HB_DIRECTION_IS_HORIZONTAL (props->direction)) + ADD_FEATURES (horizontal_features); + else + ADD_FEATURES (vertical_features); + +#undef ADD_FEATURES + for (unsigned int i = 0; i < num_user_features; i++) { const hb_feature_t *feature = &user_features[i]; planner->map.add_feature (feature->tag, feature->value, (feature->start == 0 && feature->end == (unsigned int) -1)); -- 2.7.4