Commit Graph

2495 Commits

Author SHA1 Message Date
Behdad Esfahbod cdbf24e87f [OTLayout] Accelerate lookups by batching
If we need to apply many many lookups, we can fasten that up by applying
them in batches.  For each batch we keep the union of the coverage of
the lookups participating.  We can then skip glyph ranges that do NOT
participate in any lookup in the batch.  The batch partition is
determined optimally by a mathematical probability model on the glyphs
and a dynamic-program to optimize the partition.

The net effect is 30% speedup on Amiri.  the downside is more memory
consuption as each batch will keep an hb_set_t of its coverage.

I'm not yet convinced that the tradeoff is worth pursuing.  I'm trying
to find out ways to optimized this more, with less memory overhead.

This work also ignores the number of subtables per lookup.  That may
prove to be very important for the performance numbers from here on.
2013-05-02 15:39:16 -04:00
Behdad Esfahbod 68db8c49d8 [OTLayout] Add start/end to apply_string()
No functional change.
2013-05-02 15:39:16 -04:00
Behdad Esfahbod 1b972d893a [OTLayout] Add is_inplace() method to GSUB 2013-05-02 15:39:16 -04:00
Behdad Esfahbod 07034f447b [API] Add hb_ot_layout_lookup_get_coverage() 2013-05-02 15:39:16 -04:00
Behdad Esfahbod 5d59f99920 [OTLayout] Make MultipleSubst in-place for sequences of len=1 2013-05-02 15:39:16 -04:00
Behdad Esfahbod 54f84a6b85 [OTLayout] Whitespace 2013-05-02 15:39:16 -04:00
Behdad Esfahbod 3276c354da [OTLayout] Minor refactoring 2013-05-02 15:39:15 -04:00
Behdad Esfahbod ea86efa486 Minor 2013-05-02 15:39:15 -04:00
Behdad Esfahbod 8b63efb6f8 Minor 2013-05-02 15:39:15 -04:00
Behdad Esfahbod 2265be0a62 Minor 2013-05-02 15:39:15 -04:00
Behdad Esfahbod e6f19af087 Minor 2013-05-02 14:00:16 -04:00
Behdad Esfahbod 6c15ddfe2b Renamed DEBUG to something else
Some infrastructures use DEBUG as a generic symbol.
2013-04-30 11:34:00 -04:00
Behdad Esfahbod ed79dff517 Minor 2013-04-21 15:43:27 -04:00
Behdad Esfahbod 893f57b32f Minor renaming 2013-04-21 15:23:21 -04:00
Behdad Esfahbod 8ac3c9c0b6 Rename "pause" to "stage"
The compile() function is starting to become illegible...
2013-04-21 15:19:38 -04:00
Behdad Esfahbod dd0641a432 Minor 2013-04-21 15:13:57 -04:00
Behdad Esfahbod 06a44e8593 Remove unneeded code
We always push a pause at the end such that each lookup falls in exactly
one pause_map_t.  Now, only if I can find a better name for that...
2013-04-21 15:13:08 -04:00
Behdad Esfahbod 8659c63608 Hand-code bsearch in the hot inner loop.
Saves another 3 / 4 percent with Amiri.
2013-04-19 14:36:32 -04:00
Behdad Esfahbod 797d76d07f Minor 2013-04-18 19:04:12 -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 f9a6110267 Remove HB_DEBUG_SET_DIGESTS
Wasn't correct with the new combiner.  I should add it back somehow,
but for now the digests seem to be working very well...
2013-04-17 19:01:49 -04:00
Behdad Esfahbod f7466ee76f Remove hb_set_digest_common_bits_t
Was unused.
2013-04-17 18:20:44 -04:00
Behdad Esfahbod 0d5798a137 Improve hb_set_digest_t
Make Amiri rendering faster a whopping 45% again!  Speends up pretty
much anything I tested.
2013-04-17 18:19:21 -04:00
Behdad Esfahbod c7851efcd3 Templatize hb_set_digest_lowest_bits_t filter 2013-04-17 18:18:10 -04:00
Behdad Esfahbod 0edd0fd255 Add comment 2013-04-17 17:26:56 -04:00
Behdad Esfahbod b40f2c0372 Add hb_set_digest_combiner_t 2013-04-16 23:21:38 -04:00
Behdad Esfahbod 02e5e58368 Speed up Speed up hb_set_digest_common_bits_t calcs
Correctly this time.
2013-04-16 23:13:10 -04:00
Behdad Esfahbod 893991fc9d Initialize set digests
We were not initializing the digests properly and as a result they were
being initialized to zero, making digest1 to never do any useful work.

