2011-07-08 04:35:17 +02:00
|
|
|
/*
|
2012-08-12 00:34:13 +02:00
|
|
|
* Copyright © 2010,2012 Google, Inc.
|
2011-07-08 04:35:17 +02:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* Google Author(s): Behdad Esfahbod
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "hb-ot-shape-complex-private.hh"
|
|
|
|
|
|
|
|
|
2012-04-10 16:52:07 +02:00
|
|
|
/* TODO Add kana, and other small shapers here */
|
2011-07-08 04:35:17 +02:00
|
|
|
|
2012-07-17 02:26:57 +02:00
|
|
|
|
2012-07-18 22:34:10 +02:00
|
|
|
/* The default shaper *only* adds additional per-script features.*/
|
2012-04-10 16:52:07 +02:00
|
|
|
|
2012-04-12 04:00:46 +02:00
|
|
|
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'),
|
2012-07-18 22:34:10 +02:00
|
|
|
HB_TAG_NONE
|
|
|
|
};
|
|
|
|
|
|
|
|
static const hb_tag_t tibetan_features[] =
|
|
|
|
{
|
|
|
|
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
|
2012-04-12 04:00:46 +02:00
|
|
|
};
|
|
|
|
|
2012-07-31 03:08:51 +02:00
|
|
|
static void
|
2012-08-02 15:38:28 +02:00
|
|
|
collect_features_default (hb_ot_shape_planner_t *plan)
|
2012-04-07 21:06:55 +02:00
|
|
|
{
|
2012-07-18 22:34:10 +02:00
|
|
|
const hb_tag_t *script_features = NULL;
|
|
|
|
|
2012-08-02 15:38:28 +02:00
|
|
|
switch ((hb_tag_t) plan->props.script)
|
2012-07-18 22:34:10 +02:00
|
|
|
{
|
|
|
|
/* 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++)
|
2012-08-02 15:38:28 +02:00
|
|
|
plan->map.add_bool_feature (*script_features);
|
2012-04-07 21:06:55 +02:00
|
|
|
}
|
|
|
|
|
2012-07-31 03:08:51 +02:00
|
|
|
static hb_ot_shape_normalization_mode_t
|
2012-11-13 21:35:35 +01:00
|
|
|
normalization_preference_default (const hb_segment_properties_t *props)
|
2012-04-07 21:06:55 +02:00
|
|
|
{
|
2012-11-13 21:35:35 +01:00
|
|
|
switch ((hb_tag_t) props->script)
|
2012-07-30 20:53:41 +02:00
|
|
|
{
|
|
|
|
/* Unicode-1.1 additions */
|
|
|
|
case HB_SCRIPT_HANGUL:
|
|
|
|
return HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_FULL;
|
|
|
|
}
|
2012-07-18 22:34:10 +02:00
|
|
|
return HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS;
|
2012-04-07 21:06:55 +02:00
|
|
|
}
|
|
|
|
|
2012-11-16 21:39:23 +01:00
|
|
|
static bool
|
|
|
|
compose_default (const hb_ot_shape_normalize_context_t *c,
|
2012-11-13 21:35:35 +01:00
|
|
|
hb_codepoint_t a,
|
|
|
|
hb_codepoint_t b,
|
|
|
|
hb_codepoint_t *ab)
|
|
|
|
{
|
|
|
|
/* Hebrew presentation-form shaping.
|
2012-11-17 03:49:54 +01:00
|
|
|
* https://bugzilla.mozilla.org/show_bug.cgi?id=728866
|
|
|
|
* Hebrew presentation forms with dagesh, for characters 0x05D0..0x05EA;
|
|
|
|
* Note that some letters do not have a dagesh presForm encoded.
|
|
|
|
*/
|
2012-11-13 21:35:35 +01:00
|
|
|
static const hb_codepoint_t sDageshForms[0x05EA - 0x05D0 + 1] = {
|
2012-11-17 03:49:54 +01:00
|
|
|
0xFB30, /* ALEF */
|
|
|
|
0xFB31, /* BET */
|
|
|
|
0xFB32, /* GIMEL */
|
|
|
|
0xFB33, /* DALET */
|
|
|
|
0xFB34, /* HE */
|
|
|
|
0xFB35, /* VAV */
|
|
|
|
0xFB36, /* ZAYIN */
|
|
|
|
0x0000, /* HET */
|
|
|
|
0xFB38, /* TET */
|
|
|
|
0xFB39, /* YOD */
|
|
|
|
0xFB3A, /* FINAL KAF */
|
|
|
|
0xFB3B, /* KAF */
|
|
|
|
0xFB3C, /* LAMED */
|
|
|
|
0x0000, /* FINAL MEM */
|
|
|
|
0xFB3E, /* MEM */
|
|
|
|
0x0000, /* FINAL NUN */
|
|
|
|
0xFB40, /* NUN */
|
|
|
|
0xFB41, /* SAMEKH */
|
|
|
|
0x0000, /* AYIN */
|
|
|
|
0xFB43, /* FINAL PE */
|
|
|
|
0xFB44, /* PE */
|
|
|
|
0x0000, /* FINAL TSADI */
|
|
|
|
0xFB46, /* TSADI */
|
|
|
|
0xFB47, /* QOF */
|
|
|
|
0xFB48, /* RESH */
|
|
|
|
0xFB49, /* SHIN */
|
|
|
|
0xFB4A /* TAV */
|
2012-11-13 21:35:35 +01:00
|
|
|
};
|
|
|
|
|
2012-11-16 21:39:23 +01:00
|
|
|
bool found = c->unicode->compose (a, b, ab);
|
2012-11-13 21:35:35 +01:00
|
|
|
|
|
|
|
if (!found && (b & ~0x7F) == 0x0580) {
|
2012-11-17 03:49:54 +01:00
|
|
|
/* Special-case Hebrew presentation forms that are excluded from
|
|
|
|
* standard normalization, but wanted for old fonts. */
|
2012-11-13 21:35:35 +01:00
|
|
|
switch (b) {
|
2012-11-17 03:49:54 +01:00
|
|
|
case 0x05B4: /* HIRIQ */
|
|
|
|
if (a == 0x05D9) { /* YOD */
|
2012-11-13 21:35:35 +01:00
|
|
|
*ab = 0xFB1D;
|
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
break;
|
2012-11-17 03:49:54 +01:00
|
|
|
case 0x05B7: /* patah */
|
|
|
|
if (a == 0x05F2) { /* YIDDISH YOD YOD */
|
2012-11-13 21:35:35 +01:00
|
|
|
*ab = 0xFB1F;
|
|
|
|
found = true;
|
2012-11-17 03:49:54 +01:00
|
|
|
} else if (a == 0x05D0) { /* ALEF */
|
2012-11-13 21:35:35 +01:00
|
|
|
*ab = 0xFB2E;
|
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
break;
|
2012-11-17 03:49:54 +01:00
|
|
|
case 0x05B8: /* QAMATS */
|
|
|
|
if (a == 0x05D0) { /* ALEF */
|
2012-11-13 21:35:35 +01:00
|
|
|
*ab = 0xFB2F;
|
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
break;
|
2012-11-17 03:49:54 +01:00
|
|
|
case 0x05B9: /* HOLAM */
|
|
|
|
if (a == 0x05D5) { /* VAV */
|
2012-11-13 21:35:35 +01:00
|
|
|
*ab = 0xFB4B;
|
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
break;
|
2012-11-17 03:49:54 +01:00
|
|
|
case 0x05BC: /* DAGESH */
|
2012-11-13 21:35:35 +01:00
|
|
|
if (a >= 0x05D0 && a <= 0x05EA) {
|
|
|
|
*ab = sDageshForms[a - 0x05D0];
|
|
|
|
found = (*ab != 0);
|
2012-11-17 03:49:54 +01:00
|
|
|
} else if (a == 0xFB2A) { /* SHIN WITH SHIN DOT */
|
2012-11-13 21:35:35 +01:00
|
|
|
*ab = 0xFB2C;
|
|
|
|
found = true;
|
2012-11-17 03:49:54 +01:00
|
|
|
} else if (a == 0xFB2B) { /* SHIN WITH SIN DOT */
|
2012-11-13 21:35:35 +01:00
|
|
|
*ab = 0xFB2D;
|
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
break;
|
2012-11-17 03:49:54 +01:00
|
|
|
case 0x05BF: /* RAFE */
|
2012-11-13 21:35:35 +01:00
|
|
|
switch (a) {
|
2012-11-17 03:49:54 +01:00
|
|
|
case 0x05D1: /* BET */
|
2012-11-13 21:35:35 +01:00
|
|
|
*ab = 0xFB4C;
|
|
|
|
found = true;
|
|
|
|
break;
|
2012-11-17 03:49:54 +01:00
|
|
|
case 0x05DB: /* KAF */
|
2012-11-13 21:35:35 +01:00
|
|
|
*ab = 0xFB4D;
|
|
|
|
found = true;
|
|
|
|
break;
|
2012-11-17 03:49:54 +01:00
|
|
|
case 0x05E4: /* PE */
|
2012-11-13 21:35:35 +01:00
|
|
|
*ab = 0xFB4E;
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2012-11-17 03:49:54 +01:00
|
|
|
case 0x05C1: /* SHIN DOT */
|
|
|
|
if (a == 0x05E9) { /* SHIN */
|
2012-11-13 21:35:35 +01:00
|
|
|
*ab = 0xFB2A;
|
|
|
|
found = true;
|
2012-11-17 03:49:54 +01:00
|
|
|
} else if (a == 0xFB49) { /* SHIN WITH DAGESH */
|
2012-11-13 21:35:35 +01:00
|
|
|
*ab = 0xFB2C;
|
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
break;
|
2012-11-17 03:49:54 +01:00
|
|
|
case 0x05C2: /* SIN DOT */
|
|
|
|
if (a == 0x05E9) { /* SHIN */
|
2012-11-13 21:35:35 +01:00
|
|
|
*ab = 0xFB2B;
|
|
|
|
found = true;
|
2012-11-17 03:49:54 +01:00
|
|
|
} else if (a == 0xFB49) { /* SHIN WITH DAGESH */
|
2012-11-13 21:35:35 +01:00
|
|
|
*ab = 0xFB2D;
|
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
2012-07-31 03:08:51 +02:00
|
|
|
const hb_ot_complex_shaper_t _hb_ot_complex_shaper_default =
|
2012-04-07 21:06:55 +02:00
|
|
|
{
|
2012-07-31 03:08:51 +02:00
|
|
|
"default",
|
|
|
|
collect_features_default,
|
|
|
|
NULL, /* override_features */
|
2012-08-02 16:46:34 +02:00
|
|
|
NULL, /* data_create */
|
|
|
|
NULL, /* data_destroy */
|
2012-08-12 00:34:13 +02:00
|
|
|
NULL, /* preprocess_text */
|
2012-07-31 03:08:51 +02:00
|
|
|
normalization_preference_default,
|
2012-11-13 21:35:35 +01:00
|
|
|
NULL, /* decompose */
|
|
|
|
compose_default,
|
2012-07-31 03:08:51 +02:00
|
|
|
NULL, /* setup_masks */
|
2012-08-01 05:41:06 +02:00
|
|
|
true, /* zero_width_attached_marks */
|
2012-11-14 22:48:26 +01:00
|
|
|
true, /* fallback_position */
|
2012-07-31 03:08:51 +02:00
|
|
|
};
|