Commit Graph

216 Commits

Author SHA1 Message Date
Behdad Esfahbod b47159011c Define return_trace()
Not functional change (expected!).
2015-09-29 14:57:02 +01:00
Behdad Esfahbod c917965b9e Add missing returns
Fixes possible invalid read of two bytes.

Reported by Behzad Najjarpour Jabbari, Secunia Research.
2015-09-29 14:45:35 +01:00
Behdad Esfahbod 6578575cc8 [GPOS] Fix cursive connection with mix of RTL and non-RTL lookups
See thread "Issue with cursive attachment" started by Khaled.
Turned out fixing this wasn't as bad as I had assumed.  I like the
new code better; we now have a theoretical model of cursive
connections that is easier to reason about.
2015-08-25 20:29:36 +01:00
Behdad Esfahbod 58f2a73fb9 [GPOS] Rewrite cursive attachment slightly differently
In anticipation for upcoming fix for bug reported by
Khaled in thread "Issue with cursive attachment".
2015-08-25 18:58:24 +01:00
Behdad Esfahbod 2c8b3b2e53 [debug] Print lookup index in debug-apply output 2015-08-18 14:36:43 +01:00
Behdad Esfahbod fc3c59a1d7 Fix unused var warnings 2015-04-08 13:04:29 -07:00
Behdad Esfahbod bd047d3b7f [layout] Minor 2015-02-25 15:43:31 -08:00
Behdad Esfahbod 1a2322134a [layout] Don't check glyph props against lookup flags when recursing
Shouldn't be needed.  I have a hard time imagining this breaking any
legitimate use case.
2015-02-25 15:43:30 -08:00
Behdad Esfahbod 095a1257cc [layout] Port sanitize() to use dispatch()
Needed some rework of Extension table.  Hopefully I got it right, and
the new template usage doesn't break any compilers...
2015-02-25 15:43:30 -08:00
Behdad Esfahbod 40c58923cb [layout] Refactor Lookup::dispatch() 2015-02-25 15:43:30 -08:00
Behdad Esfahbod 70366f5d19 [layout] Refactor get_subtable() 2015-02-25 15:43:29 -08:00
Behdad Esfahbod f72f326aea Minor 2015-02-25 15:43:29 -08:00
Behdad Esfahbod 8e36ccfd4f [layout] Use dispatch() for add_coverage() 2015-02-25 15:43:29 -08:00
Behdad Esfahbod 50b8dc79da [layout] Add may_dispatch()
No functional change right now.
2015-02-25 15:43:29 -08:00
Behdad Esfahbod de2118ed7a Make sanitize() a const method
This makes a lot of code safer.  We only try modifying the object in one
place, after making sure it's safe to do so.  So, do a const_cast<> in
that one place...
2015-02-25 15:43:28 -08:00
Behdad Esfahbod 6759ed95a3 Minor 2015-02-25 15:43:28 -08:00
Behdad Esfahbod 6b599dac1f Remove unnecessary check in sanitize 2015-02-25 15:43:28 -08:00
Behdad Esfahbod 365576d246 [layout] Allocate iters in the context
Can be further optimized, but I think I didn't break anything.

Saves another 3% off Roboto shaping.
2015-02-25 15:43:28 -08:00
Behdad Esfahbod 514564f544 [layout] Move skippy_iter setup from constructor into init() 2015-02-25 15:43:27 -08:00
Behdad Esfahbod b051be542a [lookup] Add skippy_iter.reset()
Towards reducing the cost of initializing skippy_iter()
2015-02-25 15:43:27 -08:00
Behdad Esfahbod 696266981d [layout] Merge forward and backward iterators 2015-02-25 15:43:26 -08:00
Behdad Esfahbod 37d13acd8d [layout] Remove some unnecessary checks in skippy 2015-02-25 15:43:26 -08:00
Behdad Esfahbod baa14e1814 [lookup] Don't initialize skippy if coverage match fails
Currently:

  - Initializing skippy is very expensive,

  - Our lookup accelerator (using set-digests) can be very ineffecite,

As such, we end up many times initializing skippy but then failing
coverage check.  Reordering fixes that.

When, later, we fix our accelerator to have truly small false-positive
rate (for example by using the frozen-sets), then we might want to
reorder these checks such that we wouldn't calculate coverage number
if skippy is going to fail.

