File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed
AndroidNative/maui/src/main/java/com/microsoft/maui Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change 19
19
import android .os .Build ;
20
20
import android .text .Editable ;
21
21
import android .text .InputFilter ;
22
+ import android .util .DisplayMetrics ;
22
23
import android .util .TypedValue ;
23
24
import android .view .Gravity ;
24
25
import android .view .View ;
@@ -598,13 +599,17 @@ public static Rect getCurrentWindowMetrics(Activity activity) {
598
599
* @return FontMetrics object or null if context or display metrics is null
599
600
*/
600
601
public static Paint .FontMetrics getFontMetrics (Context context , double defaultFontSize ) {
601
- if (context != null && context .getResources ().getDisplayMetrics () != null ) {
602
+ if (context == null )
603
+ return null ;
604
+
605
+ DisplayMetrics metrics = context .getResources ().getDisplayMetrics ();
606
+ if (metrics != null ) {
602
607
return new Paint () {{
603
608
setTextSize (
604
609
TypedValue .applyDimension (
605
610
TypedValue .COMPLEX_UNIT_SP ,
606
611
(float ) defaultFontSize ,
607
- context . getResources (). getDisplayMetrics ()
612
+ metrics
608
613
));
609
614
}}.getFontMetrics ();
610
615
} else {
You can’t perform that action at this time.
0 commit comments