Added font support

This commit is contained in:
t-moe
2015-04-27 19:45:30 +02:00
parent 7be246ac3c
commit e249fb2aa2
10 changed files with 115 additions and 5 deletions

View File

@@ -7,6 +7,7 @@
extern "C" {
#include "touch.h"
#include "tft.h"
}
#define DISPLAY_WIDTH 320
@@ -110,6 +111,24 @@ void MainWindow::draw_circle(uint16_t x, uint16_t y, uint16_t r, uint16_t color)
update();
}
void MainWindow::draw_char(uint16_t x, uint16_t y, uint16_t color, uint16_t bgcolor, QFont font, char c)
{
//render_mutex.lock();
QPainter painter(&(image));
painter.setFont(font);
if(bgcolor!=TRANSPARENT) {
painter.setBackgroundMode(Qt::OpaqueMode);
painter.setBackground(QColorFromRGB565(bgcolor));
}
painter.setPen(QColorFromRGB565(color));
y+=QFontMetrics(font).ascent(); //use y pos as highest point of char, instead of baseline
painter.drawText(QPoint(x,y), QString(QChar(c)));
//render_mutex.unlock();
update();
}
void MainWindow::paintEvent(QPaintEvent *)
{
//render_mutex.lock();