18 draw_bitmap (FT_Face face, int x, int y)
21 FT_Bitmap *bmp = &face->glyph->bitmap;
22 unsigned char *buf = (unsigned char *) bmp->buffer;
24 for (i = 0; i < bmp->rows; i++, buf += bmp->pitch)
25 for (j = 0; j < bmp->width; j++)
26 if (buf[j / 8] & (1 << (7 - (j % 8))))
27 XDrawPoint (display, win, gc, x + j, y + i);
33 fprintf (stderr, "Error by %s\n", msg);
39 otf_dump_value_record (unsigned value_format, OTF_ValueRecord *value_record)
41 if (value_format & OTF_XPlacement)
42 printf (" (XPlacement %d)", value_record->XPlacement);
43 if (value_format & OTF_YPlacement)
44 printf (" (YPlacement %d)", value_record->YPlacement);
50 otf_dump_gstring (OTF_GlyphString *gstring)
54 for (i = 0; i < gstring->used; i++)
56 OTF_Glyph *g = gstring->glyphs + i;
58 printf ("%02d: c:%04X, g:%04X class:%d\n",
59 i, g->c, g->glyph_id, g->GlyphClass);
60 // otf_dump_value_record (g->value_format1, &g->value_record1);
61 // otf_dump_value_record (g->value_format2, &g->value_record2);
67 main (int argc, char **argv)
71 OTF_GlyphString gstring;
75 fprintf (stderr, "Usage, dtfdump OTF-FILE");
79 otf = otf_open (argv[1]);
82 otf_perror ("otfdraw");
86 gstring.glyphs = (OTF_Glyph *) malloc (sizeof (OTF_Glyph) * 30);
87 memset (gstring.glyphs, 0, sizeof (OTF_Glyph) * 30);
90 gstring.glyphs[gstring.used++].c = 0x93F;
91 gstring.glyphs[gstring.used++].c = 0x939;
92 gstring.glyphs[gstring.used++].c = 0x928;
93 gstring.glyphs[gstring.used++].c = 0x94D;
94 gstring.glyphs[gstring.used++].c = 0x926;
95 gstring.glyphs[gstring.used++].c = 0x940;
97 gstring.glyphs[gstring.used++].c = 0x92A;
98 gstring.glyphs[gstring.used++].c = 0x94D;
99 gstring.glyphs[gstring.used++].c = 0x930;
100 gstring.glyphs[gstring.used++].c = 0x924;
101 gstring.glyphs[gstring.used++].c = 0x94D;
102 gstring.glyphs[gstring.used++].c = 0x92F;
103 gstring.glyphs[gstring.used++].c = 0x947;
104 gstring.glyphs[gstring.used++].c = 0x915;
106 otf_drive_cmap (otf, &gstring);
107 otf_drive_gdef (otf, &gstring);
108 otf_dump_gstring (&gstring);
109 if (otf_drive_gsub (otf, otf_tag ("deva"), 0, &gstring) < 0)
110 printf ("otf_gsub error\n");
112 printf ("RESULT of GSUB\n");
113 otf_dump_gstring (&gstring);
115 if (otf_drive_gpos (otf, otf_tag ("deva"), 0, &gstring) < 0)
116 printf ("otf_gsub error\n");
118 printf ("RESULT of GPOS\n");
119 otf_dump_gstring (&gstring);
127 err = FT_Init_FreeType (&library);
129 quit ("FT_Init_FreeType");
130 err = FT_New_Face (library, argv[1], 0, &face);
131 if (err == FT_Err_Unknown_File_Format)
132 quit ("FT_New_Face: unknown file format");
134 quit ("FT_New_Face: unknown error");
135 err = FT_Set_Char_Size (face, 0, 32*64, 400, 400);
137 quit ("FT_Set_Char_Size");
139 display = XOpenDisplay (NULL);
140 screen = DefaultScreen (display);
141 win = XCreateSimpleWindow (display, RootWindow (display, screen),
142 0, 0, 800, 600, 1, BlackPixel (display, screen),
143 WhitePixel (display, screen));
144 gc = DefaultGC (display, screen);
145 XMapWindow (display, win);
146 XSelectInput (display, win, ExposureMask);
152 XNextEvent (display, &event);
154 XClearWindow (display, win);
156 for (i = 0; i < gstring.used; i++)
158 FT_Load_Glyph (face, gstring.glyphs[i].glyph_id,
159 FT_LOAD_RENDER | FT_LOAD_MONOCHROME);
161 if (gstring.glyphs[i].positioning_type)
163 printf ("%d:%d\n", i, gstring.glyphs[i].positioning_type);
166 x + face->glyph->bitmap_left,
167 y - face->glyph->bitmap_top);
168 x += face->glyph->advance.x >> 6;