virocore icon indicating copy to clipboard operation
virocore copied to clipboard

3d text chinese garbled

Open 18320877747 opened this issue 5 years ago • 16 comments

when I use 3d text to show chinese, but I got garbled. Is there something wrong?

18320877747 avatar Jun 26 '19 07:06 18320877747

Text text = new Text(mViroView.getViroContext(),"你好", 2, 1); text.setHorizontalAlignment(Text.HorizontalAlignment.CENTER); text.setFontStyle(Text.FontStyle.Normal); text.setFontFamilies("Roboto,NotoSansCJK"); text.setClipMode(Text.ClipMode.CLIP_TO_BOUNDS); text.setLineBreakMode(Text.LineBreakMode.CHAR_WRAP);

18320877747 avatar Jun 26 '19 07:06 18320877747

image

18320877747 avatar Jun 26 '19 07:06 18320877747

OS: android Version: ViroCore 1_14_0 Device(s): huawei meta20

18320877747 avatar Jun 26 '19 10:06 18320877747

This should work -- is it possible your device does not have the Google NotoSansCJK font?

radvani avatar Jun 26 '19 14:06 radvani

@radvani ,I'm trying to look system/fonts, I find it supports NotoSansCJK font.Is there any other possible?

18320877747 avatar Jun 27 '19 02:06 18320877747

HWHMA:/system $ cd fonts HWHMA:/system/fonts $ ls image

18320877747 avatar Jun 27 '19 02:06 18320877747

Which fonts are ViroCore supports?

18320877747 avatar Jun 27 '19 03:06 18320877747

ViroCore supports any fonts that you find in your /system/fonts directory. Can you actually check your logs, there should be messages of the form:

"Loading font face [name: %s, index: %d]"

If the font loading fails, you should see a message like this:

"Failed to find suitable face matching [%s], defaulting to system font"

If you could send those messages to me that would be great. Thanks!

On Wed, Jun 26, 2019 at 11:43 PM 18320877747 [email protected] wrote:

Which fonts are ViroCore supports?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/viromedia/virocore/issues/292?email_source=notifications&email_token=ADRZL27KPIL33IV2YUCLXHTP4QZOHA5CNFSM4H3PPE7KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYVSOSI#issuecomment-506144585, or mute the thread https://github.com/notifications/unsubscribe-auth/ADRZL22D2MJGJQT5T524LXTP4QZOHANCNFSM4H3PPE7A .

radvani avatar Jun 27 '19 14:06 radvani

