[cairo] Rendering line fonts
Behdad Esfahbod
behdad at behdad.org
Sun Nov 23 05:18:52 PST 2008
Ian Britten wrote:
>> The paths are always filled. If you
>> want to stroke the paths you will need to make your FT driver create
>> paths that when filled form the strokes.
>
> Hmmm... Although I see what you're saying, things are never that
> simple (for me... :( )
> Since the thickness is a configurable attribute of the text and not
> a property of the Face (Sortof like size, underline, angle, etc),
> then I won't be able to compute the final polygon path until just
> when it's being rendered.
Fair enough, but then I don't see why you are abusing freetype here. The main
reason one would want to use freetype for their custom font format is to get
the rasterization done by freetype. You don't seem to use that at all.
>> Your best option is to use the user font feature in cairo. It would take
>> very little effort create a user font with a render function that
>> strokes the glyph path. In the PDF/PS backends user fonts are embedded
>> as a Type 3 fonts.
>
> So, given that the entry point to all this (within our rendering
> framework) passes me an FT_Face and a character, then what you're
> saying is that I'll have to:
> - Examine the FT_Face, and determine if it's one of my stroke fonts.
> - If it's not, proceed with what I'm currently doing.
Right.
> - See if it has any open lines/paths, or if it just polygons (Since
> our fonts could be either).
> - If it's just polygons, I can continue doing what I'm doing.
Right.
> - Extract the linework from the FT_Face (Somehow - Hmmm... I wonder
> if I'll have to dive into an FT_Outline_Decompose() type of draw
> solution to get at them :P To be investigated...)
No, you don't need this part.
> - Using the thickness for this text, and the just-extracted lines,
> proceed to the 'user font' stuff of Cairo (Which I haven't looked
> looked at closely yet - Sorry) and make up the glyph.
Yes. This is the pseudocode of how you should handle your FT_Face:
cairo_face = cairo_ft_font_face_create_for_ft_face (ft_face);
if (ft_face is my custom format and a stroke font)
cairo_face = my_stroke_font_face_create (cairo_face, thickness);
Where my_stroke_font_face_create() creates a cairo user-font. You then use
the cairo_face normally.
> - Finally, render it as described by Behdad in his message:
> cairo_glyph_path (cr, &cairo_glyph, 1);
> cairo_stroke (cr);
No this is what your user font's render function does. You really should go
study cairo/test/user-font-proxy.c before replying.
behdad
> [ (sigh) Doesn't really sound like something I want to get started
> on on a Friday afternoon... :P Now you see why I kept pursuing
> my initial (seemingly-simple) approach... ]
>
> Again, thanks for the help and info so far! I'll probably have
> a few more questions before I get this squished though. Gotta go
> upgrade to 1.8.x first though...
> Ian
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo
>
More information about the cairo
mailing list