
Code used to generate the .cc files:

    

static std::vector<char> ReadAllBytes(std::string filename)
{
    std::ifstream ifs(filename, std::ios::binary | std::ios::ate);
    std::ifstream::pos_type pos = ifs.tellg();

    std::vector<char> result(pos);

    ifs.seekg(0, std::ios::beg);
    ifs.read(&result[0], pos);

    return result;
}

auto gen_code = [](std::string name, std::string varname) {
    auto data = ReadAllBytes(name + ".ttf");

    auto s = glow::base64_encode(glow::array_view{(std::byte*)data.data(), data.size()});
    auto chunks = 1024;

    std::ofstream fout(name + ".cc");
    fout << "// NOTE: this file is automatically generated!\n";
    fout << "\n";
    fout << "#include <string>\n";
    fout << "#include <vector>\n";
    fout << "#include <glow/common/base64.hh>\n";
    fout << "\n";
    fout << "namespace glow::vector::detail {\n";
    fout << "std::vector<std::byte> get" << varname << "()\n";
    fout << "{\n";
    fout << "    std::string s;\n";
    fout << "    s.reserve(" << s.size() << ");\n";
    for (size_t i = 0; i < s.size(); i += chunks)
    {
        fout << "    s += \"" << s.substr(i, tg::min(chunks, s.size() - i)) << "\";\n";
    }
    fout << "    return glow::base64_decode(s);\n";
    fout << "}\n";
    fout << "}\n";
};
gen_code("FiraMono-Regular", "FontFiraMono");
gen_code("FiraSans-Regular", "FontFiraSans");

