- gfxpoly_t*dummybox = gfxpoly_createbox(bbox.xmin,bbox.ymin,bbox.xmax,bbox.ymax);
- gfxpoly_t*poly = gfxpoly_intersect(dummybox, i->clip->poly);
- gfxline_t*gfxline = gfxpoly_to_gfxline(poly);
- gfxbbox_t bbox2 = gfxline_getbbox(gfxline);
- double w = bbox2.xmax - bbox2.xmin;
- double h = bbox2.ymax - bbox2.ymin;
-
- addtounion(dev, poly); // TODO: use the whole char, not just the bbox?
-
- if(w < 0.001 || h < 0.001) /* character was clipped completely */ {
- } else if(fabs((bbox.xmax - bbox.xmin) - w) > 0.05 ||
- fabs((bbox.ymax - bbox.ymin) - h) > 0.05) {
- /* notable change in character size: character was clipped
- TODO: handle diagonal cuts
- */
- polyops_fill(dev, glyph, color);
+ gfxpoly_t*dummybox = gfxpoly_createbox(bbox.xmin,bbox.ymin,bbox.xmax,bbox.ymax, DEFAULT_GRID);
+ gfxline_t*dummybox2 = gfxline_from_gfxpoly(dummybox);
+ bbox = gfxline_getbbox(dummybox2);
+ gfxline_free(dummybox2);
+
+ char ok=0;
+ gfxline_t*gfxline = handle_poly(dev, dummybox, &ok);
+ if(ok) {
+ gfxbbox_t bbox2 = gfxline_getbbox(gfxline);
+ double w = bbox2.xmax - bbox2.xmin;
+ double h = bbox2.ymax - bbox2.ymin;
+ if(fabs((bbox.xmax - bbox.xmin) - w) > DEFAULT_GRID*2 ||
+ fabs((bbox.ymax - bbox.ymin) - h) > DEFAULT_GRID*2) {
+ /* notable change in character size: character was clipped
+ TODO: how to deal with diagonal cuts?
+ */
+ msg("<trace> Character %d was clipped: (%f,%f,%f,%f) -> (%f,%f,%f,%f)",
+ glyphnr,
+ bbox.xmin,bbox.ymin,bbox.xmax,bbox.ymax,
+ bbox2.xmin,bbox2.ymin,bbox2.xmax,bbox2.ymax);
+ polyops_fill(dev, glyph, color);
+ } else {
+ if(i->out) i->out->drawchar(i->out, font, glyphnr, color, matrix);
+ }