[cairo] OpenType font variations and cairo

Behdad Esfahbod behdad.esfahbod at gmail.com
Mon Sep 18 18:33:57 UTC 2017


Fixed the div-by-zero.  Thanks.

On Sat, Sep 16, 2017 at 10:12 PM, Adrian Johnson <ajohnson at redneon.com>
wrote:

> On 17/09/17 02:57, Matthias Clasen wrote:
> > On Fri, Sep 15, 2017 at 6:51 AM, Adrian Johnson <ajohnson at redneon.com
> > <mailto:ajohnson at redneon.com>> wrote:
> >
> >
> >
> >     We really need a test case for this. It is hard to review code I
> >     can't test.
> >
> >
> > I've added a minimal testcase here:
> >
> > https://github.com/matthiasclasen/cairo/tree/wip/
> matthiasc/font-variations
> >
> > It promptly found a freetype bug :-)
>
> I built the latest freetype, Behdad's fontconfig branch, and your branch.
>
> First problem I had was the variation test ignores the status. See
> attached patch.
>
> After fixing that and ensuring I had the correct font installed I got a
> crash in fontconfig.
>
>   fcfreetype.c line 1313 divide by zero
>
> 1312: double default_value = master->axis[i].def / (double) (1 << 16);
> 1313: double mult = value / default_value;
>
> The Adobe Variable Font Prototype font has a 'CNTR' axis with a default
> value of 0.
>
> Some more comments on your patch:
>
> In cairo-font-options.c you are adding a new function
> _intern_string_hash() which is almost identical to the
> _intern_string_hash() in cairo-misc.c Any reason why the cairo-misc.c
> version can't be used?
>
> I've attached a patch that refactors the float parsing code from
> cff-subset into a new function: _cairo_strtod(). So you can now use this
> for a C locale strtod.
>
> In cairo_ft_apply_variations(), strtod() returns a double so just make
> 'value' have type double instead of float.
>
> +/**
> + * cairo_font_options_get_variations:
> + * @options: a #cairo_font_options_t
> + *
> + * Gets the OpenType font variations for the font options object.
> + * See cairo_font_options_set_variations() for details about the
> + * string format.
> + *
> + * Return value: the font variations for the font options object. The
> + *   returned string belongs to the @options and must not be modified.
> + *   It is valid until the @options struct is modified.
>
> Should this be "It is valid until either the font options object is
> destroyed or the font variations in this object is modified with
> cairo_font_options_set_variations()"?
>



-- 
behdad
http://behdad.org/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cairographics.org/archives/cairo/attachments/20170918/25b8d05c/attachment.html>


More information about the cairo mailing list