Beispiel #1
0
        public unsafe bool Register(ResourceFile file, out string familyName)
        {
            if (file.IsNone)
            {
                throw new ArgumentException("file is none.", nameof(file));
            }
            using var stream = file.GetStream();

            SKTypeface tf;

            if (stream.CanSeek && stream.Length <= int.MaxValue)
            {
                var size = (int)stream.Length;
                using var data = SKData.Create(size);
                stream.Read(new Span <byte>((void *)data.Data, size));
                tf = SKTypeface.FromData(data, 0);
            }
            else
            {
                using var data = SKData.Create(stream);
                tf             = SKTypeface.FromData(data, 0);
            }
            familyName = tf.FamilyName;
            return(_dic.TryAdd(tf.FamilyName, tf));
        }
Beispiel #2
0
 public static Icon LoadIcon(this ResourceFile file)
 {
     using var stream = file.GetStream();
     return(IcoParser.Parse(stream));
 }