Commit Graph

2579 Commits

Author SHA1 Message Date
Behdad Esfahbod 8ac2e88def [uniscribe] Use unique font name
When installing per-process fonts using AddFontMemResourceEx(),
if a font with the same family name is already installed, sometimes
that one gets used.  Which is problematic for us.  As such, we
now mangle the font to install a new 'name' table with a unique
name, which we then use to choose the font.

Patch from Jonathan Kew.
2013-07-21 17:17:44 -04:00
Behdad Esfahbod 8751de5083 Followup fix for 3f9e2dced2
During GSUB, if a ligation happens, subsequence context input matching
matches the new indexing.  During GPOS however, the indices never
change.  So just go one by one.

Fixes 'dist' positioning with mmrtext.ttf and the following sequence:

  U+1014,U+1039,U+1011,U+1014,U+1039,U+1011,U+1014,U+1039,U+1011

Reported by Jonathan Kew.
2013-07-18 16:29:50 -04:00
Behdad Esfahbod e509d35cf1 [ft] hb_ft_get_glyph_from_name fails for the name of glyph id 0
Based on patch from Jonathan Kew, as reported on the mailing list.
2013-07-11 14:56:45 -04:00
Behdad Esfahbod 29b596ac67 [uniscribe] Fix buffer allocation
Email from Jonathan Kew:

My cygwin build kept aborting on certain test words when run with the
uniscribe backend. Turned out this was caused by a bug in the allocation
of scratch buffers in hb-uniscribe.cc.

Commit 2a17f9568d introduced a new line

  ALLOCATE_ARRAY (SCRIPT_VISATTR, vis_attr, glyphs_size);

but it failed to account for this in the computation of glyphs_size
(the number of glyphs for which scratch buffer space is available),
with the result that the vis_clusters array ends up overrunning the
end of the scratch buffer and clobbering the beginning of the buffer's
info[].

AFAICS, the vis_attr array is not actually used, so the simple fix is
to remove the line that allocates it. (If/when we -do- need to use
vis_attr for something, we'll need to add another term to the earlier
calculation of glyphs_size.)

With this patch, the uniscribe backend runs reliably again.

JK
2013-07-08 08:37:15 -06:00
Behdad Esfahbod 9245e98742 [Indic] Add Javanese config
We should add for other scripts too, send me the virama codepoint
and script name...
2013-06-26 20:57:58 -04:00
Behdad Esfahbod 5f85c80a07 [OT] Collect requiredFeature only if features are not provided
As per Werner's report on the list.
2013-06-26 20:14:18 -04:00
Behdad Esfahbod 3f9e2dced2 Fix contextual lookup recursion indexing
See email thread "Skipping Control for Attaching Marks using OpenType"
from earlier this month.
2013-06-26 19:46:55 -04:00
Bradley Grainger 89312b7417 Destroy lookups before blobs.
'layout->gsub' may depend on data owned by 'layout->gsub_blob', so it must
be deinitialized before the blob is destroyed.
2013-06-21 15:02:18 -07:00
Behdad Esfahbod 79d1007a50 If variation selector is not consumed by cmap, pass it on to GSUB
This changes the semantics of get_glyph() callback and expect that
callbacks return false if the requested variant is not available, and
then we will call them back with variation_selector=0 and will retain
the glyph for the selector in the glyph stream.

Apparently most Mongolian fonts implement the Mongolian Variation
Selectors using GSUB, not cmap.

https://bugs.freedesktop.org/show_bug.cgi?id=65258

Note that this doesn't fix the Mongolian shaping yet, because the way
that's implemented is that the, say, 'init' feature ligates the letter
and the variation-selector.  However, since currently the variation
selector doesn't have the 'init' mask on, it will not be matched...
2013-06-13 19:01:07 -04:00
Behdad Esfahbod c7a8491720 Skip over multiple variation selectors in a row 2013-06-10 15:08:49 -04:00
Behdad Esfahbod 7235f33f9e Fix misc warnings reported by cppcheck
https://bugs.freedesktop.org/show_bug.cgi?id=65544
2013-06-10 15:08:49 -04:00
Behdad Esfahbod 2fd0e02706 Minor 2013-06-06 17:16:01 -04:00
Behdad Esfahbod 4ddf937242 Remove unnecessary stdint.h include 2013-06-03 18:36:26 -04:00
Chun-wei Fan 93a04b8b5e hb-uniscribe.cc: Re-enable build under Visual Studio
-Declare hinstLib at the top of block
-Fix the definitions of the typedefs of ScriptItemizeOpenType,
 ScriptShapeOpenType and ScriptPlaceOpenType
