Exemplo n.º 1
0
        private static string[] GetGlyphNamesByFormat(TrueTypeDataBytes data, BasicMaximumProfileTable maximumProfileTable,
                                                      float formatType)
        {
            string[] glyphNames;
            if (Math.Abs(formatType - 1) < float.Epsilon)
            {
                glyphNames = new string[WindowsGlyphList4.NumberOfMacGlyphs];
                for (var i = 0; i < WindowsGlyphList4.MacGlyphNames.Count; i++)
                {
                    glyphNames[i] = WindowsGlyphList4.MacGlyphNames[i];
                }
            }
            else if (Math.Abs(formatType - 2) < float.Epsilon)
            {
                glyphNames = GetFormat2GlyphNames(data);
            }
            else if (Math.Abs(formatType - 2.5) < float.Epsilon)
            {
                var glyphNameIndex = new int[maximumProfileTable?.NumberOfGlyphs ?? 0];

                for (var i = 0; i < glyphNameIndex.Length; i++)
                {
                    var offset = data.ReadSignedByte();
                    glyphNameIndex[i] = i + 1 + offset;
                }

                glyphNames = new string[glyphNameIndex.Length];

                for (var i = 0; i < glyphNames.Length; i++)
                {
                    var name = WindowsGlyphList4.MacGlyphNames[glyphNameIndex[i]];

                    if (name != null)
                    {
                        glyphNames[i] = name;
                    }
                }
            }
            else if (Math.Abs(formatType - 3) < float.Epsilon)
            {
                glyphNames = new string[0];
            }
            else
            {
                throw new InvalidOperationException($"Format type {formatType} is not supported for the PostScript table.");
            }

            return(glyphNames);
        }
Exemplo n.º 2
0
        private static string[] GetGlyphNamesByFormat(TrueTypeDataBytes data, BasicMaximumProfileTable maximumProfileTable,
                                                      float formatType)
        {
            string[] glyphNames;
            if (Math.Abs(formatType - 1) < float.Epsilon)
            {
                glyphNames = new string[WindowsGlyphList4.NumberOfMacGlyphs];
                for (var i = 0; i < WindowsGlyphList4.MacGlyphNames.Count; i++)
                {
                    glyphNames[i] = WindowsGlyphList4.MacGlyphNames[i];
                }
            }
            else if (Math.Abs(formatType - 2) < float.Epsilon)
            {
                glyphNames = GetFormat2GlyphNames(data);
            }
            else if (Math.Abs(formatType - 2.5) < float.Epsilon)
            {
                var glyphNameIndex = new int[maximumProfileTable?.NumberOfGlyphs ?? 0];

                for (var i = 0; i < glyphNameIndex.Length; i++)
                {
                    var offset = data.ReadSignedByte();
                    glyphNameIndex[i] = i + 1 + offset;
                }

                glyphNames = new string[glyphNameIndex.Length];

                for (var i = 0; i < glyphNames.Length; i++)
                {
                    var name = WindowsGlyphList4.MacGlyphNames[glyphNameIndex[i]];

                    if (name != null)
                    {
                        glyphNames[i] = name;
                    }
                }
            }
            else if (Math.Abs(formatType - 3) < float.Epsilon)
            {
                glyphNames = EmptyArray <string> .Instance;
            }
            else
            {
                glyphNames = EmptyArray <string> .Instance;
            }

            return(glyphNames);
        }
Exemplo n.º 3
0
        public static PostScriptTable Load(TrueTypeDataBytes data, TrueTypeHeaderTable table, BasicMaximumProfileTable maximumProfileTable)
        {
            data.Seek(table.Offset);
            var formatType         = data.Read32Fixed();
            var italicAngle        = data.Read32Fixed();
            var underlinePosition  = data.ReadSignedShort();
            var underlineThickness = data.ReadSignedShort();
            var isFixedPitch       = data.ReadUnsignedInt();
            var minMemType42       = data.ReadUnsignedInt();
            var maxMemType42       = data.ReadUnsignedInt();
            var mimMemType1        = data.ReadUnsignedInt();
            var maxMemType1        = data.ReadUnsignedInt();

            var glyphNames = GetGlyphNamesByFormat(data, maximumProfileTable, formatType);

            return(new PostScriptTable(table, (decimal)formatType, (decimal)italicAngle,
                                       underlinePosition, underlineThickness, isFixedPitch,
                                       minMemType42, maxMemType42, mimMemType1,
                                       maxMemType1, glyphNames));
        }