Commit Graph

104 Commits

Author SHA1 Message Date
Behdad Esfahbod 7e2da035f6 Undo accidental change 2016-04-26 16:42:25 -07:00
Behdad Esfahbod b20305022a Do NOT ignore Mongolian Free Variation Selectors during matching
Fixes https://github.com/behdad/harfbuzz/issues/234
2016-04-26 16:41:17 -07:00
Behdad Esfahbod 86bcbd65b0 [arabic] Use glyph advance width in apply_stch() instead of extents
That seems to be what Windows is doing, and makes more sense.
2015-12-17 11:04:33 +00:00
Behdad Esfahbod 98460779ba Remove final pause from Arabic shaper
Back in the old days, we used to apply 'calt' and 'cswh' in Arabic shaper,
with a pause in between.  Then we disabled the 'cswh' because Microsoft
disabled it, but forgot to remove the unnecessary pause.  Do that now.

This has the benefit that it fixes shaping with monbaiti from Windows 10.
In that version of that font, the lookups from 'calt' are duplicated in
'rclt', and Mongolian was changed to go through Universal Shaping Engine.
We still use the Arabic shaper for Mongolian.  With a pause after 'calt',
we were applying the duplicate lookups from 'calt' and 'rclt' twice.  It
happened to be the case that these lookups were NOT idempotent.  So we
were getting wrong shaping.  See thread "Windows 10 monbaiti.ttf upgrade
(5.01 -> 5.51) caused loss of diacritical marks when shaped with harfbuz"
on the mailing list.  This fixes that.
2015-12-07 21:38:47 +01:00
jfkthame a7ffe35358 Make apply_stch() give a more precise fit
This aims to make Syriac Abbr Mark sizing more accurate when repeating segments are used, by adding an extra repeat and tightening up the spacing slightly rather than leaving a shortfall corresponding to a partial repeat-width.
2015-12-05 17:47:37 +00:00
Chun-wei Fan 4d27bb8746 hb-ot-shape-complex-arabic.cc: Fix build on Visual Studio
Visual Studio does not like declaring a enum variable within a for
statement, so fix the build by declaring the enum before doing the for
loop.
2015-11-16 23:04:36 +08:00
Behdad Esfahbod 04ff23e73d [arabic] Improve stretch length calculation
Err on the side of being too short, than too wide.  Reduces chance
of overlaps with neighboring glyphs.
2015-11-06 16:29:44 -08:00
Behdad Esfahbod 59821ab8b4 [arabic] Don't stretch over cased letters
Addresses
6e6f82b6f3 (commitcomment-14248516)
2015-11-06 16:27:44 -08:00
Behdad Esfahbod 6e6f82b6f3 Implement SYRIAC ABBREVIATION MARK with 'stch' feature
The feature is enabled for any character in the Arabic shaper.
We should experiment with using it for Arabic subtending marks.
Though, that has a directionality problem as well, since those
are used with digits...

Fixes https://github.com/behdad/harfbuzz/issues/141
2015-11-05 17:46:34 -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 9daf2dfb6b Add hb-ot-shape-complex-arabic-private.hh 2015-07-22 10:49:13 +01:00
Behdad Esfahbod f8160a4959 Add FLAG_SAFE() for values known to be small-enough
And add check to FLAG()
2015-07-21 15:50:02 +01:00
Behdad Esfahbod d5e61470fa [arabic] Fix fallback shaping regression
Was broken in 615d00ea25.

Fixes https://github.com/behdad/harfbuzz/pull/48

Micro-test added.
2014-08-05 14:19:36 -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
Behdad Esfahbod e3b42f1af4 [arabic] Disable 'cswh' again
Ouch!
2014-07-17 17:13:54 -04:00
Behdad Esfahbod 82f4d9d53f [arabic] Add note re disabled 'cswh' 2014-07-17 15:57:37 -04:00
Behdad Esfahbod 615d00ea25 [arabic] Apply init/medi/isol/fini/... in separate stages
Follows the order of the Arabic/Syriac specs.  Also don't stop
between rlig and calt in non-Arabic scripts.

