From 65503264c778bee5640b1cafd2356ee26ea54976 Mon Sep 17 00:00:00 2001 From: handa Date: Tue, 8 Jul 2003 13:04:59 +0000 Subject: [PATCH] *** empty log message *** --- example/Makefile.am | 6 ------ example/otfview.c | 51 +++++++++++++++++++++++++++++++++++---------------- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/example/Makefile.am b/example/Makefile.am index 73a7aa3..e38ebff 100644 --- a/example/Makefile.am +++ b/example/Makefile.am @@ -19,9 +19,3 @@ otfdraw_LDFLAGS = `freetype-config --libs` ${X_LIBS} ${X_PRE_LIBS} -lX11 -ldl ${ otfview_SOURCE = otfview.c otfview_LDADD = ${CommonLDADD} otfview_LDFLAGS = `freetype-config --libs` ${X_LIBS} ${X_PRE_LIBS} -lX11 -ldl ${CommonLDFLAGS} - -# We should not install any programs in this directory. - -install-binPROGRAMS: - -uninstall-binPROGRAMS: diff --git a/example/otfview.c b/example/otfview.c index aae4f94..626bce8 100644 --- a/example/otfview.c +++ b/example/otfview.c @@ -15,7 +15,6 @@ #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 @@ -52,9 +51,14 @@ int utog[0x10000]; 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) { @@ -97,9 +101,9 @@ read_unicode_seq (char *filename, int *code) 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 @@ -109,6 +113,7 @@ main (int argc, char **argv) int unicode_seq[256]; int n_codes = 0; int pixel_size = PIXEL_SIZE; + int raw_mode = 0; /* Window structure. @@ -144,13 +149,19 @@ main (int argc, char **argv) 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; + } } { @@ -159,6 +170,10 @@ main (int argc, char **argv) if (p && sscanf (p, "%d", &n) == 1) pixel_size = n; + + p = getenv ("RAW_MODE"); + if (p) + raw_mode = 1; } err = FT_Init_FreeType (&library); @@ -172,7 +187,7 @@ main (int argc, char **argv) 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++) @@ -185,7 +200,6 @@ main (int argc, char **argv) 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; @@ -308,7 +322,7 @@ main (int argc, char **argv) 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; @@ -370,7 +384,7 @@ main (int argc, char **argv) } } - if (update_mask & UPDATE_RENDERING) + if (otf && update_mask & UPDATE_RENDERING) { x = margin + font_width * 9; y = margin + font->ascent; @@ -444,10 +458,15 @@ main (int argc, char **argv) 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); } -- 1.7.10.4