mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-21 15:01:01 +01:00
[gsubgpos] Preserve concat hazards at end of input (#6238)
The RuleSet fast paths filtered out rules requiring another glyph when the skipping iterator reached the end of the buffer. Unlike the normal rule walk, that early return did not record the resulting unsafe-to-concat range. Keep the end-of-input optimization, but track filtered rules and mark their concat hazard before returning. Cover both contextual and chained contextual rule sets with a five-rule font that forces the fast paths. Assisted-by: OpenAI Codex <codex@openai.com>
This commit is contained in:
1 parent
92e67ef19f
commit
db981a8baf
3 files changed
+23
-12
No files matched your search
@@ -3351,7 +3351,7 @@ struct RuleSet
|
||||
skippy_iter.set_glyph_data ((HBUINT16 *) nullptr);
|
||||
unsigned unsafe_to = (unsigned) -1, unsafe_to1, unsafe_to2 = 0;
|
||||
hb_glyph_info_t *first = nullptr, *second = nullptr;
|
||||
bool matched = skippy_iter.next ();
|
||||
bool matched = skippy_iter.next (&unsafe_to1);
|
||||
if (likely (matched))
|
||||
{
|
||||
if (skippy_iter.may_skip (c->buffer->info[skippy_iter.idx]))
|
||||
@@ -3373,16 +3373,22 @@ struct RuleSet
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Failed to match a next glyph. Only try applying rules that have
|
||||
* no further input. */
|
||||
return_trace (
|
||||
bool unsafe_to_concat = false;
|
||||
bool ret =
|
||||
+ hb_iter (rule)
|
||||
| hb_map (hb_add (this))
|
||||
| hb_filter ([&] (const Rule &_) { return _.inputCount <= 1; })
|
||||
| hb_filter ([&] (const Rule &_)
|
||||
{
|
||||
if (_.inputCount <= 1) return true;
|
||||
unsafe_to_concat = true;
|
||||
return false;
|
||||
})
|
||||
| hb_map ([&] (const Rule &_) { return _.apply (c, lookup_context); })
|
||||
| hb_any
|
||||
)
|
||||
;
|
||||
if (unsafe_to_concat)
|
||||
c->buffer->unsafe_to_concat (c->buffer->idx, unsafe_to1);
|
||||
return_trace (ret);
|
||||
}
|
||||
matched = skippy_iter.next ();
|
||||
if (likely (matched))
|
||||
@@ -4939,7 +4945,7 @@ struct ChainRuleSet
|
||||
skippy_iter.set_glyph_data ((HBUINT16 *) nullptr);
|
||||
unsigned unsafe_to = (unsigned) -1, unsafe_to1, unsafe_to2 = 0;
|
||||
hb_glyph_info_t *first = nullptr, *second = nullptr;
|
||||
bool matched = skippy_iter.next ();
|
||||
bool matched = skippy_iter.next (&unsafe_to1);
|
||||
if (likely (matched))
|
||||
{
|
||||
if (skippy_iter.may_skip (c->buffer->info[skippy_iter.idx]))
|
||||
@@ -4961,21 +4967,24 @@ struct ChainRuleSet
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Failed to match a next glyph. Only try applying rules that have
|
||||
* no further input and lookahead. */
|
||||
return_trace (
|
||||
bool unsafe_to_concat = false;
|
||||
bool ret =
|
||||
+ hb_iter (rule)
|
||||
| hb_map (hb_add (this))
|
||||
| hb_filter ([&] (const ChainRule &_)
|
||||
{
|
||||
const auto &input = StructAfter<decltype (_.inputX)> (_.backtrack);
|
||||
const auto &lookahead = StructAfter<decltype (_.lookaheadX)> (input);
|
||||
return input.lenP1 <= 1 && lookahead.len == 0;
|
||||
if (input.lenP1 <= 1 && lookahead.len == 0) return true;
|
||||
unsafe_to_concat = true;
|
||||
return false;
|
||||
})
|
||||
| hb_map ([&] (const ChainRule &_) { return _.apply (c, lookup_context); })
|
||||
| hb_any
|
||||
)
|
||||
;
|
||||
if (unsafe_to_concat)
|
||||
c->buffer->unsafe_to_concat (c->buffer->idx, unsafe_to1);
|
||||
return_trace (ret);
|
||||
}
|
||||
matched = skippy_iter.next ();
|
||||
if (likely (matched))
|
||||
|
||||
Binary file not shown.
@@ -1,2 +1,4 @@
|
||||
../fonts/34da9aab7bee86c4dfc3b85e423435822fdf4b62.ttf;--show-flags --unsafe-to-concat;U+0628,U+200C,U+0628;[uni0628=1+993#2|uni0628=0+993#2]
|
||||
../fonts/3113f846b81ea15c02e05a1c14fa65f9fd342143.otf;--features=test --no-glyph-names --no-positions --no-clusters --show-flags --unsafe-to-concat;U+0042,U+0041,U+0058,U+0042;[66|65#2|88#2|66]
|
||||
../fonts/c70495f304286cb87964400d03752ae5bc5622b9.ttf;--features=ctxt --no-glyph-names --no-positions --no-clusters --show-flags --unsafe-to-concat;U+0041;[1#2]
|
||||
../fonts/c70495f304286cb87964400d03752ae5bc5622b9.ttf;--features=chne --no-glyph-names --no-positions --no-clusters --show-flags --unsafe-to-concat;U+0041;[1#2]
|
||||
Reference in new issue
Block a user