[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Type 42
From: |
David Turner |
Subject: |
Re: Type 42 |
Date: |
Thu, 22 Jun 2000 11:53:08 +0200 |
Hi Sivan,
Sivan Toledo a écrit :
>
> Hi David,
>
> Thanks for the detailed reply. I'm afraid, however, that I wasn't clear
> enough in my query.
>
Sorry for the misunderstanding. It seems that you really need to be able
to subset a TrueType font, before embedding it into a Type42 wrapper.
FreeType is absolutely not designed for such things, and it probably
would be a bad idea to use it to do that. You could maybe use it to
read the TrueType tables, but's that's about it and not a lot of code
to do by your own, really.. Most of the work is in the sub-setting
routines..
Hope this clarifies..
- David
> I am not interested in rasterizing glyphs from a Type42 font, which
> is what you explained how to do.
>
> What I am basically interested in is a TTF -> Type42 converter. Actually
> it's not a straight TTF->T42 file-to-file converter, because I want
> the T42 font to include only a specified subset of the glyphs in the ttf
> font.
>
> The application is this: I want to provide a piece of software that
> would (1) rasterize glyphs for on-screen disply in widgets, and
> (2) build a representation of the same fonts to send to the
> printer; this would be what we use the T42 file for.
> For (1) we can either call FreeType directly or build a font-server
> interface (or hack exising software like xfstt). For (2) we need
> to build a Type42 representation of a subset of the glyphs in the
> ttf file. We then include this T42 font in the postscript file
> that we send to the printer, and which also contains text to
> be rendered in the font, graphics, etc.
>
> I apologize for being unclear before.
>
> Sivan
>
> > There are basically two ways to support Type42 fonts with FreeType2:
> >
> > - one is to write a font driver that would be able to manage the postscript
> > "wrapper", and use the TrueType driver to manage data within it.
> >
> > - the other one is to support manage the wrapper yourself (this is important
> > if you are a Postscript interpreter like Ghostscript) and provide a custom
> > stream object in order to use the TrueType driver directly..
> >
> > The first solution would need some work. It's do-able, but I'm really
> > doubtful that it had any real interest, given that the only programs
> > that need to support these fonts are Postscript interpreters (well, I
> > may be wrong, so please let me know if this isn't true).
> >
> > I'll know talk about the second method:
> >
> > There are already hooks in the FreeType 2 TrueType driver to support
> > Type42 fonts, but it's true that I haven't completed this yet. Could
> > you tell me if the following scheme would allow you to support these
> > fonts in your application (it'd need a few changes that I'm ready
> > to commit if you agree with this):
> >
> > - you would need to provide your custom implementation of
> > the "stream" object (see <freetype/ftsystem.h>) to access
> > the data inside the encoded font file
> >
> > - you will need to provide an alternative to the function
> > TT_Goto_Table, defined in "src/sfnt/ttload.c" (line 102).
> >
> >
> > basically, all tables are accessed through a line like:
> >
> > error = face->goto_table( face, table_tag, stream, &length );
> >
> > "goto_table" is a field of TT_FaceRec which is set by default (in
> > TT_Init_Face)
> > to TT_Goto_Table. However, you could provide your own implementation to
> > seek to the data you need within your Type42 font. Its purpose is
> > simple to "seek" the stream to the start of the table, and return its
> > size in bytes in the "length" variable..
> >
> > You would thus need something like the following to open a new font file:
> >
> > ... create your own stream object, named "my_stream"
> > {
> > FT_Open_Args open;
> > FT_Parameter parameter;
> >
> > /* this extra parameter is used to pass the address of a substitue for
> > */
> > /* TT_Goto_Table
> > */
> > parameter.tag = FT_MAKE_TAG('g','o','t','o');
> > parameter.data = your_implementation_of_tt_goto_table;
> >
> > /* this indicates that we will open a new face with a custom stream, */
> > /* and that we'll pass one parameter to the font driver.. */
> > open.flags = ft_open_stream | ft_open_params;
> > open.stream = my_stream;
> > open.num_params = 1;
> > open.params = ¶meter;
> >
> > error = FT_Open_Face( library, &open, 0, &face );
> > }
> >
> > Note that the stream will be normally seeked to load the table directory
> > though. We could also add an additional parameter to the font driver to
> > specify the function to use to load the latter..
> >
> >
> > So, would this fit your needs ?? It so, I only need to change TT_Init_Face
> > in order to recognize the extra parameter..
> >
> > Best regards,
> >
> > - David
> >