Commit Graph

2938 Commits

Author SHA1 Message Date
Behdad Esfahbod e634fed428 [buffer] Validate UTF-32 input
Same as what we do for UTF-8 and UTF-16.
2014-07-16 14:17:26 -04:00
Behdad Esfahbod b98c5db32d Minor refactoring 2014-07-16 13:44:01 -04:00
Behdad Esfahbod 3b861421a7 Fix Mongolian Variation Selectors for fonts without GDEF
Originally we fixed those in 79d1007a50.
However, fonts like MongolianWhite don't have GDEF, but have IgnoreMarks
in their LigatureSubstitute init/etc features.  We were synthesizing a
GDEF class of mark for Mongolian Variation Selectors and as such the
ligature lookups where not matching.  Uniscribe doesn't do that.

I tried with more sophisticated fixes, like, if there is no GDEF and
a lookup-flag mismatch happens, instead of rejecting a match, try
skipping that glyph.  That surely produces some interesting behavior,
but since we don't want to support fonts missing GDEF more than we have
to, I went for this simpler fix which is to always mark
default-ignorables as base when synthesizing GDEF.

Micro-test added.

Fixes rest of https://bugs.freedesktop.org/show_bug.cgi?id=65258
2014-07-16 13:30:26 -04:00
Behdad Esfahbod 878a25375b Minor 2014-07-16 13:21:59 -04:00
Behdad Esfahbod ec181e5014 Minor moving around 2014-07-16 13:10:03 -04:00
Behdad Esfahbod e7ce50d9eb [indic] Fix access past end of array 2014-07-16 12:30:39 -04:00
Behdad Esfahbod 73e23b0acf Whitespace 2014-07-15 18:43:49 -04:00
Behdad Esfahbod b7bc0b671d Simplify / speed up UTF-8 code 2014-07-11 16:22:13 -04:00
Behdad Esfahbod af2490c095 Only accept well-formed UTF-8 sequences
Enable tests that were disabled before, and adjust one test,
and add more tests.
2014-07-11 16:22:13 -04:00
Behdad Esfahbod 7323d385cc Simplify hb_utf_prev<16> to call hb_utf_next<16> 2014-07-11 16:22:13 -04:00
Behdad Esfahbod c09a607a84 Use hb_in_range() for arabic and indic tables
Though, looks like gcc was smart enough to produce the same code
before...
2014-07-11 16:22:13 -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 a8b89a09f6 Simplify hb_in_range()
It's both faster and produces smaller code.  Now I feel stupid for
not writing it this way before.
2014-07-11 14:18:01 -04:00
Behdad Esfahbod db8934faa1 Simplify hb_utf_prev<8> to call hb_utf_next<8> 2014-07-11 13:58:36 -04:00
Behdad Esfahbod efe74214bb Show U+FFFD REPLACEMENT CHARACTER for invalid Unicode codepoints
Only if the font doesn't support it.  Ie, this gives the user to
use non-Unicode codepoints as private values and return a meaningful
glyph for them.  But if it's invalid and font callback doesn't
like it, and if font has U+FFFD, show that instead.

Font functions that do not want this automatic replacement to
happen should return true from get_glyph() if unicode > 0x10FFFF.

Replaces https://github.com/behdad/harfbuzz/pull/27
2014-07-11 11:59:48 -04:00
Behdad Esfahbod 6f13b6d62d When parsing UTF-16, generate invalid codepoint for lonely low surrogate
Test passes now.
2014-07-10 19:39:39 -04:00
Behdad Esfahbod 6334495ac1 Use zh-Hans / zh-Hant when converting OT language tag to hb_language_t 2014-07-10 19:22:07 -04:00
Behdad Esfahbod f381e320df Fix lang matching logic
Previous code was broken logically, but harmless.
2014-07-10 19:20:35 -04:00
Behdad Esfahbod ee5350d667 Accept BCP 47 zh-Hans / zh-Hant language tags 2014-07-10 19:18:56 -04:00
Behdad Esfahbod 8b16ff1259 [uniscribe] Fix build after recent changes to Offset 2014-07-09 17:41:09 -04:00
Behdad Esfahbod 73f7f8919e Define _POSIX_C_SOURCE only if it is not defined
Fixes https://github.com/behdad/harfbuzz/pull/45
2014-07-09 17:17:18 -04:00
Behdad Esfahbod 0cd94491b9 [ucdn] Update to Unicode 7.0.0 data
From http://github.com/behdad/ucdn
2014-07-09 16:53:06 -04:00
Behdad Esfahbod 68f724484b [indic] Remove some more now-unused special-cases 2014-06-30 15:46:53 -04:00
Behdad Esfahbod e79c948980 [indic] Remove special-casing of U+1CF2,1CF3
These were introduced in a498565ced,
but IndicSyllabicCategory has had the correct value already, so the
special code was never needed.
2014-06-30 15:39:39 -04:00
Behdad Esfahbod d743ce78e1 [indic-table] Update to Unicode 7.0 data
Touch code just enough to preserve previous syllable structure
and functionality as closely as possible.  Many further cleanups
coming later.
2014-06-30 15:24:45 -04:00
Behdad Esfahbod 5fa21b3ab7 [indic-table] Fix category frequency counts in comments 2014-06-30 14:30:54 -04:00
Behdad Esfahbod 5c4e3e9a57 Whitespace 2014-06-30 14:25:18 -04:00
Behdad Esfahbod af528b6674 Fix typo; ouch! 2014-06-27 18:07:00 -04:00
Behdad Esfahbod 7d4ada66c9 Mark unsed members with a "Z" suffix
There may be more.  There are members that are by definition
redundant or reserved and not needed, NOT what we *currently*
don't use.