Micro-tests for Arabic and Mongolian added for the latter.
2014-07-17 15:50:13 -04:00
Behdad Esfahbod 7cd33f2304 Micro optimization 2014-07-17 14:39:07 -04:00
Behdad Esfahbod 164c13d73f Another try to fix Mongolian free variation selectors
This reverts bf029281 and fixes it properly.  That commit
was not enough as it was only inheriting the shaping_action
for prev_action, but not curr_action.

Micro-test added.

https://code.google.com/p/chromium/issues/detail?id=393896
2014-07-17 14:28:04 -04:00
Behdad Esfahbod 5d4d7384ef Minor: format 2014-06-21 14:53:21 -06:00
Behdad Esfahbod 44243ae590 [arabic-table] Update to Unicode 7.0
Old table was from 6.2.  Remove hard-coded Mongolian and Phags-pa data.
This completes support for new scripts Manichian and Psaltar Pahlavi.
2014-06-21 14:19:34 -06:00
Behdad Esfahbod cd86ab9b4f [arabic-table] Add ZWJ/ZWNJ now that table is segmented 2014-06-21 14:16:54 -06:00
Behdad Esfahbod b900fa2c8c [arabic-table] Use segmented table
No functional change.
2014-06-20 17:59:43 -04:00
Behdad Esfahbod ae23c24c32 [arabic] Disable 'cswh' by default
I believe Windows 8 disables it, and spec update dated
Jan 2014 also clearly says it's disabled by default:

  http://www.microsoft.com/typography/OpenTypeDev/arabic/intro.htm#features
2014-01-22 11:03:02 -05:00
Behdad Esfahbod 3d6ca0d32e [ot] Simplify normalization_preference again
No shaper has more than one behavior re this, so no need for a callback.
2013-12-31 16:35:37 +08:00
Behdad Esfahbod 71b4c999a5 Revert "Zero marks by GDEF for Tibetan"
This reverts commit d5bd0590ae.

The reasoning behind that logic was flawed and made under
a misunderstanding of the original problem, and caused
regressions as reported by Jonathan Kew in thread titled
"tibetan marks" in Oct 2013.  Apparently I have had fixed
the original problem with this commit:

  7e08f1258d

So, revert the faulty commit and everything seems to be in good
shape.
2013-10-28 00:43:27 +01:00
Behdad Esfahbod d5bd0590ae Zero marks by GDEF for Tibetan
See:
http://lists.freedesktop.org/archives/harfbuzz/2013-April/003101.html
2013-10-18 18:17:29 +02:00
Behdad Esfahbod bf029281b1 Bug 65258 - [...] Mongolian with free variation selector 2013-10-18 18:17:29 +02:00
Behdad Esfahbod c52ddab72e [arabic] Make ZWJ prevent ligatures instead of facilitating it
Unicode 6.2.0 Section 16.2 / Figure 16.3 says:

"For backward compatibility, between Arabic characters a ZWJ acts just
like the sequence <ZWJ, ZWNJ, ZWJ>, preventing a ligature from forming
instead of requesting the use of a ligature that would not normally be
used. As a result, there is no plain text mechanism for requesting the
use of a ligature in Arabic text."

As such, we flip internal zwj to zwnj flags for GSUB matching, which
means it will block ligation in all features, unless the font
explicitly matches U+200D glyph.  This doesn't affect joining behavior.
2013-10-16 13:42:38 +02:00
Behdad Esfahbod 580d5eb93a Don't apply 'dlig' by default
Windows 8 doesn't, and the spec will be fixed.
2013-08-04 16:55:21 -04:00
Behdad Esfahbod 127daf15e0 Arabic mark width-zeroing regression
Mozilla Bug 873902 - Display Arabic text with diacritics is bad
https://bugzilla.mozilla.org/show_bug.cgi?id=873902
2013-05-20 09:11:35 -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 c2a1cdc4c4 [Arabic] Fix shaping of left-joining 'Phags-Pa U+A872
This is the first character in Unicode to have Arabic left-joining
behavior.  Update the machine to recognize that.

