#include <ft2build.h>
#include FT_FREETYPE_H
-FT_Library library;
-FT_Face face;
-
#include <X11/Xlib.h>
#include <X11/keysym.h>
#include <X11/Xutil.h>
//#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;
typedef struct
{
+ int advance;
int left, top;
int rows;
int width;
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))))
}
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);
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;
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;
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;
}
}
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;
}