Speeds up Amiri shaping significantly.
2013-04-16 21:57:35 -04:00
Behdad Esfahbod 4d2813d3e9 Print set-digest hit ratio with HB_DEBUG_SET_DIGESTS 2013-04-16 21:57:35 -04:00
Behdad Esfahbod 1357c2dd12 Revert "Speed up hb_set_digest_common_bits_t calcs"
This reverts commit 3d1b66a35e.

The calculations were buggy.  It's not worth optimizing right now.
2013-04-16 21:47:40 -04:00
Behdad Esfahbod 2b712bba3f Fix typo in unused macro 2013-04-16 16:11:09 -04:00
Behdad Esfahbod 08677c2507 [old] Speed up Unicode properties access in hb-old shaper
Just to be sure it's not punishing the old shaper performance
numbers.  Doesn't seem to have a measurable effect.
2013-04-11 14:45:58 -04:00
Behdad Esfahbod ef9e02eddf Minor 2013-04-09 14:06:54 -04:00
Behdad Esfahbod 587e5753e0 Add note re Hangul shaping 2013-04-05 12:38:58 -04:00
Behdad Esfahbod 269de14dda Don't compose Hangul jamo
See thread "an issue regarding discrepancy between Korean and Unicode
standards" on the mailing list for the rationale.  In short: Uniscribe
doesn't, so fonts are designed to work without it.
2013-04-04 23:06:54 -04:00
Behdad Esfahbod 1f97060985 Put back MemoryBarrier fallback implementation on MINGW32
This almost reverts 2761e8a632,
but only if under MINGW32, so it doesn't affect MSVC.
2013-04-04 15:02:03 -04:00
Behdad Esfahbod f368ba4a9e [Arabic] Zero marks by GDEF, not Unicode category
Testing shows that this is closer to what Uniscribe does.

Reported by Khaled Hosny:

"""
commit 568000274c
...
This commit is causing a regression with Amiri, the string “هَٰذ” with
Uniscribe and HarfBuzz before this commit, gives:

	[uni0630.fina=3+965|uni0670.medi=0+600|uni064E=0@-256,0+0|uni0647.init=0+926]

But now it gives:

	[uni0630.fina=3+965|uni0670.medi=0+0|uni064E=0@-256,0+0|uni0647.init=0+926]

i.e. uni0670.medi is zeroed though it has a base glyph GDEF class.
"""

The test case is U+0647,U+064E,U+0670,U+0630 with Amiri.
2013-04-04 14:25:36 -04:00
Behdad Esfahbod 3b80674c50 Bug 63107 - FTBFS on ppc64: symbols marked with 'D' on powerpc64 instead 2013-04-04 12:06:46 -04:00
Behdad Esfahbod 7148dc1a97 [graphite2] Don't crash if language is not set
https://bugs.webkit.org/show_bug.cgi?id=113796
2013-04-02 14:08:53 -04:00
Behdad Esfahbod a88a62f70f Minor 2013-03-21 21:02:16 -04:00
Behdad Esfahbod cc50bf5b13 Remove Hangul filler characters from Default_Ignorable chars
See discussion on mailing list.
2013-03-19 07:00:41 -04:00
Behdad Esfahbod a8cf7b43fa [Indic] Futher adjust ZWJ handling in Indic-like shapers
After the Ngapi hackfest work, we were assuming that fonts
won't use presentation features to choose specific forms
(eg. conjuncts).  As such, we were using auto-joiner behavior
for such features.  It proved to be troublesome as many fonts
used presentation forms ('pres') for example to form conjuncts,
which need to be disabled when a ZWJ is inserted.

