void
draw_bitmap (int index, int x, int y)
{
- Bitmap *bmp;
- unsigned char *buf;
+ Bitmap *bmp = bitmap + index;
+ unsigned char *buf = bmp->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)
{
}
+typedef struct
+{
+ int platform_id;
+ int encoding_id;
+ int index;
+ char name[256];
+} CharmapRec;
+
int
main (int argc, char **argv)
{
int first_idx;
int update_mask;
#define UPDATE_RENDERING 1
-#define UPDATE_BITMAP 2
+#define UPDATE_CHARMAP 2
+#define UPDATE_BITMAP 3
OTF_GlyphString gstring;
OTF_Glyph *g;
int unicode_seq[256];
int n_codes = 0;
int pixel_size = PIXEL_SIZE;
- int raw_mode = 0;
+ CharmapRec *charmap_rec;
+ int charmap_index = -1;
+ char charmap_line[256];
/* Window structure.
| | GSUB: ... | |
| | GPOS: ... | |
| +---------------------+ |
+ | +--- charmap area ----+ |
+ | | | |
+ | +---------------------+ |
| +--- bitmap area -----+ |
| | | |
| | | |
int win_width, win_height;
int cols = 16, rows = 8;
int max_glyph_width, max_glyph_height;
- int inner_width, rendering_area_height, bitmap_area_height;
+ int inner_width, rendering_area_height;
+ int charmap_area_height, bitmap_area_height;
int x, y, x0, y0, x1, y1;
char buf[1024];
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);
+ charmap_rec = alloca (sizeof (CharmapRec) * face->num_charmaps);
+ strcpy (charmap_line, "raw");
+ for (i = 0; i < face->num_charmaps; i++)
+ {
+ strcat (charmap_line, " ");
+ charmap_rec[i].index = strlen (charmap_line);
+ charmap_rec[i].platform_id = face->charmaps[i]->platform_id;
+ charmap_rec[i].encoding_id = face->charmaps[i]->encoding_id;
+ sprintf (charmap_rec[i].name, "%d-%d",
+ charmap_rec[i].platform_id, charmap_rec[i].encoding_id);
+ if (face->charmaps[i]->platform_id == 0
+ || (face->charmaps[i]->platform_id == 3
+ && face->charmaps[i]->encoding_id == 1))
+ strcat (charmap_rec[i].name, " (unicode)");
+ else if (face->charmaps[i]->platform_id == 1
+ && face->charmaps[i]->encoding_id == 0)
+ strcat (charmap_rec[i].name, " (apple-roman)");
+ strcat (charmap_line, charmap_rec[i].name);
+ }
+ strcat (charmap_line, " ");
+
memset (utog, 0, sizeof (utog));
x0 = x1 = y0 = y1 = 0;
for (i = 0; i < 0x10000; i++)
inner_width = (max_glyph_width + 1) * cols + font_width * 4 + 2;
rendering_area_height= (max_glyph_height + 1) * 3 + font_height;
+ charmap_area_height = font_height + 2;
bitmap_area_height = (max_glyph_height + 1) * rows + font_height + 2;
win_width = inner_width + margin * 2;
- win_height = rendering_area_height + bitmap_area_height + margin * 3;
-
+ win_height = (rendering_area_height
+ + charmap_area_height
+ + bitmap_area_height
+ + margin * 4);
win = XCreateSimpleWindow (display, RootWindow (display, screen),
0, 0, win_width, win_height, 1,
BlackPixel (display, screen),
int x = event.xbutton.x;
int y = event.xbutton.y;
- if (margin <= x && x < margin + inner_width
- && margin + 1 <= y && y < margin + 1 + font_height)
+ if (x < margin || x >= margin + inner_width)
+ break;
+ if (margin + rendering_area_height + 3 <= y
+ && y < margin + rendering_area_height + 3 + font_height)
+ {
+ charmap_index++;
+ if (charmap_index >= face->num_charmaps)
+ charmap_index = -1;
+ update_mask = UPDATE_CHARMAP | UPDATE_BITMAP;
+ goto redraw;
+ }
+ if (margin + 1 <= y && y < margin + 1 + font_height)
{
n_codes = read_unicode_seq (argv[2], unicode_seq);
- update_mask = UPDATE_RENDERING;
+
goto redraw;
}
}
continue;
redraw:
- if (update_mask == (UPDATE_RENDERING | UPDATE_BITMAP))
+ if (update_mask == (UPDATE_RENDERING | UPDATE_CHARMAP | UPDATE_BITMAP))
{
XClearWindow (display, win);
x = margin;
y += max_glyph_height + 1;
XDrawImageString (display, win, gc_norm, x, y, " GPOS: ", 9);
- y = margin * 2 + rendering_area_height;
+ y = margin * 3 + rendering_area_height + charmap_area_height;
XDrawLine (display, win, gc_norm, x, y, x + inner_width - 1, y);
y += font_height + 1;
for (i = 0; i <= rows; i++, y += max_glyph_height + 1)
XDrawLine (display, win, gc_norm, x, y, x + inner_width - 1, y);
- y = margin * 2 + rendering_area_height;
+ y = margin * 3 + rendering_area_height + charmap_area_height;
XDrawLine (display, win, gc_norm, x, y,
x, y + bitmap_area_height - 1);
x += font_width * 4 + 1;
}
}
+ if (update_mask & UPDATE_CHARMAP)
+ {
+ char *p = charmap_line, *pend;
+
+ x = margin + 1;
+ y = margin * 3 + rendering_area_height + font->ascent + 1;
+ XDrawImageString (display, win, gc_norm, x, y, charmap_line,
+ strlen (charmap_line));
+ if (charmap_index == -1)
+ pend = p + 3;
+ else
+ {
+ p += charmap_rec[charmap_index].index;
+ pend = p + strlen (charmap_rec[charmap_index].name);
+ FT_Set_Charmap (face, face->charmaps[charmap_index]);
+ }
+ x += font_width * (p - charmap_line);
+ *pend = '\0';
+ XDrawImageString (display, win, gc_rev, x, y, p, strlen (p));
+ *pend = ' ';
+ }
+
if (update_mask & UPDATE_BITMAP)
{
x = margin + 1;
XDrawImageString (display, win, gc_norm, x, y, buf, 4);
}
x += font_width * 4 + 1;
- y = margin * 2 + rendering_area_height + font_height + 2;
+ y = (margin * 3 + rendering_area_height + charmap_area_height
+ + font_height + 2);
for (i = 0; i < rows; i++)
for (j = 0; j < cols; j++)
{
XClearArea (display, win, x + (max_glyph_width + 1) * j,
y + (max_glyph_height + 1) * i,
max_glyph_width, max_glyph_height, False);
- if (! raw_mode)
+ if (charmap_index >= 0)
index = FT_Get_Char_Index (face, (FT_ULong) index);
draw_bitmap (index,