void RequestDownload(string familyName)
        {
            QueryBuilder queryBuilder = new QueryBuilder(familyName)
                                        .WithWidth(ProgressToWidth(WidthSeekBar.Progress))
                                        .WithWeight(ProgressToWeight(WeightSeekBar.Progress))
                                        .WithItalic(ProgressToItalic(ItalicSeekBar.Progress))
                                        .WithBestEffort(BestEffort.Checked);
            string query = queryBuilder.Build();

            Log.Debug(Tag, "Requesting a font. Query: " + query);
            FontRequest request = new FontRequest(
                "com.google.android.gms.fonts",
                "com.google.android.gms",
                query,
                Resource.Array.com_google_android_gms_fonts_certs);

            var progressBar = FindViewById(Resource.Id.progressBar) as ProgressBar;

            progressBar.Visibility = Android.Views.ViewStates.Visible;

            FontsContractCompat.FontRequestCallback callback = new FontRequestCallbackImpl
            {
                mActivity = this,
                mDownloadableFontTextView = DownloadableFontTextView,
                mRequestDownloadButton    = RequestDownloadButton,
                mProgressBar = progressBar
            };

            FontsContractCompat.RequestFont(this, request, callback, GetHandlerThreadHandler());
        }
Esempio n. 2
0
        public override void OnCreate()
        {
            base.OnCreate();

            EmojiCompat.Config config;
            if (UseBundledEmoji)
            {
                // Use the bundled font for EmojiCompat
                config = new BundledEmojiCompatConfig(this);
            }
            else
            {
                // Use a downloadable font for EmojiCompat
                var fontRequest = new FontRequest(
                    "com.google.android.gms.fonts",
                    "com.google.android.gms",
                    "Noto Color Emoji Compat",
                    Resource.Array.com_google_android_gms_fonts_certs);
                config = new FontRequestEmojiCompatConfig(this, fontRequest)
                         .SetReplaceAll(true)
                         .RegisterInitCallback(new InitCallbackImpl());
            }

            EmojiCompat.Init(config);
        }