2019-06-28 09:54:05.777 20421-20488/com.example.virosample I/Viro: Loading font face [name: Helvetica, index: -1] 2019-06-28 09:54:05.777 20421-20488/com.example.virosample I/Viro: Failed to find suitable face matching [Helvetica], defaulting to system font 2019-06-28 09:54:05.852 20421-20488/com.example.virosample I/Viro: Loading font face [name: Roboto, index: -1] 2019-06-28 09:54:05.852 20421-20488/com.example.virosample I/Viro: Failed to find suitable face matching [Roboto], defaulting to system font 2019-06-28 09:54:05.853 20421-20488/com.example.virosample I/Viro: Loading font face [name: NotoSansCJK, index: -1] 2019-06-28 09:54:05.853 20421-20488/com.example.virosample I/Viro: Failed to find suitable face matching [NotoSansCJK], defaulting to system font 2019-06-28 09:54:05.863 20421-20488/com.example.virosample I/Viro: Loading font face [name: Roboto, index: -1] 2019-06-28 09:54:05.863 20421-20488/com.example.virosample I/Viro: Failed to find suitable face matching [Roboto], defaulting to system font 2019-06-28 09:54:05.863 20421-20488/com.example.virosample I/Viro: Loading font face [name: NotoSansCJK, index: -1] 2019-06-28 09:54:05.863 20421-20488/com.example.virosample I/Viro: Failed to find suitable face matching [NotoSansCJK], defaulting to system font 2019-06-28 09:54:05.867 20421-20488/com.example.virosample I/Viro: Loading font face [name: Roboto, index: -1] 2019-06-28 09:54:05.867 20421-20488/com.example.virosample I/Viro: Failed to find suitable face matching [Roboto], defaulting to system font 2019-06-28 09:54:05.867 20421-20488/com.example.virosample I/Viro: Loading font face [name: NotoSansCJK, index: -1] 2019-06-28 09:54:05.867 20421-20488/com.example.virosample I/Viro: Failed to find suitable face matching [NotoSansCJK], defaulting to system font 2019-06-28 09:54:05.879 20421-20488/com.example.virosample I/Viro: Loading font face [name: Roboto, index: -1] 2019-06-28 09:54:05.879 20421-20488/com.example.virosample I/Viro: Failed to find suitable face matching [Roboto], defaulting to system font 2019-06-28 09:54:05.880 20421-20488/com.example.virosample I/Viro: Loading font face [name: NotoSansCJK, index: -1] 2019-06-28 09:54:05.880 20421-20488/com.example.virosample I/Viro: Failed to find suitable face matching [NotoSansCJK], defaulting to system font 2019-06-28 09:54:05.892 20421-20488/com.example.virosample I/Viro: Loading font face [name: Roboto, index: -1] 2019-06-28 09:54:05.892 20421-20488/com.example.virosample I/Viro: Failed to find suitable face matching [Roboto], defaulting to system font 2019-06-28 09:54:05.893 20421-20488/com.example.virosample I/Viro: Loading font face [name: NotoSansCJK, index: -1] 2019-06-28 09:54:05.893 20421-20488/com.example.virosample I/Viro: Failed to find suitable face matching [NotoSansCJK], defaulting to system font 2019-06-28 09:54:08.883 20421-20488/com.example.virosample I/Viro: Loading font face [name: Roboto, index: -1] 2019-06-28 09:54:08.883 20421-20488/com.example.virosample I/Viro: Failed to find suitable face matching [Roboto], defaulting to system font 2019-06-28 09:54:08.884 20421-20488/com.example.virosample I/Viro: Loading font face [name: NotoSansCJK, index: -1] 2019-06-28 09:54:08.884 20421-20488/com.example.virosample I/Viro: Failed to find suitable face matching [NotoSansCJK], defaulting to system font 2019-06-28 09:54:08.915 20421-20488/com.example.virosample I/Viro: Loading font face [name: Roboto, index: -1] 2019-06-28 09:54:08.915 20421-20488/com.example.virosample I/Viro: Failed to find suitable face matching [Roboto], defaulting to system font 2019-06-28 09:54:08.916 20421-20488/com.example.virosample I/Viro: Loading font face [name: NotoSansCJK, index: -1] 2019-06-28 09:54:08.916 20421-20488/com.example.virosample I/Viro: Failed to find suitable face matching [NotoSansCJK], defaulting to system font 2019-06-28 09:54:08.934 20421-20488/com.example.virosample I/Viro: Loading font face [name: Roboto, index: -1] 2019-06-28 09:54:08.934 20421-20488/com.example.virosample I/Viro: Failed to find suitable face matching [Roboto], defaulting to system font 2019-06-28 09:54:08.934 20421-20488/com.example.virosample I/Viro: Loading font face [name: NotoSansCJK, index: -1] 2019-06-28 09:54:08.934 20421-20488/com.example.virosample I/Viro: Failed to find suitable face matching [NotoSansCJK], defaulting to system font 2019-06-28 09:54:08.955 20421-20488/com.example.virosample I/Viro: Loading font face [name: Roboto, index: -1] 2019-06-28 09:54:08.955 20421-20488/com.example.virosample I/Viro: Failed to find suitable face matching [Roboto], defaulting to system font 2019-06-28 09:54:08.955 20421-20488/com.example.virosample I/Viro: Loading font face [name: NotoSansCJK, index: -1] 2019-06-28 09:54:08.955 20421-20488/com.example.virosample I/Viro: Failed to find suitable face matching [NotoSansCJK], defaulting to system font 2019-06-28 09:54:08.972 20421-20488/com.example.virosample I/Viro: Loading font face [name: Roboto, index: -1] 2019-06-28 09:54:08.972 20421-20488/com.example.virosample I/Viro: Failed to find suitable face matching [Roboto], defaulting to system font 2019-06-28 09:54:08.972 20421-20488/com.example.virosample I/Viro: Loading font face [name: NotoSansCJK, index: -1] 2019-06-28 09:54:08.972 20421-20488/com.example.virosample I/Viro: Failed to find suitable face matching [NotoSansCJK], defaulting to system font