This shows a 5% speedup with Roboto already.
2015-02-25 15:43:26 -08:00
Behdad Esfahbod 7788993bc1 [layout] Use setter method to set c->lookup_props 2015-02-25 15:43:25 -08:00
Behdad Esfahbod 67dfa8c7c2 When matching second glyph of kerning pairs, use bsearch
Roboto has glyphs (like 'F') that have 200 kerning pairs.
Add a handcoded bsearch instead of previous linear search.

This doesn't show much speedup though, apparently we spend the
bulk of the time somewhere before here.
2015-01-19 17:00:31 -08:00
Behdad Esfahbod 093c520de5 [otlayout] Mark variables that are C arrays as opposed to OT::ArrayOf 2014-12-12 21:07:53 -08:00
Behdad Esfahbod 00f6a8e334 [ot] Print format in dispatch trace 2014-12-12 20:36:49 -08:00
Behdad Esfahbod 8f3eebf7ee Make sure gsubgpos buffer vars are available during fallback_position
Add buffer var allocation asserts to a few key places.
2014-08-02 19:07:49 -04:00
Behdad Esfahbod 7627100f42 Mark unsigned integer literals with the u suffix
Simplifies hb_in_range() calls as the type can be inferred.
The rest is obsessiveness, I admit.
2014-07-11 16:22:13 -04:00
Behdad Esfahbod 6faff8e413 Add static storage classifier to inline functions
Before we were just relying on the compiler inlining them and not
leaving a trace in our public API.  Try to fix.  Hopefully not
breaking anyone's build.
2014-04-28 14:30:44 -07:00
Konstantin Ritt 083225916a Micro optimizations 2014-01-28 11:14:12 -05:00
Behdad Esfahbod 333cc6e2d1 [otlayout] Remove unused is_inplace()
Patch from Jonathan Kew.
2013-10-30 17:30:11 +00:00
Behdad Esfahbod ac8cd51191 Refactor 2013-10-18 19:33:09 +02:00
Behdad Esfahbod 101303dbf7 [otlayout] More shuffling around 2013-10-18 11:21:15 +02:00
Behdad Esfahbod 3ddf892b53 [otlayout] Renaming 2013-10-18 11:21:15 +02:00
Behdad Esfahbod 6c48f20eea [otlayout] Add structs for JSTF table 2013-09-09 15:43:10 -04:00
Behdad Esfahbod 45f3d980c9 [OTLayout] Merge / templateize apply_string() 2013-05-04 16:04:04 -04:00
Behdad Esfahbod e015b8f218 [OTLayout] Minor 2013-05-04 16:04:04 -04:00
Behdad Esfahbod 780cd930a9 [OTLayout] Minor 2013-05-04 16:04:04 -04:00
Behdad Esfahbod 2e0c44f4be [OTLayout] Add is_inplace() method to GSUB 2013-05-04 16:04:04 -04:00
Behdad Esfahbod ed79dff517 Minor 2013-04-21 15:43:27 -04:00
Behdad Esfahbod 0dc3a4e034 Obssesive optimization
Not measurable by any means, but conceptually this is faster since
the mask matches more often than the digest.
2013-04-17 23:04:03 -04:00
Behdad Esfahbod ee5464d17f [OTLayout] Move code around 2013-03-09 01:59:30 -05:00
Behdad Esfahbod 9c5a9ee967 [OTLayout] Rename process() to dispatch() 2013-03-09 01:55:04 -05:00
Behdad Esfahbod 607feb7cff [OTLayout] Ignore default-ignorables when matching GSUB/GPOS
When matching lookups, be smart about default-ignorable characters.
In particular:

Do nothing specific about ZWNJ, but for the other default-ignorables:

If the lookup in question uses the ignorable character in a sequence,
then match it as we used to do.  However, if the sequence match will
fail because the default-ignorable blocked it, try skipping the
ignorable character and continue.

The most immediate thing it means is that if Lam-Alef forms a ligature,
then Lam-ZWJ-Alef will do to.  Finally!

One exception: when matching for GPOS, or for backtrack/lookahead of
GSUB, we ignore ZWNJ too.  That's the right thing to do.

It certainly is possible to build fonts that this feature will result
in undesirable glyphs, but it's hard to think of a real-world case
that that would happen.

