Commit graph

11541 commits

Author SHA1 Message Date
Uli Schlachter
b7f313a8d2 fix warning: variable X might be clobbered by 'longjmp'
According to "man setjmp", one possible way to avoid variable clobbering
is to declare them as volatile. Thus, this commit turns the variables
that are changed between setjmp() and longjmp() and whose values are
still needed after setjmp() returned the second time into volatile
variables.

The warning in cairo-bentley-ottmann-rectangular.c is worked around by
not initializing the variable before setjmp(). To be honest, I don't
understand why the compiler warns here at all since the value of update
is clearly not used after setjmp()'s second return.

This commit re-fixes the warnings that were reintroduced in commit
82f40285 which reverted b092b63.

Signed-off-by: Uli Schlachter <psychon@znc.in>
Acked-by: Bryce Harrington <bryce@osg.samsung.com>
2018-01-13 11:30:50 +01:00
Uli Schlachter
62f2037bc0 Fix warning: '*' in boolean context
The full message is:

  warning: ‘*’ in boolean context, suggest ‘&&’ instead
      _cairo_malloc((unsigned) (a) * (unsigned) (size)))
                                   ^
  note: in definition of macro ‘_cairo_malloc’
      ((size) ? malloc((unsigned) (size)) : NULL)
        ^~~~

Signed-off-by: Uli Schlachter <psychon@znc.in>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2018-01-13 11:30:26 +01:00
Behdad Esfahbod
c3659d7ef6 Use FT_Done_MM_Var() if available 2018-01-08 10:07:25 +00:00
Matthias Clasen
37f9a5525d Don't leak memory in font options
The cairo_font_options_t struct may now contain allocated
memory, so call fini whenever we are about to let go of an
embedded cairo_font_options_t struct.
2018-01-05 09:10:32 -05:00
Matthias Clasen
1f0b6707ea Add a _cairo_font_options_fini function
The variations member of cairo_font_options_t is allocated,
so we need to have a method to free it for cases where
the struct is embedded in larger structs, such as cairo_ft_options_t.
2018-01-05 09:09:01 -05:00
Matthias Clasen
17871c52ef Don't leak patterns when compositing color glyphs
We were forgetting to free the pattern here.
2018-01-04 23:25:09 -05:00
Matthias Clasen
616fb7a9f2 Fix a memory leak
cairo_ft_apply_variations was leaking the FT_MM_Var struct.
2018-01-04 20:56:59 -05:00
Behdad Esfahbod
a7a0085713 Merge branch 'font-variations' 2018-01-03 12:35:12 +00:00
Behdad Esfahbod
a18c0decda [ft] Remember variations set on FT_Face and apply them
For this to work correctly with hb-view, needs a patch that went
into FreeType today.
2018-01-02 19:25:18 -05:00
Uli Schlachter
6b0593827b Add test for error handling with broken PNG streams
Would-have-caught: https://bugs.freedesktop.org/show_bug.cgi?id=104325
Signed-off-by: Uli Schlachter <psychon@znc.in>
2017-12-24 13:23:13 +01:00
Uli Schlachter
82f4028532 Revert "fix warning: variable X might be clobbered by 'longjmp'"
This reverts commit b092b63119 which
introduced a wrapper function around setjmp(). To quote from man setjmp:

  If the function which called setjmp() returns before longjmp() is
  called, the behavior is undefined.  Some kind of subtle or unsubtle
  chaos is sure to result.

Since after the above commit setjmp() is called from the wrapper
function, the result might or might not work, depending on compiler
settings. If the setjmp() wrapper is not inlined, then the state of the
stack after longjmp() will likely be garbage.
2017-12-23 13:04:59 +01:00
Bryce Harrington
3e07efd21e makefile: Fix sorting of source files 2017-12-20 17:09:05 -08:00
Behdad Esfahbod
e8ddc505b3 [ft] Fix warnings 2017-12-19 18:04:04 -05:00
Matthias Clasen
c32a5c741f Shortcut FT_Set_Var_Design_Coordinates
We currently (have to) apply font variations for every glyph.
Calling FT_Set_Var_Design_Coordinates has expensive side-effects,
like resetting the autohinter, so we should avoid doing it
fht he coordinates don't actually change.
2017-12-19 17:36:36 -05:00
Behdad Esfahbod
d8ddadc5c3 [ft] When merging font options, order variations correctly
Later wins, and we want "options" to win over "other".
2017-12-19 15:29:13 -05:00
Behdad Esfahbod
82107467f0 [ft] Use variations from ft_options, not scaled-font
Otherwise the variations from FcPattern won't be applied.
2017-12-19 15:18:57 -05:00
Matthias Clasen
976b34c31c fixup
We were passing a face index to cairo_ft_apply_variations,
but that function was expecting an instance id, which is
the face index shifted by 16.
2017-12-19 15:18:57 -05:00
Matthias Clasen
5c7f07d4ea fixup: remove a hack
This bug that this hack is working around has been
fixed in freetype now.
2017-12-19 15:18:57 -05:00
Matthias Clasen
1b5677ad6d Apply font variations when loading glyphs
So far, we only call cairo_ft_apply_variations() in
cairo_ft_scaled_font_lock_face(), but this function is not
used internally. We need to apply it also when loading
glyphs.

