------ If you just wanted to see some SVGFonts rendering, stop reading, this is not ready yet... ------
I have been working on SVG Fonts and I have recently created a coupe of files (src/display/nr-svgfonts.{cpp,h}) to deal with cairo userfont feature (rendering). It is still incomplete code, of course. I am sending a patch attached to this email. It has several issues:
* Still doesnt render at all :-P (but the cairo userfont callbacks seem to be called properly, so it is a matter of time&pacience to get it working) * The userfont callbacks are called only once for each glyph. It means cairo is caching my glyphs, which will be a problem when the user modifies them. * It deals with only one <font> declaration (should be extended to various svgfonts in a single document). * Currently I have been trying to test this code by calling cairo_set_font_face (ct, nr_svgfonts_get_user_font_face()); cairo_show_text (ct, "A!@A"); But I do not have a proper place to put this call. I have tried to call if from within nr-arena-render-glyphs.cpp, but it is probably wrong. * Our SVG fonts are not registered to the fontlister nor managed by pango yet. * We still depend on pango integration so that we can fed pango with our cairo_font_face_t* created by nr_svgfonts_get_user_font_face(). This would be integrated with the current pango code that exists in inkscape. * I also admit that I need to study a bit more about how inkscape handles units and how these are fed to cairo. Some units&coordinates in this patch are arbirary guesses.
Also, this patch depends on linking inkscape to cairo development branch (git master) which has support for userfonts. That's one of the reasons why this has not been commited to svn yet. I don't want to branch, but I will do it if there's no other option. I would rather prefer to have --enable-svgfonts option in ./configure Can anybody help me with that? I have never done this kind of thing.
cheers, Juca
On Fri, 2008-05-23 at 00:41 -0300, Felipe Sanches wrote:
Also, this patch depends on linking inkscape to cairo development branch (git master) which has support for userfonts. That's one of the reasons why this has not been commited to svn yet. I don't want to branch, but I will do it if there's no other option. I would rather prefer to have --enable-svgfonts option in ./configure Can anybody help me with that? I have never done this kind of thing.
Felipe,
It is probably better to have it do something that detects the Cairo version. If I remember right, Carl always keeps it a version ahead for such detection.
You can do something like this:
PKG_CHECK_MODULES(CAIRO, cairo >= 1.xx, cairohead=yes, cairohead=no)
That'll check the version and then you can set a variable that'll get passed to the codebase like:
if test "x$cairohead" = "xyes"; then AC_DEFINE(ENABLE_SVG_FONTS, 1, [SVG Fonts should be used]) fi
And that'll be put in config.h so that you can test for it in your code.
--Ted
--- CONTINUE READING if you want to see some SVGFonts rendering. I got it! ---
Since we don't have pango integration yet, I have used a little trick. I am working on the cairo-based implementation of SVGFonts rendering and I am viewing this rendering on a separate gtkWindow. Once we get pango integration (which could possibly be after the end of SoC, anyway) we can get rid of this auxiliary window. The window is created only when there is a svgfont in the document, so that will not be a problem for documents which don't use this feature. Remember, this is just a temporary way of getting things done without continuing blocked by the current statu of pango+cairo-userfonts integration.
The new patch is attached to this email. Try openning the share/svgfonts.svg test file to see the rendering. I am also attaching a screenshot of the rendering.
:-D Juca
The new patch is attached to this email. Try openning the share/svgfonts.svg test file to see the rendering. I am also attaching a screenshot of the rendering.
Cool.
Since we don't have pango integration yet, I have used a little trick. I am working on the cairo-based implementation of SVGFonts rendering and I am viewing this rendering on a separate gtkWindow. Once we get pango integration (which could possibly be after the end of SoC, anyway) we can get rid of this auxiliary window.
This sounds like it's going to start becoming a major inconvenience to you before long. I admit that I haven't had any more thoughts about a good way to deal with this issue before Pango is ready, have you?
Richard.
This sounds like it's going to start becoming a major inconvenience to you before long. I admit that I haven't had any more thoughts about a good way to deal with this issue before Pango is ready, have you?
This gtkWindow idea came to me yesterday after reading some code sent by Peter Clifton to the cairo-devel list and I consider it the best approach I could recently figure out. It is not that inconvenient. Indeed this is a lot useful since now I can see some rendering, and I can focus more on the task itself instead of boilerplate constraints.
If I work nice on the cairo world, I guess there wont be much problem when incorporating a future pango support for cairo-userfonts, do you agree?
This gtkWindow idea came to me yesterday after reading some code sent by Peter Clifton to the cairo-devel list and I consider it the best approach I could recently figure out. It is not that inconvenient. Indeed this is a lot useful since now I can see some rendering, and I can focus more on the task itself instead of boilerplate constraints.
If I work nice on the cairo world, I guess there wont be much problem when incorporating a future pango support for cairo-userfonts, do you agree?
My anxieties are twofold:
1) I think you're underestimating the amount of work which will be required to do the pango integration, since it will also involve all the stuff for text layout and mixing user fonts with normal fonts.
2) You can't use cairo functions for drawing to the Inkscape canvas, except in outline mode. It'll be a significant glitch in your (thus far excellent) progress when you need to start compositing with other content.
Richard.
My anxieties are twofold:
- I think you're underestimating the amount of work which will be
required to do the pango integration, since it will also involve all the stuff for text layout and mixing user fonts with normal fonts.
So, would it be wise to start thinking of doing work myself on the pango source code?
- You can't use cairo functions for drawing to the Inkscape canvas,
except in outline mode.
Well, that is news to me! What is the procedure for canvas drawing? Can you give me a general description of the procedures involved in canvas drawing, please?
- I think you're underestimating the amount of work which will be
required to do the pango integration, since it will also involve all the stuff for text layout and mixing user fonts with normal fonts.
So, would it be wise to start thinking of doing work myself on the pango source code?
Probably not, but I think you should start looking at how you're going to integrate it all sooner rather than later. Writing the new code is always the easiest bit, it's making it work with the old code that ends up being the most time-consuming.
- You can't use cairo functions for drawing to the Inkscape canvas,
except in outline mode.
Well, that is news to me! What is the procedure for canvas drawing? Can you give me a general description of the procedures involved in canvas drawing, please?
Bulia's explanation is better than mine would have been - I've never really looked at that area except in the most general terms.
Richard.
On Sat, May 24, 2008 at 9:35 PM, Felipe Sanches <felipe.sanches@...400...> wrote:
Well, that is news to me! What is the procedure for canvas drawing? Can you give me a general description of the procedures involved in canvas drawing, please?
I think you don't need to spend time on non-outline (non-using-cairo) mode, because it is going to be cairoified eventually, just like the outline mode. Right now all NRArenaItems render methods get a cairo context which you can use for drawing, and it will be visible in outline mode. After this works, enabling it for the regular mode after it's cairoified will be easy.
On Saturday, May 24, 2008, 4:23:37 PM, Richard wrote:
RH> 2) You can't use cairo functions for drawing to the Inkscape canvas, RH> except in outline mode. It'll be a significant glitch in your (thus RH> far excellent) progress when you need to start compositing with other RH> content.
I recall hearing at LGM3 that Inkscape used Cairo for outline mode only, but can't now remember why that was. Can someone remind me?
On Mon, May 26, 2008 at 9:53 AM, Chris Lilley <chris@...157...> wrote:
On Saturday, May 24, 2008, 4:23:37 PM, Richard wrote: I recall hearing at LGM3 that Inkscape used Cairo for outline mode only, but can't now remember why that was. Can someone remind me?
It's a combination of a bug we discovered in cairo (fixed recently) and just a plain lack of resources. Hopefully this will be done before the next release.
You can do something like this:
PKG_CHECK_MODULES(CAIRO, cairo >= 1.xx, cairohead=yes, cairohead=no)
That'll check the version and then you can set a variable that'll get passed to the codebase like:
if test "x$cairohead" = "xyes"; then AC_DEFINE(ENABLE_SVG_FONTS, 1, [SVG Fonts should be used]) fi
And that'll be put in config.h so that you can test for it in your code.
--Ted
I think that will trigger a whole recompiling of inkscape. Can I commit it?
On Fri, May 23, 2008 at 12:41 AM, Felipe Sanches <felipe.sanches@...400...> wrote:
- Currently I have been trying to test this code by calling
cairo_set_font_face (ct, nr_svgfonts_get_user_font_face()); cairo_show_text (ct, "A!@A"); But I do not have a proper place to put this call. I have tried to call if from within nr-arena-render-glyphs.cpp, but it is probably wrong.
nr arena items only use cairo in outline mode, and even then nr-arena-glyphs do not use this approach - they request FontInstance for the path of each glyph and pass it to cairo as a simple path. So, as I wrote you before, eventually you will need to change FontInstance (or replace it perhaps) for SVG fonts to seamlessly work. But for now, if you only need to test, you can insert this code with cairo_show_text for example to nr_arena_glyphs_render to the outline mode branch, instead of the feed_curve_to_cairo.
if you only need to test, you can insert this code with cairo_show_text for example to nr_arena_glyphs_render to the outline mode branch, instead of the feed_curve_to_cairo.
yeah, but since I need to draw a bpath to the canvas, somewhere I will need to use feed_curve_to_cairo, right?
On Sun, May 25, 2008 at 12:07 AM, Felipe Sanches <felipe.sanches@...400...> wrote:
yeah, but since I need to draw a bpath to the canvas, somewhere I will need to use feed_curve_to_cairo, right?
For a path, yes. But for testing with show_text, you can just put it there as well, using the same cairo context, and it should be displayed on the canvas so you can see if it works or not.
participants (5)
-
bulia byak
-
Chris Lilley
-
Felipe Sanches
-
Richard Hughes
-
Ted Gould