2013-06-03 18:32:59 -04:00
Behdad Esfahbod d70be29831 Fix dist 2013-05-28 17:27:31 -04:00
Behdad Esfahbod 22ce096174 Generate harfbuzz-icu.pc
Currently it only works with ICU that has .pc files.  I'll
wait till someone complains before fixing it for icu-config
systems.
2013-05-28 17:18:30 -04:00
Behdad Esfahbod d9afa11133 Build hb-icu into libharfbuzz-icu.so 2013-05-28 15:27:40 -04:00
Behdad Esfahbod 2a17f9568d Bug 55494 - ScriptItemizeOpenType doesn't exists under Windows XP
Fallback to older API if OpenType variants are not available.
2013-05-28 13:13:46 -04:00
Behdad Esfahbod 61e7775fa7 Remove hb-icu dependency from hb-icu-le shaper 2013-05-27 18:24:56 -04:00
Behdad Esfahbod 7e08f1258d Don't zero advance of mark-non-mark ligatures
If there's a mark ligating forward with non-mark, they were
inheriting the GC of the mark and later get advance-zeroed.
Don't do that if there's any non-mark glyph in the ligature.

Sample test: U+1780,U+17D2,U+179F with Kh-Metal-Chrieng.ttf

Also:
Bug 58922 - Issue with mark advance zeroing in generic shaper
2013-05-27 14:50:00 -04:00
Behdad Esfahbod cf059ac69d [icu_le] Support non-BMP text 2013-05-24 15:28:11 -04:00
Behdad Esfahbod a447c528e6 [icu_le] A bit better scaling 2013-05-23 17:05:39 -04:00
Behdad Esfahbod fb502a2278 Merge commit '9d9e72e94e7914f82ce62a304e7242f79c13edaf' 2013-05-23 15:54:52 -04:00
Behdad Esfahbod b9408d24f3 [icu_le] Fix scaling
Seems to work...
2013-05-23 15:43:02 -04:00
Behdad Esfahbod 601526392d Copy stdint.h boilerplate to ucdn 2013-05-21 17:22:13 -04:00
Behdad Esfahbod d785fa0c45 Minor refactoring 2013-05-20 09:18:52 -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 fa3d0a0ce6 Bug 64476 - Typo in hb_set_t.get_min()
Fixes previous commit's test.
2013-05-14 15:30:55 -04:00
Behdad Esfahbod 9d9e72e94e [OTLayout] Use is_inplace() when flipping buffers 2013-05-04 16:04:04 -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 bac1dd6a0f [OTLayout] Refactor a bit more 2013-05-04 16:04:04 -04:00
Behdad Esfahbod d2c96819de Move code around 2013-05-04 16:04:04 -04:00
Behdad Esfahbod 45fd9424c7 [OTLayout] Add hb_ot_layout_lookup_accelerator_t 2013-05-04 16:04:03 -04:00
Behdad Esfahbod 76ea563673 [OTLayout] Add note about collect_glyphs() and recursive lookups 2013-05-04 16:04:03 -04:00
Behdad Esfahbod a8bf0e91f1 Add U+061C ARABIC LETTER MARK to Default_Ignorable 2013-05-03 14:45:04 -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
Behdad Esfahbod 8144936d07 [Indic] Work around fonts with broken new-spec tables
See comments, and this thread:

http://lists.freedesktop.org/archives/harfbuzz/2013-March/002990.html

Originally reported here:

https://code.google.com/p/chromium/issues/detail?id=96143

