After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 118472 - some ligatures substitutions wrongly skipped
some ligatures substitutions wrongly skipped
Status: RESOLVED FIXED
Product: pango
Classification: Platform
Component: general
1.2.x
Other HP-UX
: Normal normal
: ---
Assigned To: pango-maint
pango-maint
Depends on:
Blocks:
 
 
Reported: 2003-07-28 09:34 UTC by Kailash C. Chowksey
Modified: 2003-07-29 16:31 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
utf testcase (18 bytes, application/octet-stream)
2003-07-28 09:35 UTC, Kailash C. Chowksey
  Details
bad rendering (using tunga.ttf) (871 bytes, image/png)
2003-07-28 09:36 UTC, Kailash C. Chowksey
  Details
correct rendering (with this fix) (849 bytes, image/png)
2003-07-28 09:36 UTC, Kailash C. Chowksey
  Details
patch fix (cvs diff) (1.76 KB, patch)
2003-07-28 09:37 UTC, Kailash C. Chowksey
none Details | Review
bad rendering due to length overrun (885 bytes, image/png)
2003-07-29 05:12 UTC, Kailash C. Chowksey
  Details
correct rendering with no length overrun (832 bytes, image/png)
2003-07-29 05:13 UTC, Kailash C. Chowksey
  Details

Description Kailash C. Chowksey 2003-07-28 09:34:02 UTC
After the latest merge from freetype, ftxgdef.c, Lookup_LigatureSubst()
does not handle apply the ligature substitution if either the ligature IDs
don't match OR component IDs don't match. But two ligatures can be combined
into a new ligature if such a gsub rule exists.

So the correct thing is to skip handlig the ligature substitution if
neither the ligature IDs NOR the component IDs match.

This patch also fixes boundary condition error where we overrun the
in->length. A patch and screenshots and utf test case is attached to this
bug report.
Comment 1 Kailash C. Chowksey 2003-07-28 09:35:39 UTC
Created attachment 18668 [details]
utf testcase
Comment 2 Kailash C. Chowksey 2003-07-28 09:36:11 UTC
Created attachment 18669 [details]
bad rendering (using tunga.ttf)
Comment 3 Kailash C. Chowksey 2003-07-28 09:36:42 UTC
Created attachment 18670 [details]
correct rendering (with this fix)
Comment 4 Kailash C. Chowksey 2003-07-28 09:37:23 UTC
Created attachment 18671 [details] [review]
patch fix (cvs diff)
Comment 5 Owen Taylor 2003-07-28 12:36:01 UTC
The revised check doesn't make much sense to me if
you look at the comments. If the ligature ID's are
different, comparing the components doesn't seem like
a sensical operation. I suspect the original patch
is just wrong. I'll revert it and ask Werner Lemberg
if he remembers what he was trying to fix.

As for the length checks (really should be a separate
bug report, likely), I don't understand them; don't
the checks:

      if ( in->pos + lig->ComponentCount > in->length )
        continue;                         /* Not enough glyphs in input */

[...]

      if ( in->pos + sr[k].GlyphCount > in->length )
        continue;                           /* context is too long */

[...]
      /* check whether context is too long; it is a first guess only */
 
      if ( bgc > in->pos || in->pos + igc + lgc > in->length )
        continue;

Already take care of this?
Comment 6 Owen Taylor 2003-07-28 22:29:59 UTC
Reverted out the ligature patch. If you are happy with the
existing length checks, you can go ahead and close this bug,
I think.

Sat Jul 26 09:41:22 2003  Owen Taylor  <otaylor@redhat.com>
 
        * pango/opentype/ftxgsub.c (Lookup_LigatureSubst):
        Revert back out the FreeType patch preventing
        ligatures of not-originally adjacent glyphs;
        it doesn't work for all scripts. (#118472,
        Kailash C. Chowksey)
Comment 7 Kailash C. Chowksey 2003-07-29 05:11:00 UTC
This check before the loop is not sufficient because it
does not take into account glyphs that might be skipped
because CHECK_Property() said ignore them.

if ( in->pos + lig->ComponentCount > in->length )
        continue;               /* Not enough glyphs in input */

eg take the string U+0C95,U+0CCD,U+0CB7,U+0CC3. I have
attached wrong rendering and correct rendering with this.
Comment 8 Kailash C. Chowksey 2003-07-29 05:12:50 UTC
Created attachment 18703 [details]
bad rendering due to length overrun
Comment 9 Kailash C. Chowksey 2003-07-29 05:13:32 UTC
Created attachment 18704 [details]
correct rendering with no length overrun
Comment 10 Owen Taylor 2003-07-29 16:31:58 UTC
OK, I see the issue. Yep, there is a problem there. I don't
think your patch is quite complete:

 - It's necessary to check j before checking s_in[j]
   the first time, since j++ in the main loop might take
   you past the end.

 - There is an off-by-one in the existing code. 

          if ( in->pos + j < in->length )
            j++;
          else
            break;
  
   since after the increment in->pos + j == in->length which 
   is one off the end.

 - There are *lots* more places that need fixing; I think
   about 25 total in ftxgsub.c and ftxgpos.c. (Help with
   this would definitely be appreciated!)

I've filed a separate bug about this, bug 118592, and will
close this bug, since the other problem is OK now.