[cairo] OpenType font variations and cairo

Adrian Johnson ajohnson at redneon.com
Sun Sep 17 05:12:39 UTC 2017


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()"?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: font-variation.diff
Type: text/x-patch
Size: 1171 bytes
Desc: not available
URL: <https://lists.cairographics.org/archives/cairo/attachments/20170917/3a0d1932/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-factor-out-ascii-to-double-code-in-cff-subset-into-_.patch
Type: text/x-patch
Size: 5226 bytes
Desc: not available
URL: <https://lists.cairographics.org/archives/cairo/attachments/20170917/3a0d1932/attachment-0001.bin>


More information about the cairo mailing list