Commit Graph

276 Commits

Author SHA1 Message Date
Behdad Esfahbod 1a0f4aa6df Revert "Synthesize GDEF glyph class for any glyph that does not have one in GDEF"
This reverts commit 69f9fbc420.

See https://github.com/behdad/harfbuzz/issues/347#issuecomment-268873401
Fixes https://github.com/behdad/harfbuzz/issues/347
2016-12-22 14:43:14 -06:00
Behdad Esfahbod 0aedfd59be [GX] Apply 'rvrn' feature before any other feature 2016-12-16 19:06:26 -06:00
Behdad Esfahbod 72ada4f0c6 [GX] Hook up feature variations
Shape-plan caching is not implemented.
2016-12-16 19:06:26 -06:00
Behdad Esfahbod 69f9fbc420 Synthesize GDEF glyph class for any glyph that does not have one in GDEF
Previously we only synthesized GDEF glyph classes if the glyphClassDef
array in GDEF was null.  This worked well enough, and is indeed what
OpenType requires: "If the font does not include a GlyphClassDef table,
the client must define and maintain this information when using the
GSUB and GPOS tables."  That sentence does not quite make sense since
one needs Unicode properties as well, but is close enough.

However, looks like Arial Unicode as shipped on WinXP, does have GDEF
glyph class array, but defines no classes for Hebrew.  This results
in Hebrew marks not getting their widths zeroed.  So, with this change,
we synthesize glyph class for any glyph that is not specified in the
GDEF glyph class table.  Since, from our point of view, a glyph not
being listed in that table is a font bug, any unwanted consequence of
this change is a font bug :).

Note that we still don't get the same rendering as Uniscribe, since
Uniscribe seems to do fallback positioning as well, even though the
font does have a GPOS table (which does NOT cover Hebrew!).  We are
not going to try to match that though.

Test string for Arial Unicode:

	U+05E9,U+05B8,U+05C1,U+05DC

Before:		[gid1166=3+991|gid1142=0+737|gid5798=0+1434]
After:		[gid1166=3+991|gid1142=0+0|gid5798=0+1434]
Uniscribe:	[gid1166=3+991|gid1142=0@348,0+0|gid5798=0+1434]

Note that our new output matches what we were generating until July
2014, because the Hebrew shaper used to zero mark advances based on
Unicode, NOT GDEF.  That's 9e834e29e0.

Reported by Greg Douglas.
2016-03-17 11:59:43 -07:00
Behdad Esfahbod 8b5bc141cd Add get_nominal_glyph() and get_variation_glyph() instead of get_glyph()
New API:
- hb_font_get_nominal_glyph_func_t
- hb_font_get_variation_glyph_func_t
- hb_font_funcs_set_nominal_glyph_func()
- hb_font_funcs_set_variation_glyph_func()
- hb_font_get_nominal_glyph()
- hb_font_get_variation_glyph()

Deprecated API:
- hb_font_get_glyph_func_t
- hb_font_funcs_set_glyph_func()

Clients that implement their own font-funcs are encouraged to replace
their get_glyph() implementation with a get_nominal_glyph() and
get_variation_glyph() pair.  The variation version can assume that
variation_selector argument is not zero.
2016-02-24 19:05:23 +09:00
Behdad Esfahbod 815bdd7700 In cluster-level=0, group ZWJ/ZWNJ with previous cluster
This better emulates Unicode grapheme clusters.

Note that Uniscribe does NOT do this, but should be harmless with most clients,
and improve fallback with clients that use HarfBuzz cluster as unit of fallback.

