Skip to content

Commit a4d2f0a

Browse files
committed
fix(textlayer): incorrect text line height calculation (#169)
1 parent e53b42c commit a4d2f0a

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

src/font/textlayer.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ static void TextLayer_UpdateRowSize(LCUI_TextLayer layer, LCUI_TextRow txtrow)
196196
if (layer->line_height > -1) {
197197
txtrow->height = layer->line_height;
198198
} else {
199-
txtrow->height = GetDefaultLineHeight(txtrow->height);
199+
txtrow->height = GetDefaultLineHeight(txtrow->text_height);
200200
}
201201
}
202202

test/test_string_render.c

+15-15
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,39 @@
44
#include <LCUI/image.h>
55
#include <LCUI/font.h>
66

7-
int main( void )
7+
int main(void)
88
{
99
int ret;
1010
LCUI_Graph img;
11-
LCUI_Pos pos = {0, 80};
12-
LCUI_Rect area = {0, 0, 320, 240};
11+
LCUI_Pos pos = { 0, 80 };
12+
LCUI_Rect area = { 0, 0, 320, 240 };
1313
LCUI_TextLayer txt = TextLayer_New();
1414
LCUI_TextStyleRec txtstyle;
1515

1616
/* 初始化字体处理功能 */
1717
LCUI_InitFontLibrary();
1818

1919
/* 创建一个图像,并使用灰色填充 */
20-
Graph_Init( &img );
21-
Graph_Create( &img, 320, 240 );
22-
Graph_FillRect( &img, RGB( 240, 240, 240 ), NULL, FALSE );
20+
Graph_Init(&img);
21+
Graph_Create(&img, 320, 240);
22+
Graph_FillRect(&img, RGB(240, 240, 240), NULL, FALSE);
2323

2424
/* 设置文本的字体大小 */
25-
TextStyle_Init( &txtstyle );
25+
TextStyle_Init(&txtstyle);
2626
txtstyle.pixel_size = 24;
2727
txtstyle.has_pixel_size = TRUE;
2828

2929
/* 设置文本图层的固定尺寸、文本样式、文本内容、对齐方式 */
30-
TextLayer_SetFixedSize( txt, 320, 240 );
31-
TextLayer_SetTextStyle( txt, &txtstyle );
32-
TextLayer_SetTextAlign( txt, SV_CENTER );
33-
TextLayer_SetTextW( txt, L"这是一段测试文本\nHello, World!", NULL );
34-
TextLayer_Update( txt, NULL );
30+
TextLayer_SetFixedSize(txt, 320, 240);
31+
TextLayer_SetTextStyle(txt, &txtstyle);
32+
TextLayer_SetTextAlign(txt, SV_CENTER);
33+
TextLayer_SetTextW(txt, L"这是一段测试文本\nHello, World!", NULL);
34+
TextLayer_Update(txt, NULL);
3535

3636
/* 将文本图层绘制到图像中,然后将图像写入至 png 文件中 */
37-
TextLayer_RenderTo( txt, area, pos, &img );
38-
ret = LCUI_WritePNGFile( "test_string_render.png", &img );
39-
Graph_Free( &img );
37+
TextLayer_RenderTo(txt, area, pos, &img);
38+
ret = LCUI_WritePNGFile("test_string_render.png", &img);
39+
Graph_Free(&img);
4040

4141
/* 释放字体处理功能相关资源 */
4242
LCUI_FreeFontLibrary();

0 commit comments

Comments
 (0)