Test case: U+A840,U+A872,U+A840.
2013-02-15 09:27:02 -05:00
Behdad Esfahbod ec5448667b Add hb_ot_map_feature_flags_t
Code cleanup.  No (intended) functional change.
2013-02-14 12:53:57 -05:00
Behdad Esfahbod e7ffcfafb1 Clean-up add_bool_feature 2013-02-14 11:58:13 -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 0beb66e3a6 Fix warnings 2012-12-05 19:14:28 -05:00
Behdad Esfahbod ba82325b7a Add note re 'Phags-pa letter U+A872, which is Joining_Type=L 2012-11-14 15:36:53 -08:00
Behdad Esfahbod 865745b5b8 Don't do fallback positioning for Indic and Thai shapers 2012-11-14 13:48:26 -08:00
Behdad Esfahbod 5669a6cf41 [Arabic] Fix post-context handling
Ouch!
2012-11-13 15:11:51 -08:00
Behdad Esfahbod 0c7df22228 Add buffer flags
New API:

	hb_buffer_flags_t

	HB_BUFFER_FLAGS_DEFAULT
	HB_BUFFER_FLAG_BOT
	HB_BUFFER_FLAG_EOT
	HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES

	hb_buffer_set_flags()
	hb_buffer_get_flags()

We use the BOT flag to decide whether to insert dottedcircle if the
first char in the buffer is a combining mark.

The PRESERVE_DEFAULT_IGNORABLES flag prevents removal of characters like
ZWNJ/ZWJ/...
2012-11-13 14:42:35 -08:00
Behdad Esfahbod 0736915b8e [Indic] Decompose Sinhala split matras the way old HarfBuzz / Pango did
Had to do some refactoring to make this happen...

Under uniscribe bug compatibility mode, we still plit them
Uniscrie-style, but Jonathan and I convinced ourselves that there is no
harm doing this the Unicode way.  This change makes that happen, and
unbreaks free Sinhala fonts.
2012-11-13 12:35:35 -08:00
Behdad Esfahbod 4899801155 U+A872 PHAGS-PA SUPERFIXED LETTER RA is "Right"-Joining 2012-11-08 15:08:26 -08:00
Behdad Esfahbod 22a685836a Adjust Mongolian shaping
For U+1880..U+1886 Uniscribe thinks they are non-joining.
For U+1887 Uniscribe thinks it's joining, but looks wrong to me.
For now, match Uniscribe.
2012-11-05 15:20:10 -08:00
Behdad Esfahbod 3ba7bc14ea Implement 'Phags-pa shaping
Through the Arabic shaper.  It's similar to Mongolian.
2012-11-01 20:05:04 -07:00
Behdad Esfahbod 937f8d3871 [Arabic] Enable dlig and mset for Arabic
That's what the spec says, and what Uniscribe does.
2012-10-29 21:49:33 -07:00
Behdad Esfahbod bdc2fc8294 [Arabic] Respect Arabic joining from neighboring context
Now we respect Arabic joining across runs.
2012-09-25 21:32:35 -04:00
Behdad Esfahbod fabd3113a9 [OT] Port Arabic fallback shaping to synthetic GSUB
All of init/medi/fina/isol and rlig implemented.

Let there be dragons... ⻯
2012-09-06 00:51:44 -04:00
Behdad Esfahbod 2bd9fe3598 Refactor 2012-09-04 15:15:19 -04:00
Behdad Esfahbod a5ddd9e31c [OT] Really fix possible NULL dereference this time 2012-09-04 14:55:00 -04:00