From bcc8eaac3f589a9026e2eab5673b28639708116b Mon Sep 17 00:00:00 2001 From: handa Date: Wed, 15 Feb 2006 02:14:25 +0000 Subject: [PATCH] (DumpProc): Fix handling of non-existing glyph. (create_otf_script_widgets): Fix typo; gsub -> gpos. --- example/otfview.c | 75 ++++++++++++++++++++++++++--------------------------- 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/example/otfview.c b/example/otfview.c index 9d2bb5e..5a61b85 100644 --- a/example/otfview.c +++ b/example/otfview.c @@ -584,44 +584,43 @@ DumpProc (Widget w, XtPointer client_data, XtPointer call_data) idx = FT_Get_Char_Index (face, (FT_ULong) index); else idx = index; - if (FT_Load_Glyph (face, idx, FT_LOAD_RENDER | FT_LOAD_MONOCHROME) == 0) + if (idx > 0 + && FT_Load_Glyph (face, idx, FT_LOAD_RENDER | FT_LOAD_MONOCHROME) == 0 + && face->glyph->bitmap.rows > 0 + && face->glyph->bitmap.width > 0) { - if (face->glyph->bitmap.rows > 0 - && face->glyph->bitmap.width > 0) + unsigned char *p = face->glyph->bitmap.buffer; + int width = (face->glyph->bitmap.width - 1) / 8 + 1; + + fprintf (fp, "gsave %f %f translate %d %d scale 0 0 moveto\n", + xoff + (unit + margin * 2) * j + margin - g_x, + yoff + (unit + label_height + margin * 2) * (15 - i) + label_height + margin - g_y, + 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, + face->glyph->bitmap_top); + fprintf (fp, "{< "); + for (k = 0; k < face->glyph->bitmap.rows; + k++, p += face->glyph->bitmap.pitch) { - unsigned char *p = face->glyph->bitmap.buffer; - int width = (face->glyph->bitmap.width - 1) / 8 + 1; - - fprintf (fp, "gsave %f %f translate %d %d scale 0 0 moveto\n", - xoff + (unit + margin * 2) * j + margin - g_x, - yoff + (unit + label_height + margin * 2) * (15 - i) + label_height + margin - g_y, - 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, - face->glyph->bitmap_top); - fprintf (fp, "{< "); - for (k = 0; k < face->glyph->bitmap.rows; - k++, p += face->glyph->bitmap.pitch) - { - for (l = 0; l < width; l++) - fprintf (fp, "%02X", p[l]); - fprintf (fp, "\n"); - } - fprintf (fp, ">} imagemask grestore\n"); - } - else - { - int boxsize = unit + margin * 2; - - fprintf (fp, "gsave 0 setlinewidth %d %d translate\n", - xoff + boxsize * j, - yoff + (boxsize + label_height) * (15 - i) + label_height); - fprintf (fp, "0 0 moveto %d %d lineto stroke\n", - boxsize, boxsize); - fprintf (fp, "0 %d moveto %d 0 lineto stroke grestore\n", - boxsize, boxsize); + for (l = 0; l < width; l++) + fprintf (fp, "%02X", p[l]); + fprintf (fp, "\n"); } + fprintf (fp, ">} imagemask grestore\n"); + } + else + { + int boxsize = unit + margin * 2; + + fprintf (fp, "gsave 0 setlinewidth %d %d translate\n", + xoff + boxsize * j, + yoff + (boxsize + label_height) * (15 - i) + label_height); + fprintf (fp, "0 0 moveto %d %d lineto stroke\n", + boxsize, boxsize); + fprintf (fp, "0 %d moveto %d 0 lineto stroke grestore\n", + boxsize, boxsize); } } fprintf (fp, "showpage\n"); @@ -941,7 +940,7 @@ create_otf_script_widgets (Widget prev) n += otf->gsub->ScriptList.Script[i].LangSysCount + 1; if (otf->gpos) for (i = 0; i < otf->gpos->ScriptList.ScriptCount; i++) - n += otf->gsub->ScriptList.Script[i].LangSysCount + 1; + n += otf->gpos->ScriptList.Script[i].LangSysCount + 1; script_langsys = alloca ((sizeof script_langsys[0]) * n); n = 0; nfeatures = 0; @@ -994,13 +993,13 @@ create_otf_script_widgets (Widget prev) script_langsys[n].script = tag; script_langsys[n++].langsys = 0; } - for (j = 0; j < otf->gsub->ScriptList.Script[i].LangSysCount; j++) + for (j = 0; j < otf->gpos->ScriptList.Script[i].LangSysCount; j++) { int l; if (k < prev_n) { - OTF_Script *script = otf->gsub->ScriptList.Script + i; + OTF_Script *script = otf->gpos->ScriptList.Script + i; for (l = k; l < prev_n && tag == script_langsys[l].script; l++) if (script->LangSysRecord[j].LangSysTag -- 1.7.10.4