internal static string PullFontPathFromTheme(Context context, int styleAttrId, int[] attributeId)
        {
            if (styleAttrId == -1 || attributeId == null)
            {
                return(null);
            }

            Android.Content.Res.Resources.Theme theme = context.Theme;
            var value = new TypedValue();

            theme.ResolveAttribute(styleAttrId, value, true);
            TypedArray typedArray = theme.ObtainStyledAttributes(value.ResourceId, attributeId);

            try
            {
                string font = typedArray.GetString(0);
                return(font);
            }
            catch (Exception)
            {
                //failed for some reason
                return(null);
            }
            finally
            {
                typedArray.Recycle();
            }
        }
        /// <summary>
        /// Last but not least, try to pull the Font Path from the Theme, which is defined.
        /// </summary>
        /// <returns>null if no theme or attribute defined.</returns>
        /// <param name="context">Activity Context.</param>
        /// <param name="styleAttrId">Theme style id.</param>
        /// <param name="subStyleAttrId">the sub style from the theme to look up after the first style.</param>
        /// <param name="attributeId">if -1 returns null.</param>
        internal static string PullFontPathFromTheme(Context context, int styleAttrId, int subStyleAttrId, int[] attributeId)
        {
            if (styleAttrId == -1 || attributeId == null)
            {
                return(null);
            }

            Android.Content.Res.Resources.Theme theme = context.Theme;
            var value = new TypedValue();

            theme.ResolveAttribute(styleAttrId, value, true);
            int        subStyleResId    = -1;
            TypedArray parentTypedArray = theme.ObtainStyledAttributes(value.ResourceId, new int[] { subStyleAttrId });

            try
            {
                subStyleResId = parentTypedArray.GetResourceId(0, -1);
            }
            catch (Exception)
            {
                // Failed for some reason.
                return(null);
            }
            finally
            {
                parentTypedArray.Recycle();
            }

            if (subStyleResId == -1)
            {
                return(null);
            }
            TypedArray subTypedArray = context.ObtainStyledAttributes(subStyleResId, attributeId);

            if (subTypedArray != null)
            {
                try
                {
                    return(subTypedArray.GetString(0));
                }
                catch (Exception)
                {
                    // Failed for some reason.
                    return(null);
                }
                finally
                {
                    subTypedArray.Recycle();
                }
            }
            return(null);
        }