예제 #1
0
 static void LoadBundleFont(Typography.FontManagement.InstalledTypefaceCollection fontCollection, string fontFilename)
 {
     if (File.Exists(fontFilename))
     {
         using (Stream s = new FileStream(fontFilename, FileMode.Open, FileAccess.Read))
             using (var ms = new MemoryStream())// This is a simple hack because on Xamarin.Android, a `Stream` created by `AssetManager.Open` is not seekable.
             {
                 s.CopyTo(ms);
                 fontCollection.AddFontStreamSource(new BundleResourceFontStreamSource(new MemoryStream(ms.ToArray()), fontFilename));
             }
     }
 }
예제 #2
0
        static void LoadBundleFont(Typography.FontManagement.InstalledTypefaceCollection fontCollection, string fontfile)
        {
            // This is a simple hack because on Xamarin.Android, a `Stream` created by `AssetManager.Open` is not seekable.

            using (Stream s = MainActivity.AssetManager.Open(fontfile))
            {
                var ms = new MemoryStream();
                s.CopyTo(ms);
                ms.Position = 0;
                fontCollection.AddFontStreamSource(new BundleResourceFontStreamSource(ms, fontfile));
            }
        }