Check if custom font can display character

前端 未结 6 988
感情败类
感情败类 2020-12-06 17:14

I have a custom font which is displaying the box character. The font I am using does not support all languages apparently. I want to check if the String I am about to displa

6条回答
  •  爱一瞬间的悲伤
    2020-12-06 17:55

    To check whether the music symbol ♫ is being displayed in a string (if it is not being displayed on some devices), you can try measuring the string width; if width == 0 then the symbol is absent.

    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    Rect rtt = new Rect();
    paint.getTextBounds( "♫", 0, 1, rtt );
        if( rtt.width() == 0 ){
    }
    

提交回复
热议问题