mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-12 22:41:49 +00:00
fix projected 3d text for non-monospace fonts
This commit is contained in:
parent
3de2a41092
commit
4837e1de02
2 changed files with 19 additions and 3 deletions
|
|
@ -196,13 +196,26 @@ static inline void draw_text(
|
||||||
float advance = baseAdvance;
|
float advance = baseAdvance;
|
||||||
if (auto glyph = font.getGlyph(c)) {
|
if (auto glyph = font.getGlyph(c)) {
|
||||||
yOffset = glyph->yOffset;
|
yOffset = glyph->yOffset;
|
||||||
advance = glyph->xAdvance;
|
advance = glyph->xAdvance /
|
||||||
|
static_cast<float>(font.getLineHeight()) * 2.0f *
|
||||||
|
baseAdvance;
|
||||||
}
|
}
|
||||||
uint charpage = c >> 8;
|
uint charpage = c >> 8;
|
||||||
if (charpage == page){
|
if (charpage == page){
|
||||||
batch.texture(font.getPage(charpage));
|
batch.texture(font.getPage(charpage));
|
||||||
draw_glyph(
|
draw_glyph(
|
||||||
batch, pos, glm::vec2(x, y - yOffset * (is3d ? -1 : 1) / static_cast<float>(font.getLineHeight())), c, right, up, interval, style
|
batch,
|
||||||
|
pos,
|
||||||
|
glm::vec2(
|
||||||
|
x,
|
||||||
|
y - yOffset * (is3d ? -1 : 1) /
|
||||||
|
static_cast<float>(font.getLineHeight())
|
||||||
|
),
|
||||||
|
c,
|
||||||
|
right,
|
||||||
|
up,
|
||||||
|
interval,
|
||||||
|
style
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if (charpage > page && charpage < next){
|
else if (charpage > page && charpage < next){
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,10 @@ void TextsRenderer::renderNote(
|
||||||
yvec = camera.up;
|
yvec = camera.up;
|
||||||
}
|
}
|
||||||
float scale =
|
float scale =
|
||||||
(1.0f - preset.perspective) * glm::pow(glm::distance(camera.position, pos), 1.0f-preset.perspective);
|
(1.0f - preset.perspective) *
|
||||||
|
glm::pow(
|
||||||
|
glm::distance(camera.position, pos), 1.0f - preset.perspective
|
||||||
|
);
|
||||||
xvec *= 1.0f + scale;
|
xvec *= 1.0f + scale;
|
||||||
yvec *= 1.0f + scale;
|
yvec *= 1.0f + scale;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue