title: Resolution Depdendent FontSize for Xamarin.Forms
body: <p>So I am developing a <code>Xamarin.Forms</code> application for Tablets, and now I need it to also run on phones - Great, Xamarin.Forms should handle all that (or so I thought).</p>
  
  <p>I ran the application on my phone but it didnt scale down the Font (or any sizes for that matter, but I'll start with font)</p>
  
  <p>I created an extension method like so:</p>
  
  <pre><code>[ContentProperty("FontSize")]
  public class FontExtension : IMarkupExtension
  {
      public string FontSize { get; set; }
  
      public object ProvideValue(IServiceProvider serviceProvider)
      {
          double fontSize;
  
          if (FontSize == null)
              throw new Exception("No Font Size provided");
  
          if (!double.TryParse(FontSize, out fontSize))
              throw new Exception("Font Size Provided is not a double");
  
          return App.Scaling * fontSize;
      }
  }
  </code></pre>
  
  <p>and I use this in my application like <code>FontSize={ns:Font 18}</code> and this will downscale my application based on the <code>App.Scaling</code> property. This property is just set to <code>0.8</code> if it is a <code>Phone</code>.</p>
  
  <p>I also found two links that provided a way in <code>Xamarin.Android</code> but I am doing a <code>Xamarin.Forms</code> application so didnt apply. (<a href="https://developer.xamarin.com/recipes/android/resources/device_specific/detect_screen_size/" rel="nofollow noreferrer">link1</a>,<a href="https://stackoverflow.com/questions/30527724/resolution-dependent-font-size-in-xamarin">link2</a>)</p>
  
  <p>Is it possible to scale the font down based on the devices <strong>Resolution</strong> rather than <strong>Idiom</strong>?</p>