add 3d text 'font' property

This commit is contained in:
MihailRis 2026-07-26 16:39:54 +03:00
parent 4295af15cc
commit 3de2a41092
4 changed files with 11 additions and 2 deletions

View file

@ -162,6 +162,8 @@ static inline void draw_text(
const FontStylesScheme* styles,
size_t styleMapOffset
) {
bool is3d = std::is_same<Batch, Batch3D>();
static FontStylesScheme defStyles {{{}}, {0}};
if (styles == nullptr) {
@ -200,7 +202,7 @@ static inline void draw_text(
if (charpage == page){
batch.texture(font.getPage(charpage));
draw_glyph(
batch, pos, glm::vec2(x, y - yOffset / 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){

View file

@ -58,7 +58,10 @@ void TextsRenderer::renderNote(
}
opacity = preset.xrayOpacity;
}
auto& font = assets.require<Font>(FONT_DEFAULT);
auto specifiedFont = assets.get<Font>(preset.font);
auto& font =
specifiedFont ? *specifiedFont : assets.require<Font>(FONT_DEFAULT);
glm::vec3 xvec = note.getAxisX();
glm::vec3 yvec = note.getAxisY();
@ -118,6 +121,7 @@ void TextsRenderer::renderNote(
}
auto color = preset.color;
batch.setColor(glm::vec4(color.r, color.g, color.b, color.a * opacity));
font.draw(
batch,
text,

View file

@ -13,6 +13,7 @@ dv::value NotePreset::serialize() const {
{"render_distance", renderDistance},
{"xray_opacity", xrayOpacity},
{"perspective", perspective},
{"font", font},
});
}
@ -27,4 +28,5 @@ void NotePreset::deserialize(const dv::value& src) {
src.at("render_distance").get(renderDistance);
src.at("xray_opacity").get(xrayOpacity);
src.at("perspective").get(perspective);
src.at("font").get(font);
}

View file

@ -28,6 +28,7 @@ struct NotePreset : public Serializable {
float renderDistance = 32.0f;
float xrayOpacity = 0.0f;
float perspective = 1.0f;
std::string font {};
dv::value serialize() const override;
void deserialize(const dv::value& src) override;