Re: Glyph Outlines in Trace Driver
Ken Sharp <[email protected]>
| Newsgroups | gmane.comp.printing.ghostscript.devel |
|---|---|
| Message-ID | <[email protected]> |
At 22:15 12/06/2015 +0000, Allen Blaylock wrote:
>How do I determine which transforms I need to apply?
All of them :-)
>Where are they stored (I know where ctm is and how to access it)?
The font matrix is stored in the font instance. For a regular font that and
the CTM are the only matrices you need to worry about. The 'original' font
matrix scales the co-ordinates in the font into the canonical 1x1
PostScript unit space. The scaled font matrix is that matrix scaled by the
argument applied to scalefont. Which is why you need the matrix from the
specific font instance, to get the correct scaling.
For CIDFonts its more complex, you need to apply one or both of the parent
and descendant font matrices (As I recall there must be at least one, but
may not be both). The 'next' and 'prev' members are not the descendants,
they point to the next font in the font cache.
In ghostpdl/gs/devices/vector/gdevpdtc.c the routine
process_composite_text() demonstrates one part of this:
font_code = pte->orig_font->procs.next_char_glyph
((gs_text_enum_t *)&curr, &chr, &glyph);
/*
* We check for a font change by comparing the current
* font, rather than testing the return code, because
* it makes the control structure a little simpler.
*/
switch (font_code) {
case 0: /* no font change */
case 1: /* font change */
....
new_font = curr.fstack.items[curr.fstack.depth].font;
....
case 2: /* end of string */
break;
default: /* error */
return font_code;
}
break;
>able to find a good description of them in the code or the documents online.
You will need the Type 1 font specification (aka 'Black and white' book),
and the supplement, Adobe tech note 5015. The TrueType font specification,
and the Type 42 description (I think that's in the 2nd edition PLRM,but
Adobe Tech note 5012 is the stand-alone). The CFF font format
specification, Adobe tech note 5176, you probably don't need to worry about
the type 2 CharString format but its tech note 5177. Tech note 5092 for an
overview of CIDKeyed fonts and Tech Note 5014 for CIDFonts and CMaps
I can't recall where the wrinkles about type 0 fonts and their descendants
and how to apply their matrices is given. I do remember it took a lot of
finding and careful reading and rereading of the specification to get it
all working correctly.
>Is there a set of code which sets everything up to append the path to the
>path provided in text_begin?
No, Ghostscript doesn't render text by appending the outline to the path
(except for very large glyphs). The glyph is rendered and the bitmap added
to the glyph cache, the bitmap is then rendered at the correct position
given by the current point, and the current point is advanced by the glyph
metrics (taking overrides into account). Subsequent uses of that glyph are
then rendered from the glyph cache in the same way.
>The end goal is to just grab the text outline and dump it like any other
>paths in the trace driver, I may be chasing the wrong solution entirely.
>Feel free to say that as well.
Why not simply decode the font ? Its probably quicker and you get all the
hinting information, which will already have been applied by the time you
get a path back.
Perhaps if you said why you wanted to do this we could suggest a different
approach. Fonts and text are in many ways the most complex area of
PostScript, and the most convoluted and difficult to understand parts of
Ghostscript.
Ken