- return(1); /* FIXME: Always true - check the return values of the init_t1 and init_tt functions */
-}
-
-
-
-
-#ifdef HAVE_LIBT1
-
-
-
-/*
-=item i_init_t1(t1log)
-
-Initializes the t1lib font rendering engine.
-
-=cut
-*/
-
-undef_int
-init_t1(int t1log) {
- int init_flags = IGNORE_CONFIGFILE|IGNORE_FONTDATABASE;
- mm_log((1,"init_t1()\n"));
-
- if (t1log)
- init_flags |= LOGFILE;
- if ((T1_InitLib(init_flags) == NULL)){
- mm_log((1,"Initialization of t1lib failed\n"));
- return(1);
- }
- T1_SetLogLevel(T1LOG_DEBUG);
- i_t1_set_aa(1); /* Default Antialias value */
- return(0);
-}
-
-
-/*
-=item i_close_t1()
-
-Shuts the t1lib font rendering engine down.
-
- This it seems that this function is never used.
-
-=cut
-*/
-
-void
-i_close_t1(void) {
- T1_CloseLib();
-}
-
-
-/*
-=item i_t1_new(pfb, afm)
-
-Loads the fonts with the given filenames, returns its font id
-
- pfb - path to pfb file for font
- afm - path to afm file for font
-
-=cut
-*/
-
-int
-i_t1_new(char *pfb,char *afm) {
- int font_id;
- mm_log((1,"i_t1_new(pfb %s,afm %s)\n",pfb,(afm?afm:"NULL")));
- font_id = T1_AddFont(pfb);
- if (font_id<0) {
- mm_log((1,"i_t1_new: Failed to load pfb file '%s' - return code %d.\n",pfb,font_id));
- return font_id;
- }
-
- if (afm != NULL) {
- mm_log((1,"i_t1_new: requesting afm file '%s'.\n",afm));
- if (T1_SetAfmFileName(font_id,afm)<0) mm_log((1,"i_t1_new: afm loading of '%s' failed.\n",afm));
- }
- return font_id;
-}
-
-/*
-=item i_t1_destroy(font_id)
-
-Frees resources for a t1 font with given font id.
-
- font_id - number of the font to free
-
-=cut
-*/
-
-int
-i_t1_destroy(int font_id) {
- mm_log((1,"i_t1_destroy(font_id %d)\n",font_id));
- return T1_DeleteFont(font_id);
-}
-
-
-/*
-=item i_t1_set_aa(st)
-
-Sets the antialiasing level of the t1 library.
-
- st - 0 = NONE, 1 = LOW, 2 = HIGH.
-
-=cut
-*/
-
-void
-i_t1_set_aa(int st) {
- int i;
- unsigned long cst[17];
- switch(st) {
- case 0:
- T1_AASetBitsPerPixel( 8 );
- T1_AASetLevel( T1_AA_NONE );
- T1_AANSetGrayValues( 0, 255 );
- mm_log((1,"setting T1 antialias to none\n"));
- break;
- case 1:
- T1_AASetBitsPerPixel( 8 );
- T1_AASetLevel( T1_AA_LOW );
- T1_AASetGrayValues( 0,65,127,191,255 );
- mm_log((1,"setting T1 antialias to low\n"));
- break;
- case 2:
- T1_AASetBitsPerPixel(8);
- T1_AASetLevel(T1_AA_HIGH);
- for(i=0;i<17;i++) cst[i]=(i*255)/16;
- T1_AAHSetGrayValues( cst );
- mm_log((1,"setting T1 antialias to high\n"));
- }
-}
-
-
-/*
-=item i_t1_cp(im, xb, yb, channel, fontnum, points, str, len, align)
-
-Interface to text rendering into a single channel in an image
-
- im pointer to image structure
- xb x coordinate of start of string
- yb y coordinate of start of string ( see align )
- channel - destination channel
- fontnum - t1 library font id
- points - number of points in fontheight
- str - string to render
- len - string length
- align - (0 - top of font glyph | 1 - baseline )
-
-=cut
-*/
-
-undef_int
-i_t1_cp(i_img *im,int xb,int yb,int channel,int fontnum,float points,char* str,int len,int align) {
- GLYPH *glyph;
- int xsize,ysize,x,y;
- i_color val;
-
- unsigned int ch_mask_store;
-
- if (im == NULL) { mm_log((1,"i_t1_cp: Null image in input\n")); return(0); }
-
- glyph=T1_AASetString( fontnum, str, len, 0, T1_KERNING, points, NULL);
- if (glyph == NULL)
- return 0;
-
- mm_log((1,"metrics: ascent: %d descent: %d\n",glyph->metrics.ascent,glyph->metrics.descent));
- mm_log((1," leftSideBearing: %d rightSideBearing: %d\n",glyph->metrics.leftSideBearing,glyph->metrics.rightSideBearing));
- mm_log((1," advanceX: %d advanceY: %d\n",glyph->metrics.advanceX,glyph->metrics.advanceY));
- mm_log((1,"bpp: %d\n",glyph->bpp));
-
- xsize=glyph->metrics.rightSideBearing-glyph->metrics.leftSideBearing;
- ysize=glyph->metrics.ascent-glyph->metrics.descent;
-
- mm_log((1,"width: %d height: %d\n",xsize,ysize));
-
- ch_mask_store=im->ch_mask;
- im->ch_mask=1<<channel;
-
- if (align==1) { xb+=glyph->metrics.leftSideBearing; yb-=glyph->metrics.ascent; }
-
- for(y=0;y<ysize;y++) for(x=0;x<xsize;x++) {
- val.channel[channel]=glyph->bits[y*xsize+x];
- i_ppix(im,x+xb,y+yb,&val);
- }
-
- im->ch_mask=ch_mask_store;
- return 1;
-}
-
-
-/*
-=item i_t1_bbox(handle, fontnum, points, str, len, cords)
-
-function to get a strings bounding box given the font id and sizes
-
- handle - pointer to font handle
- fontnum - t1 library font id
- points - number of points in fontheight
- str - string to measure
- len - string length
- cords - the bounding box (modified in place)
-
-=cut
-*/
-
-void
-i_t1_bbox(int fontnum,float points,char *str,int len,int cords[6]) {
- BBox bbox;
- BBox gbbox;
-
- mm_log((1,"i_t1_bbox(fontnum %d,points %.2f,str '%.*s', len %d)\n",fontnum,points,len,str,len));
- T1_LoadFont(fontnum); /* FIXME: Here a return code is ignored - haw haw haw */
- bbox = T1_GetStringBBox(fontnum,str,len,0,T1_KERNING);
- gbbox = T1_GetFontBBox(fontnum);
-
- mm_log((1,"bbox: (%d,%d,%d,%d)\n",
- (int)(bbox.llx*points/1000),
- (int)(gbbox.lly*points/1000),
- (int)(bbox.urx*points/1000),
- (int)(gbbox.ury*points/1000),
- (int)(bbox.lly*points/1000),
- (int)(bbox.ury*points/1000) ));
-
-
- cords[0]=((float)bbox.llx*points)/1000;
- cords[2]=((float)bbox.urx*points)/1000;
-
- cords[1]=((float)gbbox.lly*points)/1000;
- cords[3]=((float)gbbox.ury*points)/1000;
-
- cords[4]=((float)bbox.lly*points)/1000;
- cords[5]=((float)bbox.ury*points)/1000;
-}
-
-
-/*
-=item i_t1_text(im, xb, yb, cl, fontnum, points, str, len, align)
-
-Interface to text rendering in a single color onto an image
-
- im - pointer to image structure
- xb - x coordinate of start of string
- yb - y coordinate of start of string ( see align )
- cl - color to draw the text in
- fontnum - t1 library font id
- points - number of points in fontheight
- str - char pointer to string to render
- len - string length
- align - (0 - top of font glyph | 1 - baseline )
-
-=cut
-*/
-
-undef_int
-i_t1_text(i_img *im,int xb,int yb,i_color *cl,int fontnum,float points,char* str,int len,int align) {
- GLYPH *glyph;
- int xsize,ysize,x,y,ch;
- i_color val;
- unsigned char c,i;
-
- if (im == NULL) { mm_log((1,"i_t1_cp: Null image in input\n")); return(0); }
-
- glyph=T1_AASetString( fontnum, str, len, 0, T1_KERNING, points, NULL);
- if (glyph == NULL)
- return 0;
-
- mm_log((1,"metrics: ascent: %d descent: %d\n",glyph->metrics.ascent,glyph->metrics.descent));
- mm_log((1," leftSideBearing: %d rightSideBearing: %d\n",glyph->metrics.leftSideBearing,glyph->metrics.rightSideBearing));
- mm_log((1," advanceX: %d advanceY: %d\n",glyph->metrics.advanceX,glyph->metrics.advanceY));
- mm_log((1,"bpp: %d\n",glyph->bpp));
-
- xsize=glyph->metrics.rightSideBearing-glyph->metrics.leftSideBearing;
- ysize=glyph->metrics.ascent-glyph->metrics.descent;
-
- mm_log((1,"width: %d height: %d\n",xsize,ysize));
-
- if (align==1) { xb+=glyph->metrics.leftSideBearing; yb-=glyph->metrics.ascent; }
-
- for(y=0;y<ysize;y++) for(x=0;x<xsize;x++) {
- c=glyph->bits[y*xsize+x];
- i=255-c;
- i_gpix(im,x+xb,y+yb,&val);
- for(ch=0;ch<im->channels;ch++) val.channel[ch]=(c*cl->channel[ch]+i*val.channel[ch])/255;
- i_ppix(im,x+xb,y+yb,&val);
- }
- return 1;
-}
-
-
-#endif /* HAVE_LIBT1 */
-
-
-
-
-
-
-
-
-
-
-/* Truetype font support */
-
-#ifdef HAVE_LIBTT