This makes pango-view show font variations correctly.
2017-12-19 15:18:57 -05:00
Matthias Clasen
f2b6fac43f Trivial: code movement
Move cairo_ft_apply_font_variations() earlier in the code
since we will be using it in another place soon.
2017-12-19 15:18:57 -05:00
Matthias Clasen
42f07ef903 Always save the origin face index
Save the original face_index also for the from_face case,
so we can always rely on it when applying font variations.
This prevents us from running into the same trap we've seen
before where ft_face->face_index changes underneath us as
font variations are applied.
2017-12-19 15:18:57 -05:00
Matthias Clasen
1735fc41d3 Apply font variation options consistently
We must not look at the instance_id field of the cached ft_face,
since freetype changes it underneath us (if we set the axis values
to match a named instance, the instance_id gets changed to reflect
that). Thankfully, we have the original instance_id stashed away
in the cairo_unscaled_font, so we can just use that to decide if
we are dealing with a named instance or not.

This makes the font variations tests pass.
2017-12-19 15:18:57 -05:00
Matthias Clasen
46034b0547 Make the font-variations test pass
Not sure what I was thinking - the test is checking the width
axis, but the font we're using has only weight and contrast
as axes...
2017-12-19 15:18:57 -05:00
Behdad Esfahbod
db946d1788 [varfonts] Correctly (re)set variations of named instances 2017-12-19 15:18:57 -05:00
Behdad Esfahbod
7125c4bf5e [varfonts] Use blend, not design, coordinates to check for non-base variation
If all blend coordinates are zero, we are at base font.  This is more robust.
2017-12-19 15:18:57 -05:00
Behdad Esfahbod
374ee5a2fd [variations] Merge variations in cairo-ft font option merging
This function should be rewritten to call cairo_font_options_merge(), but
currently it doesn't.

Speculative. Untested.
2017-12-19 15:17:01 -05:00
Behdad Esfahbod
34047d11db [variations] Fix test
This does not exercise merging of variations from font-options and from
pattern.  Before this commit the code was more towards doing that.
2017-12-19 15:17:01 -05:00
Behdad Esfahbod
6accf16093 [variations] Towards fixing test 2017-12-19 15:17:01 -05:00
Matthias Clasen
7cc07f184b Work around a freetype bug
The first call to FT_Get_MM_Var on a newly created FT_Face
fails. So just repeat the call.
2017-12-19 15:17:01 -05:00
Matthias Clasen
38b6e23609 Add a test for font variations
This test checks that passing font variation settings via
font options has the desired effect. It checks this by reading
the effective axis values out of the FT_Face after creating
a font with these options.
2017-12-19 15:17:01 -05:00
Matthias Clasen
721b7ea0a7 Apply font variations when loading fonts
Parse font variation settings and pass them on to
freetype when loading fonts.
2017-12-19 15:17:01 -05:00
Matthias Clasen
a8ae2eafc8 Use strtod_l when available
Using strtod_l and newlocale is a nicer way to have provide
a C-locale-only strtod. Since these APIs are not available
everywhere, keep the old code as a fallback.
2017-12-19 15:17:01 -05:00
Matthias Clasen
ac5acc4538 Load font variations from fontconfig too
When extracting font options from a fontconfig pattern,
also extract font variation information if present.
2017-12-19 15:16:20 -05:00
Matthias Clasen
edf9497c3a Add font variations to font options
Add a font option for OpenType font variations, specified
as a string in a format similar to the proposed css
font-variation-settings property.
2017-12-19 15:16:19 -05:00
Matthias Clasen
4ece386149 Make _intern_string_hash non-static
We will use this function in cairo-font-options.c in the following
commits.
2017-12-19 15:16:19 -05:00
Matthias Clasen
d50dbbaf27 Make _intern_string_hash safe for ""
The loop was unnecessarily written in a way that fails
to terminate if len is 0 (ie for the empty string).
Avoid that by checking for len > 0 explicitly.
2017-12-19 15:16:19 -05:00
Matthias Clasen
903b0de539 Fix a logic error in color glyph compositing
When a color glyph is completely clipped away, we
get the non-zero status 'nothing to do'. In that case,
we must not exit early, since there might still be work
to do for the other color glyphs.

This bug was showing up as color glyphs stopping to render
in GTK+ entries that are scrolled to the right, and also
as color glyphs not rendering inside the selection sometimes.

