Commit Graph

41 Commits

Author SHA1 Message Date
Christoph Reiter 7473215210 Add new cairo 1.16 API
Plus some mime type constants from 1.14 which I forgot.

All the API is only exposed when building with cairo 1.15.10+ (Ubuntu 18.04)
except the font variation stuff which is 1.15.12+ (Ubuntu 18.10)
2018-11-02 15:03:04 +01:00
Chun-wei Fan 1da7ee8b60 cairo/private.h: Add macro for controlling deprecation warnings
Define macros that are used to disable temporarily and re-enable
deprecation warnings, for both GCC and Visual Studio
2018-09-27 13:21:23 +08:00
Christoph Reiter 4ad2228488 tuple subclasses: use tp_getset instead of tp_getattro for member access
With tp_getset things will show up in the class __dict__ which helps
with auto completion and also allows us to compare things with
the annotation stubs.
2018-02-25 16:03:45 +01:00
Christoph Reiter 5c2cfef838 Remove use of PyState_FindModule. See #90
Instead of using the module state API just import the module
end fetch the error type. This lets us get rid of the PyState API
which isn't available under PyPy3 and also reduces the difference
between Python 2 and 3.
2018-01-30 15:16:20 +01:00
Christoph Reiter 6e14bbf621 setup.py: get rid of config.h
Just pass the macros at compile time.
2018-01-21 22:05:11 +01:00
Christoph Reiter fac2acf1ed enums: ensure that enum values passed in match the ones passed back out
When taking enum values from Python we cast the signed values to the
enum type, which in case the enum type is unsigned leads to a defined
overflow.

When going the opposite way and creating Python enum values from
C enum values we have to do the reverse. Since casts from unsigned int
to signed int are undefined for > INT_MAX we need to do the type
conversion manually.
2017-11-07 23:01:57 +01:00
Christoph Reiter 9bc5fb7ba1 Try using more warning flags when testing and fail for warnings under msvc
We can't check if the compiler supports the flags, so enable
them only when PYCAIRO_WARN is defined in the environment.
2017-09-16 17:06:40 +02:00
Christoph Reiter 9b2d4d2a3a fspaths: improve error messages for methods taking filenames or file objects
First decide on the input type and only parse once instead of parsing
multiple times and throwing away the filename parsing errors.
2017-08-18 22:33:31 +02:00
Christoph Reiter e4fc9db660 Add support for all fspaths 2017-08-18 16:27:37 +02:00
Christoph Reiter 14d1f71b17 More hypothesis tests; fix an overflow in cairo.Glyph.__new__ 2017-07-26 15:18:23 +02:00
Christoph Reiter 806cfcb1cf Make tuple subclasses take keyword args 2017-07-24 09:57:44 +02:00
Christoph Reiter 87dbb471d7 Add cairo.TextExtents() and ScaledFont.glyph_extents(). Fixes #62 2017-07-24 08:19:48 +02:00
Christoph Reiter 0d6fbbc42b Add Context.show_text_glyphs() 2017-07-23 12:50:47 +02:00
Christoph Reiter 6981691097 Add cairo.TextCluster. Fixes #61 2017-07-22 22:24:07 +02:00
Christoph Reiter 23933c3658 Add cairo.Rectangle. Fixes #54 2017-07-22 21:42:44 +02:00
Christoph Reiter c05af22381 Add cairo.Glyph. Fixes #53
It's a tuple subclass, so can be used everywhere where it was used before.

In the documentation remove all the optional glyph array lengths, as they
are not strictly needed (one cas just pass slices) and just complicate things.
2017-07-22 16:13:30 +02:00
Christoph Reiter 42eb8a30f5 Add RasterSourcePattern. Fixes #48
This only adds the type, constructor and the get/set_acquire() methods.

Since for some reason the callbacks don't get passed the pattern, this
uses the callback data to access the Python functions in the callbacks.
The whole thing doesn't look heavily tested in cairo, so I'm waiting
for a response in https://bugs.freedesktop.org/show_bug.cgi?id=101866
before looking into wrapping more functions there.
2017-07-21 15:58:34 +02:00
Christoph Reiter 2afdb760a7 Raise a subclass of MemoryError and cairo.Error instead of MemoryError. See #55
The plan is to do the same for IOError, but that needs some more work first.

The subclass currently is only exposed in the docs to make it clear that
previously MemoryError was raised.
2017-07-14 20:55:57 +02:00
Christoph Reiter b780969870 Implement richcompare for Surface and Path. See #52
So that two instances wrapping the same object compare equally.
2017-07-14 09:21:29 +02:00
Christoph Reiter 96a2a26f10 Add Surface.map_to_image() and Surface.unmap_image(). Fixes #51
This keeps the same API as cairo but adds some additional checks
to prevent crashes. Those cases still are undefined but at least
you get some error messages.

* It adds a new ImageSurface subtype so we can do some type checking.
* It swaps the underlying image surface to a dummy finished one
  when it gets unmapped so that operations after unmap
  on the wrapper don't crash.
