From: handa Date: Tue, 16 Mar 2004 13:16:27 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=c40bd7cf3f90597087238a1f8d8b698e52e37b7c;p=m17n%2Fm17n-lib.git *** empty log message *** --- diff --git a/src/font-ft.c b/src/font-ft.c index 83e73f0..34bfea1 100644 --- a/src/font-ft.c +++ b/src/font-ft.c @@ -426,9 +426,9 @@ ft_find_metric (MRealizedFont *rfont, MGlyph *g) else code = FT_Get_Char_Index (ft_face, (FT_ULong) g->code); - FT_Load_Glyph (ft_face, code, FT_LOAD_RENDER | FT_LOAD_MONOCHROME); + FT_Load_Glyph (ft_face, code, FT_LOAD_RENDER); metrics = &ft_face->glyph->metrics; - g->lbearing = metrics->horiBearingX >> 6; + g->lbearing = (metrics->horiBearingX >> 6); g->rbearing = (metrics->horiBearingX + metrics->width) >> 6; g->width = metrics->horiAdvance >> 6; g->ascent = metrics->horiBearingY >> 6; @@ -464,6 +464,11 @@ ft_encode_char (MRealizedFont *rfont, int c, unsigned ignored) /* The FreeType font driver function RENDER. */ +struct { + int size, inc, used; + MDrawPoint *points; +} point_table[7]; + static void ft_render (MDrawWindow win, int x, int y, MGlyphString *gstring, MGlyph *from, MGlyph *to, @@ -473,11 +478,22 @@ ft_render (MDrawWindow win, int x, int y, MFrame *frame; MFTInfo *ft_info; FT_Face ft_face = NULL; + FT_Int32 load_flags = FT_LOAD_RENDER; MGlyph *g; + int i, j; if (from == to) return; + if (! gstring->control.anti_alias) + { +#ifdef FT_LOAD_TARGET_MONO + load_flags |= FT_LOAD_TARGET_MONO; +#else + load_flags |= FT_LOAD_MONOCHROME; +#endif + } + /* It is assured that the all glyphs in the current range use the same realized face. */ rface = from->rface; @@ -485,47 +501,56 @@ ft_render (MDrawWindow win, int x, int y, ft_info = (MFTInfo *) rface->rfont->info; ft_face = ft_info->ft_face; - g = from; - while (g < to) + for (i = 0; i < 7; i++) + MLIST_RESET (point_table + i); + + for (g = from; g < to; x += g++->width) { - if (g->type == GLYPH_CHAR) - { - FT_UInt code; + FT_UInt code; + unsigned char *bmp; + MDrawPoint p; + int intensity = reverse ? 0 : 7; - if (g->otf_encoded) - code = g->code; - else - code = FT_Get_Char_Index (ft_face, (FT_ULong) g->code); -#if 0 -#ifdef FT_LOAD_TARGET_MONO - FT_Load_Glyph (ft_face, code, FT_LOAD_RENDER | FT_LOAD_TARGET_MONO); -#else - FT_Load_Glyph (ft_face, code, FT_LOAD_RENDER | FT_LOAD_MONOCHROME); -#endif - mwin__draw_bitmap (frame, win, rface, reverse, - x + ft_face->glyph->bitmap_left + g->xoff, - y - ft_face->glyph->bitmap_top + g->yoff, - ft_face->glyph->bitmap.width, - ft_face->glyph->bitmap.rows, - ft_face->glyph->bitmap.pitch, - ft_face->glyph->bitmap.buffer, - region); -#else - FT_Load_Glyph (ft_face, code, FT_LOAD_RENDER); - mwin__draw_pixmap (frame, win, rface, reverse, - x + ft_face->glyph->bitmap_left + g->xoff, - y - ft_face->glyph->bitmap_top + g->yoff, - ft_face->glyph->bitmap.width, - ft_face->glyph->bitmap.rows, - ft_face->glyph->bitmap.pitch, - ft_face->glyph->bitmap.buffer, - region); -#endif + if (g->otf_encoded) + code = g->code; + else + code = FT_Get_Char_Index (ft_face, (FT_ULong) g->code); + FT_Load_Glyph (ft_face, code, load_flags); + bmp = ft_face->glyph->bitmap.buffer; + if (! gstring->control.anti_alias) + { + for (i = 0; i < ft_face->glyph->bitmap.rows; + i++, bmp += ft_face->glyph->bitmap.pitch) + for (j = 0; j < ft_face->glyph->bitmap.width; j++) + if (bmp[j / 8] & (1 << (7 - (j % 8)))) + { + p.x = x + ft_face->glyph->bitmap_left + g->xoff + j; + p.y = y - ft_face->glyph->bitmap_top + g->yoff + i; + MLIST_APPEND1 (point_table + intensity - 1, points, p, + MERROR_FONT_FT); + } + } + else + { + for (i = 0; i < ft_face->glyph->bitmap.rows; + i++, bmp += ft_face->glyph->bitmap.pitch) + for (j = 0; j < ft_face->glyph->bitmap.width; j++) + if (bmp[j]) + { + intensity = reverse ? (7 - (bmp[j] >> 5)) : (bmp[j] >> 5); + + p.x = x + ft_face->glyph->bitmap_left + g->xoff + j; + p.y = y - ft_face->glyph->bitmap_top + g->yoff + i; + MLIST_APPEND1 (point_table + intensity - 1, points, p, + MERROR_FONT_FT); + } } - x += g++->width; } - return; + for (i = 0; i < 7; i++) + if (point_table[i].used) + mwin__draw_points (frame, win, rface, i + 1, + point_table[i].points, point_table[i].used); } @@ -564,6 +589,9 @@ mfont__ft_init () mfont__driver_list[MFONT_TYPE_FT] = &ft_driver; + for (i = 0; i < 7; i++) + MLIST_INIT1 (point_table + i, points, 0x1000); + return 0; } diff --git a/src/internal-gui.h b/src/internal-gui.h index 1f42b07..efd15df 100644 --- a/src/internal-gui.h +++ b/src/internal-gui.h @@ -81,7 +81,7 @@ enum glyph_type GLYPH_TYPE_MAX }; -struct MGlyph +typedef struct { int pos, to; int c; @@ -97,9 +97,7 @@ struct MGlyph unsigned bidi_level : 6; enum glyph_type type : 3; int combining_code; -}; - -typedef struct MGlyph MGlyph; +} MGlyph; struct MGlyphString { @@ -186,6 +184,11 @@ typedef struct MGlyphString MGlyphString; typedef struct MFontDriver MFontDriver; +typedef struct +{ + short x, y; +} MDrawPoint; + extern int mfont__init (); extern void mfont__fini (); @@ -233,19 +236,16 @@ extern void mwin__draw_box (MFrame *frame, MDrawWindow win, MGlyph *g, int x, int y, int width, MDrawRegion region); +extern void mwin__draw_points (MFrame *frame, MDrawWindow win, + MRealizedFace *rface, + int intensity, MDrawPoint *points, int num); + extern void mwin__draw_bitmap (MFrame *frame, MDrawWindow win, MRealizedFace *rface, int reverse, int x, int y, int width, int height, int row_bytes, unsigned char *bmp, - MDrawRegion region); - -extern void mwin__draw_pixmap (MFrame *frame, MDrawWindow win, - MRealizedFace *rface, int reverse, - int x, int y, - int width, int height, int row_bytes, - unsigned char *pmp, - MDrawRegion region); + MDrawRegion region, int pixmap); extern MDrawRegion mwin__region_from_rect (MDrawMetric *rect); diff --git a/src/m17n-gui.h b/src/m17n-gui.h index ba9adf6..9be293e 100644 --- a/src/m17n-gui.h +++ b/src/m17n-gui.h @@ -438,6 +438,10 @@ typedef struct implemented. */ unsigned fixed_width : 1; + /***en If nonzero, draw glyphs with anti-aliasing if a backend font + driver supports it. */ + unsigned anti_alias : 1; + /***en If nonzero, the values are minimum line ascent and descent pixels. */ unsigned int min_line_ascent;