Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The button component cannot be displayed in Chinese #5456

Closed
rulongche opened this issue Jun 22, 2024 · 4 comments
Closed

The button component cannot be displayed in Chinese #5456

rulongche opened this issue Jun 22, 2024 · 4 comments
Labels
a:text Text rendering, fonts, Text input (mS,bF) bug Something isn't working

Comments

@rulongche
Copy link

After setting the height of the button component, the preview display is normal, but the Chinese language cannot be displayed after publication
Button { text: "复制"; height: 24px; }
screenshot-20240622-180601

@ogoffart
Copy link
Member

Thanks for filling an issue. Looks like a font problem.
What platform and renderer are you using?

@ogoffart ogoffart added a:text Text rendering, fonts, Text input (mS,bF) bug Something isn't working labels Jun 24, 2024
@humbinal
Copy link

Thanks for filling an issue. Looks like a font problem. What platform and renderer are you using?

I had the same problem, windows and winit renderer.

@tronical
Copy link
Member

tronical commented Jul 11, 2024

I think I can reproduce this. Here's a simpler test case:

import { Slider } from "std-widgets.slint";
export component Demo {
    width: 200px;
    height: 200px;
    Text {
        x: 50px;
        y: 50px;
        text: "Hello";
        height: sl.value * 1px;
    }

    sl := Slider {
        width: 100%;
        y: parent.height - self.height;
        value: 10;
        minimum: 8;
        maximum: 64;
    }
}

Observe how the text of the button appears and disappears depending on the height. When a Text element does not have sufficient height to display the text, it will not render anything.

In your case, as it happens, the height is insufficient for the font selected to display the Chinese text - I suspect the ascent/descent is just above the 24px you specify.

I recommend placing widgets into layouts and letting them resize based on their minimum size, instead of hard-coding a specific height. That way the application also works well when users have bigger font sizes configured on their system, for example, for improved readability.

@tronical
Copy link
Member

Duplicate of #2029

@tronical tronical marked this as a duplicate of #2029 Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:text Text rendering, fonts, Text input (mS,bF) bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants