Commit graph

7423 commits

Author SHA1 Message Date
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
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
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
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
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
Adrian Johnson
f614f588e6 Prevent -Wundef warnings in when cairo-ft.h is used without fontconfig 2017-11-26 13:03:44 +10:30
Adrian Johnson
a709197121 pdf: fix some annotation bugs
- each annotation was emitted on every page instead of just the page
  that contains the annotation

- the document structure did not correctly link to annotation objects

- fix some annotation related memory leaks
2017-11-26 13:03:18 +10:30
Adrian Johnson
17e2abc992 ps: fix compile with old versions of MSVC
https://lists.cairographics.org/archives/cairo/2017-November/028452.html
2017-11-20 05:37:34 +10:30
Adrian Johnson
0c8070f5bc pdf: fix document structure for non tagged structures 2017-11-16 20:16:14 +10:30
Adrian Johnson
5c7a6ca141 ps: fix extend-*-similar failures 2017-11-10 20:10:01 +10:30
Adrian Johnson
9bfa9df2bb ps: fix padded image crash 2017-11-09 22:02:05 +10:30
Adrian Johnson
f7d6d78f94 ps: prevent self-copy infinite loop 2017-11-09 22:02:05 +10:30
Adrian Johnson
5ffbaf9e2f ps: add CAIRO_MIME_TYPE_EPS mime type for embedding EPS files 2017-11-09 22:02:05 +10:30
Adrian Johnson
7d3ba77b6c ps: use Reusable streams for forms in Level 3
to avoid emitting image data as strings
2017-11-09 22:01:40 +10:30
Adrian Johnson
b1c7a087b5 ps: use forms for surfaces with UNIQUE_ID mime type
to ensure the surfaces are emitted only once.

fixes mime-unique-id PS output
2017-11-09 22:01:40 +10:30
Adrian Johnson
638d64a702 ps: don't acquire image or snapshot in acquire_source_image_from_pattern
otherwise emit_surface may not see the mime data
2017-11-09 22:01:40 +10:30
Adrian Johnson
fcc037a76e ps: use << >> for dictionaries instead of dict begin end 2017-11-09 22:01:40 +10:30
Adrian Johnson
632232c3ce ps: remove unused prolog 2017-11-09 22:01:40 +10:30
Adrian Johnson
9d372ca91a ps: emit base85 strings instead of strings of base85
When image data is emitted as strings (required when an image is used
in a PaintProc), the base85 encoded data was emitted inside PS strings
(...) and the image filters included an ASCI85Decode filter.

This has been changed to emit the strings as ASCII85 strings <~...~>
and remove the ASCII85Decode filter since the base85 is decoded when
the string is parsed.

Also factor out the string data source procedure into the prolog.
2017-11-09 22:01:40 +10:30
Adrian Johnson
d5cb45013b pdf: fix mime-unique-id jpeg attached to recording test
- Restructure the emit_surface code so that mime types are checked first.

- Add a test parameter to emit_surface to test if the surface will be emitted
  as an image or recording instead checking the surface type as the attached
  mime may override this.

- Mark surface as not clear when mime is attached to avoid optimizing away
  "clear" surfaces that have mime attached.

- Include entire surface in analysis if mime attached (also fixes bug with
  calculating the extents CONTENT_COLOR surfaces)
2017-11-09 22:01:40 +10:30
Adrian Johnson
bff47b43c4 pdf: fix mime-unique-id unbounded recording test
PDF XObjects need to specify the bounding box. Emit unbounded surfaces
when finishing as at this point the extents of all uses of the
unbounded surface are known.
2017-11-09 20:52:36 +10:30
Adrian Johnson
cf9a070352 pdf: fix mime-unique-id bounded recording test
The embedded bounded recording surface was being clipped to the
extents of its first use.
2017-11-09 20:52:36 +10:30
Adrian Johnson
38fbe621cf image: prevent invalid ptr access for > 4GB images
Image data is often accessed using:

  image->data + y * image->stride

On 64-bit achitectures if the image data is > 4GB, this computation
will overflow since both y and stride are 32-bit types.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=98165
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2017-11-07 17:01:49 -08:00
Bryce Harrington
35fccff6ec Un-doxygen disabled cairo_set_opacity
The cairo_set_opacity() routine has been disabled since 2010.  There
appears to be support for it internally in the backend, so it is unclear
why it is not enabled or what might break if it were re-enabled.  Given
the lack of bug reports about its omission, it may be vestigal.  For
now, just hide the doxygen for it to suppress warnings.  It may be worth
deeper review to either re-enable it or remove it entirely.

Reported-by: Rafał Mużyło (See fdo bugzilla #82741)
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
2017-11-06 12:18:37 -08:00
Adrian Johnson
3322580f04 pdf: remove old comment
These issues have been fixed.
2017-10-24 21:44:08 +10:30