How can I show text with different language direct

2019-07-29 08:22发布

I need to show some text in Arabic (which is right-to-left) and some other text in English (which is left-to-right) in the same GTK+ windows. Is there any way to set the language to the GktLabel instead of the application?

标签: gtk pango
1条回答
我欲成王,谁敢阻挡
2楼-- · 2019-07-29 09:10

Yes, with gtk_widget_set_direction:

label = gtk_label_new ("Hello World");
gtk_widget_set_halign (label, GTK_ALIGN_START);
gtk_container_add (GTK_CONTAINER (box), label);

label = gtk_label_new ("برنامج أهلا بالعالم");
gtk_widget_set_halign (label, GTK_ALIGN_START);
gtk_widget_set_direction (label, GTK_TEXT_DIR_RTL);
gtk_container_add (GTK_CONTAINER (box), label);

Screenshot

查看更多
登录 后发表回答