Example #1
0
        protected virtual List <IFontInfo> ReadCollection(BigEndianReader reader, string source)
        {
            var header             = TTCHeader.ReadHeader(reader, this);
            List <IFontInfo> found = new List <IFontInfo>();

            for (int f = 0; f < header.NumFonts; f++)
            {
                TypefaceVersionReader innerVers;

                reader.Position = header.FontOffsets[f];
                if (TryGetVersion(reader, out innerVers))
                {
                    var info = innerVers.ReadTypefaceInfoAfterVersion(reader, source);
                    if (info is Utility.SingleTypefaceInfo sti)
                    {
                        sti.OffsetInFile = header.FontOffsets[f];
                    }
                    if (null != info && info.FontCount == 1)
                    {
                        found.Add(info.Fonts[0]);
                    }
                }
            }

            return(found);
        }
        internal static bool TryReadHeader(BigEndianReader reader, out TTCHeader header)
        {
            header = null;
            TypefaceVersionReader vers;

            if (TypefaceVersionReader.TryGetVersion(reader, out vers) == false)
            {
                return(false);
            }
            else if (vers is TTCollectionVersionReader ttc)
            {
                header = ReadHeader(reader, ttc);
            }
            else
            {
                return(false);
            }

            return(null != header);
        }