This *does* break Indic shaping right now, since Indic Unicode has
specific rules for what ZWJ/ZWNJ mean, and skipping ZWJ is breaking
those rules.  That will be fixed in upcoming commits.
2013-02-14 12:57:50 -05:00
Behdad Esfahbod c074ebc466 [OTLayout] Minor refactoring 2013-02-13 11:22:42 -05:00
Behdad Esfahbod 407fc12466 [OTLayout] Remove bogus caching of glyph property 2013-02-13 11:13:06 -05:00
Behdad Esfahbod 568000274c Adjust mark advance-width zeroing logic for Myanmar
Before, we were zeroing advance width of attached marks for
non-Indic scripts, and not doing it for Indic.

We have now three different behaviors, which seem to better
reflect what Uniscribe is doing:

  - For Indic, no explicit zeroing happens whatsoever, which
    is the same as before,

  - For Myanmar, zero advance width of glyphs marked as marks
    *in GDEF*, and do that *before* applying GPOS.  This seems
    to be what the new Win8 Myanmar shaper does,

  - For everything else, zero advance width of glyphs that are
    from General_Category=Mn Unicode characters, and do so
    before applying GPOS.  This seems to be what Uniscribe does
    for Latin at least.

With these changes, positioning of all tests matches for Myanmar,
except for the glitch in Uniscribe not applying 'mark'.  See preivous
commit.
2013-02-12 09:44:57 -05:00
Behdad Esfahbod 54f7b4d9ec [OTLayout] Respect lookup-flags skipping over non-mark glyphs
Before, when matching ligatures, we never skipping over base / liga
glyphs even if that was what the LookupFlags asked for.

Fixed now.  We carefully reviewed all instances of this, and tested with
Amiri as well as some Indic scripts, and are confident that this should
NOT break anyone's fonts.  It's also how Uniscribe does it, from what
we can tell.
2013-02-11 13:27:17 -05:00
Behdad Esfahbod 9082efc4aa [OTLayout] s/mark_skipping/skipping/
In aticipation of upcoming changes.
2013-02-11 13:14:56 -05:00
Behdad Esfahbod e95e031b56 [GPOS] If an Anchor offset is NULL, return false
If in a MarkPos table, a base has no anchor for a particular mark class,
return NULL such that the subsequent subtables get a chance at it.

Test case:
hb-shape ./EBGaramond12-Regular.otf ἂ --features="ss20","smcp"
2013-01-08 16:17:06 -06:00
Behdad Esfahbod 8303593ba1 Minor
Use pointers instead of references, in preparation for upcoming change.
2012-12-04 17:08:41 -05:00
Behdad Esfahbod 1bcfa06d11 [OTLayout] Don't recurse in collect_glyphs() for GPOS 2012-12-04 16:58:09 -05:00
Behdad Esfahbod 3038ae6adb [OTLayout] Minor 2012-11-30 08:24:13 +02:00
Behdad Esfahbod 2dc1141d7d [OTLayout] Remove operator() from ClassDef 2012-11-24 19:16:34 -05:00
Behdad Esfahbod b67881b171 [OTLayout] Remove operator() from Coverage 2012-11-24 19:13:55 -05:00
Behdad Esfahbod cdd756b9f4 [OTLayout] Implement GPOS collect_glyphs() 2012-11-24 01:38:41 -05:00
Behdad Esfahbod 4c4e8f0e75 [OTLayout] Reuse apply context for recursion 2012-11-24 01:13:20 -05:00
Behdad Esfahbod 26514d51b6 [OTLayout] More collect_glyphs() 2012-11-23 18:13:48 -05:00
Behdad Esfahbod c6fb843f2a [OTLayout] Templatize process_recurse_func 2012-11-23 18:04:08 -05:00
Behdad Esfahbod f48ec0e834 [OTLayout] Add process() tracing 2012-11-23 17:23:41 -05:00
Behdad Esfahbod ed2e135944 [OTLayout] More Extension templatizing 2012-11-23 17:10:40 -05:00
Behdad Esfahbod 7dddd4e72b [OTLayout] More templatizing Extension 2012-11-23 17:04:55 -05:00
Behdad Esfahbod 653eeb2645 Make Extension a template 2012-11-23 16:57:36 -05:00
Behdad Esfahbod 08f1eede1b Minor 2012-11-23 16:51:43 -05:00
Behdad Esfahbod be218c688c Pass this object to trace macros 2012-11-23 15:32:14 -05:00
Behdad Esfahbod c779d82b2f Fix warnings 2012-11-23 14:09:21 -05:00
Behdad Esfahbod ec35a72a44 [OTLayout] Port apply() operator to process() template 2012-11-22 16:33:46 -05:00
Behdad Esfahbod 2005fa5340 [OTLayout] Port would_apply() and get_coverage() to process() templates 2012-11-22 16:33:46 -05:00
Behdad Esfahbod 7d52e6601f Whitespace 2012-11-16 18:49:54 -08:00
Behdad Esfahbod 5a08ecf920 Implement hb_ot_layout_get_glyph_class() 2012-11-16 13:34:29 -08:00
Behdad Esfahbod 1d3947a6bd Minor 2012-09-04 22:42:17 -04:00
Behdad Esfahbod 2bd9fe3598 Refactor 2012-09-04 15:15:19 -04:00
Behdad Esfahbod 7c8e844d92 Use namespace for OpenType tables
Avoids USHORT, SHORT, ULONG, LONG clashes with Windows API.
2012-08-28 17:57:49 -04:00
Behdad Esfahbod df5d5c68f3 Whitespace 2012-08-23 09:33:30 -04:00
Behdad Esfahbod 6c459c8fef Minor 2012-08-02 03:45:53 -04:00
Behdad Esfahbod 0120ce9679 [GSUB/GPOS] Remove unused get_coverage() methods 2012-08-01 21:56:35 -04:00
Behdad Esfahbod 1336ecdf8e [GSUB/GPOS] Use Coverage digests as gatekeeper
Gives me a good 10% speedup for the Devanagari test case.  Less so
for less lookup-intensive tests.