Fixes https://github.com/behdad/harfbuzz/issues/217
2016-02-22 18:22:44 +09:00
Behdad Esfahbod 89137e325a Minor 2016-02-22 16:00:59 +09:00
Behdad Esfahbod 62c2711121 [coretext] Limit grapheme-cluster forming to cluster-level=0 2016-02-22 15:07:20 +09:00
Behdad Esfahbod 7d8d58ac81 [GPOS] Divide position_finish() into two phases, for advances and offsets
Right now the position_finish_advances() is empty.  To be used for
spacing attachments proposal later.
2016-02-11 16:34:28 +07:00
Behdad Esfahbod 8474231567 [ot] Minor shuffling code around 2016-02-11 16:27:41 +07:00
Behdad Esfahbod 660c9d3fc2 Remove font-dependent ASCII-only perf hack
Is confusing.  I already hit it myself.  Remove.  We can optimize
ASCII based on Unicode properties.  But should not do based on
assumptions on the font.
2016-02-11 12:14:27 +07:00
Behdad Esfahbod eaadcbbc53 Remove now-unused mark zeroing BY_UNICODE 2016-02-10 18:29:54 +07:00
Behdad Esfahbod 35d18585fc Fix a few docs blocks 2015-11-26 19:30:37 -05:00
Behdad Esfahbod ea512f7108 Use C-style casts instead of compare to 0, to convert hb_bool_t to bool 2015-11-26 19:22:22 -05:00
Behdad Esfahbod 67a36a725e Fix vertical GPOS
This was brorken earlier, though, it's really hard to notice it.
Unlike the glyph_h_origin(), an unset glyph_v_origin() does NOT
mean that the vertical origin is at 0,0.

Related to https://github.com/behdad/harfbuzz/issues/187
2015-11-26 18:49:54 -05:00
Behdad Esfahbod 766963adba Merge pull request #114 from ThePhD/vc++-fixes
Fix all VC++ warnings and errors
2015-11-24 15:38:43 -06:00
Behdad Esfahbod abadc1717d Try to better handle OOM situations
Fixes assert fail in https://github.com/behdad/harfbuzz/issues/161
with libharfbuzz-fuzzing.
2015-11-18 17:52:08 -08:00
Behdad Esfahbod 4301703bdd Limit buffer max size growth
https://github.com/behdad/harfbuzz/issues/161
2015-11-05 23:44:59 -08:00
Behdad Esfahbod 136863371c Add new shaper method postprocess_glyphs()
Unused currently.  To be used for Syriac stretch implementation.

https://github.com/behdad/harfbuzz/issues/141
2015-11-05 13:24:15 -08:00
Behdad Esfahbod e95eb23a4e Don't try zeroing marks by GDEF if there are no non-ASCII
This one is a hack, but should be ok.
2015-11-04 22:59:28 -08:00
Behdad Esfahbod 7fa54ed75a Don't try zeroing mark attachments by Unicode if there's no non-ASCII 2015-11-04 22:59:24 -08:00
Behdad Esfahbod 0f407325f6 Minor 2015-11-04 22:28:44 -08:00
Behdad Esfahbod 497a6c2071 Skip forming clusters if text is all ASCII 2015-11-04 22:24:19 -08:00
Behdad Esfahbod 5bc28b5f68 Optimize positioning for when h_origin is nil 2015-11-04 21:53:16 -08:00
Behdad Esfahbod bee901b38e Optimize positioning direction calculations
It makes the binary smaller AND faster.  Yumm!
2015-11-04 19:28:17 -08:00
Behdad Esfahbod e3e4bb011a Don't do fractions if buffer is ASCII-only 2015-11-04 18:58:02 -08:00
Behdad Esfahbod 6986208ba3 Optimize runs without Default_Ignorable's
Now that we have a buffer-wide scratch flags facility, use it to
optimize away a few passes.
2015-11-04 18:46:41 -08:00
Behdad Esfahbod 49ef630936 Adjust the width of various spaces if font does not cover them
See discussion here:
81ef4f407d

There's no way to disable this fallback, but I don't think it would
be needed.  Let's hope for the best!

Fixes https://github.com/behdad/harfbuzz/issues/153
2015-11-04 17:27:07 -08:00
Behdad Esfahbod aa7044de0c Generalize flags types 2015-11-04 16:25:57 -08:00
Behdad Esfahbod f883de664f [OT] Merge /before/ reordering 2015-09-01 16:23:40 +01:00
Behdad Esfahbod e47b772a56 [ot] Change buffer content type right after we map to glyphs
Needed for upcoming debug output changes.
2015-08-18 18:42:47 +01:00
ThePhD 5c99cf93d6 Merge branch 'master' into vc++-fixes 2015-08-14 01:02:00 -04:00
Behdad Esfahbod 0f98fe88f4 [ot] Search globally for 'vert' feature if not found in specified script/lang
Fixes https://github.com/behdad/harfbuzz/issues/63
2015-07-23 11:52:11 +01:00
Behdad Esfahbod f327aacfa1 [ot] Minor 2015-07-23 11:32:59 +01:00
Behdad Esfahbod 8cfbc304ee Fix hide-default-ignorables after f0010dfd01
We can't delete things before hb_ot_layout_position_finish().  So,
just zero the advance before it, and remove later.
2015-07-22 18:41:10 +01:00
Behdad Esfahbod 2dbd3d29d6 Fix hide-ignorables if font doesn't have space glyph
Was broken by 82b521aeb7, as we have
positioning data by then and can't use the output buffer.  Ouch!
2015-07-22 18:29:47 +01:00
Behdad Esfahbod 4ba796b26e Refactor _hb_glyph_info_is_default_ignorable() 2015-07-22 17:41:31 +01:00
Behdad Esfahbod f0010dfd01 [ot] Hide default-ignorables before finishing off positioning
For example, fixes the following sequence with Arial XP:
628 25cc 651 25cc 64e 3a 20 628 651 34f 64e
628 25cc 64e 25cc 651 3a 20 628 64e 34f 651

