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;
/* 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,
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;
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);
}
\f
mfont__driver_list[MFONT_TYPE_FT] = &ft_driver;
+ for (i = 0; i < 7; i++)
+ MLIST_INIT1 (point_table + i, points, 0x1000);
+
return 0;
}
GLYPH_TYPE_MAX
};
-struct MGlyph
+typedef struct
{
int pos, to;
int c;
unsigned bidi_level : 6;
enum glyph_type type : 3;
int combining_code;
-};
-
-typedef struct MGlyph MGlyph;
+} MGlyph;
struct MGlyphString
{
typedef struct MFontDriver MFontDriver;
+typedef struct
+{
+ short x, y;
+} MDrawPoint;
+
extern int mfont__init ();
extern void mfont__fini ();
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);