Add offscreen text rendering.

This commit is contained in:
jmsgrogan 2023-01-12 10:58:43 +00:00
parent c63138c455
commit 076e32b1d6
17 changed files with 156 additions and 101 deletions

View file

@ -0,0 +1,35 @@
#include "LatexSymbols.h"
#include "StringUtils.h"
std::unordered_map<std::string, std::wstring> LatexSymbolLookup::mSymbols = {
{"Psi", L"\u03A8"},
{"alpha", L"\u03B1"},
{"beta", L"\u03B2"},
{"gamma", L"\u03B3"},
{"psi", L"\u03C8"}
};
std::optional<std::string> LatexSymbolLookup::getSymbolUtf8(const std::string& tag)
{
if (auto entry = getSymbolUtf16(tag); entry)
{
return StringUtils::convert(*entry);
}
else
{
return std::nullopt;
}
}
std::optional<std::wstring> LatexSymbolLookup::getSymbolUtf16(const std::string& tag)
{
if (auto iter = mSymbols.find(tag); iter != mSymbols.end())
{
return iter->second;
}
else
{
return std::nullopt;
}
}

View file

@ -22,5 +22,10 @@ struct LatexMathSymbol
class LatexSymbolLookup
{
public:
std::unordered_map<std::string, LatexMathSymbol> mTags;
static std::optional<std::string> getSymbolUtf8(const std::string& tag);
static std::optional<std::wstring> getSymbolUtf16(const std::string& tag);
private:
static std::unordered_map<std::string, std::wstring> mSymbols;
};