const Size EvasText::size() const { int width = horizontalAdvance(); int height = verticalAdvance(); Dout( dc::notice, *this << " EvasText::size() - width = " << width << ", height = " << height ); return Size( width, height ); }
int main() { std::cout << "hello world" << std::endl; std::string path = "/usr/share/yandex/maps/renderer5/fonts/LiberationSans-Regular.ttf"; fu::FontFace face(path); std::cout << face.glyphCount() << std::endl; yandex::maps::proto::vector_data::glyphs::FontDescription fd; auto capitalX = face.render( face.charGlyphIndex(U'x'), 32, fu::RenderingType::GrayscaleWhiteOnBlack); fd.set_fontid("haah"); fd.set_xheight(capitalX.height()); fd.set_margin(3); // std::cout << fd.fontid() << std::endl; std::stringstream ss; fd.SerializeToOstream(&ss); SDFFont<mms::Standalone> sdfFont(ss.str()); for (auto index: face.glyphIndices()) { auto glyph = face.render(index, 32, fu::RenderingType::GrayscaleWhiteOnBlack); yandex::maps::proto::vector_data::glyphs::Glyph proto; proto.set_id(index); proto.set_bitmap(glyph.data().data(), glyph.data().size()); proto.set_width(glyph.width()); proto.set_height(glyph.height()); proto.set_bearingx(glyph.horizontalBearingX()); proto.set_bearingy(glyph.horizontalBearingY()); proto.set_advance(glyph.horizontalAdvance()); std::stringstream gss; proto.SerializeToOstream(&gss); sdfFont.glyphsProto[index] = gss.str(); } std::ofstream out("font.mms"); mms::Writer w(out); size_t ofs = mms::safeWrite(w, sdfFont); std::cout << "file size = " << ofs << std::endl; out.close(); return 0; }