X-Git-Url: http://git.imager.perl.org/imager.git/blobdiff_plain/02c63035876648ef730cbde539cd75c53236a032..e1c0692925:/fontft1.c diff --git a/fontft1.c b/fontft1.c index e0332f12..50602902 100644 --- a/fontft1.c +++ b/fontft1.c @@ -150,7 +150,6 @@ static int LTT_hinted = 1; /* FIXME: this too */ void i_tt_start(void) { - im_context_t ctx = im_get_context(); if (slot == -1) slot = im_context_slot_new(i_tt_uninit); } @@ -372,6 +371,7 @@ i_tt_new(const char *fontname) { /* load the typeface */ error = TT_Open_Face( tteng->engine, fontname, &handle->face ); if ( error ) { + myfree(handle); if ( error == TT_Err_Could_Not_Open_File ) { mm_log((1, "Could not find/open %s.\n", fontname )); } @@ -613,7 +613,7 @@ i_tt_get_glyph( TT_Fonthandle *handle, int inst, unsigned long j) { if ( LTT_hinted ) load_flags |= TTLOAD_HINT_GLYPH; if ( !TT_VALID(handle->char_map) ) { - code = (j - ' ' + 1) < 0 ? 0 : (j - ' ' + 1); + code = (j < ' ' - 1) ? 0 : (j - (' ' - 1)); if ( code >= handle->properties.num_Glyphs ) code = 0; } else code = TT_Char_Index( handle->char_map, j ); @@ -687,7 +687,7 @@ i_tt_has_chars(TT_Fonthandle *handle, char const *text, size_t len, int utf8, index = TT_Char_Index(handle->char_map, c); } else { - index = (c - ' ' + 1) < 0 ? 0 : (c - ' ' + 1); + index = (c < ' ' - 1) ? 0 : (c - (' ' - 1)); if (index >= handle->properties.num_Glyphs) index = 0; } @@ -763,12 +763,10 @@ i_tt_render_glyph( TT_Glyph glyph, TT_Glyph_Metrics* gmetrics, TT_Raster_Map *bi if ( !smooth ) TT_Get_Glyph_Bitmap( glyph, bit, x_off * 64, y_off * 64); else { - TT_F26Dot6 xmin, ymin, xmax, ymax; + TT_F26Dot6 xmin, ymin; xmin = gmetrics->bbox.xMin & -64; ymin = gmetrics->bbox.yMin & -64; - xmax = (gmetrics->bbox.xMax + 63) & -64; - ymax = (gmetrics->bbox.yMax + 63) & -64; i_tt_clear_raster_map( small_bit ); TT_Get_Glyph_Pixmap( glyph, small_bit, -xmin, -ymin ); @@ -872,22 +870,30 @@ i_tt_dump_raster_map2( i_img* im, TT_Raster_Map* bit, i_img_dim xb, i_img_dim yb } i_render_done(&r); } else { + unsigned char *bmp = mymalloc(bit->width); + i_render r; + + i_render_init(&r, im, bit->width); + for(y=0;yrows;y++) { unsigned mask = 0x80; unsigned char *p = bmap + y * bit->cols; + unsigned char *pout = bmp; for(x = 0; x < bit->width; x++) { - if (*p & mask) { - i_ppix(im, x+xb, y+yb, cl); - } + *pout++ = (*p & mask) ? 0xFF : 0; mask >>= 1; if (!mask) { mask = 0x80; ++p; } } + + i_render_color(&r, xb, yb+y, bit->width, bmp, cl); } + i_render_done(&r); + myfree(bmp); } } @@ -966,7 +972,7 @@ interface for generating single channel raster of text (internal) static int -i_tt_rasterize( TT_Fonthandle *handle, TT_Raster_Map *bit, i_img_dim cords[6], double points, char const* txt, size_t len, int smooth, int utf8 ) { +i_tt_rasterize( TT_Fonthandle *handle, TT_Raster_Map *bit, i_img_dim *cords, double points, char const* txt, size_t len, int smooth, int utf8 ) { int inst; i_img_dim width, height; TT_Raster_Map small_bit; @@ -1102,7 +1108,7 @@ Function to get texts bounding boxes given the instance of the font (internal) static undef_int -i_tt_bbox_inst( TT_Fonthandle *handle, int inst ,const char *txt, size_t len, i_img_dim cords[BOUNDING_BOX_COUNT], int utf8 ) { +i_tt_bbox_inst( TT_Fonthandle *handle, int inst ,const char *txt, size_t len, i_img_dim *cords, int utf8 ) { int upm, casc, cdesc, first; int start = 0; @@ -1114,8 +1120,6 @@ i_tt_bbox_inst( TT_Fonthandle *handle, int inst ,const char *txt, size_t len, i_ int rightb = 0; unsigned long j; - unsigned char *ustr; - ustr=(unsigned char*)txt; mm_log((1,"i_tt_box_inst(handle %p,inst %d,txt '%.*s', len %ld, utf8 %d)\n", handle, inst, (int)len, txt, (long)len, utf8)); @@ -1203,7 +1207,7 @@ Interface to get a strings bounding box */ undef_int -i_tt_bbox( TT_Fonthandle *handle, double points,const char *txt,size_t len,i_img_dim cords[6], int utf8) { +i_tt_bbox( TT_Fonthandle *handle, double points,const char *txt,size_t len,i_img_dim *cords, int utf8) { int inst; i_clear_error();