Adding font property and example C++ code for rendering font in bitmap.
Cleaning up our MiniDisplay signal names.
1 #include "minidisplay.h"
4 MiniDisplay::MiniDisplay(QQuickItem *parent):
7 // By default, QQuickItem does not draw anything. If you subclass
8 // QQuickItem to create a visual item, you will need to uncomment the
9 // following line and re-implement updatePaintNode()
11 // setFlag(ItemHasContents, true);
13 //qDebug() << "New MiniDisplay";
16 MiniDisplay::~MiniDisplay()
18 //qDebug() << "Delete MiniDisplay";
22 void MiniDisplay::open()
36 void MiniDisplay::close()
43 bool MiniDisplay::isOpen()
45 return iDisplay.IsOpen();
48 void MiniDisplay::clear()
50 if (!iDisplay.IsOpen()) return;
55 void MiniDisplay::fill()
57 if (!iDisplay.IsOpen()) return;
59 iDisplay.SetAllPixels(0xFF);
62 void MiniDisplay::swapBuffers()
64 if (!iDisplay.IsOpen()) return;
66 iDisplay.SwapBuffers();
73 void MiniDisplay::setFont(const QFont& aFont)
76 QString strDemo="0123456789ABCDEF";
77 QFontMetrics metrics(iFont);
78 QSize size(metrics.width(strDemo),metrics.height());
79 QImage image(size,QImage::Format_Mono);
80 image.fill(0xFFFFFFFF);
82 QPainter painter(&image);
83 //painter.begin(&image);
84 painter.setPen(0xFF000000);
85 painter.setFont(iFont);
86 painter.drawText(0,metrics.ascent(),strDemo);
89 image.save("font.png");