mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-12-01 01:11:46 +00:00
Qt: Use pixel size instead of point size. Set color.
This commit is contained in:
parent
957defc419
commit
35de964293
@ -244,7 +244,9 @@ void TextDrawer::SetFont(uint32_t fontHandle) {
|
|||||||
|
|
||||||
void TextDrawer::MeasureString(const char *str, float *w, float *h) {
|
void TextDrawer::MeasureString(const char *str, float *w, float *h) {
|
||||||
#ifdef USING_QT_UI
|
#ifdef USING_QT_UI
|
||||||
QFontMetrics fm(QFont("default", fontSize_));
|
QFont font("default");
|
||||||
|
font.setPixelSize(fontSize_);
|
||||||
|
QFontMetrics fm(font);
|
||||||
QSize size = fm.size(0, str);
|
QSize size = fm.size(0, str);
|
||||||
*w = (float)size.width() * fontScaleX_;
|
*w = (float)size.width() * fontScaleX_;
|
||||||
*h = (float)size.height() * fontScaleY_;
|
*h = (float)size.height() * fontScaleY_;
|
||||||
@ -269,7 +271,9 @@ void TextDrawer::DrawString(DrawBuffer &target, const char *str, float x, float
|
|||||||
entry->lastUsedFrame = frameCount_;
|
entry->lastUsedFrame = frameCount_;
|
||||||
glBindTexture(GL_TEXTURE_2D, entry->textureHandle);
|
glBindTexture(GL_TEXTURE_2D, entry->textureHandle);
|
||||||
} else {
|
} else {
|
||||||
QFontMetrics fm(QFont("default", fontSize_));
|
QFont font("default");
|
||||||
|
font.setPixelSize(fontSize_);
|
||||||
|
QFontMetrics fm(font);
|
||||||
QSize size = fm.size(0, str);
|
QSize size = fm.size(0, str);
|
||||||
QImage image((size.width() + 3) & ~ 3, (size.height() + 3) & ~ 3, QImage::Format_ARGB32_Premultiplied);
|
QImage image((size.width() + 3) & ~ 3, (size.height() + 3) & ~ 3, QImage::Format_ARGB32_Premultiplied);
|
||||||
if (image.isNull()) {
|
if (image.isNull()) {
|
||||||
@ -279,8 +283,8 @@ void TextDrawer::DrawString(DrawBuffer &target, const char *str, float x, float
|
|||||||
|
|
||||||
QPainter painter;
|
QPainter painter;
|
||||||
painter.begin(&image);
|
painter.begin(&image);
|
||||||
painter.setFont(QFont("default", fontSize_));
|
painter.setFont(font);
|
||||||
painter.setPen(Qt::white);
|
painter.setPen(color);
|
||||||
painter.drawText(0, fontSize_, QString::fromLocal8Bit(str));
|
painter.drawText(0, fontSize_, QString::fromLocal8Bit(str));
|
||||||
painter.end();
|
painter.end();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user