XFontStruct *font;
#define FONT_HEIGHT (font->ascent + font->descent)
#define FONT_DESCENT (font->descent)
+#define FONT_WIDTH (font->max_bounds.width)
XtAppContext context;
/* Widget structure.
int render_width, render_height;
Pixmap raw_pixmap, seq_pixmap, gsub_pixmap, gpos_pixmap;
+Pixmap none_pixmap;
FT_Face face;
struct {
int n_glyphs;
int glyphs[64];
-} glyph_rec;
+ int codes[64];
+} glyph_rec;
OTF *otf;
for (i = 0; i < 128; i++)
{
int index = glyph_index + i;
- int num_args = 0;
if (charmap_index >= 0)
index = FT_Get_Char_Index (face, (FT_ULong) index);
- XtSetArg (arg[num_args], XtNbitmap, bitmap[index].pixmap), num_args++;
- if (! bitmap[index].pixmap)
- XtSetArg (arg[num_args], XtNlabel, "none"), num_args++;
- XtSetValues (glyph[i], arg, num_args);
+ if (bitmap[index].pixmap)
+ XtSetArg (arg[0], XtNbitmap, bitmap[index].pixmap);
+ else
+ XtSetArg (arg[0], XtNbitmap, none_pixmap);
+ XtSetValues (glyph[i], arg, 1);
}
sprintf (buf, " %04X-%04X ", glyph_index, glyph_index + 0x7F);
for (i = 0, x = glyph_x; i < glyph_rec.n_glyphs; i++)
{
BitmapRec *bmp = bitmap + glyph_rec.glyphs[i];
+ char buf[5];
XCopyArea (display, bmp->pixmap, raw_pixmap, gc,
0, 0, glyph_width, glyph_height,
XDrawRectangle (display, raw_pixmap, gc_set,
(glyph_width + 1) * i, 0,
glyph_width + 1, glyph_height + 1);
+ XDrawLine (display, raw_pixmap, gc_set,
+ (glyph_width + 1) * i + 1 + glyph_x, 1,
+ (glyph_width + 1) * i + 1 + glyph_x, glyph_height + 1);
+ XDrawLine (display, raw_pixmap, gc_set,
+ (glyph_width + 1) * i + 1 + glyph_x + bmp->advance, 1,
+ (glyph_width + 1) * i + 1 + glyph_x + bmp->advance,
+ glyph_height + 1);
+
+ sprintf (buf, "%04X", glyph_rec.codes[i]);
+ XDrawString (display, raw_pixmap, gc_inv,
+ (glyph_width + 1) * i + 1
+ + (glyph_width - XTextWidth (font, buf, 4)) / 2,
+ glyph_height + 2 + FONT_HEIGHT, buf, 4);
XCopyArea (display, bmp->pixmap, seq_pixmap, gc_or,
glyph_x + bmp->x, glyph_y + bmp->y, bmp->width, bmp->height,
x + bmp->x, glyph_y + bmp->y);
{
int index = glyph_index + (int) client_data;
+ if (charmap_index >= 0)
+ index = FT_Get_Char_Index (face, (FT_ULong) index);
if (bitmap[index].pixmap)
{
- if (charmap_index >= 0)
- index = FT_Get_Char_Index (face, (FT_ULong) index);
+ glyph_rec.codes[glyph_rec.n_glyphs] = glyph_index + (int) client_data;
glyph_rec.glyphs[glyph_rec.n_glyphs++] = index;
update_render_area ();
}
glyph_width = ((face->bbox.xMax - face->bbox.xMin)
* pixel_size / face->units_per_EM);
}
+ if (glyph_width < FONT_WIDTH * 4)
+ glyph_width = FONT_WIDTH * 4;
+
glyph_height = ((face->bbox.yMax - face->bbox.yMin)
* pixel_size / face->units_per_EM);
glyph_x = - (face->bbox.xMin * pixel_size / face->units_per_EM);
- glyph_y = face->bbox.yMax * pixel_size / face->units_per_EM;
+ glyph_y = face->ascender * pixel_size / face->units_per_EM;
+
+ for (i = 0; i < 0x10000; i++)
+ if (FT_Load_Glyph (face, i, FT_LOAD_RENDER | FT_LOAD_MONOCHROME) == 0)
+ {
+ if (glyph_x < - face->glyph->bitmap_left)
+ glyph_x = - face->glyph->bitmap_left;
+ if (glyph_y < face->glyph->bitmap_top)
+ glyph_y = face->glyph->bitmap_top;
+ if (glyph_width
+ < glyph_x + face->glyph->bitmap_left + face->glyph->bitmap.width)
+ glyph_width
+ = glyph_x + face->glyph->bitmap_left + face->glyph->bitmap.width;
+ if (glyph_height
+ < glyph_y - face->glyph->bitmap_top + face->glyph->bitmap.rows)
+ glyph_height
+ = glyph_y - face->glyph->bitmap_top + face->glyph->bitmap.rows;
+ }
+
+ none_pixmap = XCreatePixmap (display, DefaultRootWindow (display),
+ glyph_width, glyph_height + 1 + FONT_HEIGHT, 1);
+
+ {
+ unsigned long valuemask = GCFunction | GCLineWidth;
+ XGCValues values;
+
+ gc = XCreateGC (display, none_pixmap, (unsigned long) 0, NULL);
+ values.function = GXset;
+ values.line_width = 1;
+ gc_set = XCreateGC (display, none_pixmap, valuemask, &values);
+ values.function = GXor;
+ gc_or = XCreateGC (display, none_pixmap, valuemask, &values);
+ values.function = GXcopyInverted;
+ gc_inv = XCreateGC (display, none_pixmap, valuemask, &values);
+ }
+
+ XFillRectangle (display, none_pixmap, gc, 0, 0,
+ glyph_width, glyph_height + 1 + FONT_HEIGHT);
+ XDrawString (display, none_pixmap, gc_inv,
+ (glyph_width - XTextWidth (font, "none", 4)) / 2,
+ glyph_height / 2, "none", 4);
render_width = (glyph_width + 1) * 15 + 1;
- render_height = glyph_height + 2;
+ render_height = glyph_height + FONT_HEIGHT + 2;
charmap_rec[0].platform_id = -1;
charmap_rec[0].encoding_id = -1;
render_width, render_height, 1);
gpos_pixmap = XCreatePixmap (display, DefaultRootWindow (display),
render_width, render_height, 1);
- {
- unsigned long valuemask = GCFunction | GCLineWidth;
- XGCValues values;
-
- gc = XCreateGC (display, raw_pixmap, (unsigned long) 0, NULL);
- values.function = GXset;
- values.line_width = 1;
- 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++)
create_pixmap (pixel_size, i);
--- /dev/null
+#!/bin/sh
+# libotf-config -- helper script for libotf.
+# Copyright (C) 2003, 2004
+# National Institute of Advanced Industrial Science and Technology (AIST)
+# Registration Number H15PRO167
+# See the end for copying conditions.
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+
+help ()
+{
+ echo "Usage: otflib-config [--version | --libs | --cflags ]"
+}
+
+if test $# -eq 0; then
+ help 1>&2
+ exit 0
+fi
+
+case $1 in
+--version)
+ echo "@PACKAGE_VERSION@";;
+
+--libs)
+ if test "@libdir@" != "/usr/lib"; then
+ echo "-L@libdir@ -lotf"
+ else
+ echo "-lotf"
+ fi;;
+
+--cflags)
+ if test "@includedir@" != "/usr/include"; then
+ echo "-I@includedir@"
+ fi;;
+
+*)
+ help
+ exit 1;;
+esac
+
+# Copyright (C) 2003, 2004
+# National Institute of Advanced Industrial Science and Technology (AIST)
+# Registration Number H15PRO167
+
+# This file is part of libotf.
+
+# Libotf is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published
+# by the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+
+# Libotf is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+# License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library, in a file named COPYING; if not,
+# write to the Free Software Foundation, Inc., 59 Temple Place, Suite
+# 330, Boston, MA 02111-1307, USA.