Doesn't change test suite numbers.
2013-03-05 20:08:59 -05:00
Behdad Esfahbod cd54d505d1 Fix distcheck 2013-03-04 21:29:38 -05:00
Behdad Esfahbod 41732f1fe3 [Indic] Help compiler put indic_features table in .rodata
The overridden "or" operator was preventing the flag expression from
being const, and putting the table in .data instead or .rodata.
2013-02-27 20:40:54 -05:00
Behdad Esfahbod 778d7f844c [buffer] Better parse glyph names 2013-02-27 18:49:18 -05:00
Behdad Esfahbod 20b817ac21 [buffer] Implement buffer deserialization for format=json
Using a ragel machine.
2013-02-27 18:49:18 -05:00
Behdad Esfahbod 847794e929 [buffer] Implement buffer deserialization for format=text
Using a ragel machine.
2013-02-27 18:49:18 -05:00
Behdad Esfahbod 4ee803b42a [buffer] Fix serializing of buffer with invalid direction 2013-02-27 18:49:15 -05:00
Behdad Esfahbod e54dd26300 [buffer] Start implementing buffer deserialization 2013-02-27 18:49:13 -05:00
Behdad Esfahbod bcc8f32b4c [buffer] Minor 2013-02-27 18:49:10 -05:00
Behdad Esfahbod d3e14aafff [buffer] Move buffer serialization code to a new file 2013-02-27 18:49:05 -05:00
Behdad Esfahbod 8da5111269 Minor 2013-02-27 18:49:05 -05:00
Behdad Esfahbod 94789fd601 [Indic] Sort pre-base reordering consonants with post-forms
Before, we were marking them as below-form for initial reordering.
However, there is a rule that says "post consonants should follow
below consonsnts" for base determination purposes.  Malayalam has
port-form YA/VA, and RA is pre-base.  As such, for a sequence like
YA,Virama,YA,Virama,RA, the correct base is at index 0.  But
because the code was seeing RA as a below-base, it was stopping at
the second YA as base, instead of jumping it as a post-base.

By treating prebase-reordering consonants like post-forms, this
is fixed.

MALAYALAM went down from 351 to 265.  Other numbers didn't change:

BENGALI: 353686 out of 354188 tests passed. 502 failed (0.141733%)
DEVANAGARI: 707305 out of 707394 tests passed. 89 failed (0.0125814%)
GUJARATI: 366262 out of 366457 tests passed. 195 failed (0.0532122%)
GURMUKHI: 60706 out of 60747 tests passed. 41 failed (0.067493%)
KANNADA: 950680 out of 951913 tests passed. 1233 failed (0.129529%)
KHMER: 299074 out of 299124 tests passed. 50 failed (0.0167155%)
LAO: 53611 out of 53644 tests passed. 33 failed (0.0615167%)
MALAYALAM: 1048069 out of 1048334 tests passed. 265 failed (0.0252782%)
ORIYA: 42320 out of 42329 tests passed. 9 failed (0.021262%)
SINHALA: 271539 out of 271847 tests passed. 308 failed (0.113299%)
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-02-26 21:22:37 -05:00
Behdad Esfahbod 05d5d3cd63 Fix "comparison between signed and unsigned" warnings
Patch from Jonathan Kew.
2013-02-25 23:57:51 -05:00
Behdad Esfahbod 07a52b6211 Give up sanitizing after 100 edit requests
Such fonts are *definitely* really broken.  Give up.
Limits time spent in sanitize for extremely / deliberately broken
fonts.  For example, two fonts with these md5sum / names:

  9343f0a1b8c84b8123e7d201cae62ffd.ttf
  eb8c978547f09d368fc204194fb34688.ttf

were spending over a second in sanitize!  Not anymore.
2013-02-25 19:09:57 -05:00
Behdad Esfahbod 29ff254815 Add HB_DEBUG_VERBOSE
Only affects the verbosity of function name printing right now.
2013-02-25 19:04:56 -05:00
Behdad Esfahbod c3ba49b6fa Always create sub-blobs in MEMORY_MODE_READONLY
This fixes a design bug with sanitize and sub-blobs that can
cause crashes.  Jonathan and I found and debugged this issue
when we tested a corrupt font with the md5sum / filename:
ea395483d37af0cb933f40689ff7b60a.  Two hours of intense
debugging we found out that the font has overlapping GSUB/GPOS
tables, and as such, sanitizing the second table can modify
the first one, which can cause all kinds of undefined behavior.

The correct way to fix this is to make sure sub-blobs are
always created readonly, since we consider the parent blob
to be a shared resource and can't modify it, even if it *is*
writable.

This essentially makes the READONLY_MAY_MAKE_WRITABLE mode
unused...  Maybe we should simply remove / deprecate it.
2013-02-25 17:06:35 -05:00