From: handa Date: Thu, 23 Jan 2003 02:01:50 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: REL-0-9-1~111 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=96d8966b2706ee041a247bb019c5b0a8ea12b084;p=m17n%2Flibotf.git *** empty log message *** --- diff --git a/example/otfview.c b/example/otfview.c index 66cab62..d5dc341 100644 --- a/example/otfview.c +++ b/example/otfview.c @@ -9,9 +9,6 @@ #include #include FT_FREETYPE_H -FT_Library library; -FT_Face face; - #include #include #include @@ -21,8 +18,12 @@ FT_Face face; //#define FONT_NAME "-adobe-courier-medium-r-normal--12-120-75-75-m-70-iso8859-1" #define FONT_NAME "6x13" #define FONT_HEIGHT 14 + int font_height, font_width; +FT_Library library; +FT_Face face; + Display *display; int screen; Window win; @@ -34,6 +35,7 @@ XGCValues values; typedef struct { + int advance; int left, top; int rows; int width; @@ -48,19 +50,16 @@ Bitmap bitmap[0x10000]; int utog[0x10000]; void -draw_bitmap (int index, int x, int xoff, int width, - int y, int yoff, int height, int clear) +draw_bitmap (int index, int x, int y) { Bitmap *bmp = bitmap + index; unsigned char *buf = bmp->buf; int i, j; - if (clear) - XClearArea (display, win, x, y, width, height, False); if (buf) { - x += xoff + bmp->left; - y += yoff - bmp->top; + x += bmp->left; + y -= bmp->top; for (i = 0; i < bmp->rows; i++, buf += bmp->pitch) for (j = 0; j < bmp->width; j++) if (buf[j / 8] & (1 << (7 - (j % 8)))) @@ -69,31 +68,6 @@ draw_bitmap (int index, int x, int xoff, int width, } void -draw_big_bitmat (int index, - int x, int xoff, int width, - int y, int yoff, int height) -{ - FT_Bitmap *bmp; - unsigned char *buf; - int i, j; - - FT_Set_Pixel_Sizes (face, 0, PIXEL_SIZE * 4); - if (FT_Load_Glyph (face, index, FT_LOAD_RENDER | FT_LOAD_MONOCHROME)) - return; - - bmp = &face->glyph->bitmap; - buf = bmp->buffer; - XFillRectangle (display, win, gc_rev, x, y, width, height); - XDrawRectangle (display, win, gc_norm, x - 1, y - 1, width + 1, height + 1); - x += xoff + face->glyph->bitmap_left; - y += yoff - face->glyph->bitmap_top; - for (i = 0; i < bmp->rows; i++, buf += bmp->pitch) - for (j = 0; j < bmp->width; j++) - if (buf[j / 8] & (1 << (7 - (j % 8)))) - XDrawPoint (display, win, gc_norm, x + j, y + i); -} - -void quit (char *msg) { fprintf (stderr, "Error by %s\n", msg); @@ -200,6 +174,7 @@ main (int argc, char **argv) int bmpsize; max_glyph_idx = i; + bmp->advance = face->glyph->metrics.horiAdvance >> 6; bmp->left = face->glyph->bitmap_left; bmp->top = face->glyph->bitmap_top; bmp->rows = face->glyph->bitmap.rows; @@ -395,19 +370,17 @@ main (int argc, char **argv) OTF_drive_cmap (otf, &gstring); y = margin + font_height + 1; for (i = 0; i < n_codes; i++, x += max_glyph_width) - draw_bitmap (gstring.glyphs[i].glyph_id, x, -x0, max_glyph_width, - y, -y0, max_glyph_height, 1); + draw_bitmap (gstring.glyphs[i].glyph_id, x - x0, y - y0); OTF_drive_gsub (otf, &gstring, "deva", NULL, NULL); x = margin + font_width * 9; y += max_glyph_height; for (i = 0; i < gstring.used; i++, x += max_glyph_width) - draw_bitmap (gstring.glyphs[i].glyph_id, x, -x0, max_glyph_width, - y, -y0, max_glyph_height, 0); + draw_bitmap (gstring.glyphs[i].glyph_id, x - x0, y - y0); OTF_drive_gpos (otf, &gstring, "deva", NULL, NULL); - x = margin + font_width * 9; - y += max_glyph_height; + x = margin + font_width * 9 - x0; + y += max_glyph_height - y0; for (i = 0; i < gstring.used; i++) { int xoff = 0, yoff = 0; @@ -436,10 +409,8 @@ main (int argc, char **argv) break; } - draw_bitmap (gstring.glyphs[i].glyph_id, x, -x0 + xoff, - max_glyph_width, - y, -y0 + yoff, max_glyph_height, 0); - x += bitmap[gstring.glyphs[i].glyph_id].width; + draw_bitmap (gstring.glyphs[i].glyph_id, x + xoff, y + yoff); + x += bitmap[gstring.glyphs[i].glyph_id].advance; } } @@ -457,10 +428,14 @@ main (int argc, char **argv) y = margin * 2 + rendering_area_height + font_height + 2; for (i = 0; i < rows; i++) for (j = 0; j < cols; j++) - draw_bitmap (first_idx + i * cols + j, - x + (max_glyph_width + 1) * j, -x0, max_glyph_width, - y + (max_glyph_height + 1) * i, - -y0, max_glyph_height, 1); + { + XClearArea (display, win, x + (max_glyph_width + 1) * j, + y + (max_glyph_height + 1) * i, + max_glyph_width, max_glyph_height, False); + draw_bitmap (first_idx + i * cols + j, + x + (max_glyph_width + 1) * j - x0, + y + (max_glyph_height + 1) * i - y0); + } } update_mask = 0; }