I'm sure there's more...
2014-06-27 17:32:56 -04:00
Behdad Esfahbod 23afcff1d1 [ot-font] Implement Unicode variation selectors 2014-06-27 17:22:36 -04:00
Behdad Esfahbod a5a4736916 [cmap] Implement subtable format 14 2014-06-27 17:22:31 -04:00
Behdad Esfahbod 586b60622c Minor: final bits of cleanup 2014-06-27 15:39:47 -04:00
Behdad Esfahbod 51d9ba09bc Minor 2014-06-27 15:27:15 -04:00
Behdad Esfahbod 3084767e92 Minor: Remove LongArrayOf 2014-06-27 15:24:35 -04:00
Behdad Esfahbod 41ea594950 Minor: Remove LongSortedArrayOf 2014-06-27 15:23:18 -04:00
Behdad Esfahbod bb6ecf2ce5 Minor: Remove LongOffsetArrayOf and LongOffsetLongArrayOf 2014-06-27 15:21:08 -04:00
Behdad Esfahbod 99d2817123 Minor: Remove GenericOffset 2014-06-27 15:19:15 -04:00
Behdad Esfahbod 9da552dcc5 Minor: Remove some GenericXXX templates 2014-06-27 15:18:36 -04:00
Behdad Esfahbod 36073ede5b Minor: Reorder template parameter order 2014-06-27 15:18:26 -04:00
Behdad Esfahbod 0394ec1bfb Minor: Introduce GenericOffset 2014-06-27 15:18:08 -04:00
Behdad Esfahbod 0d1b3419a7 Minor: Use template parameter default values for OffsetTo 2014-06-27 15:17:47 -04:00
Behdad Esfahbod 546b1adcdc Minor: Use template parameter default values for hb_prealloced_array_t 2014-06-27 15:17:01 -04:00
Behdad Esfahbod 911ca38645 Add back API removed recently
Add hb_ot_layout_language_get_required_feature_index() again, which
is used in Pango.  This was removed in
da13293798 in favor of
hb_ot_layout_language_get_required_feature().

API changes:

  - Added hb_ot_layout_language_get_required_feature_index back.
2014-06-24 10:20:36 -06:00
Behdad Esfahbod 89e4946929 Add new IndicSyllabicCategory short forms for Unicode 7.0 2014-06-22 11:32:13 -06:00
Behdad Esfahbod dcee838e89 Minor 2014-06-22 11:29:59 -06:00
Behdad Esfahbod f2ad86e605 [indic-table-gen] Minor 2014-06-21 15:31:10 -06:00
Behdad Esfahbod 2ec62279aa [indic-table] Update to Unicode 6.3.0
Was from 6.2.0.  It's a no-op.  Committing for the record.
2014-06-21 15:25:59 -06: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 2390d9b67e [arabic-table] Further tune
In anticipation of Unicode 7.0 data coming in the next commit.
2014-06-21 14:07:02 -06:00
Behdad Esfahbod a133e6067a [indic-table] Minor 2014-06-20 18:01:34 -04:00
Behdad Esfahbod b900fa2c8c [arabic-table] Use segmented table
No functional change.
2014-06-20 17:59:43 -04:00
Behdad Esfahbod c2e1134046 [indic-table] Make output stable 2014-06-20 17:57:03 -04:00
Behdad Esfahbod 55abfbd2ac [indic-table] Minor
No output change.
2014-06-20 16:47:43 -04:00
Behdad Esfahbod f886707490 [arabic-table] Don't write comments
No functional change.
2014-06-20 16:30:10 -04:00
Behdad Esfahbod 200dfe3eb1 [arabic-table] Use short names for values
No functional change.
2014-06-20 16:20:59 -04:00
Behdad Esfahbod 3f5327a41e [arabic-table] Read Blocks.txt and shuffle code around
No functional change.
2014-06-20 16:17:42 -04:00
Behdad Esfahbod 171f970e4f [indic-table] Black-list Thai, Lao, and Tibetan
We don't need Indic table for those.
2014-06-20 15:30:29 -04:00
Behdad Esfahbod 65ac2dae4f [indic-table] Speed up lookup 2014-06-20 15:29:38 -04:00
Behdad Esfahbod 64442a3f4c [indic-table] Fix compiler warning 2014-06-20 15:29:21 -04:00
Behdad Esfahbod 0436e1d505 [indic-table] Make table more compact by not covering full blocks
-#define indic_offset_total 4416
+#define indic_offset_total 3816

