From: handa Date: Tue, 7 Feb 2006 12:50:14 +0000 (+0000) Subject: (DumpProc): Fix calculation of x/y offsets. X-Git-Tag: REL-0-9-5~32 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a104e19fa44b620b17e88f51c57c215b49c1231;p=m17n%2Flibotf.git (DumpProc): Fix calculation of x/y offsets. --- diff --git a/example/otfview.c b/example/otfview.c index 87b67c9..9d2bb5e 100644 --- a/example/otfview.c +++ b/example/otfview.c @@ -516,6 +516,24 @@ DumpProc (Widget w, XtPointer client_data, XtPointer call_data) int index = (glyph_index / 0x100) * 0x100; float scale; + g_width = face->bbox.xMax - face->bbox.xMin; + g_height = face->bbox.yMax - face->bbox.yMin; + if (g_width > g_height) + { + scale = g_width * size; + g_x = face->bbox.xMin * unit / g_width; + g_y = face->bbox.yMin * unit / g_width; + } + else + { + scale = g_height * size; + g_x = face->bbox.xMin * unit / g_height; + g_y = face->bbox.yMin * unit / g_height; + } + scale /= face->units_per_EM; + + FT_Set_Pixel_Sizes (face, 0, size); + sprintf (name, "%s-%04X.ps", face->family_name, index); printf ("Writing %s ... ", name); fflush (stdout); @@ -557,14 +575,6 @@ DumpProc (Widget w, XtPointer client_data, XtPointer call_data) fprintf (fp, "%s\n", "%%EndProlog"); fprintf (fp, "DrawTitle DrawFrame\n"); - g_width = face->bbox.xMax - face->bbox.xMin; - g_height = face->bbox.yMax - face->bbox.yMin; - scale = ((g_width > g_height) ? g_width : g_height) * size; - scale /= face->units_per_EM; - g_x = face->bbox.xMin * scale / unit / face->units_per_EM; - g_y = face->bbox.yMin * scale / unit / face->units_per_EM; - - FT_Set_Pixel_Sizes (face, 0, size); for (i = 0; i < 16; i++) for (j = 0; j < 16; j++, index++) { @@ -588,7 +598,7 @@ DumpProc (Widget w, XtPointer client_data, XtPointer call_data) unit, unit); fprintf (fp, "%d %d true [%f 0 0 %f %d %d]\n", width * 8, face->glyph->bitmap.rows, - scale, -scale, face->glyph->bitmap_left, + scale, -scale, -face->glyph->bitmap_left, face->glyph->bitmap_top); fprintf (fp, "{< "); for (k = 0; k < face->glyph->bitmap.rows;