* It checks if the source surface is correct when unmapping.
2017-07-13 16:38:19 +02:00
Christoph Reiter 3ebeb2c951 Add cairo.MeshPattern. Fixes #18 2017-07-11 23:37:16 +02:00
Christoph Reiter 4b8aba8a97 Add TeeSurface 2017-07-11 20:20:15 +02:00
Christoph Reiter 92ed20967c Add cairo.SurfaceObserverMode enum 2017-07-10 17:12:00 +02:00
Christoph Reiter 76dbc3044f Add cairo.TextClusterFlags 2017-07-10 17:05:13 +02:00
Christoph Reiter c8713e8132 Add cairo.ScriptSurface. Fixes #17 2017-07-10 10:10:56 +02:00
Christoph Reiter 0a73a8a24d Add cairo.ScriptDevice() 2017-07-09 22:01:00 +02:00
Christoph Reiter 0240732fce Add cairo.Device() class and Surface.get_device()
This only adds new Python API an no C API for now.
2017-07-07 09:45:09 +02:00
Christoph Reiter 4ab80df68d bufferproxy: properly pass flags to PyBuffer_FillInfo; also expose the readonly flag 2017-05-31 21:44:44 +02:00
Christoph Reiter 07ee64b3fb Fix leak when using ImageSurface.get_data() with Python 3. Fixes #41
Turns out the buffer/memoryview API can only be used in implementations
of the buffer protocol of some object and the current approach
worked by accident and for some unknown reason leaked the exporter as
well.

This creates a new Python class implementing the buffer interface,
which takes the buffer information and is only used to keep the
image surface alive and to hand out memory views.

In case the last view dies, the proxy will die and unref the image
surface.
2017-05-31 21:35:42 +02:00
Nicolas P. Rougier 949beb4149 Fixed duplicate symbols on macos Sierra 2017-05-05 18:11:45 +02:00
Christoph Reiter 66534d99ea Change all functions returning enum values to return instances of the new enum types
This includes cairo.Error.status, which is now a cairo.Status
2017-05-02 13:32:45 +02:00
Christoph Reiter acc4578f5f Add enum types. Fixes #26
This adds a new Python type for each C level enum type.
The enum type is an int sublcass with its own repr implementation
to get something nice like cairo.Antialias.DEFAULT.

The module level constants are now aliases for the type attributes,
e.g. cairo.ANTIALIAS_DEFAULT == cairo.Antialias.DEFAULT.

This only adds the types and does not make function return them
(except in one case to see how it works). More work will follow
in the following commits.
2017-05-02 12:35:03 +02:00
Christoph Reiter eeea4de31f cairo.Error: add a status attribute; add CairoError alias
This extends the cairo.Error exception type to have a status attribute
containing the cairo_status_t constants. This is what cairocffi
implements and will also make testing for specific error cases easier.

Also adds an cairo.CairoError alias to be compatible with the default
cairocffi naming.

Switch some functions which raise cairo.Error on programming errors
to ValueError, so we have a valid status value in all cases.
2017-04-16 10:47:34 +02:00
Christoph Reiter 6b956ad986 Re-add support for RecordingSurface
This time without breaking ABI
2017-04-12 15:32:53 +02:00
Christoph Reiter 55259f63c5 Revert "Add support for RecordingSurface, using patch (modified) from bug #36854. Add docs and tests for RecordingSurface. Adding the RecordingSurface to the pycairo API breaks ABI compatibility with previous pycairo versions."
This reverts commit c4df9b51c8.

I didn't notice that pyc2cairo master also broke ABI :(
2017-04-12 15:14:10 +02:00
Christoph Reiter 52c270b0a1 Revert "Remove xpyb support."
This reverts commit e00cd9d634.

Fedora builds pycairo with xpyb and has some packages depending on it.
So we have to keep it and figure out how to build it.
2017-04-09 16:13:01 +02:00
Christoph Reiter e00cd9d634 Remove xpyb support.
It's Python 2 only and was never enabled for py2/3 on debian/ubuntu
so this should not change much.

Handle instantiating of XCBSurface like is currently done for
XlibSurface. Getting an instance through the C-API still works.

If support gets added back we should look into xcffib, which is
what cairocffi uses. It also has the advandage that we don't
have to link against it and can use it at runtime.
2017-04-09 11:09:47 +02:00
Christoph Reiter 062f75a75c python3: Expose cairo.Error and fix raising it
Instead of using the global error object look up the module+state
and fetch the error object from there.
2017-04-08 20:40:54 +02:00
Christoph Reiter a05e95a3fc Add support for cairo_region_t and cairo_rectangle_int_t
This is based on a patch at (by mozbugbox@yahoo.com.au)
    https://bugs.freedesktop.org/show_bug.cgi?id=44336#c2
2017-04-08 12:20:19 +02:00
Christoph Reiter 727470e8a1 Port to Python 3 2017-04-07 11:15:35 +02:00
Christoph Reiter 7630f6d7d0 Rename src->cairo, doc->docs, test->tests 2017-04-07 09:45:40 +02:00