For the Devanagari test case, the false positive rate of the GSUB digest
is 4%.
2012-08-01 21:46:36 -04:00
Behdad Esfahbod a878c58a8f [GSUB/GPOS] Add add_coverage() 2012-08-01 21:46:19 -04:00
Behdad Esfahbod 8fbfda920e Inline font getters 2012-08-01 19:03:46 -04:00
Behdad Esfahbod 1e7d860613 [GPOS] Adjust mark advance-width zeroing logic
If there is no GPOS, zero mark advances.

If there *is* GPOS and the shaper requests so, zero mark advances for
attached marks.

Fixes regression with Tibetan, where the font has GPOS, and marks a
glyph as mark where it shouldn't get zero advance.
2012-07-31 23:41:06 -04:00
Behdad Esfahbod c2e42c3db6 Minor 2012-07-30 19:54:50 -04:00
Behdad Esfahbod 03f67bc012 More refactoring glyph class access 2012-07-30 19:47:53 -04:00
Behdad Esfahbod 05bd1b6342 [GSUB/GPOS] Move glyph props matching around 2012-07-30 19:30:01 -04:00
Behdad Esfahbod 0aef425e25 [GSUB] Minor 2012-07-30 00:55:15 -04:00
Behdad Esfahbod 5d874d566f [GPOS] Fix mark-to-mark positioning when one of the marks is a ligature
This commit: a3313e5400 broke MarkMarkPos
when one of the marks itself is a ligature.  That regressed 26 Tibetan
tests (up from zero!).  Fix that.  Tibetan back to zero.
2012-07-28 21:05:25 -04:00
Behdad Esfahbod dadede012e Minor 2012-07-28 18:13:09 -04:00
Behdad Esfahbod 0b99429ead [GSUB/GPOS] Add get_coverage() and use it to speed up main loop
And use it to speed up the hotspot by checking coverage directly in
the main loop, not 10 functions deep in.

Gives me a solid 20% boost with Indic test suite.  Less so for less
lookup-intensive scenarios.

Remove the "fast_path" hack from before.
2012-07-28 17:46:35 -04:00
Behdad Esfahbod ea278d3895 Partially switch ot shaper to shape_plan 2012-07-27 02:12:28 -04:00
Behdad Esfahbod a3313e5400 [GPOS] Fix MarkMarkPos applied to results of MultipleSubst
This was broken as a result of 7b84c536c1.
As Khaled reported, MarkMark positioning was broken with glyphs
resulting from a MultipleSubst.  Fixed.  Test with the ALLAH character
in Amiri.
2012-07-25 18:37:51 -04:00
Behdad Esfahbod ec8d249469 Make data members of various OpenType structs protected instead of private
Should fix warnings generated when building with -Wunused-private-field.
Based on patch from Jonathan Kew.
2012-07-24 15:40:37 -04:00
Behdad Esfahbod 34a7440b7c [GPOS] Don't zero mark advances
Fixes more of Telugu, Kannada, and Oriya.

