ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Variable OTF font resulting in invalid font due to stack overflow
@ 2021-05-12 21:46 Marcel Fabian Krüger
  2021-05-13  7:19 ` Hans Hagen
  2021-05-13 14:23 ` Hans Hagen
  0 siblings, 2 replies; 4+ messages in thread
From: Marcel Fabian Krüger @ 2021-05-12 21:46 UTC (permalink / raw)
  To: ConTeXt users list

Hi,

recently we got an interesting bug report in luaotfload (the original report
is at https://github.com/latex3/luaotfload/issues/184) which relates to the
ConTeXt fontloader. Take the following ConTeXt example:

    \starttext
    \definefontfeature [default:bold] [default] [axis={weight=500}]
    \definedfont[file:NotoSansCJKsc-VF.otf*default:bold @ 10pt]
    
    U+5E2E 帮
    
    \stoptext

The font is available at
https://github.com/googlefonts/noto-cjk/raw/main/Sans/Variable/OTF/NotoSansCJKsc-VF.otf.

This compiles correctly, but the CJK glyph do not appear since
it's Type2 CharString is invalid. The CFF2 CharStrings of this
glyph invokes the rrcurveto operator with 63 arguments, which is
allowed in CFF2 where the argument limit is 513, but not allowed in
Type2 where the limit is at 48.

It would be great if ConTeXt could check for this and insert additional
rrcuveto operators when necessary to avoid this issue.

Additionally we got a report that inkscape 1.0 seems to be incompatible
with the way commmands are passed to it for SVG files. Hendrik Seliger
suggested to set f_convert (defined in font-ocl.lua, otfsvg.topdf, line 435)
to `formatters["file-open:%s; export-%s:%s; export-do\n"]` when a new
inkscape version is detected. (See https://github.com/latex3/luaotfload/issues/183)
I wasn't able to reproduce the issue in ConTeXt yet.


Best regards,
Marcel
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Variable OTF font resulting in invalid font due to stack overflow
  2021-05-12 21:46 Variable OTF font resulting in invalid font due to stack overflow Marcel Fabian Krüger
@ 2021-05-13  7:19 ` Hans Hagen
  2021-05-13 14:23 ` Hans Hagen
  1 sibling, 0 replies; 4+ messages in thread
From: Hans Hagen @ 2021-05-13  7:19 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Marcel Fabian Krüger

On 5/12/2021 11:46 PM, Marcel Fabian Krüger wrote:
> Hi,
> 
> recently we got an interesting bug report in luaotfload (the original report
> is at https://github.com/latex3/luaotfload/issues/184) which relates to the
> ConTeXt fontloader. Take the following ConTeXt example:
> 
>      \starttext
>      \definefontfeature [default:bold] [default] [axis={weight=500}]
>      \definedfont[file:NotoSansCJKsc-VF.otf*default:bold @ 10pt]
>      
>      U+5E2E 帮
>      
>      \stoptext
> 
> The font is available at
> https://github.com/googlefonts/noto-cjk/raw/main/Sans/Variable/OTF/NotoSansCJKsc-VF.otf.
> 
> This compiles correctly, but the CJK glyph do not appear since
> it's Type2 CharString is invalid. The CFF2 CharStrings of this
> glyph invokes the rrcurveto operator with 63 arguments, which is
> allowed in CFF2 where the argument limit is 513, but not allowed in
> Type2 where the limit is at 48.
> 
> It would be great if ConTeXt could check for this and insert additional
> rrcuveto operators when necessary to avoid this issue.

hm, i can try but not today -)

> Additionally we got a report that inkscape 1.0 seems to be incompatible
> with the way commmands are passed to it for SVG files. Hendrik Seliger
> suggested to set f_convert (defined in font-ocl.lua, otfsvg.topdf, line 435)
> to `formatters["file-open:%s; export-%s:%s; export-do\n"]` when a new
> inkscape version is detected. (See https://github.com/latex3/luaotfload/issues/183)
> I wasn't able to reproduce the issue in ConTeXt yet.
context tries to identify the version and adapt (as it will take a while 
before 1.0 ends up in linux distributions) but last week i noticed some 
strange xml related messages so i need to look at that

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Variable OTF font resulting in invalid font due to stack overflow
  2021-05-12 21:46 Variable OTF font resulting in invalid font due to stack overflow Marcel Fabian Krüger
  2021-05-13  7:19 ` Hans Hagen
@ 2021-05-13 14:23 ` Hans Hagen
  2021-05-16 16:53   ` Marcel Fabian Krüger
  1 sibling, 1 reply; 4+ messages in thread
From: Hans Hagen @ 2021-05-13 14:23 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Marcel Fabian Krüger

[-- Attachment #1: Type: text/plain, Size: 1607 bytes --]

On 5/12/2021 11:46 PM, Marcel Fabian Krüger wrote:
> Hi,
> 
> recently we got an interesting bug report in luaotfload (the original report
> is at https://github.com/latex3/luaotfload/issues/184) which relates to the
> ConTeXt fontloader. Take the following ConTeXt example:
> 
>      \starttext
>      \definefontfeature [default:bold] [default] [axis={weight=500}]
>      \definedfont[file:NotoSansCJKsc-VF.otf*default:bold @ 10pt]
>      
>      U+5E2E 帮
>      
>      \stoptext
> 
> The font is available at
> https://github.com/googlefonts/noto-cjk/raw/main/Sans/Variable/OTF/NotoSansCJKsc-VF.otf.
> 
> This compiles correctly, but the CJK glyph do not appear since
> it's Type2 CharString is invalid. The CFF2 CharStrings of this
> glyph invokes the rrcurveto operator with 63 arguments, which is

66 etc .. multiples of 6

> allowed in CFF2 where the argument limit is 513, but not allowed in
> Type2 where the limit is at 48.

a rather low limit right from the start (we can assume only rrcurveto is 
affected)

> It would be great if ConTeXt could check for this and insert additional
> rrcuveto operators when necessary to avoid this issue.
after some experiments ... attached

(no upload yet as i'm renaming some low level helpers which needs testing)

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------

[-- Attachment #2: largestack.pdf --]
[-- Type: application/pdf, Size: 8882 bytes --]

[-- Attachment #3: largestack.tex --]
[-- Type: text/plain, Size: 698 bytes --]

\definefontfeature
  [default:bold]
  [default]
  [axis={weight=500}]

\definefontfeature
  [default:heavy]
  [default]
  [axis={weight=800}]

\definefontfeature
  [default:light]
  [default]
  [axis={weight=250}]

\definefont
  [DemoFontBold]
  [file:NotoSansCJKsc-VF.otf*default:bold @ 10pt]

\definefont
  [DemoFontHeavy]
  [file:NotoSansCJKsc-VF.otf*default:heavy @ 10pt]

\definefont
  [DemoFontLight]
  [file:NotoSansCJKsc-VF.otf*default:light @ 10pt]

\startTEXpage
    \DemoFontBold  \char"5E2D\kern10pt\char"5E2E\kern10pt\char"5E2F\par
    \DemoFontHeavy \char"5E2D\kern10pt\char"5E2E\kern10pt\char"5E2F\par
    \DemoFontLight \char"5E2D\kern10pt\char"5E2E\kern10pt\char"5E2F
\stopTEXpage

[-- Attachment #4: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Variable OTF font resulting in invalid font due to stack overflow
  2021-05-13 14:23 ` Hans Hagen
@ 2021-05-16 16:53   ` Marcel Fabian Krüger
  0 siblings, 0 replies; 4+ messages in thread
From: Marcel Fabian Krüger @ 2021-05-16 16:53 UTC (permalink / raw)
  To: Hans Hagen; +Cc: mailing list for ConTeXt users

On Thu, May 13, 2021 at 04:23:21PM +0200, Hans Hagen wrote:
> On 5/12/2021 11:46 PM, Marcel Fabian Krüger wrote:
> > Hi,
> > 
> > recently we got an interesting bug report in luaotfload (the original report
> > is at https://github.com/latex3/luaotfload/issues/184) which relates to the
> > ConTeXt fontloader. Take the following ConTeXt example:
> > 
> >      \starttext
> >      \definefontfeature [default:bold] [default] [axis={weight=500}]
> >      \definedfont[file:NotoSansCJKsc-VF.otf*default:bold @ 10pt]
> >      U+5E2E 帮
> >      \stoptext
> > 
> > The font is available at
> > https://github.com/googlefonts/noto-cjk/raw/main/Sans/Variable/OTF/NotoSansCJKsc-VF.otf.
> > 
> > This compiles correctly, but the CJK glyph do not appear since
> > it's Type2 CharString is invalid. The CFF2 CharStrings of this
> > glyph invokes the rrcurveto operator with 63 arguments, which is
> 
> 66 etc .. multiples of 6

Counting is hard... (I assumed that all arguments are created through
blend operators)

> 
> > allowed in CFF2 where the argument limit is 513, but not allowed in
> > Type2 where the limit is at 48.
> 
> a rather low limit right from the start (we can assume only rrcurveto is
> affected)
> 
> > It would be great if ConTeXt could check for this and insert additional
> > rrcuveto operators when necessary to avoid this issue.
> after some experiments ... attached

Thanks you very much for looking into this so quickly.

> 
> (no upload yet as i'm renaming some low level helpers which needs testing)

I've noticed that both issues are fixed in the latest upload and testing
showed that it works, except for two small issues:

  1. The cache version of the streams cache didn't change, therefore the
     fix only gets picked up if the old cache is manually deleted.
     Could it be increased to automatically trigger a rebuilt?
  2. The change to f_convert in font-ocl.lua relies on `new` being set,
     which only happens when inkscapeformat is first called which happens
     later in the same function. Therefore it does not work for the
     first SVG font loaded, while others work fine.

Best regards,
Marcel

> 
> Hans
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-16 16:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-12 21:46 Variable OTF font resulting in invalid font due to stack overflow Marcel Fabian Krüger
2021-05-13  7:19 ` Hans Hagen
2021-05-13 14:23 ` Hans Hagen
2021-05-16 16:53   ` Marcel Fabian Krüger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).