Git Product home page Git Product logo

pangocairocffi's Introduction

pangocairocffi

Latest PyPi Release Supported Python Versions Build Status Documentation Status Code Coverage

pangocairocffi is a CFFI-based set of Python bindings for the cairo rendering methods with pango. It is meant to be used in conjunction with cairocffi and pangocffi.

The bindings are currently not fully implemented. Feel free to make a pull request to contribute!

Installation and usage

See 'Overview' for information on how to install the necessary libraries.

See 'Python API Reference' for additional information on all the objects.

Contributing

If you would like to contribute to this project, either by leaving feedback or submitting a pull request, please read 'CONTRIBUTING.md'.

pangocairocffi's People

Contributors

andymortimeransys avatar leifgehrmann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pangocairocffi's Issues

`_generated/ffi.py` missing from binary install

Hi,

I just noticed this:

$ echo $VIRTUAL_ENV
/tmp/toto
$ pip install -U pangocairocffi
Processing /root/.cache/pip/wheels/5e/b4/90/3317813d0940443f4e9302caf89a8b7fe79eaf174823abadea/pangocairocffi-0.3.0-py3-none-any.whl
Requirement already satisfied, skipping upgrade: cairocffi>=1.0.2 in /tmp/toto/lib/python3.8/site-packages (from pangocairocffi) (1.1.0)
Requirement already satisfied, skipping upgrade: cffi>=1.1.0 in /tmp/toto/lib/python3.8/site-packages (from pangocairocffi) (1.14.3)
Requirement already satisfied, skipping upgrade: pangocffi>=0.4.0 in /tmp/toto/lib/python3.8/site-packages (from pangocairocffi) (0.6.0)
Requirement already satisfied, skipping upgrade: setuptools>=39.2.0 in /tmp/toto/lib/python3.8/site-packages (from cairocffi>=1.0.2->pangocairocffi) (50.3.0)
Requirement already satisfied, skipping upgrade: pycparser in /tmp/toto/lib/python3.8/site-packages (from cffi>=1.1.0->pangocairocffi) (2.20)
Installing collected packages: pangocairocffi
Successfully installed pangocairocffi-0.3.0

but then

$ ls -al /tmp/toto/lib/python3.8/site-packages/pangocairocffi/_generated/
drwxr-xr-x 3 root root 4096 Sep 23 10:13 .
drwxr-xr-x 4 root root 4096 Sep 23 10:13 ..
drwxr-xr-x 2 root root 4096 Sep 23 10:13 __pycache__
-rw-r--r-- 1 root root   47 Sep 23 10:13 ffi_pango.py

While if I do

$ pip install --no-binary :all: -U pangocairocffi
Collecting pangocairocffi
  Using cached pangocairocffi-0.3.0.tar.gz (20 kB)
Requirement already satisfied, skipping upgrade: cffi>=1.1.0 in /tmp/toto/lib/python3.8/site-packages (from pangocairocffi) (1.14.3)
Requirement already satisfied, skipping upgrade: cairocffi>=1.0.2 in /tmp/toto/lib/python3.8/site-packages (from pangocairocffi) (1.1.0)
Requirement already satisfied, skipping upgrade: pangocffi>=0.4.0 in /tmp/toto/lib/python3.8/site-packages (from pangocairocffi) (0.6.0)
Requirement already satisfied, skipping upgrade: pycparser in /tmp/toto/lib/python3.8/site-packages (from cffi>=1.1.0->pangocairocffi) (2.20)
Requirement already satisfied, skipping upgrade: setuptools>=39.2.0 in /tmp/toto/lib/python3.8/site-packages (from cairocffi>=1.0.2->pangocairocffi) (50.3.0)
Skipping wheel build for pangocairocffi, due to binaries being disabled for it.
Installing collected packages: pangocairocffi
    Running setup.py install for pangocairocffi ... done
Successfully installed pangocairocffi-0.3.0

$ ls -al /tmp/toto/lib/python3.8/site-packages/pangocairocffi/_generated/
drwxr-xr-x 3 root root  4096 Sep 23 10:16 .
drwxr-xr-x 4 root root  4096 Sep 23 10:16 ..
drwxr-xr-x 2 root root  4096 Sep 23 10:16 __pycache__
-rw-r--r-- 1 root root 29120 Sep 23 10:16 ffi.py
-rw-r--r-- 1 root root    47 Mar 23  2019 ffi_pango.py

So the file ffi.py is properly set up, while it does not seem to be part of the binary archive. Taking a deeper look, when wheel is installed and upon first installation, the generated whl file in the cache does not contain the ffi.py file neither. Any subsequent installation in a virtual environment will have the same issue.

Prevent Installtion Failure

from pangocffi.ffi_instance_builder import \
FFIInstanceBuilder as PangoFFIBuilder

I would suggest removing those lines because it causes installation error if the user doesn't have pango binary. Instead using importlib function would do I think because it should pick that without executing __init__.py of pangocffi. Or duplicating code also doesn't hurt.

Build Wheels

I would like to have wheels distributed in PyPi which may possibly avoid installation issues. Something like including the binaries of Pango can be done so that users no need to download it manually(Windows and Mac).

