Merge pull request #847 from MihailRis/client-side-tests

client-side `--script`, `--test` support (part 1)
This commit is contained in:
MihailRis 2026-07-25 21:59:10 +03:00 • committed by GitHub
commit 4295af15cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
55 changed files with 1660 additions and 590 deletions

View file

@ -26,6 +26,11 @@ Font::Font(
pages(std::move(pages)),
glyphs(std::move(glyphs)),
fontFile(std::move(fontFile)) {
if (this->fontFile.has_value()) {
if (auto fontPtr = this->fontFile->lock()) {
monospace = fontPtr->isMonospace();
}
}
}
Font::~Font() = default;
@ -34,6 +39,10 @@ int Font::getYOffset() const {
return yoffset;
}
bool Font::isMonospace() const {
return monospace;
}
int Font::getLineHeight() const {
return lineHeight;
}
@ -53,7 +62,7 @@ bool Font::isPrintableChar(uint codepoint) const {
int FontMetrics::calcWidth(std::wstring_view text, size_t offset, size_t length) const {
auto font = this->font.has_value() ? this->font->lock() : nullptr;
if (font == nullptr) {
if (font == nullptr || font->isMonospace()) {
return std::min(text.length() - offset, length) * _glyphInterval;
}
int totalWidth = 0;

View file

@ -39,6 +39,7 @@ public:
);
~Font();
bool isMonospace() const;
int getLineHeight() const;
int getYOffset() const;
@ -94,6 +95,7 @@ private:
int lineHeight;
int yoffset;
int glyphInterval;
bool monospace = true;
std::vector<std::unique_ptr<Texture>> pages;
std::vector<Glyph> glyphs;
std::optional<std::weak_ptr<vector_fonts::FontFile>> fontFile;

View file

@ -13,7 +13,7 @@ InlineFrame::~InlineFrame() = default;
void InlineFrame::setSrc(const std::string& src) {
this->src = src;
if (document) {
scripting::on_ui_close(document.get(), nullptr);
scripting::on_ui_close(*document, nullptr);
document = nullptr;
root = nullptr;
}
@ -31,7 +31,7 @@ void InlineFrame::setDocument(const std::shared_ptr<UiDocument>& document) {
root->setSize(size);
gui.postRunnable([this]() {
scripting::on_ui_open(this->document.get(), {});
scripting::on_ui_open(*this->document, {});
});
}