aframe icon indicating copy to clipboard operation
aframe copied to clipboard

Language issue

Open DYBDDY opened this issue 1 year ago • 19 comments

How do I write in a language other than English? For example, Chinese?

DYBDDY avatar Nov 26 '24 15:11 DYBDDY

The built-in text component and <a-text> primitive uses so-called (M)SDF fonts. These need to be generated with all the characters you plan to use. The default font only supports ASCII characters, so for characters from other writing systems, you'll have to generate your own font. See the following documentation page for details: https://aframe.io/docs/1.6.0/components/text.html#non-ascii-characters

Alternatively you can use the aframe-troika-text library. It uses Troika's text renderer under the hood, which can generate the font on the fly.

mrxz avatar Nov 26 '24 16:11 mrxz

Should troika be A-Frame default?

dmarcos avatar Nov 26 '24 17:11 dmarcos

maybe something like https://github.com/foxglove/three-text with @mapbox/tiny-sdf could be a first step

arpu avatar Nov 26 '24 18:11 arpu

For my own projects I exclusively use Troika, mostly out of convenience but also because it builds nicely on top of the Three.js material system. I think making it the default in A-Frame isn't a bad idea, I'll try and experiment with it and create a PR.

mrxz avatar Nov 27 '24 10:11 mrxz

What are the downsides from switching to Troika?

dmarcos avatar Nov 27 '24 15:11 dmarcos

The only downside i can think of, is if aframe switching to WebGPURenderer (webgl2, webgpu) with TLS more glsl shader code needs to port to TSL, but what i read @lojjic have plans to support TLS ( correct me if i am wrong)

arpu avatar Nov 27 '24 15:11 arpu

Yes TSL support is planned, but no concrete timeframe yet. It would bump up in priority if there were a significant number of people or projects asking for it. 😅

lojjic avatar Nov 27 '24 20:11 lojjic

The other downside I can think of is that it's asynchronous, and runs in a worker by default. That could complicate things that expect to be able to use metrics of the text in a synchronous way -- e.g. scaling a background plane to match the text dimensions.

lojjic avatar Nov 27 '24 20:11 lojjic

I hadn't even considered TSL in A-Frame, but that integration would encourage me to learn TSL and give me better grounds to advocate for it in the office.

koktavy avatar Nov 27 '24 21:11 koktavy

I'd love to see troika as default (I'm all in on it), so it gets tested with aframe changes - I noticed that the troika aframe component does not work and throws this error on the aframe master branch:

troika-three-utils.esm.js:22 Uncaught TypeError: Cannot read properties of undefined (reading 'replace') at b (troika-three-utils.esm.js:22:17)

see https://glitch.com/edit/#!/gusty-childlike-durian

@lojjic I was going to post this as an issue on your github, but wasn't sure about the propriety of posting bugs that only appear on the master branch...

polytropoi avatar Nov 27 '24 21:11 polytropoi

@mrxz switching to troika is still something we want to do?

dmarcos avatar Jan 21 '25 00:01 dmarcos

@mrxz switching to troika is still something we want to do?

I do believe there are still many upsides to switching. But doing so in a backwards compatible turns out to be quite tricky, not to mention that there is no way to support MSDF fonts people have already generated.

For those interested, here's my WIP changes so far: https://github.com/aframevr/aframe/compare/master...mrxz:aframe:troika-text

mrxz avatar Jan 23 '25 11:01 mrxz

@mrxz we can add a new text component and a deprecation message for the old one that we will remove in 1.8.0

dmarcos avatar Jan 23 '25 14:01 dmarcos

@dmarcos That isn't a bad idea, the old component could also be moved into a separate repo (probably under c-frame) in case people still want to use it beyond 1.7.0. Though what would be a good name for the new component? Hard to beat text/<a-text> in terms of simplicity and clarity. 🤔

mrxz avatar Jan 27 '25 18:01 mrxz

@mrxz We can also rip the band-aid and replace text with troika and put a console message "Text component has been replaced... link to migration info"

dmarcos avatar Jan 27 '25 21:01 dmarcos

Yes I would also prefer we keep the text component name for the new implementation and make the breaking change only once. From your earlier comments @dmarcos it seemed you wanted to introduce the new component with a new name like maybe newtext, text2 and maybe later in 1.8.0 rename again to just text? Not good, it would mean I would need to change my projects twice. The warning should only show if you use the text component in a way that is not supported by the new implementation, like using a custom font. We could rename the existing one to text-legacy (similar to gltf-model-legacy, collada-model-legacy we have in aframe-extras) and keep it in the repo in the 1.7.0 release and just remove it in 1.8.0. If someone really need it, we'll recreate it in c-frame organization.

vincentfretin avatar Jan 28 '25 09:01 vincentfretin

I’m fine with a single “text” component that detects old usage and throws a message in console for the dev to adjust

dmarcos avatar Jan 28 '25 19:01 dmarcos

@mrxz troika for 1.7.0? yes, no?

dmarcos avatar Feb 10 '25 18:02 dmarcos

@mrxz troika for 1.7.0? yes, no?

@dmarcos I don't really have the time to work on it now, so not for 1.7.0, I'm afraid. It might be for the better as well, since then we can do the replacement on master and really iron out the bugs before the next release.

mrxz avatar Feb 11 '25 10:02 mrxz