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 149696 - Extending the OpenType support to GSUB Lookup type 8 viz. reverse chain contextual substituion table.
Extending the OpenType support to GSUB Lookup type 8 viz. reverse chain conte...
Status: RESOLVED FIXED
Product: pango
Classification: Platform
Component: general
1.4.x
Other Linux
: High normal
: Medium feature
Assigned To: pango-maint
pango-maint
Depends on:
Blocks:
 
 
Reported: 2004-08-09 05:24 UTC by Aamir Wali
Modified: 2007-10-09 16:44 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
implements reverse chain subst. table (18.27 KB, patch)
2004-08-10 04:00 UTC, Aamir Wali
needs-work Details | Review
Corrected patch (15.21 KB, patch)
2004-08-25 08:28 UTC, Aamir Wali
none Details | Review
Version with my fixes (13.57 KB, patch)
2004-12-15 01:23 UTC, Owen Taylor
needs-work Details | Review
committed patch. (14.06 KB, patch)
2006-01-30 22:38 UTC, Behdad Esfahbod
committed Details | Review

Description Aamir Wali 2004-08-09 05:24:23 UTC
Providing support for this lookup will enable the correct functioning of arabic 
scripts like Nastaliq.
Detail:
In any font glyph forms can depend on following or preceeding glyphs. In Urdu 
however, connections between glyphs should be in sequence of thick-thin-thick 
etc for the whole word segment. By language rules connection between last two 
glyph is always fixed. 

This means that we should start from the end and moving backwards assign 
correct forms to one glyph after another. If we have only lookups going forward 
it is hard to implement such script behavior. This is where lookup type 8 helps.

Aamir
Comment 1 Aamir Wali 2004-08-09 08:21:20 UTC
Hello, 
I could send you the patch whenever you give the green signal.

Aamir
Comment 2 Owen Taylor 2004-08-09 12:20:10 UTC
I don't see anything that blocks submitting a patch.
Comment 3 Behdad Esfahbod 2004-08-09 12:41:20 UTC
As Owen said, nothing blocks you from submitting a patch.  But I'm wondering
what do you really mean by this.  Using Nafees Nastaliq font myself, I see that
it's already possible to do what you explained.  Nafees font can be found in bug
122330.  See this screenshot for what Pango can currently do (the upper one):

http://bugzilla.gnome.org/attachment.cgi?id=23841&action=view
Comment 4 Aamir Wali 2004-08-10 04:00:16 UTC
Created attachment 30384 [details] [review]
implements reverse chain subst. table
Comment 5 Aamir Wali 2004-08-10 04:06:48 UTC
Well its a long story. You see when we first made this font, this 'type 8 
luxury' was new and unavailable (at least in VOLT at that time). So we had to 
model the script using the simple chain table. As a result instead of one OT 
rule we had to write (in some cases upto) 5 to get that output. If you are 
using the font you will see that its pretty slow. Work is still going on on 
this font to speed it up a little. We are actually in the design phase 
of 'refurnishing' the font where we are thinking about reducing the # of rules 
without affecting the output. We have other ideas about the huge number of 
positioning rules but as far as subs. rules are concerned our initial study 
shows that by simple lookup ordering, grouping and intrducing type8 we can 
reduce the number of GSUB lookups. Its going to take time but in the meantime  
we had this time to work in pango and get the type 8 table moving.

Thanks for using our font. You can try our other fonts at www.crulp.org

Only recently the biggest Urdu newspaper of pakistan (or the world) choose to 
use one of our other font for their web site. http://www.jang.net/urdu.

Bye 

Aamir
Comment 6 Owen Taylor 2004-08-10 17:59:24 UTC
If you look at how the lookup type 8 is defined, it's carefully
restricted so that it can be done in-place. It's always a one-to-one
substitution.

otl_buffer_add_output_glyph_reverse() has all the inefficiency of
what we do for the normal case *and* it only works for 1-to-1
substitutions.

I think it would be better to write another loop that replaces
Do_String_Lookup() for the particular case of lookup 8 and
instead of copying in=>out, just modify in in place. (Look-behind
refers to the modified glyphs, so this works fine)

 FT_ULong i;

 if (buffer->in_length == 0)
   return;

 i = buffer->in_length - 1;
 do
 {
    if ( ~IN_PROPERTIES( i ) & properties[lookup_index] )
      Lookup_ReverseChainContextSubst ( ... )
 
 }
 while (i--)