Something like https://github.com/getsentry/milksnake can be used for it and also auditwheels would surely help here.

SVG path not Unique for character > 25

I'm from Manim were we this project for rendering Text. Now, here there is a problem.
We have a method to create a SVG file using this project and later that SVG file is parsed in as Mobject(more like numpy array). It is made so that each letter would represent a submobject(again a numpy array) where the user can manipulate the submobject also. Now, the problem here is the SVG file created using this project and cairocffi, the number of SVG path != number of character for total lenth of character is greater than 25(>25). <25 works like a charm.
On carefully examining it, it look like the path string of the last two character are concadinated (which is unexpected) and it looks like a bug for me. I expected that the length of string = length of paths - number of space and line break but it wasn't so, for string length>25.

Reproducing Code

import cairocffi
import pangocffi
import pangocairocffi
surface = cairocffi.SVGSurface("bug.svg", 600, 400)
context = cairocffi.Context(surface)
context.move_to(10, 10)
layout = pangocairocffi.create_layout(context)
layout.set_width(pangocffi.units_from_double(600))
fontdesc = pangocffi.FontDescription()
fontdesc.set_size(pangocffi.units_from_double(10))
layout.set_font_description(fontdesc)
layout.set_text("#This is some custom confl")
pangocairocffi.show_layout(context, layout)
surface.finish()

After running this I get a SVG file, bug.zip, packed in a zip file attached at end,
Here, there is 26 character on the whole and it has 4 white spaces. But there are only 25 paths defined as below.

<g style="fill:rgb(0%,0%,0%);fill-opacity:1;">
  <use xlink:href="#glyph0-1" x="10" y="22"/>
  <use xlink:href="#glyph0-2" x="21" y="22"/>
  <use xlink:href="#glyph0-3" x="30" y="22"/>
  <use xlink:href="#glyph0-4" x="39" y="22"/>
  <use xlink:href="#glyph0-5" x="43" y="22"/>
  <use xlink:href="#glyph0-6" x="50" y="22"/>
  <use xlink:href="#glyph0-4" x="54" y="22"/>
  <use xlink:href="#glyph0-5" x="58" y="22"/>
  <use xlink:href="#glyph0-6" x="65" y="22"/>
  <use xlink:href="#glyph0-5" x="69" y="22"/>
  <use xlink:href="#glyph0-7" x="76" y="22"/>
  <use xlink:href="#glyph0-8" x="84" y="22"/>
  <use xlink:href="#glyph0-9" x="97" y="22"/>
  <use xlink:href="#glyph0-6" x="105" y="22"/>
  <use xlink:href="#glyph0-10" x="109" y="22"/>
  <use xlink:href="#glyph0-11" x="116" y="22"/>
  <use xlink:href="#glyph0-5" x="125" y="22"/>
  <use xlink:href="#glyph0-12" x="132" y="22"/>
  <use xlink:href="#glyph0-7" x="137" y="22"/>
  <use xlink:href="#glyph0-8" x="145" y="22"/>
  <use xlink:href="#glyph0-6" x="158" y="22"/>
  <use xlink:href="#glyph0-10" x="162" y="22"/>
  <use xlink:href="#glyph0-7" x="169" y="22"/>
  <use xlink:href="#glyph0-13" x="177" y="22"/>
  <use xlink:href="#glyph0-14" x="186" y="22"/>
</g>

Where it should 26 though. On further examining I found that

<symbol overflow="visible" id="glyph0-14">
<path style="stroke:none;" d="M 4.773438 -10.128906 L 7.355469 -10.128906 L 7.355469 -0.691406 L 8.496094 -0.691406 L 8.496094 0 L 5.011719 0 L 5.011719 -0.691406 L 6.160156 -0.691406 L 6.160156 -9.441406 L 4.757813 -9.441406 C 4.050781 -9.4375 3.550781 -9.296875 3.261719 -9.015625 C 2.96875 -8.730469 2.824219 -8.25 2.824219 -7.570313 L 2.824219 -6.921875 L 4.746094 -6.921875 L 4.746094 -6.222656 L 2.824219 -6.222656 L 2.824219 -0.691406 L 3.957031 -0.691406 L 3.957031 0 L 0.480469 0 L 0.480469 -0.691406 L 1.628906 -0.691406 L 1.628906 -6.222656 L 0.480469 -6.222656 L 0.480469 -6.921875 L 1.628906 -6.921875 L 1.628906 -7.546875 C 1.628906 -8.417969 1.886719 -9.066406 2.40625 -9.492188 C 2.921875 -9.914063 3.710938 -10.125 4.773438 -10.128906 Z M 4.773438 -10.128906 "/>
</symbol>

the above one represent two charaters fl. But it should actually be one character l alone. This is the main issue which simply broke many parts of Manim Code.

I had to make an here issue to make a reference in Pango Repo ;-) https://gitlab.gnome.org/GNOME/pango/-/issues/516
bug.zip

Pango Version:

>>> pangocffi.pango_version_string()
'1.46.1'

On my Windows 10, with Pango provided by msys2 project.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.