-}; /* Table occupancy: 60% */
+}; /* Table occupancy: 69% */
2014-06-20 15:28:38 -04:00
Behdad Esfahbod 190a251479 [indic-table] Remove block range from data table
No functional change.
2014-06-20 14:42:03 -04:00
Behdad Esfahbod 2b051c6057 Rename HB_VERSION_CHECK and hb_version_check to "atleast"
HB_VERSION_CHECK's comparison was originally written wrongly
by mistake.  When API tests were written, they were also written
wrongly to pass given the wrong implementation... Sigh.

Given the purpose of this API, there's no point in fixing it
without renaming it.  As such, rename.

API changes:

  HB_VERSION_CHECK -> HB_VERSION_ATLEAST
  hb_version_check -> hb_version_atleast
2014-06-20 14:09:57 -04:00
Behdad Esfahbod cabfa538ed Adjust unused doc symbols 2014-06-20 14:02:30 -04:00
Jonathan Kew da13293798 Rework handling of requiredFeature to solve problem with rlig in arial.ttf from winxp
https://bugzilla.mozilla.org/show_bug.cgi?id=986802
Fixes https://github.com/behdad/harfbuzz/pull/39

API Change:

-hb_ot_layout_language_get_required_feature_index
+hb_ot_layout_language_get_required_feature

New API takes an extra pointer argument.  Pass NULL in to get
behavior of previous API.

Reworked by behdad
2014-06-19 16:33:48 -04:00
Behdad Esfahbod df554af99d Rename search() to bsearch() and lsearch()
Such that the complexity of the algorithm used is clear at
call site.
2014-06-19 15:39:18 -04:00
Behdad Esfahbod fb8cc86ff9 Rename sort() to qsort()
In an effort to make the algorithm used clear.
2014-06-19 15:31:09 -04:00
Behdad Esfahbod 577ca48143 [unicode7] Update list of Default_Ignorable codepoints 2014-06-18 12:29:23 -04:00
Behdad Esfahbod 7cfee38276 [unicode7] Route Manichaean and Psalter Pahlavi through Arabic shaper
Still needs update to joining table to fully work.
2014-06-18 12:22:45 -04:00
Behdad Esfahbod a4a7899cd9 [unicode7] Mark right-to-left scripts 2014-06-18 12:22:45 -04:00
Behdad Esfahbod 62587bfc51 [unicode7] Declare Unicode 7 scripts 2014-06-18 12:22:45 -04:00
Behdad Esfahbod dc61294aa9 [unicode7] Add missing ISO 15924 tags 2014-06-18 12:22:45 -04:00
Behdad Esfahbod 7526373e70 [coretext] Remove unused var 2014-06-17 11:45:26 -04:00
Jonathan Kew 798e4185bc When zeroing mark widths for LTR, also adjust offset...
...so that they overstrike preceding glyph.

https://github.com/behdad/harfbuzz/pull/43
2014-06-12 18:34:15 -04:00
Jonathan Kew 80f7405a52 [Thai] set the correct general category on Nikhahit when decomposing Sara-Am. 2014-06-12 18:25:58 -04:00
Behdad Esfahbod 1d634cbb4b Fix base-position when 'pref' is NOT formed
If pre-base reordering Ra is NOT formed (or formed and then
broken up), we should consider that Ra as base.  This is
observable when there's a left matra or dotreph that positions
before base.

Now, it might be that we shouldn't do this if the Ra happend
to form a below form.  We can't quite deduce that right now...

Micro test added.  Also at:

https://code.google.com/a/google.com/p/noto-alpha/issues/detail?id=186#c29
2014-06-12 17:10:35 -04:00
Behdad Esfahbod 04dc52fa15 [indic] Recover OT_H undergone ligation and multiplication
Sometimes font designers form half/pref/etc consonant forms
unconditionally and then undo that conditionally.  Try to
recover the OT_H classification in those cases.

