ZaStoGram_desktop/Telegram/SourceFiles/tgw/tgw_emoji.h
John Preston 285bc8ef26 Bound the colour glyphs Qt draws for a widget in a frame
Qt rasterizes and caches a colour glyph at its device size, clipped or
not: one regional indicator under scale(1000) took gigabytes.
2026-11-13 18:03:36 +04:00

33 lines
857 B
C++

/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "emoji.h"
class QFontMetricsF;
namespace Tgw {
struct EmojiCell {
int from = 0;
int till = 0;
EmojiPtr emoji = nullptr;
};
[[nodiscard]] std::vector<EmojiCell> FindEmojiCells(QStringView text);
[[nodiscard]] int ColorGlyphCandidates(QStringView text);
[[nodiscard]] float64 EmojiAdvance(float64 fontSize);
[[nodiscard]] QRectF EmojiBox(float64 x, float64 fontSize);
float64 WalkTextWithEmoji(
const QFontMetricsF &metrics,
const QString &text,
const std::vector<EmojiCell> &cells,
float64 fontSize,
Fn<void(float64, const QString &, EmojiPtr)> visit = nullptr);
} // namespace Tgw