troika-three-text: feasibility of adding support for *limited* rich text rendering #334
-
I'm interested in using troika-three-text to render rich text (bold, italic, variable font sizes, etc.). I have developed a proof-of-concept using multiple troika instances (with my own layout typesetting, word wrapping, etc.) but it has many pitfalls and is less than ideal. What is the feasibility of adding support for rendering rich text directly with troika-three-text? It seems that the Is it a reasonable approach to do this at the typesetter or would more extensive changes be needed? Note: I'm not mentioning the other work to define and parse a format, split things into similar runs, etc. That is all solvable :) Thanks for the advice! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
It's definitely feasible, and you're exactly right that Typesetter would be the place to handle it since it's already set up to process the text in runs that can use different fonts/sizes/styles/weights/etc. It's really that "other work" you mentioned that's been keeping me from doing it. 😉 |
Beta Was this translation helpful? Give feedback.
-
@lojjic this is fantastic news. Thanks for the confirmation! If I move forward with this I'll add it to that issue. |
Beta Was this translation helpful? Give feedback.
-
Hi, I've been working on doing exactly this, which I require for a project I'm working on (I'll eventually fork and make that code available). I've been having quite a few problems though. The first thing I've added is a ranged text offset property, similar in interface to the font colourisation (which I'm expanding into a style system), in order to have arbitrarily spaced blocks of text in the same draw call (I need to render millions of lines, so separate Text objects aren't suitable). My offsets resolve to a per-character index into a table of paragraph x,y offsets. At the moment I handle these in the shader but I'll probably just offset the vertices before they get there. Styles (which will involve colour, SDF softness, font size, outline etc.) I plan to implement as a uniform table and per character index - maybe not size thinking on it, that's probably better handled at the vertex construction stage. From what I've said here, would you say I'm going about this in the right way? |
Beta Was this translation helpful? Give feedback.
It's definitely feasible, and you're exactly right that Typesetter would be the place to handle it since it's already set up to process the text in runs that can use different fonts/sizes/styles/weights/etc. It's really that "other work" you mentioned that's been keeping me from doing it. 😉
#65