18320877747 avatar Jun 28 '19 01:06 18320877747

Text.TextBuilder textBuilder = Text.builder().fontSize(20).fontFamilies("Roboto,NotoSansCJK").height(1f).width(2.0f).maxLines(1).textString("hello(你好)").viroContext(mViroView.getViroContext()). clipMode(Text.ClipMode.NONE).horizontalAlignment(Text.HorizontalAlignment.LEFT).verticalAlignment(Text.VerticalAlignment.TOP);

18320877747 avatar Jun 28 '19 01:06 18320877747

@radvani Above is the relevant log and code. It looks like fontFamilies are not in effect, but I don't know why

18320877747 avatar Jun 28 '19 01:06 18320877747

Looks like a bug in viro

18320877747 avatar Jun 28 '19 01:06 18320877747

java.lang.NullPointerException: Attempt to invoke virtual method 'com.viro.core.internal.font.FontFamily$Font com.viro.core.internal.font.FontFamily.getFont(boolean, int)' on a null object reference
    at com.viro.core.internal.font.SystemFontLoader.init(SystemFontLoader.java:145)
    at com.viro.core.internal.PlatformUtil.<init>(PlatformUtil.java:113)
    at com.viro.core.ViroViewARCore.init(ViroViewARCore.java:555)
    at com.viro.core.ViroViewARCore.<init>(ViroViewARCore.java:446)
    at com.viro.core.ViroViewARCore.<init>(ViroViewARCore.java:418)
    at com.example.virosample.ViroActivity.onCreate(ViroActivity.java:103)
    at android.app.Activity.performCreate(Activity.java:7436)
    at android.app.Activity.performCreate(Activity.java:7426)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1286)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3279)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3484)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:86)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2123)
    at android.os.Handler.dispatchMessage(Handler.java:109)
    at android.os.Looper.loop(Looper.java:207)
    at android.app.ActivityThread.main(ActivityThread.java:7470)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958)

18320877747 avatar Jun 28 '19 02:06 18320877747

fonts.txt this file is system/etc/fonts.xml

18320877747 avatar Jun 28 '19 02:06 18320877747

A nullpointException occurs when SystemFontLoader init, resulting in sTypefaceFontMap not being assigned a value. When findFont is called, no Font is retrieved, resulting in a load failure

18320877747 avatar Jun 28 '19 03:06 18320877747

Map<String, Font> fontsByAlias = new HashMap(); Alias[] var20 = fontConfig.getAliases(); int var21 = var20.length;

        for(int var22 = 0; var22 < var21; ++var22) {
            Alias alias = var20[var22];
            FontFamily toFamily = fontsByName.get(alias.getToName());
            int weight = alias.getWeight();
            Font font = toFamily.getFont(false, weight);
            if (font != null) {
                fontsByAlias.put(alias.getName(), font);
                if (DEBUG_FONTS) {
                    Log.i(TAG, "Aliased [" + alias.getName() + "] to font " + font.getPath());
                }
            }
        }

this code in systemfontloader.init is to assign sAliasedFonts, but sAliasedFonts isn't used anywhere. But this code caused my problem

18320877747 avatar Jun 28 '19 03:06 18320877747