TextBaseline's alphabetic and ideographic enums do not work in Flutter

前端 未结 3 1080
囚心锁ツ
囚心锁ツ 2021-01-13 09:34

I thought I understand how these enums work based on this post. When I tried it using the following code, it does not seem to work.

Row(
  mainAxisAlignment:         


        
3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-13 10:17

    So, I did some digging and found some info on this article here.

    According to this article :

    "alphabetic"
    
    The text baseline is the normal alphabetic baseline. Default value.
    
    "ideographic"
    
    The text baseline is the ideographic baseline; this is the bottom of the body of the characters, 
    if the main body of characters protrudes beneath the alphabetic baseline. 
    (Used by Chinese, Japanese, and Korean scripts.)
    

    According to this, the output should be differentiable as stated in the problem. So, in order to test the second part of the explanation, I tried using it with Chinese characters.

    Column(
                  children: [
                      Row(
                      mainAxisAlignment: MainAxisAlignment.center,
                      crossAxisAlignment: CrossAxisAlignment.baseline,
                      textBaseline: TextBaseline.ideographic,
                      children: [
                      Text(
                        '的',
                        style: TextStyle(
                          fontSize: 100.0),
                        ),
                        Text(
                          '的',
                          style: TextStyle(fontSize: 15.0),
                        ),
                      ],
                   ),
                    Row(
                      mainAxisAlignment: MainAxisAlignment.center,
                      crossAxisAlignment: CrossAxisAlignment.baseline,
                      textBaseline: TextBaseline.alphabetic,
                      children: [
                      Text(
                        '的',
                        style: TextStyle(
                          fontSize: 100.0),
                        ),
                        Text(
                          '的',
                          style: TextStyle(fontSize: 15.0),
                        ),
                      ],
                   ),
                    ],
              ),
          ),
    

    The output was this.

    As you can see, this too is not the expected output, and both work in the same manner. Hence, it is safe to assume that there may be some problem in Flutter's implementation of these enums.

提交回复
热议问题