Dear all, Thanks to Olivier Berten who let me know that all I need is to tell hb which opentype features I want to use in order for Indic to work, I got Indic scripts to work.
As said before, I can't read these languages, but from what I have seen, it works like a charm. I just took the list of features used in Harfbuzz.old and hacked together an Indic shaper. Attached is a patch implementing that shaper. I don't know if adding those features is really enough, nor am I sure they need to be applied on all the scripts I applied them all, but this patch gets the job done. It's now roughly the same as the Arabic shaper. Let me know if you have any comments. Thanks, Tom. P.S Why don't we use the "init" feature by default?
>From 6d85220e15fdbb68a8ebf831558ac1c4e3687a23 Mon Sep 17 00:00:00 2001 From: Tom 'TAsn' Hacohen <[email protected]> Date: Thu, 21 Apr 2011 17:33:45 +0300 Subject: [PATCH] [Shaping] Added complex indic shaper. Currently I only add features that make sense for the various indic scripts. I just took the list of features from Harfbuzz.old, tweaked a bit and put it there. I don't speak those languages so I don't know if it's enough, but at least from my tests it looks good. --- src/Makefile.am | 1 + src/hb-ot-shape-complex-indic.cc | 55 ++++++++++++++++++++++++++++++++++++ src/hb-ot-shape-complex-private.hh | 15 +++++++++- src/hb-ot-shape-private.hh | 3 +- 4 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 src/hb-ot-shape-complex-indic.cc diff --git a/src/Makefile.am b/src/Makefile.am index 70c51d1..49ddc79 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -50,6 +50,7 @@ HBSOURCES += \ hb-ot-shape.cc \ hb-ot-shape-complex-arabic.cc \ hb-ot-shape-complex-arabic-table.h \ + hb-ot-shape-complex-indic.cc \ hb-ot-shape-complex-private.hh \ hb-ot-shape-private.hh \ hb-ot-tag.c \ diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc new file mode 100644 index 0000000..325b9f5 --- /dev/null +++ b/src/hb-ot-shape-complex-indic.cc @@ -0,0 +1,55 @@ +/* + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Author(s): Tom Hacohen <[email protected]> + */ + +#include "hb-ot-shape-complex-private.hh" + +HB_BEGIN_DECLS + +static const hb_tag_t indic_features[] = +{ + HB_TAG('a', 'b', 'v', 's'), + HB_TAG('a', 'k', 'h', 'n'), + HB_TAG('b', 'l', 'w', 'f'), + HB_TAG('b', 'l', 'w', 's'), + HB_TAG('c', 'j', 'c', 't'), + HB_TAG('h', 'a', 'l', 'f'), + HB_TAG('h', 'a', 'l', 'n'), + HB_TAG('i', 'n', 'i', 't'), + HB_TAG('n', 'u', 'k', 't'), + HB_TAG('p', 'r', 'e', 's'), + HB_TAG('p', 's', 't', 'f'), + HB_TAG('p', 's', 't', 's'), + HB_TAG('r', 'p', 'h', 'f'), + HB_TAG('v', 'a', 't', 'u'), +}; + +void +_hb_ot_shape_complex_collect_features_indic (hb_ot_shape_plan_t *plan, const hb_segment_properties_t *props) +{ + unsigned int num_features = sizeof(indic_features); + for (unsigned int i = 0; i < num_features; i++) + plan->map.add_bool_feature (indic_features[i], true); +} + +HB_END_DECLS diff --git a/src/hb-ot-shape-complex-private.hh b/src/hb-ot-shape-complex-private.hh index 8147945..aa0f758 100644 --- a/src/hb-ot-shape-complex-private.hh +++ b/src/hb-ot-shape-complex-private.hh @@ -45,7 +45,17 @@ hb_ot_shape_complex_categorize (const hb_segment_properties_t *props) case HB_SCRIPT_MANDAIC: case HB_SCRIPT_MONGOLIAN: return hb_ot_complex_shaper_arabic; - + case HB_SCRIPT_BENGALI: + case HB_SCRIPT_DEVANAGARI: + case HB_SCRIPT_GUJARATI: + case HB_SCRIPT_GURMUKHI: + case HB_SCRIPT_KANNADA: + case HB_SCRIPT_MALAYALAM: + case HB_SCRIPT_ORIYA: + case HB_SCRIPT_SINHALA: + case HB_SCRIPT_TAMIL: + case HB_SCRIPT_TELUGU: + return hb_ot_complex_shaper_indic; default: return hb_ot_complex_shaper_none; } @@ -63,12 +73,15 @@ hb_ot_shape_complex_categorize (const hb_segment_properties_t *props) HB_INTERNAL void _hb_ot_shape_complex_collect_features_arabic (hb_ot_shape_plan_t *plan, const hb_segment_properties_t *props); +HB_INTERNAL void _hb_ot_shape_complex_collect_features_indic (hb_ot_shape_plan_t *plan, const hb_segment_properties_t *props); + static inline void hb_ot_shape_complex_collect_features (hb_ot_shape_plan_t *plan, const hb_segment_properties_t *props) { switch (plan->shaper) { case hb_ot_complex_shaper_arabic: _hb_ot_shape_complex_collect_features_arabic (plan, props); return; + case hb_ot_complex_shaper_indic: _hb_ot_shape_complex_collect_features_indic (plan, props); return; case hb_ot_complex_shaper_none: default: return; } } diff --git a/src/hb-ot-shape-private.hh b/src/hb-ot-shape-private.hh index 1a5c670..2460231 100644 --- a/src/hb-ot-shape-private.hh +++ b/src/hb-ot-shape-private.hh @@ -43,7 +43,8 @@ HB_BEGIN_DECLS enum hb_ot_complex_shaper_t { hb_ot_complex_shaper_none, - hb_ot_complex_shaper_arabic + hb_ot_complex_shaper_arabic, + hb_ot_complex_shaper_indic }; -- 1.7.0.4
_______________________________________________ HarfBuzz mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/harfbuzz
