>
> FreeType stores the size of its module structures as their second field
> explicitly for this very reason. This way you won’t need any special hooks.
>

Alexei, I know about that field and I am using it too. But I don't know how
it really helps with getting the memory for the rendering port state
structure, which is really of different size and type for each SVG
rendering library. Also, my hook functions at the moment, don't have any
access to the rendering module. It's only true the other way around. The
SVG rendering module knows about the hooks and stores them in a field named
`hooks'. The `module_size' field that you're talking about is used while
initializing the modules and in my design, at the time of module
initialization the module has no hooks. The hooks get injected quite later
after `FT_Init_FreeType' has been called.

I am not sure if you've looked at my SVG rendering module. You can find it
in `src/svg'. For your convenience however, I'll briefly describe the
design.

`SVG_RendererRec' is a module that inherits from `FT_RendererRec'. This was
done so that I can add a new field for storing the `hooks'. These hooks are
really empty until `FT_Set_Svg_Hooks' is called to set these hooks, that's
far after the module has been initialized. `module_init' doesn't do
anything interesting. The only interesting function is `render_glyph'. When
called for the first time, it calls the `svg_lib_init' hook. Then calls the
`svg_lib_render' hook to do the actual rendering. Now, the actual body of
these functions may need a persistence state structure that stays alive
until the module is destroyed. The question was, how do I create and manage
this state structure? Which could be different for each SVG rendering
library. I was just creating it globally until Behdad suggested to store it
inside `FT_LibraryRec'. The line of thinking after this, is in my email
<https://lists.nongnu.org/archive/html/freetype-devel/2019-07/msg00045.html>
I sent a while ago.

Also I want to mention that, the SVG rendering module remains the same no
matter which SVG rendering library you're plugging in. Only the hook
pointers change, nothing else. So to switch from `resvg' to `librsvg' you
will only change the call to `FT_Set_Svg_Hooks'. I hope this is how it was
supposed to done. :D
_______________________________________________
Freetype-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/freetype-devel

Reply via email to