#define PIXEL_SIZE 40
-//#define FONT_NAME "-adobe-courier-medium-r-normal--12-120-75-75-m-70-iso8859-1"
#define FONT_NAME "6x13"
#define FONT_HEIGHT 14
void
draw_bitmap (int index, int x, int y)
{
- Bitmap *bmp = bitmap + index;
- unsigned char *buf = bmp->buf;
+ Bitmap *bmp;
+ unsigned char *buf;
int i, j;
+ unsigned code = FT_Get_Char_Index (face, (FT_ULong) index);
+ //unsigned code = index;
+
+ bmp = bitmap + code;
+ buf = bmp->buf;
if (buf)
{
int
main (int argc, char **argv)
{
- OTF *otf;
+ OTF *otf = NULL;
int err;
- int i, j, max_glyph_idx;
+ int i, j;
int first_idx;
int update_mask;
#define UPDATE_RENDERING 1
int unicode_seq[256];
int n_codes = 0;
int pixel_size = PIXEL_SIZE;
+ int raw_mode = 0;
/* Window structure.
exit (1);
}
- otf = OTF_open (argv[1]);
- if (! otf
- || OTF_get_table (otf, "head") < 0
- || OTF_get_table (otf, "cmap") < 0)
+ if (strstr (argv[1], ".ttf")
+ || strstr (argv[1], ".TTF")
+ || strstr (argv[1], ".otf")
+ || strstr (argv[1], ".OTF"))
{
- OTF_perror ("otfview");
- exit (1);
+ otf = OTF_open (argv[1]);
+ if (! otf
+ || OTF_get_table (otf, "head") < 0
+ || OTF_get_table (otf, "cmap") < 0)
+ {
+ OTF_perror ("otfview");
+ otf = NULL;
+ }
}
{
if (p && sscanf (p, "%d", &n) == 1)
pixel_size = n;
+
+ p = getenv ("RAW_MODE");
+ if (p)
+ raw_mode = 1;
}
err = FT_Init_FreeType (&library);
err = FT_Set_Pixel_Sizes (face, 0, pixel_size);
if (err)
quit ("FT_Set_Char_Size");
-
+ err = FT_Select_Charmap (face, FT_ENCODING_APPLE_ROMAN);
memset (utog, 0, sizeof (utog));
x0 = x1 = y0 = y1 = 0;
for (i = 0; i < 0x10000; i++)
Bitmap *bmp = bitmap + i;
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;
goto finish;
if (buf[0] == 'n' || buf[0] == ' ')
{
- if (first_idx + cols * rows <= max_glyph_idx)
+ if (first_idx + cols * rows < 0x10000)
{
first_idx += cols * rows;
update_mask |= UPDATE_BITMAP;
}
}
- if (update_mask & UPDATE_RENDERING)
+ if (otf && update_mask & UPDATE_RENDERING)
{
x = margin + font_width * 9;
y = margin + font->ascent;
for (i = 0; i < rows; i++)
for (j = 0; j < cols; j++)
{
+ unsigned index = first_idx + i * cols + j;
+
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,
+ if (! raw_mode)
+ index = FT_Get_Char_Index (face, (FT_ULong) index);
+
+ draw_bitmap (index,
x + (max_glyph_width + 1) * j - x0,
y + (max_glyph_height + 1) * i - y0);
}