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]);
81 otf_perror ("otfdraw:");
83 gstring.glyphs = (OTF_Glyph *) malloc (sizeof (OTF_Glyph) * 30);
84 memset (gstring.glyphs, 0, sizeof (OTF_Glyph) * 30);
87 gstring.glyphs[gstring.used++].c = 0x93F;
88 gstring.glyphs[gstring.used++].c = 0x939;
89 gstring.glyphs[gstring.used++].c = 0x928;
90 gstring.glyphs[gstring.used++].c = 0x94D;
91 gstring.glyphs[gstring.used++].c = 0x926;
92 gstring.glyphs[gstring.used++].c = 0x940;
94 gstring.glyphs[gstring.used++].c = 0x92A;
95 gstring.glyphs[gstring.used++].c = 0x94D;
96 gstring.glyphs[gstring.used++].c = 0x930;
97 gstring.glyphs[gstring.used++].c = 0x924;
98 gstring.glyphs[gstring.used++].c = 0x94D;
99 gstring.glyphs[gstring.used++].c = 0x92F;
100 gstring.glyphs[gstring.used++].c = 0x947;
101 gstring.glyphs[gstring.used++].c = 0x915;
103 otf_drive_cmap (otf, &gstring);
104 otf_drive_gdef (otf, &gstring);
105 otf_dump_gstring (&gstring);
106 if (otf_drive_gsub (otf, otf_tag ("deva"), 0, &gstring) < 0)
107 printf ("otf_gsub error\n");
109 printf ("RESULT of GSUB\n");
110 otf_dump_gstring (&gstring);
112 if (otf_drive_gpos (otf, otf_tag ("deva"), 0, &gstring) < 0)
113 printf ("otf_gsub error\n");
115 printf ("RESULT of GPOS\n");
116 otf_dump_gstring (&gstring);
124 err = FT_Init_FreeType (&library);
126 quit ("FT_Init_FreeType");
127 err = FT_New_Face (library, argv[1], 0, &face);
128 if (err == FT_Err_Unknown_File_Format)
129 quit ("FT_New_Face: unknown file format");
131 quit ("FT_New_Face: unknown error");
132 err = FT_Set_Char_Size (face, 0, 32*64, 400, 400);
134 quit ("FT_Set_Char_Size");
136 display = XOpenDisplay (NULL);
137 screen = DefaultScreen (display);
138 win = XCreateSimpleWindow (display, RootWindow (display, screen),
139 0, 0, 800, 600, 1, BlackPixel (display, screen),
140 WhitePixel (display, screen));
141 gc = DefaultGC (display, screen);
142 XMapWindow (display, win);
143 XSelectInput (display, win, ExposureMask);
149 XNextEvent (display, &event);
151 XClearWindow (display, win);
153 for (i = 0; i < gstring.used; i++)
155 FT_Load_Glyph (face, gstring.glyphs[i].glyph_id,
156 FT_LOAD_RENDER | FT_LOAD_MONOCHROME);
158 if (gstring.glyphs[i].positioning_type)
160 printf ("%d:%d\n", i, gstring.glyphs[i].positioning_type);
163 x + face->glyph->bitmap_left,
164 y - face->glyph->bitmap_top);
165 x += face->glyph->advance.x >> 6;