Support Density Independent Pixel on FontSize
authorSeungkeun Lee <sngn.lee@samsung.com>
Wed, 4 Jan 2017 05:01:48 +0000 (14:01 +0900)
committerKangho Hur <kangho.hur@samsung.com>
Fri, 24 Mar 2017 04:18:58 +0000 (13:18 +0900)
 - FontSize on Span was use DP unit

Change-Id: I1a0a50dbeae3ede0c61a67f60f7238631684537d

Xamarin.Forms.Platform.Tizen/Forms.cs
Xamarin.Forms.Platform.Tizen/Native/Span.cs
Xamarin.Forms.Platform.Tizen/TizenPlatformServices.cs

index 34828a4..453bab8 100644 (file)
@@ -11,6 +11,12 @@ namespace Xamarin.Forms.Platform.Tizen
 {
        public static class Forms
        {
+               static Lazy<int> s_dpi = new Lazy<int>(() =>
+               {
+                       int dpi = 0;
+                       TSystemInfo.TryGetValue<int>("http://tizen.org/feature/screen.dpi", out dpi);
+                       return dpi;
+               });
                class TizenDeviceInfo : DeviceInfo
                {
                        readonly Size pixelScreenSize;
@@ -178,6 +184,11 @@ namespace Xamarin.Forms.Platform.Tizen
                        // TODO: implement me
                        return Color.Black;
                }
+
+               internal static int ConvertToPixel(double dp)
+               {
+                       return (int)Math.Round(dp * s_dpi.Value / 160.0);
+               }
        }
 
        class TizenExpressionSearch : ExpressionVisitor, IExpressionSearch
@@ -206,4 +217,4 @@ namespace Xamarin.Forms.Platform.Tizen
                        return base.VisitMember(node);
                }
        }
-}
\ No newline at end of file
+}
index 7ac4134..0e3f000 100644 (file)
@@ -175,7 +175,7 @@ namespace Xamarin.Forms.Platform.Tizen.Native
 
                        if (FontSize != -1)
                        {
-                               _formattingString.AppendFormat("font_size={0} ", FontSize);
+                               _formattingString.AppendFormat("font_size={0} ", Forms.ConvertToPixel(FontSize));
                        }
 
                        if ((FontAttributes & FontAttributes.Bold) != 0)
index 7d44231..db7ee1d 100644 (file)
@@ -82,14 +82,14 @@ namespace Xamarin.Forms.Platform.Tizen
                        switch (size)
                        {
                                case NamedSize.Micro:
-                                       return 16;
+                                       return 10;
                                case NamedSize.Small:
-                                       return 20;
+                                       return 12;
                                case NamedSize.Default:
                                case NamedSize.Medium:
-                                       return 24;
+                                       return 14;
                                case NamedSize.Large:
-                                       return 30;
+                                       return 18;
                                default:
                                        throw new ArgumentOutOfRangeException();
                        }