#define DEFAULT_FONT_NAME "6x13"
XFontStruct *font;
#define FONT_HEIGHT (font->ascent + font->descent)
+#define FONT_DESCENT (font->descent)
XtAppContext context;
/* Widget structure.
- +--- frame (form) ------------------+
- | +--- command_area (box) --------+ |
- | | quit charmap ... | |
- | +-------------------------------+ |
- | +---- navi_area (box) ----------+ |
- | | PREV prev label next NEXT | |
- | +-------------------------------+ |
- | +--- glyph_area (form) ---------+ |
- | | glyph[0] ... glyph[15] | |
- | | ... ... | |
- | | glyph[112] ... glyph[127]| |
- | +-------------------------------+ |
- | +--- render_area (form) --------+ |
- | | clear | |
- | | +--- raw (box) -------------+ | |
- | | | raw_label raw_image | | |
- | | +--- seq (box) -------------+ | |
- | | | seq_label seq_image | | |
- | | +--- gsub (box) ------------+ | |
- | | | gsub_label gsub_image | | |
- | | +--- gpos (box) ------------+ | |
- | | | gpos_label gpos_image | | |
- | | +---------------------------+ | |
- | +-------------------------------+ |
- +-----------------------------------+ */
+ +--- frame (form) -------------------------+
+ | +--- command_area (box) ---------------+ |
+ | | quit charmap ... | |
+ | +--------------------------------------+ |
+ | +---- navi_area (box) -----------------+ |
+ | | FIRST PREV prev label next NEXT LAST | |
+ | +--------------------------------------+ |
+ | +--- glyph_area (form) ----------------+ |
+ | | glyph[0] ... glyph[15] | |
+ | | ... ... | |
+ | | glyph[112] ... glyph[127]| |
+ | +--------------------------------------+ |
+ | +--- render_area (form) ---------------+ |
+ | | clear | |
+ | | +--- raw (box) --------------------+ | |
+ | | | raw_label raw_image | | |
+ | | +--- seq (box) --------------------+ | |
+ | | | seq_label seq_image | | |
+ | | +--- gsub (box) -------------------+ | |
+ | | | gsub_label gsub_image | | |
+ | | +--- gpos (box) -------------------+ | |
+ | | | gpos_label gpos_image | | |
+ | | +----------------------------------+ | |
+ | +--------------------------------------+ |
+ +------------------------------------------+ */
Widget shell, frame;
Widget command_area, quit, *charmap;
-Widget navi_area, PREV, prev, label, next, NEXT;
+Widget navi_area, FIRST, PREV, prev, label, next, NEXT, LAST;
Widget glyph_area, glyph[128];
Widget render_area, clear, raw, seq, gsub, gpos;
Widget raw_label, raw_image, seq_label, seq_image;
int glyph_char[128];
Display *display;
-GC gc, gc_set, gc_or;
+GC gc, gc_set, gc_or, gc_inv;
typedef struct {
Pixmap pixmap;
int err = FT_Load_Glyph (face, index, FT_LOAD_RENDER | FT_LOAD_MONOCHROME);
XImage ximage;
Pixmap pixmap;
+ int height = glyph_height + 1 + FONT_HEIGHT;
+ char index_buf[5];
if (err)
{
ximage.bytes_per_line = face->glyph->bitmap.pitch;
XInitImage (&ximage);
pixmap = XCreatePixmap (display, DefaultRootWindow (display),
- glyph_width, glyph_height, 1);
- XFillRectangle (display, pixmap, gc, 0, 0, glyph_width, glyph_height);
+ glyph_width, height, 1);
+ XFillRectangle (display, pixmap, gc, 0, 0, glyph_width, height);
XPutImage (display, pixmap, gc, &ximage, 0, 0,
glyph_x + face->glyph->bitmap_left,
glyph_y - face->glyph->bitmap_top,
ximage.width, ximage.height);
+ sprintf (index_buf, "%04X", index);
+ XDrawLine (display, pixmap, gc_inv,
+ 0, glyph_height + 1, glyph_width, glyph_height + 1);
+ XDrawString (display, pixmap, gc_inv,
+ (glyph_width - XTextWidth (font, index_buf, 4)) / 2,
+ height - FONT_DESCENT, index_buf, 4);
bitmap[index].pixmap = pixmap;
bitmap[index].width = ximage.width;
bitmap[index].height = ximage.height;
{
int old_glyph_index = glyph_index;
- if ((int) client_data == -2 && glyph_index > 0)
+ if ((int) client_data == -3 && glyph_index > 0)
+ glyph_index = 0;
+ else if ((int) client_data == -2 && glyph_index > 0)
glyph_index = (glyph_index - 1) & 0xF000;
else if ((int) client_data == -1 && glyph_index > 0)
glyph_index -= 0x80;
glyph_index += 0x80;
else if ((int) client_data == 2 && glyph_index < 0xF000)
glyph_index = (glyph_index + 0x1000) & 0xF000;
+ else if ((int) client_data == 3 && glyph_index < 0xF000)
+ glyph_index = 0xFF80;
if (glyph_index != old_glyph_index)
update_glyph_area ();
}
create_widgets ()
{
String quit_action = "<KeyPress>q: set() notify() unset()";
+ String FIRST_action = "~Shift<KeyPress>f: set() notify() unset()";
String PREV_action = "Shift<KeyPress>p: set() notify() unset()";
String prev_action = "~Shift<KeyPress>p: set() notify() unset()";
String next_action = "~Shift<KeyPress>n: set() notify() unset()";
String NEXT_action = "Shift<KeyPress>n: set() notify() unset()";
+ String LAST_action = "~Shift<KeyPress>l: set() notify() unset()";
Arg arg[10];
int i, j;
+ int glyph_widget_height;
frame = XtCreateManagedWidget ("frame", formWidgetClass, shell, NULL, 0);
XtSetArg (arg[0], XtNleft, XawChainLeft);
XtAddCallback (charmap[i + 1], XtNcallback, CharmapProc, (XtPointer) i);
}
- XtSetArg (arg[0], XtNlabel, "-0x1000 (P)");
+ XtSetArg (arg[0], XtNlabel, " |< (f)");
+ XtSetArg (arg[1], XtNaccelerators, XtParseAcceleratorTable (FIRST_action));
+ FIRST = XtCreateManagedWidget ("FIRST", commandWidgetClass,
+ navi_area, arg, 2);
+ XtAddCallback (FIRST, XtNcallback, GlyphProc, (XtPointer) -3);
+ XtSetArg (arg[0], XtNlabel, "<< (P)");
XtSetArg (arg[1], XtNaccelerators, XtParseAcceleratorTable (PREV_action));
PREV = XtCreateManagedWidget ("PREV", commandWidgetClass,
navi_area, arg, 2);
XtAddCallback (PREV, XtNcallback, GlyphProc, (XtPointer) -2);
- XtSetArg (arg[0], XtNlabel, "-0x80 (p)");
+ XtSetArg (arg[0], XtNlabel, "< (p)");
XtSetArg (arg[1], XtNaccelerators, XtParseAcceleratorTable (prev_action));
prev = XtCreateManagedWidget ("prev", commandWidgetClass,
navi_area, arg, 2);
XtSetArg (arg[0], XtNlabel, " 0000 ");
label = XtCreateManagedWidget ("label", labelWidgetClass,
navi_area, arg, 1);
- XtSetArg (arg[0], XtNlabel, "+0x80 (n)");
+ XtSetArg (arg[0], XtNlabel, "> (n)");
XtSetArg (arg[1], XtNaccelerators, XtParseAcceleratorTable (next_action));
next = XtCreateManagedWidget ("next", commandWidgetClass,
navi_area, arg, 2);
XtAddCallback (next, XtNcallback, GlyphProc, (XtPointer) 1);
- XtSetArg (arg[0], XtNlabel, "+0x1000 (N)");
+ XtSetArg (arg[0], XtNlabel, ">> (N)");
XtSetArg (arg[1], XtNaccelerators, XtParseAcceleratorTable (NEXT_action));
NEXT = XtCreateManagedWidget ("NEXT", commandWidgetClass,
navi_area, arg, 2);
XtAddCallback (NEXT, XtNcallback, GlyphProc, (XtPointer) 2);
+ XtSetArg (arg[0], XtNlabel, ">| (l)");
+ XtSetArg (arg[1], XtNaccelerators, XtParseAcceleratorTable (LAST_action));
+ LAST = XtCreateManagedWidget ("LAST", commandWidgetClass,
+ navi_area, arg, 2);
+ XtAddCallback (LAST, XtNcallback, GlyphProc, (XtPointer) 3);
+ glyph_widget_height = glyph_height + 1 + FONT_HEIGHT;
XtSetArg (arg[0], XtNleft, XawChainLeft);
XtSetArg (arg[1], XtNright, XawChainLeft);
XtSetArg (arg[2], XtNtop, XawChainTop);
int num_args = 4;
XtSetArg (arg[num_args], XtNwidth, glyph_width), num_args++;
- XtSetArg (arg[num_args], XtNheight, glyph_height), num_args++;
+ XtSetArg (arg[num_args], XtNheight, glyph_widget_height), num_args++;
if (j > 0)
XtSetArg (arg[num_args], XtNfromHoriz, glyph[k - 1]), num_args++;
if (i > 0)
XtSetArg (arg[num_args], XtNfromVert, glyph[k - 16]), num_args++;
+ XtSetArg (arg[num_args], XtNinternalWidth, 0), num_args++;
glyph[k] = XtCreateManagedWidget ("glyph", commandWidgetClass,
glyph_area, arg, num_args);
XtAddCallback (glyph[k], XtNcallback, RenderProc, (XtPointer) k);
display = XtDisplay (shell);
display_width = DisplayWidth (display,
XScreenNumberOfScreen (XtScreen (shell)));
+ font = XLoadQueryFont (display, DEFAULT_FONT_NAME);
+ if (! font)
+ font = XLoadQueryFont (display, "fixed");
if (argc != 2)
FATAL_ERROR ("%s\n", "Usage: otfview [ X-OPTION ... ] OTF-FILE");
gc_set = XCreateGC (display, raw_pixmap, valuemask, &values);
values.function = GXor;
gc_or = XCreateGC (display, raw_pixmap, valuemask, &values);
+ values.function = GXcopyInverted;
+ gc_inv = XCreateGC (display, raw_pixmap, valuemask, &values);
}
for (i = 0; i < 0x10000; i++)