Re: [gnome-print] Gnome2 printing, font subsetting and CJK fonts



I wrote TrueType to Type42 font subsetting for OpenOffice and I'd be happy 
to contribute it to gnome-print. The source is available at: 

http://gsl.openoffice.org/source/browse/gsl/psprint/source/fontsubset

The license is LGPL 2.1 or SISSL 1.1

The functions that do font subsetting are:

/**
 * Generates a new PostScript Type42 font and dumps it to <b>outf</b> file. 
 * This functions subsititues glyph 0 for all glyphIDs that are not found in the font.
 * @param ttf         pointer to the TrueTypeFont structure 
 * @param outf        output stream for a resulting font
 * @param psname      PostScript name of the resulting font
 * @param glyphArray  pointer to an array of glyphs that are to be extracted from ttf. The first
 *                    element of this array has to be glyph 0 (default glyph)
 * @param encoding    array of encoding values. encoding[i] specifies character code for
 *                    the glyphID glyphArray[i]. Character code 0 usually points to a default
 *                    glyph (glyphID 0)
 * @param nGlyphs     number of glyph IDs in glyphArray and encoding values in encoding
 * @return            SF_OK - no errors
 *                    SF_GLYPHNUM - too many glyphs (> 255)
 *                    SF_TTFORMAT - corrupted TrueType fonts 
 * 
 * @see               SFErrCodes 
 * @ingroup sft       
 * 
 */                   
    int  CreateT42FromTTGlyphs(TrueTypeFont  *ttf,
                               FILE          *outf,
                               const char    *psname,
                               uint16        *glyphArray,
                               byte          *encoding,
                               int            nGlyphs);

/**
 * Generates a new PostScript Type 3 font and dumps it to <b>outf</b> file.
 * This functions subsititues glyph 0 for all glyphIDs that are not found in the font.
 * @param ttf         pointer to the TrueTypeFont structure
 * @param outf        the resulting font is written to this stream
 * @param fname       font name for the new font. If it is NULL the PostScript name of the
 *                    original font will be used
 * @param glyphArray  pointer to an array of glyphs that are to be extracted from ttf
 * @param encoding    array of encoding values. encoding[i] specifies the position of the glyph
 *                    glyphArray[i] in the encoding vector of the resulting Type3 font
 * @param nGlyphs     number of glyph IDs in glyphArray and encoding values in encoding
 * @param wmode       writing mode for the output file: 0 - horizontal, 1 - vertical
 * @return            return the value of SFErrCodes enum
 * @see               SFErrCodes
 * @ingroup sft
 *
 */
    int  CreateT3FromTTGlyphs(TrueTypeFont *ttf, FILE *outf, const char *fname, uint16 *glyphArray, byte *encoding, int nGlyphs, int wmode);
#endif


AG


On Thu, Dec 20, 2001 at 08:24:13PM +0200, Lauris Kaplinski wrote:
> Hello!
> 
> On Thu, 2001-12-20 at 03:24, Richard Shih-Ping Chan wrote:
> > Any interest in embedding TTF fonts as type 42 or type 2 CID for
> > printers with the TT rasteriser? Any work on embedding CID-Keyed fonts?
> > I would like to offer to help if you think it's a "Good Thing" for gnome-print.
> 
> It certainly is, if it helps to reduce embedded size and or
> improve rasterizing.
> We do Type42 for TTF-s with small table sizes (AFAIK it requires
> all tables except 'glyf' to fit in PS strings - i.e. 65336 bytes),
> but without any subsetting.
> If you are interested in helping, then the most current code
> is at moment in gnome-print (gnome1 version) CVS, branch
> gnome-1-4-branch, in libgnomeprint/gnome-font-face.c
> What happens, is simply generation of embeddable PS objects,
> a) covering used glyphs (given as bit array)
> b) encoded to the encoding identical to freetype glyph numbering
> Due to (b) the resulting encoding will contain many 'holes'
> for subsetted fonts. If this will be problem, we have to
> change PS generation code to generate additional glyph mapping.
> 
> > > Technically gnome-print target is larger than PostScript,
> > > but for bitmap and screen based formats things are easier
> > > to do - just letting freetype to do actual rendering and
> > > compose bitmap images into buffer.
> > 
> > What is the target list? 
> > For raster targets like HP PCL I presume you convert all fonts to 
> > bitmaps before sending to the printer?
> 
> At moment, we are targeting only:
> - PS (working, stable) - most important
> - PDF (buggy, needs lot of cleaning/rewriting)
> - RGB/RGBA rasters (working, need performance tweaks)
> - Onscreen preview (works, techincally is similar to raster rendering)
> 
> There were experimental raster and vector HP PCL drivers at some
> point, but currently we do not plan to put much efforts into
> such things. What is more important, is writing reliable font embedding
> into PDF.
> 
> Best wishes,
> Lauris Kaplinski
> 
> 
> 
> _______________________________________________
> Gnome-print maillist  -  Gnome-print@ximian.com
> http://lists.ximian.com/mailman/listinfo/gnome-print

-- 
Alexander Gelfenbain, Sun Microsystems, Inc.
+1 (408) 635-0612 





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]