Exemplo n.º 1
0
        public override void Serialize(BinaryWriter writer, long startOffset, SerializationInfo additionalInfo)
        {
            writer.BaseStream.Position = startOffset;
            DataTypeConverter.WriteUShort(writer, Format);
            var lengthOffset = writer.BaseStream.Position;

            writer.BaseStream.Position += DataTypeLength.UShort;
            DataTypeConverter.WriteUShort(writer, Language);
            for (uint i = 0; i < 256; i++)
            {
                if (CharGlyphIdMap.ContainsKey(i))
                {
                    writer.Write((byte)CharGlyphIdMap[i]);
                }
                else
                {
                    writer.Write((byte)0);
                }
            }

            // Set length
            var length = writer.BaseStream.Position - startOffset;

            writer.BaseStream.Position = lengthOffset;
            DataTypeConverter.WriteUShort(writer, (ushort)length);

            // Recover writer position
            writer.BaseStream.Position = startOffset + length;
        }
Exemplo n.º 2
0
        public object DeepCopy()
        {
            var newTable = (CmapSubtable)MemberwiseClone();

            newTable.CharGlyphIdMap = CharGlyphIdMap.ToDictionary(pair => pair.Key, pair => pair.Value);
            newTable.Environments   = Environments.Select(environment => (Environment)environment.DeepCopy()).ToList();
            return(newTable);
        }
Exemplo n.º 3
0
        public override void Serialize(BinaryWriter writer, long startOffset, SerializationInfo additionalInfo)
        {
            writer.BaseStream.Position = startOffset;
            DataTypeConverter.WriteUShort(writer, Format);
            var lengthOffset = writer.BaseStream.Position;

            writer.BaseStream.Position += DataTypeLength.UShort;
            DataTypeConverter.WriteUShort(writer, Language);

            var firstCode = CharGlyphIdMap.Keys.Min();
            var lastCode  = CharGlyphIdMap.Keys.Max();

            DataTypeConverter.WriteUShort(writer, (ushort)firstCode);
            DataTypeConverter.WriteUShort(writer, (ushort)(lastCode - firstCode + 1));

            for (var i = firstCode; i <= lastCode; i++)
            {
                if (CharGlyphIdMap.ContainsKey(i))
                {
                    DataTypeConverter.WriteUShort(writer, (ushort)CharGlyphIdMap[i]);
                }
                else
                {
                    DataTypeConverter.WriteUShort(writer, 0);
                }
            }

            // Set length
            var length = writer.BaseStream.Position - startOffset;

            writer.BaseStream.Position = lengthOffset;
            DataTypeConverter.WriteUShort(writer, (ushort)length);

            // Recover writer position
            writer.BaseStream.Position = startOffset + length;
        }