Discovered as part of:
https://bugs.freedesktop.org/show_bug.cgi?id=85873
2015-07-22 17:36:23 +01:00
Behdad Esfahbod 376d587f36 Implement more granular cluster-merging
TODO: Documentation.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=71445
2015-07-22 16:51:12 +01:00
Behdad Esfahbod a60e2cfa39 [ot] Don't rely on cluster numbers for ensure_native_direction() 2015-07-22 15:49:08 +01:00
Behdad Esfahbod 701112dad9 [ot] Simplify form_clusters() 2015-07-22 15:42:20 +01:00
Behdad Esfahbod 7b8b63adc5 [ot] Don't mirror character if font doesn't support mirrored character! 2015-07-22 15:24:26 +01:00
ThePhD 8e545d5961 Fix all VC++ warnings and errors in the current commit's builds. 2015-06-22 22:29:04 -04:00
Behdad Esfahbod 5f13bbd9d4 When removing default-ignorables, merge clusters
Fixes test-shape, and:
https://code.google.com/p/chromium/issues/detail?id=497578
2015-06-19 13:31:49 -07:00
Behdad Esfahbod 82b521aeb7 Rewrite hide_default_ignorables
Separate the loops for the two cases of replacing with space
and deleting.  For deleting, use the out-buffer machinery.

Needed for upcoming cluster merge fix.
2015-06-19 13:26:03 -07:00
Sascha Brawer 01c3a88543 Fix "Since:" tags
Based on data from http://upstream-tracker.org/versions/harfbuzz.html
Resolves #103
2015-06-01 13:25:27 +02:00
Behdad Esfahbod 982d94eaa2 [coretext] Don't generate notdef glyph for default-ignorables
As discovered on Chrome Mac:
https://code.google.com/p/chromium/issues/detail?id=452326
2015-01-28 10:51:33 -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 2053f369f8 Disable 'liga' for vertical text
The reason we turned it on is because Kazuraki uses it.  But that's
not reason enough.  Until the OpenType spec gets its act together re
adding design-direction to lookups, this is better user experience.
2014-08-02 16:31:16 -04:00
Behdad Esfahbod 763e5466c0 Make it easier to use HB_BUFFER_FLAG_BOT/EOT
Previously, we expected users to provide BOT/EOT flags when the
text *segment* was at paragraph boundaries.  This meant that for
clients that provide full paragraph to HarfBuzz (eg. Pango), they
had code like this:

  hb_buffer_set_flags (hb_buffer,
                       (item_offset == 0 ? HB_BUFFER_FLAG_BOT : 0) |
                       (item_offset + item_length == paragraph_length ?
                        HB_BUFFER_FLAG_EOT : 0));

  hb_buffer_add_utf8 (hb_buffer,
                      paragraph_text, paragraph_length,
                      item_offset, item_length);

After this change such clients can simply say:

  hb_buffer_set_flags (hb_buffer,
                       HB_BUFFER_FLAG_BOT | HB_BUFFER_FLAG_EOT);

  hb_buffer_add_utf8 (hb_buffer,
                      paragraph_text, paragraph_length,
                      item_offset, item_length);

Ie, HarfBuzz itself checks whether the segment is at the beginning/end
of the paragraph.  Clients that only pass item-at-a-time to HarfBuzz
continue not setting any flags whatsoever.

Another way to put it is: if there's pre-context text in the buffer,
HarfBuzz ignores the BOT flag.  If there's post-context, it ignores
EOT flag.
2014-08-02 16:17:44 -04:00