bugThe FreeType Project - Bugs: bug #59544, WOFF2 TTC - face_index causes...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #59544: WOFF2 TTC - face_index causes failure

Submitter:  Avery Crits-Christoph <averycc>
Submitted:  Wed 25 Nov 2020 06:35:34 PM UTC
   
 
Severity:  3 - Normal Item Group:  Incorrect behaviour
Status:  Confirmed Privacy:  Public
Assigned to:  wl Open/Closed:  Open
Planned Release:  None

Wed 16 Dec 2020 08:50:32 AM UTC, comment #3: 

Thanks for your patch and sorry for not reacting earlier.

I think your code is a first step to a solution.  However, it is not sufficient, I think: `ftdump` still reports that the font contains a single face only, which is obviously wrong.

Will have a look soon, but if you can invest some more time to fix this, too, I would be more than happy :-)

Werner LEMBERG <wl>
Group administrator
Tue 15 Dec 2020 10:15:03 PM UTC, comment #2: 

I'm attaching a proposed fix that allows ftbench to pass for the both the ttc and the woff2. Please let me know what you think.


I looked at this more after my last post and now understand that the tag is read as OTTO only after the WOFF2 stream is decompressed and replaced with the font at the given face index. The problem that occurs when reading the font as a CFF is that the face_index is still the original value (eg. 2) even though the collection context is gone. Updating the face_index fixes the issue.

There may be better fixes, but at least this will help show the underlying issue.

(file #50482)

Avery Crits-Christoph <averycc>
Sat 05 Dec 2020 12:18:42 AM UTC, comment #1: 

This font is first attempted to be read as TrueType but encounters a BadFormat error:
https://git.savannah.gnu.org/cgit/freetype/freetype2.git/tree/src/truetype/ttobjs.c#n653

It then read as a CFF font encounters an error here:
https://git.savannah.gnu.org/cgit/freetype/freetype2.git/tree/src/sfnt/sfobjs.c#n562

ttc_header.count has not been set, even though face_instance_index (2) and woff2_num_fonts (8) are both set.

I'm not sure there's a straightforward fix. Just accounting for woff2_num_fonts where the error is causes later problems. The tag is currently reading as "OTTO", so maybe separate handling for tag OTTO in sfnt_open_font (like TTCF) to set the header offsets or maybe there's a bug deeper in WOFF2 and the tag is being read wrongly?

For the TTC version, it also does a TT attempt (Bad Format) and then CFF success (as TTCF). So I think the BadFormat error is expected, but I'm not sure. It seems suboptimal since it goes through the whole WOFF2 decompression before hitting it a
nd re-trying.

Avery Crits-Christoph <averycc>
Wed 25 Nov 2020 06:35:34 PM UTC, original submission:  

Hello!

There seems to be an error with WOFF2 TTCs when specifying a face_index. The error is reproducible with ftbench.cc:

- Edit ftbench.cc get_face() function such that face_index is not 0. The font I am using for testing (NotoSansCJK-Regular.woff2) has four faces, so face_index = 1,  2, or 3 would trigger this error. I set face_index = 3, which is "Noto Sans CJK TC" face.
https://git.savannah.gnu.org/cgit/freetype/freetype2-11.

- Configure/make freetype with --with-brotli=yes
- Make ftdemos
- Run ./ftbench -b g NotoSansCJK-Regular.ttc
- Observe successful completion for Noto Sans CJK TC.
- Run ./ftbench -b g NotoSansCJK-Regular.woff2
- "couldn't load font resource" error.

(You can download the TTC from: https://www.google.com/get/noto/help/cjk/
and then run "woff2_compress NotoSansCJK-Regular.ttc" to convert to WOFF2)

Thanks and please let me know if I can provide more information!

Avery Crits-Christoph <averycc>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #50482:  woff2_ttc_fix.patch added by averycc (2KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by wl (Posted a comment)
  • -email is unavailable- added by averycc (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-12-16 wl StatusNone Confirmed
        Assigned toNone wl
    2020-12-15 averycc Attached File- Added woff2_ttc_fix.patch, #50482

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code