See https://bugzilla.gnome.org/show_bug.cgi?id=790255 and
https://bugzilla.gnome.org/show_bug.cgi?id=788071.
2017-12-17 21:36:17 -05:00
Bryce Harrington
06964531e0 svg: Label for cairo_svg_unit_t doxygen was incorrect 2017-12-14 09:58:57 -08:00
Bryce Harrington
742199768d Bump version for new development tree, 1.15.9 2017-12-11 14:44:07 -08:00
Bryce Harrington
5e6b9aeb5e 1.15.10 release
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
2017-12-11 14:44:07 -08:00
Antonio Ospite
19ee921187 svg: fix compilation with MSVC which doesn't support C99 initializers
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Tested-by: John Emmas <john@creativepost.co.uk>
2017-12-10 20:13:19 -08:00
Adrian Johnson
f9cf6f9200 ps: fix compile warning
https://lists.cairographics.org/archives/cairo/2017-December/028481.html
2017-12-08 18:13:20 +10:30
Bryce Harrington
f723ce3192 pattern: Mark a private routine as cairo_private.
Fixes distcheck PLT error:

  Checking .libs/libcairo.so for local PLT entries
  000000000031f1d0  0000024200000007 R_X86_64_JUMP_SLOT
  0000000000055de0 _cairo_pattern_is_constant_alpha + 0
2017-12-07 15:53:16 -08:00
Bryce Harrington
c9a78ec9c2 Fix distcheck errors on use of #ifdef
Checking that feature conditionals are used with #if only (not #ifdef)
./cairo-ft.h:#ifdef CAIRO_HAS_FC_FONT
./cairo-ft.h:#ifdef CAIRO_HAS_FC_FONT
2017-12-07 14:15:17 -08:00
Bryce Harrington
04b4967586 Fix various doxygen warnings found by check-doc-syntax.sh
./cairo-clip-boxes.c (268): ERROR: copy invalid doc id (should be 'cairo_...:')
./cairo-clip-boxes.c (274): ERROR: copy bad line: ' */'
./cairo-clip-boxes.c (274): ERROR: copy documentation comment not closed with **/
./cairo-boxes.c (106): ERROR: Computes invalid doc id (should be 'cairo_...:')
./cairo-boxes.c (114): ERROR: Computes bad line: ' */'
./cairo-boxes.c (114): ERROR: Computes documentation comment not closed with **/
./cairo-boxes.c (279): ERROR: Computes invalid doc id (should be 'cairo_...:')
./cairo-boxes.c (284): ERROR: Computes bad line: ' */'
./cairo-boxes.c (284): ERROR: Computes documentation comment not closed with **/
./cairo-boxes.c (338): ERROR: Linearize invalid doc id (should be 'cairo_...:')
./cairo-boxes.c (345): ERROR: Linearize documentation comment not closed with **/
./cairo.c (240): ERROR: SECTION:cairo-tag bad line: ''
./cairo.c (892): ERROR: cairo_set_source_rgb: Duplicate 'Since' field
2017-12-07 14:13:32 -08:00
Bryce Harrington
dbc1636a9b win32: Fix since field version number
check-doc-syntax.sh expects since numbers to be MAJOR.MINOR without a
patch level number
2017-12-07 14:13:32 -08:00
Bryce Harrington
bb0d616c4e image: Fix include for use of ptrdiff
Commit 38fbe621 added use of the ptrdiff_t type in a header file,
however `make distcheck` complains:

In file included from headers-standalone-tmp.c:1:0:
../../../src/cairo-image-surface-private.h:74:5: error: unknown type name ‘ptrdiff_t’
     ptrdiff_t stride;
     ^
2017-12-07 14:13:28 -08:00
Antonio Ospite
15559b54af svg: add a new function to specify the SVG document unit
Add a cairo_svg_surface_set_document_unit() function to allow users to
set a unit for the width and height values of the root <svg> element.

In particular this allows to draw in pixels and still have the expected
result when generating SVG output.

Add also the correspondent getter function.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=90166
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2017-12-04 13:58:34 -08:00
Tom Schoonjans
84fc0ce91d Use UTF-8 filenames on Windows
Until now fopen was used on Windows to open files for reading and
writing. This assumed however that the filename would be encoded in the
current codepage, which is a major inconvenience and makes it even
impossible to use filenames that use characters from more than one
codepage. This patch enforces the use of UTF-8 filenames on all
platforms.

Based on the work of Owen Taylor (https://lists.cairographics.org/archives/cairo/2007-February/009591.html)
2017-11-26 20:16:43 +10:30
Mikhail Fludkov
e5532f5ad7 Fix code generation when using GCC legacy atomic operations
https://bugs.freedesktop.org/show_bug.cgi?id=103559
2017-11-26 13:09:51 +10:30