Check the family of a Typeface object in Android

前端 未结 2 1203
你的背包
你的背包 2021-01-19 13:34

Is it possible to check what family a Typeface object is using in Android API 8?

I am creating the Typeface on a Paint object like so

//Simplified co         


        
2条回答
  •  自闭症患者
    2021-01-19 14:07

    If you look at the sources, you will see that the default ones are created with style DEFAULT (*), so:

    Typeface paintTf = paint.getTypeface();
    Typeface.SERIF.equals(Typeface.create(paintTf, Typeface.DEFAULT));
    

    might do the job (here I check is family is serif).

    NB: (*) is not true for DEFAULT_BOLD.

提交回复
热议问题