#ifndef HB_NO_AAT_SHAPE /* If we're using morx shaping, we cancel mark position adjustment because Apple Color Emoji assumes this will NOT be done when forming emoji sequences; https://github.com/harfbuzz/harfbuzz/issues/2967. */ if (plan.apply_morx)
plan.adjust_mark_positioning_when_zeroing = false;
/* Currently we always apply trak. */
plan.apply_trak = plan.requested_tracking && hb_aat_layout_has_tracking (face); #endif
}
/* We really want to find a 'vert' feature if there's any in the font, no * matter which script/langsys it is listed (or not) under. * See various bugs referenced from:
* https://github.com/harfbuzz/harfbuzz/issues/63 */
map->enable_feature (HB_TAG ('v','e','r','t'), F_GLOBAL_SEARCH);
}
if (num_user_features)
map->is_simple = false; for (unsignedint i = 0; i < num_user_features; i++)
{ const hb_feature_t *feature = &user_features[i];
map->add_feature (feature->tag,
(feature->start == HB_FEATURE_GLOBAL_START &&
feature->end == HB_FEATURE_GLOBAL_END) ? F_GLOBAL : F_NONE,
feature->value);
}
if (planner->shaper->override_features)
planner->shaper->override_features (planner);
}
staticvoid
hb_set_unicode_props (hb_buffer_t *buffer)
{ /* Implement enough of Unicode Graphemes here that shaping * in reverse-direction wouldn't break graphemes. Namely, * we mark all marks and ZWJ and ZWJ,Extended_Pictographic * sequences as continuations. The foreach_grapheme() * macro uses this bit. * * https://www.unicode.org/reports/tr29/#Regex_Definitions
*/ unsignedint count = buffer->len;
hb_glyph_info_t *info = buffer->info; for (unsignedint i = 0; i < count; i++)
{
_hb_glyph_info_set_unicode_props (&info[i], buffer);
unsigned gen_cat = _hb_glyph_info_get_general_category (&info[i]); if (FLAG_UNSAFE (gen_cat) &
(FLAG (HB_UNICODE_GENERAL_CATEGORY_LOWERCASE_LETTER) |
FLAG (HB_UNICODE_GENERAL_CATEGORY_UPPERCASE_LETTER) |
FLAG (HB_UNICODE_GENERAL_CATEGORY_TITLECASE_LETTER) |
FLAG (HB_UNICODE_GENERAL_CATEGORY_OTHER_LETTER) |
FLAG (HB_UNICODE_GENERAL_CATEGORY_SPACE_SEPARATOR))) continue;
/* Marks are already set as continuation by the above line.
* Handle Emoji_Modifier and ZWJ-continuation. */ if (unlikely (gen_cat == HB_UNICODE_GENERAL_CATEGORY_MODIFIER_SYMBOL &&
hb_in_range<hb_codepoint_t> (info[i].codepoint, 0x1F3FBu, 0x1F3FFu)))
{
_hb_glyph_info_set_continuation (&info[i]);
} /* Regional_Indicators are hairy as hell...
* https://github.com/harfbuzz/harfbuzz/issues/2265 */ elseif (unlikely (i && _hb_codepoint_is_regional_indicator (info[i].codepoint)))
{ if (_hb_codepoint_is_regional_indicator (info[i - 1].codepoint) &&
!_hb_glyph_info_is_continuation (&info[i - 1]))
_hb_glyph_info_set_continuation (&info[i]);
} #ifndef HB_NO_EMOJI_SEQUENCES elseif (unlikely (_hb_glyph_info_is_zwj (&info[i])))
{
_hb_glyph_info_set_continuation (&info[i]); if (i + 1 < count &&
_hb_unicode_is_emoji_Extended_Pictographic (info[i + 1].codepoint))
{
i++;
_hb_glyph_info_set_unicode_props (&info[i], buffer);
_hb_glyph_info_set_continuation (&info[i]);
}
} #endif /* Or part of the Other_Grapheme_Extend that is not marks. * As of Unicode 15 that is just: * * 200C ; Other_Grapheme_Extend # Cf ZERO WIDTH NON-JOINER * FF9E..FF9F ; Other_Grapheme_Extend # Lm [2] HALFWIDTH KATAKANA VOICED SOUND MARK..HALFWIDTH KATAKANA SEMI-VOICED SOUND MARK * E0020..E007F ; Other_Grapheme_Extend # Cf [96] TAG SPACE..CANCEL TAG * * ZWNJ is special, we don't want to merge it as there's no need, and keeping * it separate results in more granular clusters. * Tags are used for Emoji sub-region flag sequences: * https://github.com/harfbuzz/harfbuzz/issues/1556 * Katakana ones were requested: * https://github.com/harfbuzz/harfbuzz/issues/3844
*/ elseif (unlikely (hb_in_ranges<hb_codepoint_t> (info[i].codepoint, 0xFF9Eu, 0xFF9Fu, 0xE0020u, 0xE007Fu)))
_hb_glyph_info_set_continuation (&info[i]);
}
}
/* Numeric runs in natively-RTL scripts are actually native-LTR, so we reset * the horiz_dir if the run contains at least one decimal-number char, and no * letter chars (ideally we should be checking for chars with strong * directionality but hb-unicode currently lacks bidi categories). * * This allows digit sequences in Arabic etc to be shaped in "native" * direction, so that features like ligatures will work as intended. * * https://github.com/harfbuzz/harfbuzz/issues/501 * * Similar thing about Regional_Indicators; They are bidi=L, but Script=Common. * If they are present in a run of natively-RTL text, they get assigned a script * with natively RTL direction, which would result in wrong shaping if we * assign such native RTL direction to them then. Detect that as well. * * https://github.com/harfbuzz/harfbuzz/issues/3314
*/ if (unlikely (horiz_dir == HB_DIRECTION_RTL && direction == HB_DIRECTION_LTR))
{ bool found_number = false, found_letter = false, found_ri = false; constauto* info = buffer->info; constauto count = buffer->len; for (unsigned i = 0; i < count; i++)
{ auto gc = _hb_glyph_info_get_general_category (&info[i]); if (gc == HB_UNICODE_GENERAL_CATEGORY_DECIMAL_NUMBER)
found_number = true; elseif (HB_UNICODE_GENERAL_CATEGORY_IS_LETTER (gc))
{
found_letter = true; break;
} elseif (_hb_codepoint_is_regional_indicator (info[i].codepoint))
found_ri = true;
} if ((found_number || found_ri) && !found_letter)
horiz_dir = HB_DIRECTION_LTR;
}
/* TODO vertical: * The only BTT vertical script is Ogham, but it's not clear to me whether OpenType * Ogham fonts are supposed to be implemented BTT or not. Need to research that
* first. */ if ((HB_DIRECTION_IS_HORIZONTAL (direction) &&
direction != horiz_dir && horiz_dir != HB_DIRECTION_INVALID) ||
(HB_DIRECTION_IS_VERTICAL (direction) &&
direction != HB_DIRECTION_TTB))
{
_hb_ot_layout_reverse_graphemes (buffer);
buffer->props.direction = HB_DIRECTION_REVERSE (buffer->props.direction);
}
}
/* * Substitute
*/
#ifndef HB_NO_VERTICAL static hb_codepoint_t
hb_vert_char_for (hb_codepoint_t u)
{ switch (u >> 8)
{ case 0x20: switch (u) { case 0x2013u: return 0xfe32u; // EN DASH case 0x2014u: return 0xfe31u; // EM DASH case 0x2025u: return 0xfe30u; // TWO DOT LEADER case 0x2026u: return 0xfe19u; // HORIZONTAL ELLIPSIS
} break; case 0x30: switch (u) { case 0x3001u: return 0xfe11u; // IDEOGRAPHIC COMMA case 0x3002u: return 0xfe12u; // IDEOGRAPHIC FULL STOP case 0x3008u: return 0xfe3fu; // LEFT ANGLE BRACKET case 0x3009u: return 0xfe40u; // RIGHT ANGLE BRACKET case 0x300au: return 0xfe3du; // LEFT DOUBLE ANGLE BRACKET case 0x300bu: return 0xfe3eu; // RIGHT DOUBLE ANGLE BRACKET case 0x300cu: return 0xfe41u; // LEFT CORNER BRACKET case 0x300du: return 0xfe42u; // RIGHT CORNER BRACKET case 0x300eu: return 0xfe43u; // LEFT WHITE CORNER BRACKET case 0x300fu: return 0xfe44u; // RIGHT WHITE CORNER BRACKET case 0x3010u: return 0xfe3bu; // LEFT BLACK LENTICULAR BRACKET case 0x3011u: return 0xfe3cu; // RIGHT BLACK LENTICULAR BRACKET case 0x3014u: return 0xfe39u; // LEFT TORTOISE SHELL BRACKET case 0x3015u: return 0xfe3au; // RIGHT TORTOISE SHELL BRACKET case 0x3016u: return 0xfe17u; // LEFT WHITE LENTICULAR BRACKET case 0x3017u: return 0xfe18u; // RIGHT WHITE LENTICULAR BRACKET
} break; case 0xfe: switch (u) { case 0xfe4fu: return 0xfe34u; // WAVY LOW LINE
} break; case 0xff: switch (u) { case 0xff01u: return 0xfe15u; // FULLWIDTH EXCLAMATION MARK case 0xff08u: return 0xfe35u; // FULLWIDTH LEFT PARENTHESIS case 0xff09u: return 0xfe36u; // FULLWIDTH RIGHT PARENTHESIS case 0xff0cu: return 0xfe10u; // FULLWIDTH COMMA case 0xff1au: return 0xfe13u; // FULLWIDTH COLON case 0xff1bu: return 0xfe14u; // FULLWIDTH SEMICOLON case 0xff1fu: return 0xfe16u; // FULLWIDTH QUESTION MARK case 0xff3bu: return 0xfe47u; // FULLWIDTH LEFT SQUARE BRACKET case 0xff3du: return 0xfe48u; // FULLWIDTH RIGHT SQUARE BRACKET case 0xff3fu: return 0xfe33u; // FULLWIDTH LOW LINE case 0xff5bu: return 0xfe37u; // FULLWIDTH LEFT CURLY BRACKET case 0xff5du: return 0xfe38u; // FULLWIDTH RIGHT CURLY BRACKET
} break;
}
hb_codepoint_t invisible = buffer->invisible; if (!(buffer->flags & HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES) &&
(invisible || font->get_nominal_glyph (' ', &invisible)))
{ /* Replace default-ignorables with a zero-advance invisible glyph. */ for (unsignedint i = 0; i < count; i++)
{ if (_hb_glyph_info_is_default_ignorable (&info[i]))
info[i].codepoint = invisible;
}
} else
buffer->delete_glyphs_inplace (_hb_glyph_info_is_default_ignorable);
}
staticinlinevoid
hb_ot_map_glyphs_fast (hb_buffer_t *buffer)
{ /* Normalization process sets up glyph_index(), we just copy it. */ unsignedint count = buffer->len;
hb_glyph_info_t *info = buffer->info; for (unsignedint i = 0; i < count; i++)
info[i].codepoint = info[i].glyph_index();
staticinlinevoid
hb_synthesize_glyph_classes (hb_buffer_t *buffer)
{ unsignedint count = buffer->len;
hb_glyph_info_t *info = buffer->info; for (unsignedint i = 0; i < count; i++)
{
hb_ot_layout_glyph_props_flags_t klass;
/* Never mark default-ignorables as marks. * They won't get in the way of lookups anyway, * but having them as mark will cause them to be skipped * over if the lookup-flag says so, but at least for the * Mongolian variation selectors, looks like Uniscribe * marks them as non-mark. Some Mongolian fonts without * GDEF rely on this. Another notable character that
* this applies to is COMBINING GRAPHEME JOINER. */
klass = (_hb_glyph_info_get_general_category (&info[i]) !=
HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK ||
_hb_glyph_info_is_default_ignorable (&info[i])) ?
HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH :
HB_OT_LAYOUT_GLYPH_PROPS_MARK;
_hb_glyph_info_set_glyph_props (&info[i], klass);
}
}
/* This is unfortunate to go here, but necessary... */ if (c->plan->fallback_mark_positioning)
_hb_ot_shape_fallback_mark_position_recategorize_marks (c->plan, c->font, buffer);
if (HB_DIRECTION_IS_HORIZONTAL (direction))
{
c->font->get_glyph_h_advances (count, &info[0].codepoint, sizeof(info[0]),
&pos[0].x_advance, sizeof(pos[0])); /* The nil glyph_h_origin() func returns 0, so no need to apply it. */ if (c->font->has_glyph_h_origin_func ()) for (unsignedint i = 0; i < count; i++)
c->font->subtract_glyph_h_origin (info[i].codepoint,
&pos[i].x_offset,
&pos[i].y_offset);
} else
{
c->font->get_glyph_v_advances (count, &info[0].codepoint, sizeof(info[0]),
&pos[0].y_advance, sizeof(pos[0])); for (unsignedint i = 0; i < count; i++)
{
c->font->subtract_glyph_v_origin (info[i].codepoint,
&pos[i].x_offset,
&pos[i].y_offset);
}
} if (c->buffer->scratch_flags & HB_BUFFER_SCRATCH_FLAG_HAS_SPACE_FALLBACK)
_hb_ot_shape_fallback_spaces (c->plan, c->font, c->buffer);
}
/* If the font has no GPOS and direction is forward, then when * zeroing mark widths, we shift the mark with it, such that the * mark is positioned hanging over the previous glyph. When * direction is backward we don't shift and it will end up * hanging over the next glyph after the final reordering. * * Note: If fallback positioning happens, we don't care about * this as it will be overridden.
*/ bool adjust_offsets_when_zeroing = c->plan->adjust_mark_positioning_when_zeroing &&
HB_DIRECTION_IS_FORWARD (c->buffer->props.direction);
/* We change glyph origin to what GPOS expects (horizontal), apply GPOS, change it back. */
/* The nil glyph_h_origin() func returns 0, so no need to apply it. */ if (c->font->has_glyph_h_origin_func ()) for (unsignedint i = 0; i < count; i++)
c->font->add_glyph_h_origin (info[i].codepoint,
&pos[i].x_offset,
&pos[i].y_offset);
hb_ot_layout_position_start (c->font, c->buffer);
if (c->plan->zero_marks) switch (c->plan->shaper->zero_width_marks)
{ case HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_EARLY:
zero_mark_widths_by_gdef (c->buffer, adjust_offsets_when_zeroing); break;
default: case HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE: case HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_LATE: break;
}
c->plan->position (c->font, c->buffer);
if (c->plan->zero_marks) switch (c->plan->shaper->zero_width_marks)
{ case HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_LATE:
zero_mark_widths_by_gdef (c->buffer, adjust_offsets_when_zeroing); break;
default: case HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE: case HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_EARLY: break;
}
/* Finish off. Has to follow a certain order. */
hb_ot_layout_position_finish_advances (c->font, c->buffer);
hb_ot_zero_width_default_ignorables (c->buffer); #ifndef HB_NO_AAT_SHAPE if (c->plan->apply_morx)
hb_aat_layout_zero_width_deleted_glyphs (c->buffer); #endif
hb_ot_layout_position_finish_offsets (c->font, c->buffer);
/* The nil glyph_h_origin() func returns 0, so no need to apply it. */ if (c->font->has_glyph_h_origin_func ()) for (unsignedint i = 0; i < count; i++)
c->font->subtract_glyph_h_origin (info[i].codepoint,
&pos[i].x_offset,
&pos[i].y_offset);
if (c->plan->fallback_mark_positioning)
_hb_ot_shape_fallback_mark_position (c->plan, c->font, c->buffer,
adjust_offsets_when_zeroing);
}
staticinlinevoid
hb_propagate_flags (hb_buffer_t *buffer)
{ /* Propagate cluster-level glyph flags to be the same on all cluster glyphs.
* Simplifies using them. */
if (!(buffer->scratch_flags & HB_BUFFER_SCRATCH_FLAG_HAS_GLYPH_FLAGS)) return;
/* If we are producing SAFE_TO_INSERT_TATWEEL, then do two things: * * - If the places that the Arabic shaper marked as SAFE_TO_INSERT_TATWEEL, * are UNSAFE_TO_BREAK, then clear the SAFE_TO_INSERT_TATWEEL, * - Any place that is SAFE_TO_INSERT_TATWEEL, is also now UNSAFE_TO_BREAK. * * We couldn't make this interaction earlier. It has to be done here.
*/ bool flip_tatweel = buffer->flags & HB_BUFFER_FLAG_PRODUCE_SAFE_TO_INSERT_TATWEEL;
foreach_cluster (buffer, start, end)
{ unsignedint mask = 0; for (unsignedint i = start; i < end; i++)
mask |= info[i].mask & HB_GLYPH_FLAG_DEFINED;
if (flip_tatweel)
{ if (mask & HB_GLYPH_FLAG_UNSAFE_TO_BREAK)
mask &= ~HB_GLYPH_FLAG_SAFE_TO_INSERT_TATWEEL; if (mask & HB_GLYPH_FLAG_SAFE_TO_INSERT_TATWEEL)
mask |= HB_GLYPH_FLAG_UNSAFE_TO_BREAK | HB_GLYPH_FLAG_UNSAFE_TO_CONCAT;
}
if (clear_concat)
mask &= ~HB_GLYPH_FLAG_UNSAFE_TO_CONCAT;
for (unsignedint i = start; i < end; i++)
info[i].mask = mask;
}
}
/* Pull it all together! */
staticvoid
hb_ot_shape_internal (hb_ot_shape_context_t *c)
{ /* Save the original direction, we use it later. */
c->target_direction = c->buffer->props.direction;
/** * hb_ot_shape_plan_collect_lookups: * @shape_plan: #hb_shape_plan_t to query * @table_tag: GSUB or GPOS * @lookup_indexes: (out): The #hb_set_t set of lookups returned * * Computes the complete set of GSUB or GPOS lookups that are applicable * under a given @shape_plan. * * Since: 0.9.7
**/ void
hb_ot_shape_plan_collect_lookups (hb_shape_plan_t *shape_plan,
hb_tag_t table_tag,
hb_set_t *lookup_indexes /* OUT */)
{
shape_plan->ot.collect_lookups (table_tag, lookup_indexes);
}
/* TODO Move this to hb-ot-shape-normalize, make it do decompose, and make it public. */ staticvoid
add_char (hb_font_t *font,
hb_unicode_funcs_t *unicode,
hb_bool_t mirror,
hb_codepoint_t u,
hb_set_t *glyphs)
{
hb_codepoint_t glyph; if (font->get_nominal_glyph (u, &glyph))
glyphs->add (glyph); if (mirror)
{
hb_codepoint_t m = unicode->mirroring (u); if (m != u && font->get_nominal_glyph (m, &glyph))
glyphs->add (glyph);
}
}
/** * hb_ot_shape_glyphs_closure: * @font: #hb_font_t to work upon * @buffer: The input buffer to compute from * @features: (array length=num_features): The features enabled on the buffer * @num_features: The number of features enabled on the buffer * @glyphs: (out): The #hb_set_t set of glyphs comprising the transitive closure of the query * * Computes the transitive closure of glyphs needed for a specified * input buffer under the given font and feature list. The closure is * computed as a set, not as a list. * * Since: 0.9.2
**/ void
hb_ot_shape_glyphs_closure (hb_font_t *font,
hb_buffer_t *buffer, const hb_feature_t *features, unsignedint num_features,
hb_set_t *glyphs)
{ constchar *shapers[] = {"ot", nullptr};
hb_shape_plan_t *shape_plan = hb_shape_plan_create_cached (font->face, &buffer->props,
features, num_features, shapers);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.