+
+void CharWindow::RenderPathInImage(QPainterPath * path, QImage * img)
+{
+ if ((path == NULL) || (img == NULL))
+ return;
+
+ QPainter p(img);
+
+ p.setPen(QPen(Qt::black, 1.0, Qt::SolidLine));
+ p.setBrush(Qt::black);
+
+ QRectF rect = path->boundingRect();
+ QSize paintSize = img->size();
+
+#if 0
+ // For some reason, this code cuts off two pixels when rendering the path.
+ // Not sure why, but we compensate for that here.
+ paintSize.rwidth() -= 2;
+ paintSize.rheight() -= 2;
+#endif
+
+ p.translate(0, paintSize.height());
+ float extraX = 0.0f, extraY = 0.0f;
+ float xConvFac = (float)paintSize.width() / rect.width();
+ float yConvFac = (float)paintSize.height() / rect.height();
+
+ if (xConvFac > yConvFac)
+ {
+ // height is limiting factor (smaller than width)
+ p.scale(yConvFac, -yConvFac);
+ extraX = (((float)paintSize.width() / yConvFac) - rect.width()) / 2.0f;