Skip to content

Commit

Permalink
Fix text padding (#399)
Browse files Browse the repository at this point in the history
* refactor: kCTLineBoundsIncludeLanguageExtents lead text padding too much replace with origin implement

* refactor: use CTLineGetBoundsWithOptions function to implement text width calculate
  • Loading branch information
JohnTsaii authored May 17, 2023
1 parent 4a6d027 commit 7b2a90b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions GaiaXiOS/GaiaXiOS/Component/Node/GXTextNode.m
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,10 @@ - (CGSize)labelSizeForFont:(UIFont *)font
// 等于1行时,动态计算宽度
CTLineRef lineRef = (__bridge CTLineRef)[linesRef firstObject];
// 通过kCTLineBoundsIncludeLanguageExtents来确保不同的语言都有足够的空间
CGRect rect = CTLineGetBoundsWithOptions(lineRef, kCTLineBoundsIncludeLanguageExtents);
width = rect.size.width;
CGRect rect = CTLineGetBoundsWithOptions(lineRef,
kCTLineBoundsExcludeTypographicLeading|
kCTLineBoundsExcludeTypographicShifts);
width = rect.size.width;
} else {
// 大于1行时,行宽直接用最大宽度
width = maxWidth;
Expand Down

0 comments on commit 7b2a90b

Please sign in to comment.