tensorspace
tensorspace copied to clipboard
Support configure font style in scene
TensorSpace use fonts/helvetiker_regular.typeface.json as the basic font style for output1d layer text information. However, it does not support some text, for example, when input 中文, the fonts/helvetiker_regular.typeface.json will show ?? (this case can be reproduced in three.js docs's playground).
To handle this case, add a configuration in model, user can override the default fonts/helvetiker_regular.typeface.json with own fonts.
For example:
// user loadFont file through AJAX
let ownFont = loadFont();
let model = new TSP.models.Sequential({
...
font: ownFont,
...
});
@syt123450 So I did a bit of digging on this after setting up a local instance of tensor (fixed a bug with missing dep aswell). I found the hard coded font and saw that there is an npm module for this specific font already (https://www.npmjs.com/package/three.regular.helvetiker). The rollup config didn't have common module and ES6 external resolver support so I added that into the build aswell. That at least trims down that giant line of json into one easy import. Still looking at the best way to pass through the option without rewriting too much function calls, but looks doable.
@Truemedia It's really a good news! I think this refactoring will highly improve the TensorSpace's source code readability. Could you send a PR related your refactoring?
@BoTime Could you give some suggestions about rollup configuration?
@syt123450 Sure, would you be able to open a feature branch/develop branch for me to do a new request on so it doesn't go into master just yet.
Hi @Truemedia , I created a new issue #192 and create a new branch refactorfont. We can work under the new issue for refactoring, separate the work of refactor and new feature ~
@syt123450 Ok cool, I won't have much time to commit any code during week but weekend can probably box off both those branches with the new features