You get the idea. (Careful with reverse iteration for an unsigned index variable);
Comment 7 Aamir Wali 2004-08-17 13:58:09 UTC
I have a few over heads in my code. For e.g. i had been optimistic that in 
future there may be more than one format for reverse chain. Any ways this seems 
fine. Do i have to send you a new patch or will this do.
Comment 8 Owen Taylor 2004-08-17 15:47:56 UTC
I'd appreciate a new patch.
Comment 9 Aamir Wali 2004-08-25 08:28:19 UTC
Created attachment 30914 [details] [review]
Corrected patch
Comment 10 Owen Taylor 2004-12-15 01:21:45 UTC
Here's a revised version of your patch ... can you test?

Summary of changes:

 - The code only checked the properties for the first character
   in the buffer
 - Apply_ReverseChainContextSubst was returning TTO_Err_Not_Covered
   in most cases, needed to copy the retError handling from 
   Do_String_Lookup
 - Check for GSUB_LOOKUP_REVERSE_CHAIN in Do_Glyph_Lookup and
   return an error. (See also bug 161327)
 - Removed unused context_length and nesting_level
   arguments to Lookup_ReverseChainContextSubst
 - Fix off by one in
       if ( bgc > string_index || string_index + lgc > buffer->in_length )
   need to account for 1 input glpyh
 - Fixed usage of IN_CURGLYPH(0) in Lookup_ReverseChainContextSubst,
   should be IN_ITEM( string_index ) (GLYPH=>ITEM change probably
   postdates this patch)
 - Fixed usage of buffer->out_pos in Lookup_ReverseChainContextSubst
 - Used various variables to simplify TT_GSUB_Apply_String changes
 - Some formatting, comment fixes to make it conform to existing code,
   fix variable declaration mixed with code.
 - Fixed leak of rccs->Substitute in Free_ReverseChainContextSubst
 - Fixed leaks of rccs-Coverage in Load_ReverseChainContextSubst (spurious 
   return, return instead of goto Fail4)
 - Check that SubstFormat == 1.
 - Make Apply_ReverseChainContextSubst const

I haven't tested beyond compilation
Comment 11 Owen Taylor 2004-12-15 01:23:04 UTC
Created attachment 34842 [details] [review]
Version with my fixes
Comment 12 Aamir Wali 2004-12-15 05:51:53 UTC
Hello, 

Certainly. Can you please send me the (.zip and .rar) version of OpenType 
Folder. Our download services have currently been suspended. I will need the 
updated version because there is no use of IN_ITEM in the one i have... and i 
cant download either.

Aamir
Comment 13 Aamir Wali 2004-12-15 05:55:59 UTC
Hello, 

Certainly. Can you please send me the (.zip and .rar) version of OpenType 
Folder. Our download services have currently been suspended. I will need the 
updated version because there is no use of IN_ITEM in the one i have... and i 
cant download either.

Aamir
Comment 14 Aamir Wali 2005-01-12 07:03:02 UTC
Dear Owen,

I have very carefully tested these changes and everything seem fine. There is 
this silly error though. The function call to otl_buffer_copy_output_glyph ( 
in do_string_lookup) has a space between the function name and opening bracket.
No need discussing this..anyway, is there anything else you would want me to 
do?

Aamir
Comment 15 Aamir Wali 2005-03-30 13:48:23 UTC
Hi,

Any plans of incorporating GSUB 8 in the next release?

Aamir
Comment 16 Behdad Esfahbod 2005-03-30 20:38:39 UTC
I'm working on a unified OpenType code base.  I will include your patch.  That
should not take more than a couple months to show up in the release.
Comment 17 Behdad Esfahbod 2006-01-16 11:40:06 UTC
The patch needs some slight changes to apply on the current code base.  An updated patch will be committed instantly.
Comment 18 Behdad Esfahbod 2006-01-30 22:38:25 UTC
Created attachment 58430 [details] [review]
committed patch.

2006-01-30  Behdad Esfahbod  <behdad@gnome.org>

        * pango/opentype/ftxgsub.c: Handle GSUB Lookup type 8,
        and ReverseChainContextualSubst table.  (bug #149696,
        patch from Aamir Wali)
Comment 19 Behdad Esfahbod 2006-01-30 22:39:17 UTC
Thanks for the patch.  It's in CVS and will be in Pango 1.11.3 due to release in an hour.  Please test.
Comment 20 Behdad Esfahbod 2006-02-18 18:09:53 UTC
Closing as it's fixed.  Test please.
Comment 21 Behdad Esfahbod 2007-10-09 16:44:21 UTC
Aamir, did you ever update the Nafees Nastaliq font to use this type of lookups?  I'm looking for any font using it and fail to find any.  Thanks.