From: handa Date: Thu, 22 Jan 2004 08:01:10 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: REL-0-9-1~79 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=67a27c717a44891d264f5f64bc118d0a19a65c9c;p=m17n%2Flibotf.git *** empty log message *** --- diff --git a/.cvsignore b/.cvsignore index 44abe1e..e109556 100644 --- a/.cvsignore +++ b/.cvsignore @@ -1,4 +1,4 @@ -otflib-config +libotf-config libtool configure config.status @@ -7,3 +7,4 @@ autom4te.cache aclocal.m4 Makefile.in Makefile +*.gz diff --git a/example/Makefile.am b/example/Makefile.am index 2dfe880..9cfdb47 100644 --- a/example/Makefile.am +++ b/example/Makefile.am @@ -1,3 +1,27 @@ +# Makefile.am -- example level Makefile for libotf. +# 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 + +## Process this file with Automake to create Makefile.in + bin_PROGRAMS = otfdump otfdraw otfview otflist otftobdf INCLUDES = `freetype-config --cflags` diff --git a/example/otfview.c b/example/otfview.c index 392729e..45750a4 100644 --- a/example/otfview.c +++ b/example/otfview.c @@ -24,6 +24,7 @@ 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. @@ -76,6 +77,7 @@ BitmapRec bitmap[0x10000]; int render_width, render_height; Pixmap raw_pixmap, seq_pixmap, gsub_pixmap, gpos_pixmap; +Pixmap none_pixmap; FT_Face face; @@ -94,7 +96,8 @@ int glyph_index; struct { int n_glyphs; int glyphs[64]; -} glyph_rec; + int codes[64]; +} glyph_rec; OTF *otf; @@ -156,14 +159,14 @@ update_glyph_area () 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); @@ -183,6 +186,7 @@ update_render_area () 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, @@ -190,6 +194,19 @@ update_render_area () 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); @@ -259,10 +276,11 @@ RenderProc (Widget w, XtPointer client_data, XtPointer call_data) { 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 (); } @@ -523,14 +541,57 @@ main (int argc, char **argv) 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; @@ -559,19 +620,6 @@ main (int argc, char **argv) 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); diff --git a/libotf-config.in b/libotf-config.in new file mode 100644 index 0000000..a82f92c --- /dev/null +++ b/libotf-config.in @@ -0,0 +1,61 @@ +#!/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. diff --git a/otflib-config.in b/otflib-config.in deleted file mode 100644 index d56c895..0000000 --- a/otflib-config.in +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -# libotf-config -- helper script for the m17n library. -*- coding: euc-jp; -*- -# Copyright (C) 2003 -# National Institute of Advanced Industrial Science and Technology (AIST) -# Registration Number H15PRO112 -# 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