many sparse changes

This commit is contained in:
Geoffray Levasseur committed 2026-11-03 18:33:45 +01:00
1 parent 2c26c6f795
commit 7aa4ea4425
23 files changed
+1317 -290

No files matched your search

+44
View File
@@ -29,9 +29,11 @@
#include "Cevo/CevoScreenTools.h"
#include "Cevo/CevoGraphicSet.h"
#include "Cevo/CevoTexture.h"
#include "Dpi/DpiCommon.h"
#include "Dpi/DpiPixelPointer.h"
#include <QFileInfo>
#include <QFile>
#include <algorithm>
#include <cmath>
@@ -59,6 +61,48 @@ void drawBufferEnsureSize(int width, int height)
drawBuffer.canvas().end();
}
void loadFonts(const QString &scriptFileName)
{
QFile file(scriptFileName);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return;
FontType section = FontType::Normal;
while (!file.atEnd()) {
const QString line = QString::fromUtf8(file.readLine()).trimmed();
if (line.isEmpty())
continue;
if (line.at(0) == QLatin1Char('#')) {
if (line == QLatin1String("#SMALL"))
section = FontType::Small;
else if (line == QLatin1String("#TINY"))
section = FontType::Tiny;
else if (line == QLatin1String("#CAPTION"))
section = FontType::Caption;
else if (line == QLatin1String("#BUTTON"))
section = FontType::Button;
else
section = FontType::Normal;
continue;
}
const int comma = line.indexOf(QLatin1Char(','));
if (comma <= 0)
continue;
Dpi::Font &font = UniFont[static_cast<std::size_t>(section)];
font.setName(line.left(comma).trimmed());
int size = 0;
for (int i = comma + 1; i < line.length(); ++i) {
const QChar c = line.at(i);
if (c >= QLatin1Char('0') && c <= QLatin1Char('9'))
size = size * 10 + c.digitValue();
else if (c == QLatin1Char('B') || c == QLatin1Char('b'))
font.setBold(true);
else if (c == QLatin1Char('I') || c == QLatin1Char('i'))
font.setItalic(true);
}
font.setHeight(Dpi::scaleToNative(size)); // the script gives pixel heights
}
}
QColor colorFromDelphi(int value)
{
return QColor(value & 0xFF, (value >> 8) & 0xFF, (value >> 16) & 0xFF);