May break things (outside Indic...), but we cannot think of any font relying
on this immediately.
2012-07-20 12:40:39 -04:00
Behdad Esfahbod e72b360ac6 Refactor / finish would_apply() operation
Untested.
2012-07-19 14:44:46 -04:00
Behdad Esfahbod 6d08c7f1b3 Revert "Towards templatizing common Lookup types"
This reverts commit 727135f3a9.

This is work-in-progress.  Didn't mean to push it out just yet.
2012-07-11 18:01:27 -04:00
Behdad Esfahbod 727135f3a9 Towards templatizing common Lookup types 2012-07-11 18:00:28 -04:00
Behdad Esfahbod f211d5c291 More Oops! Fix fast-path with sub-type==0 2012-06-09 03:11:22 -04:00
Behdad Esfahbod b1de6aa1f3 Oops! 2012-06-09 03:07:59 -04:00
Behdad Esfahbod faf0f20253 Add sanitize() logic for fast-paths 2012-06-09 03:02:36 -04:00
Behdad Esfahbod 4e766ff28d Add fast-path for GPOS too
Shaves another 3% for DejaVu Sans long Latin strings.
2012-06-09 02:53:57 -04:00
Behdad Esfahbod 44b8ee0c90 Minor 2012-06-09 00:23:24 -04:00
Behdad Esfahbod 7b84c536c1 In MarkBase attachment, only attach to first of a MultipleSubst sequence
This is apparently what Uniscribe does.  Test case is:

  SEEN FATHA TEH ALEF

with Arabic Typesetting.  Originally reported by Khaled Hosny.
2012-06-08 22:04:23 -04:00
Behdad Esfahbod 68b76121f8 Fix regressions introduced by sed. Ouch!
Introduced in 99c2695759.
Broken mark-mark and mark-ligature stuff.
2012-06-08 10:47:00 -04:00
Behdad Esfahbod 99c2695759 Add accessort to buffer for current info, current pos, and prev info 2012-05-13 15:45:18 +02:00
Behdad Esfahbod 5df809b655 [GSUB/GPOS] Remove context_length
The spec doesn't say contextual matching should be done this way,
and AOTS doesn't do it either.  It was inherited from old HarfBuzz.
Remove it.
2012-05-13 15:17:51 +02:00
Behdad Esfahbod cee7187447 [Indic] Move syllable tracking from Indic to generic layer
This is to incorporate it into GSUB/GPOS processing.
2012-05-11 11:41:39 +02:00
Behdad Esfahbod acea183e98 Add return annotation for APPLY 2012-05-11 02:33:11 +02:00
Behdad Esfahbod 0ab8c86217 Annotate SANITIZE return values
More to come, for APPLY, CLOSURE, etc.
2012-05-11 02:11:52 +02:00
Behdad Esfahbod a9844d41c6 Combine lig_id and lig_comp into one byte, to free up one for Indic 2012-05-09 17:53:13 +02:00
Behdad Esfahbod 5b93e8d94f Update copyright headers 2012-04-23 22:26:27 -04:00
Behdad Esfahbod 650ac00da3 Minor refactoring 2012-04-23 13:17:09 -04:00
Behdad Esfahbod c6035cf802 Add names to enums
gdb was showing <anonymous enum> instead of useful stuff, so name
all our enums.
2012-04-12 13:23:59 -04:00
Behdad Esfahbod 41ae674f68 Don't create hb_apply_context_t per glyph!
I couldn't measure significant performance gains out of this; maybe
about 5% (with one million Malayalam strings).  Still, not bad.
But reminds me that optimizing this codebase without profiling first
is simply not going to work.  Oh well...
2012-04-11 17:13:50 -04:00
Behdad Esfahbod 4ab9731154 Refactor mark skipping 2012-01-16 22:20:31 -05:00
Behdad Esfahbod 4d3aeb8cb2 [GSUB/GPOS] Fix mark skip indexing issues
Mozilla bug 701637 and 714067 combined.

Patch from Jonathan Kew.
2012-01-16 16:43:26 -05:00
Behdad Esfahbod ae9877dea6 Add hhea-table support 2011-08-17 15:00:10 +02:00
Behdad Esfahbod 7a750ac33e Rename table files from eg maxp-private.hh to maxp-table.hh 2011-08-17 14:19:59 +02:00