-
Hello, I want to render text(utf-8),so i modified the vsgExamples\vsgtext.cpp and test.
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
For large .ttf the SDF generation that the vsgXchange::freetype ReaderWriter does can be quite slow, so converting to native .vsgb will be the way of avoiding this performance overhead. I recommend using .vsgb rather than .vsgt as the binary format is small and significantly faster. As a general note, the VisualStudio debug build is very slow so you may find using a release build might provide good enough performance without converting to native .vsgb. When I wrote vsg::Text functionality I never had Chinese test sample to work with so just tested with what I know which is European fonts which work fine with standard ascii character set so std::stringValue works fine. I knew at some point users would want to use extended characters sets so made it possible to assign the text as a vsg::Data leaving the door open to use std::ushortArray and std::uintArray so you could pack your strings into either of these. There isn't any UTF8 support built into vsgText and I'm inclined to maintain this as vsg::Text supports doing GpuLayout and while we could write a vertex shader that decodes UTF8 it really would be a waste of GPU resources. Perhaps a better way would be for us to add a vsg::wstringValue to compliment the existing vsg::stringValue that is predefined in include/vsg/core/Value.h. You should be able to use just use vsg::Valuestd::wstring right now but I haven;t ever tried it. |
Beta Was this translation helpful? Give feedback.
-
I have done a quick test and found the the vsg::Text didn't support vsg::Valuestd::wstring so I've added a vsg::wstringValue to compliment the exiting vsg::stringValue and added support for the new wstringValue to the vsg::Text functionality. These changes are checked into wstringValue branch of the VSG: https://github.com/vsg-dev/VulkanSceneGraph/tree/wstringValue I've tested it with a quick mode to vsgtext example:
@xjgong could you try out the wstringValue branch and let me know if that allows you to use wstringValue with the fonts and text you want to use. |
Beta Was this translation helpful? Give feedback.
-
In trying to add the reading/writing of std::wstring to the
vsg::Input/Output classes I have tripped up on wchat_t being 16bit under
Windows vs 32bit under Linux. Ouch.
For vsg::AsciiInput/AsciiOutput I have already implemented a conversion of
wstring to utf8 string so perhaps doing the same for binary will be
sufficient.
|
Beta Was this translation helpful? Give feedback.
I have checked in read/write support for wstring with commit: 46230aa
@xjgong could you test out the wstringValue branch and let me know it works for you, if there aren't any problems then I'll merge with VSG master.