Esempio n. 1
0
        /// <summary>
        ///     Populate the <i>composites</i>IList containing all child glyphs 
        ///     that this glyph uses.
        /// </summary>
        /// <remarks>
        ///     The <i>stream</i> parameter must be positioned 10 bytes from 
        ///     the beginning of the glyph description, i.e. the flags field.
        /// </remarks>
        /// <param name="stream"></param>
        private void ReadCompositeGlyph(FontFileStream stream, Glyph glyph) {
            bool moreComposites = true;
            while (moreComposites) {
                short flags = stream.ReadShort();
                long offset = stream.Position;
                int subsetIndex = reader.IndexMappings.Map(stream.ReadShort());

                glyph.AddChild(subsetIndex);

                // While we're here, remap the child glyph index
                stream.Position = stream.Position - PrimitiveSizes.Short;
                stream.WriteShort(subsetIndex);

                // The following code is based on the C pseudo code supplied 
                // in the glyf table specification.
                int skipBytes = 0;
                if ((flags & BitMasks.Arg1And2AreWords) > 0) {
                    skipBytes = PrimitiveSizes.Short*2;
                }
                else {
                    skipBytes = PrimitiveSizes.UShort;
                }

                if ((flags & BitMasks.WeHaveAScale) > 0) {
                    // Skip scale
                    skipBytes = PrimitiveSizes.F2DOT14;
                }
                else if ((flags & BitMasks.WeHaveAnXAndYScale) > 0) {
                    // Skip xscale and yscale
                    skipBytes = PrimitiveSizes.F2DOT14*2;
                }
                else if ((flags & BitMasks.WeHaveATwoByTwo) > 0) {
                    // Skip xscale, scale01, scale10 and yscale
                    skipBytes = PrimitiveSizes.F2DOT14*4;
                }

                // Glyph instructions
                if ((flags & BitMasks.WeHaveInstructions) > 0) {
                    skipBytes = PrimitiveSizes.Byte*stream.ReadUShort();
                }

                if ((flags & BitMasks.MoreComponents) > 0) {
                    moreComposites = true;
                }
                else {
                    moreComposites = false;
                }

                stream.Skip(skipBytes);
            }
        }
Esempio n. 2
0
        /// <summary>
        ///     Populate the <i>composites</i>IList containing all child glyphs
        ///     that this glyph uses.
        /// </summary>
        /// <remarks>
        ///     The <i>stream</i> parameter must be positioned 10 bytes from
        ///     the beginning of the glyph description, i.e. the flags field.
        /// </remarks>
        /// <param name="stream"></param>
        private void ReadCompositeGlyph(FontFileStream stream, Glyph glyph)
        {
            bool moreComposites = true;

            while (moreComposites)
            {
                short flags       = stream.ReadShort();
                long  offset      = stream.Position;
                int   subsetIndex = reader.IndexMappings.Map(stream.ReadShort());

                glyph.AddChild(subsetIndex);

                // While we're here, remap the child glyph index
                stream.Position = stream.Position - PrimitiveSizes.Short;
                stream.WriteShort(subsetIndex);

                // The following code is based on the C pseudo code supplied
                // in the glyf table specification.
                int skipBytes = 0;
                if ((flags & BitMasks.Arg1And2AreWords) > 0)
                {
                    skipBytes = PrimitiveSizes.Short * 2;
                }
                else
                {
                    skipBytes = PrimitiveSizes.UShort;
                }

                if ((flags & BitMasks.WeHaveAScale) > 0)
                {
                    // Skip scale
                    skipBytes = PrimitiveSizes.F2DOT14;
                }
                else if ((flags & BitMasks.WeHaveAnXAndYScale) > 0)
                {
                    // Skip xscale and yscale
                    skipBytes = PrimitiveSizes.F2DOT14 * 2;
                }
                else if ((flags & BitMasks.WeHaveATwoByTwo) > 0)
                {
                    // Skip xscale, scale01, scale10 and yscale
                    skipBytes = PrimitiveSizes.F2DOT14 * 4;
                }

                // Glyph instructions
                if ((flags & BitMasks.WeHaveInstructions) > 0)
                {
                    skipBytes = PrimitiveSizes.Byte * stream.ReadUShort();
                }

                if ((flags & BitMasks.MoreComponents) > 0)
                {
                    moreComposites = true;
                }
                else
                {
                    moreComposites = false;
                }

                stream.Skip(skipBytes);
            }
        }