+2008-04-14 Carlos Garcia Campos <carlosgc@gnome.org>
+
+ * 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 <carlosgc@gnome.org>
* shell/ev-jobs.[ch]: (ev_job_render_dispose),
* 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;
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;
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;
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;
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 <stdio.h>
extern void bitmap_print __PROTO((FILE *, BITMAP *));
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)
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);