From dc921b70a94249212cfb0260e0037a46afc6423f Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Mon, 14 Apr 2008 18:58:00 +0000 Subject: [PATCH] Fix T1 font rendering in dvi backend. Patch by Mattias Nissler. 2008-04-14 Carlos Garcia Campos * backend/dvi/mdvi-lib/bitmap.[ch]: (bitmap_convert_lsb8), (bitmap_convert_msb8): * backend/dvi/mdvi-lib/t1.c: (t1_glyph_bitmap): * backend/dvi/mdvi-lib/tt.c: (tt_get_bitmap): Fix T1 font rendering in dvi backend. Patch by Mattias Nissler. svn path=/trunk/; revision=3006 --- ChangeLog | 9 +++++++++ backend/dvi/mdvi-lib/bitmap.c | 10 ++++++---- backend/dvi/mdvi-lib/bitmap.h | 4 ++-- backend/dvi/mdvi-lib/t1.c | 17 ++++------------- backend/dvi/mdvi-lib/tt.c | 2 +- 5 files changed, 22 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 568aa5c0..ab660183 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-04-14 Carlos Garcia Campos + + * backend/dvi/mdvi-lib/bitmap.[ch]: (bitmap_convert_lsb8), + (bitmap_convert_msb8): + * backend/dvi/mdvi-lib/t1.c: (t1_glyph_bitmap): + * backend/dvi/mdvi-lib/tt.c: (tt_get_bitmap): + + Fix T1 font rendering in dvi backend. Patch by Mattias Nissler. + 2008-04-14 Carlos Garcia Campos * shell/ev-jobs.[ch]: (ev_job_render_dispose), diff --git a/backend/dvi/mdvi-lib/bitmap.c b/backend/dvi/mdvi-lib/bitmap.c index 0c598209..3b16042d 100644 --- a/backend/dvi/mdvi-lib/bitmap.c +++ b/backend/dvi/mdvi-lib/bitmap.c @@ -125,7 +125,7 @@ static Uchar bit_swap[] = { * hopelessly slow. */ -BITMAP *bitmap_convert_lsb8(Uchar *bits, int w, int h) +BITMAP *bitmap_convert_lsb8(Uchar *bits, int w, int h, int stride) { BITMAP *bm; int i; @@ -147,12 +147,13 @@ BITMAP *bitmap_convert_lsb8(Uchar *bits, int w, int h) for(i = 0; i < h; i++) { #ifdef WORD_LITTLE_ENDIAN memcpy(unit, curr, bytes); - curr += bytes; + curr += stride; #else int j; for(j = 0; j < bytes; curr++, j++) unit[j] = bit_swap[*curr]; + cur += stride - bytes; #endif memzero(unit + bytes, bm->stride - bytes); unit += bm->stride; @@ -162,7 +163,7 @@ BITMAP *bitmap_convert_lsb8(Uchar *bits, int w, int h) return bm; } -BITMAP *bitmap_convert_msb8(Uchar *data, int w, int h) +BITMAP *bitmap_convert_msb8(Uchar *data, int w, int h, int stride) { BITMAP *bm; Uchar *unit; @@ -180,9 +181,10 @@ BITMAP *bitmap_convert_msb8(Uchar *data, int w, int h) for(j = 0; j < bytes; curr++, j++) unit[j] = bit_swap[*curr]; + curr += stride - bytes; #else memcpy(unit, curr, bytes); - curr += bytes; + curr += stride; #endif memzero(unit + bytes, bm->stride - bytes); unit += bm->stride; diff --git a/backend/dvi/mdvi-lib/bitmap.h b/backend/dvi/mdvi-lib/bitmap.h index 4d5f23ac..692cb398 100644 --- a/backend/dvi/mdvi-lib/bitmap.h +++ b/backend/dvi/mdvi-lib/bitmap.h @@ -136,8 +136,8 @@ extern void bitmap_rotate_clockwise __PROTO((BITMAP *)); extern void bitmap_rotate_counter_clockwise __PROTO((BITMAP *)); extern void bitmap_flip_rotate_clockwise __PROTO((BITMAP *)); extern void bitmap_flip_rotate_counter_clockwise __PROTO((BITMAP *)); -extern BITMAP *bitmap_convert_lsb8 __PROTO((Uchar *, int, int)); -extern BITMAP *bitmap_convert_msb8 __PROTO((Uchar *, int, int)); +extern BITMAP *bitmap_convert_lsb8 __PROTO((Uchar *, int, int, int)); +extern BITMAP *bitmap_convert_msb8 __PROTO((Uchar *, int, int, int)); #include extern void bitmap_print __PROTO((FILE *, BITMAP *)); diff --git a/backend/dvi/mdvi-lib/t1.c b/backend/dvi/mdvi-lib/t1.c index 1e96f3e8..e7cd4f80 100644 --- a/backend/dvi/mdvi-lib/t1.c +++ b/backend/dvi/mdvi-lib/t1.c @@ -437,25 +437,16 @@ static int t1_load_font(DviParams *params, DviFont *font) static inline BITMAP *t1_glyph_bitmap(GLYPH *glyph) { - BITMAP *bm; - int w, h; + int w, h, pad; w = GLYPH_WIDTH(glyph); h = GLYPH_HEIGHT(glyph); if(!w || !h) return MDVI_GLYPH_EMPTY; - switch(glyph->bpp << 3) { - case 8: - bm = bitmap_convert_lsb8((unsigned char *)glyph->bits, w, h); - break; - default: - warning(_("(t1) unsupported bitmap pad size %d\n"), - glyph->bpp); - bm = MDVI_GLYPH_EMPTY; - break; - } - return bm; + + pad = T1_GetBitmapPad(); + return bitmap_convert_lsb8((unsigned char *)glyph->bits, w, h, ROUND(w, pad) * (pad >> 3)); } static void t1_font_shrink_glyph(DviContext *dvi, DviFont *font, DviFontChar *ch, DviGlyph *dest) diff --git a/backend/dvi/mdvi-lib/tt.c b/backend/dvi/mdvi-lib/tt.c index e383006b..ab096d30 100644 --- a/backend/dvi/mdvi-lib/tt.c +++ b/backend/dvi/mdvi-lib/tt.c @@ -382,7 +382,7 @@ static int tt_get_bitmap(DviParams *params, DviFont *font, TT_Translate_Outline(&outline, -bbox.xMin, -bbox.yMin); TT_Get_Outline_Bitmap(tt_handle, &outline, &raster); - glyph->data = bitmap_convert_msb8(raster.bitmap, w, h); + glyph->data = bitmap_convert_msb8(raster.bitmap, w, h, ROUND(w, 8)); TT_Done_Outline(&outline); mdvi_free(raster.bitmap); -- 2.43.5