You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Tizen应用中C语言设置Elm Label字体大小失效求助

Fixing Font Size for Elm Label in Tizen C Application

Let’s break down why your font size setting isn’t working and fix it step by step:

1. The Immediate Problem: Incorrect String Formatting

That comma-separated expression in your elm_object_text_set call isn’t doing what you expect. In C, the expression ("<font_size=30 >%s</font_size>","TestString") only returns the last operand ("TestString"), so the <font_size> tag never actually gets passed to the label. You need to properly format the string to inject your test text into the markup template.

Use snprintf (or asprintf for dynamic memory allocation) to build the complete formatted string:

char label_text[256]; // Adjust the buffer size based on your actual text length
snprintf(label_text, sizeof(label_text), "<font_size=30>%s</font_size>", "TestString");

2. Enable Markup Parsing for Elm Label

By default, Elm Label doesn’t parse HTML-like markup tags. You have to explicitly enable this functionality so the label recognizes and applies the <font_size> tag:

elm_label_markup_allowed_set(wid->label, EINA_TRUE);

Full Corrected Code Example

Here’s how your code should look after addressing both issues:

/* Label*/
wid->label = elm_label_add(wid->conform);
evas_object_resize(wid->label, 200, 100);
evas_object_move(wid->label, (w / 4)+115, (h / 2 )+100);
evas_object_color_set(wid->label, 50, 255, 150, 255);

// Enable markup parsing to recognize font size tags
elm_label_markup_allowed_set(wid->label, EINA_TRUE);

// Build the properly formatted text with font size styling
char label_text[256];
snprintf(label_text, sizeof(label_text), "<font_size=30>%s</font_size>", "TestString");

elm_object_text_set(wid->label, label_text);
evas_object_show(wid->label);

Alternative: Using Tizen’s Style API

If you prefer to avoid markup, you can set the font size directly via the label’s style property, which aligns with EFL’s native styling conventions:

elm_object_text_style_set(wid->label, "font_size=30");
elm_object_text_set(wid->label, "TestString");

This method doesn’t require enabling markup parsing, and it’s often more maintainable for consistent app styling.


内容的提问来源于stack exchange,提问作者Rifat

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.12 04:25:47