No test number changes expected.
2014-06-09 14:20:06 -04:00
Behdad Esfahbod 39c8201f8e [indic] Improve base re-finding
No test numbers change.
2014-06-09 14:20:06 -04:00
Behdad Esfahbod c04d5f0dd2 [indic] Minor 2014-06-09 14:20:06 -04:00
Behdad Esfahbod 832a6f99b3 [indic] Don't reorder reph/pref if ligature was expanded
Normally if you want to, say, conditionally prevent a 'pref', you
would use blocking contextual matching.  Some designers instead
form the 'pref' form, then undo it in context.  To detect that
we now also remember glyphs that went through MultipleSubst.

In the only place that this is used, Uniscribe seems to only care
about the "last" transformation between Ligature and Multiple
substitions.  Ie. if you ligate, expand, and ligate again, it
moves the pref, but if you ligate and expand it doesn't.  That's
why we clear the MULTIPLIED bit when setting LIGATED.

Micro-test added.  Test: U+0D2F,0D4D,0D30 with font from:

[1]
https://code.google.com/a/google.com/p/noto-alpha/issues/detail?id=186#c29
2014-06-05 20:36:01 -04:00
Behdad Esfahbod b5be231720 [gsub] Adjust single-length ligature subst to act like single subst 2014-06-05 19:00:22 -04:00
Behdad Esfahbod aae69451df [gsub] Minor shuffling 2014-06-05 19:00:08 -04:00
Behdad Esfahbod b6b304f12b [ot] Add TODO re zero-len MultipleSubst sequences 2014-06-05 17:12:54 -04:00
Behdad Esfahbod f1a72fe7bf [ot-font] Fix cmap EncodingRecord cmp order 2014-06-04 19:03:16 -04:00
Behdad Esfahbod ce34f0b07e [ot-font] Use binary search for format12 cmap subtable 2014-06-04 18:57:46 -04:00
Behdad Esfahbod 257d1adfa1 [ot-font] Work around broken cmap subtable format 4 length
Roboto was hitting this.  FreeType also has pretty much the
same code for this, in ttcmap.c:tt_cmap4_validate():

    /* in certain fonts, the `length' field is invalid and goes */
    /* out of bound.  We try to correct this here...            */
    if ( table + length > valid->limit )
    {
      if ( valid->level >= FT_VALIDATE_TIGHT )
        FT_INVALID_TOO_SHORT;

      length = (FT_UInt)( valid->limit - table );
    }
2014-06-04 18:47:55 -04:00
Behdad Esfahbod 51f563579b Move try_set to sanitize context 2014-06-04 18:42:32 -04:00
Behdad Esfahbod 500737e8e1 [ot-font] Don't select a Null cmap subtable
Can happen either in broken fonts, or as a result of sanitize().
2014-06-04 18:17:29 -04:00
Behdad Esfahbod dac86026a6 Fix some cppcheck warnings
Bug 77800 - cppcheck reports
2014-06-03 17:57:00 -04:00
Behdad Esfahbod c306410cab Bug 77732 - Fix unused typedef warning for ASSERT_STATIC with GCC 4.8 2014-06-03 17:00:07 -04:00
Behdad Esfahbod ae2b854eab Move code around 2014-06-03 16:59:09 -04:00
Behdad Esfahbod 17c3b809f4 [indic] Treat U+A8E0..A8F1 as OT_A instead of OT_VD
Apparently they can intermix with other OT_A.

Test: U+0915,A8E2,1CD0
2014-06-02 15:08:18 -04:00
Behdad Esfahbod 6ae13f257c [graphite2] Fix cluster mapping
Patch from Martin Hosken.  I expect this to fix the following bugs:

https://bugs.freedesktop.org/show_bug.cgi?id=75076
https://bugzilla.gnome.org/show_bug.cgi?id=723582
https://bugzilla.redhat.com/show_bug.cgi?id=998812
2014-05-30 17:38:14 -04:00
Behdad Esfahbod 7977ca17aa [indic] Allow decimal and Brahmi digits as placeholders
Tests: U+0967,0951 U+0031,093F
2014-05-29 15:34:26 -04:00
Behdad Esfahbod e8b5d64039 [indic] Do NOT allow reph formation on placeholders
Only allow it on DOTTED CIRCLE.  No effect on test numbers.

Test: U+0930,094D,00A0
2014-05-29 15:20:15 -04:00
Behdad Esfahbod 52b562a6a0 [indic] Clean up a bit
No functional change intended.
2014-05-27 18:19:52 -04:00
Behdad Esfahbod 3bf652b907 [indic] Treat U+002D and U+2010..2014 as placeholders 2014-05-27 18:07:26 -04:00
Behdad Esfahbod e0de95f402 [indic] Treat U+00D7 MULTIPLICATION SIGN as placeholder 2014-05-27 17:58:34 -04:00
Behdad Esfahbod cf78dd483c [indic/myanmar] Rename OT_NBSP to OT_PLACEHOLDER 2014-05-27 17:53:37 -04:00