17 draw_bitmap (FT_Face face, int x, int y)
20 FT_Bitmap *bmp = &face->glyph->bitmap;
21 unsigned char *buf = (unsigned char *) bmp->buffer;
23 for (i = 0; i < bmp->rows; i++, buf += bmp->pitch)
24 for (j = 0; j < bmp->width; j++)
25 if (buf[j / 8] & (1 << (7 - (j % 8))))
26 XDrawPoint (display, win, gc, x + j, y + i);
32 fprintf (stderr, "Error by %s\n", msg);
38 otf_dump_value_record (unsigned value_format, OTF_ValueRecord *value_record)
40 if (value_format & OTF_XPlacement)
41 printf (" (XPlacement %d)", value_record->XPlacement);
42 if (value_format & OTF_YPlacement)
43 printf (" (YPlacement %d)", value_record->YPlacement);
49 otf_dump_gstring (OTF_GlyphString *gstring)
53 for (i = 0; i < gstring->used; i++)
55 OTF_Glyph *g = gstring->glyphs + i;
57 printf ("%02d: c:%04X, g:%04X class:%d\n",
58 i, g->c, g->glyph_id, g->GlyphClass);
59 // otf_dump_value_record (g->value_format1, &g->value_record1);
60 // otf_dump_value_record (g->value_format2, &g->value_record2);
66 main (int argc, char **argv)
70 OTF_GlyphString gstring;
74 fprintf (stderr, "Usage, dtfdump OTF-FILE");
78 otf = otf_open (argv[1]);
81 gstring.glyphs = (OTF_Glyph *) malloc (sizeof (OTF_Glyph) * 10);
84 gstring.glyphs[gstring.used++].c = 0x93F;
85 gstring.glyphs[gstring.used++].c = 0x939;
86 gstring.glyphs[gstring.used++].c = 0x928;
87 gstring.glyphs[gstring.used++].c = 0x94D;
88 gstring.glyphs[gstring.used++].c = 0x926;
89 gstring.glyphs[gstring.used++].c = 0x940;
91 gstring.glyphs[gstring.used++].c = 0x92A;
92 gstring.glyphs[gstring.used++].c = 0x94D;
93 gstring.glyphs[gstring.used++].c = 0x930;
94 gstring.glyphs[gstring.used++].c = 0x924;
95 gstring.glyphs[gstring.used++].c = 0x94D;
96 gstring.glyphs[gstring.used++].c = 0x92F;
97 gstring.glyphs[gstring.used++].c = 0x947;
98 gstring.glyphs[gstring.used++].c = 0x915;
100 otf_cmap (otf, &gstring);
101 otf_gdef (otf, &gstring);
102 otf_dump_gstring (&gstring);
103 if (otf_gsub (otf, otf_tag ("deva"), 0, &gstring) < 0)
104 printf ("otf_gsub error\n");
106 printf ("RESULT of GSUB\n");
107 otf_dump_gstring (&gstring);
109 if (otf_gpos (otf, otf_tag ("deva"), 0, &gstring) < 0)
110 printf ("otf_gsub error\n");
112 printf ("RESULT of GPOS\n");
113 otf_dump_gstring (&gstring);
121 err = FT_Init_FreeType (&library);
123 quit ("FT_Init_FreeType");
124 err = FT_New_Face (library, argv[1], 0, &face);
125 if (err == FT_Err_Unknown_File_Format)
126 quit ("FT_New_Face: unknown file format");
128 quit ("FT_New_Face: another error");
129 err = FT_Set_Char_Size (face, 0, 32*64, 400, 400);
131 quit ("FT_Set_Char_Size");
133 display = XOpenDisplay (NULL);
134 screen = DefaultScreen (display);
135 win = XCreateSimpleWindow (display, RootWindow (display, screen),
136 0, 0, 800, 600, 1, BlackPixel (display, screen),
137 WhitePixel (display, screen));
138 gc = DefaultGC (display, screen);
139 XMapWindow (display, win);
140 XSelectInput (display, win, ExposureMask);
146 XNextEvent (display, &event);
148 XClearWindow (display, win);
150 for (i = 0; i < gstring.used; i++)
152 FT_Load_Glyph (face, gstring.glyphs[i].glyph_id,
153 FT_LOAD_RENDER | FT_LOAD_MONOCHROME);
156 x + face->glyph->bitmap_left,
157 y - face->glyph->bitmap_top);
158 x += face->glyph->advance.x >> 6;