Two examples:

	U+0D2F,U+200D,U+0D4D,U+0D2F with kartika.ttf
	U+0995,U+09CD,U+200D,U+09B7 with vrinda.ttf

What we do now is to never do magic to ZWJ during GSUB's main input
match for Indic-style shapers.  Note that backtrack/lookahead are still
matched liberally, as is GPOS.  This seems to be an acceptable
compromise.

As to the bug that initially started this work, that one needs to
be fixed differently:

  Bug 58714 - Kannada u+0cb0 u+200d u+0ccd u+0c95 u+0cbe does not
  provide same results as Windows8
  https://bugs.freedesktop.org/show_bug.cgi?id=58714

New numbers:

BENGALI: 353689 out of 354188 tests passed. 499 failed (0.140886%)
DEVANAGARI: 707305 out of 707394 tests passed. 89 failed (0.0125814%)
GUJARATI: 366349 out of 366457 tests passed. 108 failed (0.0294714%)
GURMUKHI: 60706 out of 60747 tests passed. 41 failed (0.067493%)
KANNADA: 951030 out of 951913 tests passed. 883 failed (0.0927606%)
KHMER: 299070 out of 299124 tests passed. 54 failed (0.0180527%)
LAO: 53611 out of 53644 tests passed. 33 failed (0.0615167%)
MALAYALAM: 1048102 out of 1048334 tests passed. 232 failed (0.0221304%)
ORIYA: 42320 out of 42329 tests passed. 9 failed (0.021262%)
SINHALA: 271666 out of 271847 tests passed. 181 failed (0.0665816%)
TAMIL: 1091753 out of 1091754 tests passed. 1 failed (9.15957e-05%)
TELUGU: 970555 out of 970573 tests passed. 18 failed (0.00185457%)
TIBETAN: 208469 out of 208469 tests passed. 0 failed (0%)
2013-03-19 06:22:06 -04:00
Behdad Esfahbod 190e19e684 [ft] Remove TODO items that I'm not going to fix 2013-03-09 20:30:22 -05:00
Behdad Esfahbod 392ee97431 [ft] Remove TODO item re FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH
That flag is redundant, deprecated, and ignored since April 2011.
From FreeType git log:

commit 8c82ec5b17d0cfc9b0876a2d848acc207a62a25a
Author: Behdad Esfahbod <behdad@behdad.org>
Date:   Thu Apr 21 08:21:37 2011 +0200

    Always ignore global advance.

    This makes FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH redundant,
    deprecated, and ignored.  The new behavior is what every major user
    of FreeType has been requesting.  Global advance is broken in many
    CJK fonts.  Just ignoring it by default makes most sense.

    * src/truetype/ttdriver.c (tt_get_advances),
    src/truetype/ttgload.c (TT_Get_HMetrics, TT_Get_VMetrics,
    tt_get_metrics, compute_glyph_metrics, TT_Load_Glyph),
    src/truetype/ttgload.h: Implement it.

    * docs/CHANGES: Updated.
2013-03-09 20:27:55 -05:00
Behdad Esfahbod c5d91f3980 Add hb_auto_array_t 2013-03-09 04:34:21 -05: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 2761e8a632 [win32] Remove MemoryBarrier() fallback implementation
I added these because the older mingw32 toolchain didn't have
MemoryBarrier().  The newer mingw-w64 toolchain however has.
As reported by John Emmas this was causing build failure with
MSVC (on glib) because of inline issues.  But that reminded me
that we may be taking this path even if the system implements
MemoryBarrier as a function, which is a waste.  So, just remove
it.
2013-03-07 20:51:30 -05:00
Behdad Esfahbod 5594c2d112 [FT] Just return if glyph name not found
The fallback happens in higher level already.  No need to do here.
2013-03-06 19:37:31 -05:00
Behdad Esfahbod fb7c182bf9 [Indic] Minor 2013-03-06 00:53:24 -05:00