Exemplo n.º 1
0
		public static AndroidFont FromFamilyName(string familyName, FontStyle style, float sizeInPoints)
		{
			AndroidFont font = new AndroidFont ();
			font.InnerFont = Typeface.Create(familyName, style.Convert());
			font.FontFamily = familyName;
			font.Style = style;
			font.SizeInPoints = sizeInPoints;
			return font;
		}
Exemplo n.º 2
0
        public static AndroidFont FromFamilyName(string familyName, FontStyle style, float sizeInPoints)
        {
            AndroidFont font      = new AndroidFont();
            Typeface    innerFont = null;

            if (familyName != null)
            {
                _fontsFromFiles.TryGetValue(familyName, out innerFont);
            }
            if (innerFont != null)
            {
                innerFont = Typeface.Create(innerFont, style.Convert());
            }
            font.InnerFont    = innerFont ?? Typeface.Create(familyName, style.Convert());
            font.FontFamily   = familyName;
            font.Style        = style;
            font.SizeInPoints = sizeInPoints;
            return(font);
        }
Exemplo n.º 3
0
		public static AndroidFont FromPath(string path, FontStyle style, float sizeInPoints)
		{
            try
            {
                AndroidFont font = new AndroidFont();
                font.InnerFont = Typeface.Create(Typeface.CreateFromFile(path), style.Convert());
                font.FontFamily = path;
                font.Style = style;
                font.SizeInPoints = sizeInPoints;
                return font;
            }
            catch (RuntimeException e)
            {
                Debug.WriteLine(string.Format("Failed to load font from path: {0}, will resort to default font", path));
                Debug.WriteLine(e.ToString());
                return FromFamilyName("sans-serif", style, sizeInPoints);
            }
		}
Exemplo n.º 4
0
 public static AndroidFont FromPath(string path, FontStyle style, float sizeInPoints)
 {
     try
     {
         AndroidFont font = new AndroidFont();
         font.InnerFont        = Typeface.Create(Typeface.CreateFromFile(path), style.Convert());
         _fontsFromFiles[path] = font.InnerFont;
         font.FontFamily       = path;
         font.Style            = style;
         font.SizeInPoints     = sizeInPoints;
         return(font);
     }
     catch (RuntimeException e)
     {
         Debug.WriteLine($"Failed to load font from path: {path}, will resort to default font");
         Debug.WriteLine(e.ToString());
         return(FromFamilyName("sans-serif", style, sizeInPoints));
     }
 }