-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
celiagg Kiva backend #247
celiagg Kiva backend #247
Conversation
Current coverage is 52.05% (diff: 100%)@@ master #247 diff @@
==========================================
Files 126 126
Lines 13176 13176
Methods 0 0
Messages 0 0
Branches 1943 1943
==========================================
Hits 6859 6859
Misses 5872 5872
Partials 445 445
|
'text_transform', 'font']) | ||
|
||
|
||
class GraphicsContext(object): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might make sense to inherit from AbstractGraphicsContext
or basecore2d.GraphicsContextBase
. Although at this point it may be more hassle than its worth.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see that you've registered it with the ABC below. Ignore the above, then.
Yay! Will try this out at some point soon. |
raise NotImplementedError(msg) | ||
|
||
def set_text_drawing_mode(self): | ||
""" XXX: What is this for?? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how to draw text: filled, outline, etc. See constants.py
for the options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh... You can probably see that I based this on the QPainter backend. Also, based on what I've read in the AGG backend, this isn't possible to implement there (fonts are raster only).
Do you know of a backend which implements this correctly? Quartz?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, Quartz, although it is cheating somewhat because it just maps to the appropriate Quartz constant and passes it through to Quartz's corresponding method.
The raster-only stuff is likely why the current agg backend has a vendorized freetype2. Eg. see https://github.com/enthought/enable/blob/master/kiva/agg/src/kiva_graphics_context_base.cpp#L579, https://github.com/enthought/enable/blob/master/kiva/agg/src/kiva_graphics_context_base.cpp#L644 and https://github.com/enthought/enable/blob/master/kiva/agg/src/kiva_graphics_context.h#L1286
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are ctypes-based FreeType wrappers for Python (eg. https://pypi.python.org/pypi/freetype-py/) but I don't think they will help. I didn't see a Cython-based wrapper, which would be nicer for this use case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pyagg already has support for vector and raster font representations. In fact, I've got it hard-coded to use vectors in the current backend code (see agg.FontCacheType.VectorFontCache
in the set_font
method). That should basically cover it, right (minus the complication of switching between representations in the Font
instances)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, if pyagg has vector font support that should cover it if you can specify the render method (fill, stroke, etc.) for the vector path of the text.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented!
4f7bd69
to
7172029
Compare
I removed some previously committed changes to the examples... Force pushed. Mind the gap. This is almost usable now. 😄 |
The pyagg backend is now functionally complete!
This is now functionally complete. Bugs included at no extra cost to you! |
Also, fixed the implementation of CompiledPath.add_path
758c9be
to
393a6b2
Compare
I've fixed all the bugs I could find. This actually works pretty well with all of the Chaco demos now! |
Still faking it, but just about making it!
This was introduced by recent pyagg API changes
To answer the question about how to proceed. There are two ways we could do this:
I'm not sure which is best. I'd be happy to see the back of the current Agg wrappers, but they work for the most part, so it may make sense to have a more gradual transition |
The font color issue is an interesting one. If you try kiva_explorer.py with the Quartz backend, you will see that it matches celiagg. Basically, some backends use stroke color for text, others use fill color. I kinda punted and followed Quartz, but honestly it's not hard to change. |
Hmmm... The Making sure we are consistent in the change throughout the dependent codebases will be a little finicky. |
Thought a bit more about the way forward. I'm happy for this to be merged as-is so that we can work on further improvements based on this. We can revisit what to do with the current agg backend as things go forward. |
I'd like to explore the image drawing issue a little bit first, but I suspect that it lies completely within celiagg. We shall see. After that, yes, I think this should just be merged since it's not disruptive on its own. Then we can begin to discuss the more disruptive changes. |
Okie dokie. I'm pulling the trigger. Thanks for the feedback Corran! |
This requires https://github.com/celiagg/celiagg (or
pip install celiagg
!) to be built and installed.This works fairly well now. We should discuss how to proceed.