What parameters should I use to make sure that a text is rendered nicely? #45
-
I was able to create a MTSDF font atlas in using this library and render the glyphs to the screen using shaders. I went a bit of a brute force approach and just rendered every glyph in a quad that is bound by This did not give the most perfect result and I see two problems here:
What parameters do I need to use to from the Glyph information in order to render the text in a consistent way. I am retrieving glyph bounds in the following way: std::vector<GlyphGeometry> msdfGlyphs;
std::unordered_map<uint32_t, FontGlyph> glyphMap;
for (auto &msdfGlyph : msdfGlyphs) {
// Engine specific structure for glyphs
FontGlyph glyph{};
double top = 0.0, left = 0.0, bottom = 0.0, right = 0.0;
msdfGlyph.getQuadAtlasBounds(left, bottom, right, top);
// Note: fHeight - bottom/top is used since I need
// the atlas to be flipped to work properly in Vulkan
glyph.bounds = glm::vec4(static_cast<float>(left),
static_cast<float>(fHeight - bottom),
static_cast<float>(right),
static_cast<float>(fHeight - top)) /
fWidth;
glyphMap.insert_or_assign(msdfGlyph.getCodepoint(), glyph);
} What values do I need to use from |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Beta Was this translation helpful? Give feedback.
getQuadPlaneBounds
andgetAdvance
for spacing.