Exemple #1
0
            static public glyph_composite GetCompositeGlyphLogicalData(header h)
            {
                glyph_composite gc = null;

                CompositeGlyph cg = h.GetCompositeGlyph();

                if (cg != null)
                {
                    // glyph is a composite glyph

                    gc = new glyph_composite(h.xMin, h.yMin, h.xMax, h.yMax);

                    // copy any hinting instructions
                    if (cg.AnyComponentsHaveInstructions())
                    {
                        ushort nInstructions = cg.GetNumInstructions();
                        gc.m_arrInstructions = new byte[nInstructions];
                        for (uint i = 0; i < nInstructions; i++)
                        {
                            gc.m_arrInstructions[i] = cg.GetInstruction(i);
                        }
                    }

                    while (cg != null)
                    {
                        glyph_composite.component cc = new glyph_composite.component();
                        cc.flags   = cg.flags;
                        cc.glyphid = cg.glyphIndex;
                        cc.arg1    = cg.arg1;
                        cc.arg2    = cg.arg2;
                        if ((cg.flags & (ushort)CompositeGlyph.Flags.WE_HAVE_A_SCALE) != 0)
                        {
                            cc.scale = cg.scale;
                        }
                        else if ((cg.flags & (ushort)CompositeGlyph.Flags.WE_HAVE_AN_X_AND_Y_SCALE) != 0)
                        {
                            cc.xscale = cg.xscale;
                            cc.yscale = cg.yscale;
                        }
                        else if ((cg.flags & (ushort)CompositeGlyph.Flags.WE_HAVE_A_TWO_BY_TWO) != 0)
                        {
                            cc.xscale_2x2  = cg.xscale_2x2;
                            cc.scale01_2x2 = cg.scale01_2x2;
                            cc.scale10_2x2 = cg.scale10_2x2;
                            cc.yscale_2x2  = cg.yscale_2x2;
                        }

                        gc.m_arrComponents.Add(cc);

                        cg = cg.GetNextCompositeGlyph();
                    }
                }

                return(gc);
            }
Exemple #2
0
            public uint CalcLength()
            {
                uint length = 0;

                if (AnyComponentsHaveInstructions())
                {
                    length += (uint)2 + GetNumInstructions();
                }

                CompositeGlyph nextCG = this;

                while (nextCG != null)
                {
                    length += nextCG.GetCompositeGlyphLength();
                    nextCG  = nextCG.GetNextCompositeGlyph();
                }

                return(length);
            }
Exemple #3
0
            public ushort GetNumInstructions()
            {
                ushort nInstructions = 0;

                if (AnyComponentsHaveInstructions())
                {
                    // instructions follow the last component
                    CompositeGlyph lastCG = this;
                    CompositeGlyph nextCG = GetNextCompositeGlyph();
                    while (nextCG != null)
                    {
                        lastCG = nextCG;
                        nextCG = lastCG.GetNextCompositeGlyph();
                    }

                    uint nOffset = lastCG.m_offsetCompositeGlyph + lastCG.GetCompositeGlyphLength();

                    nInstructions = m_bufTable.GetUshort(nOffset);
                }

                return(nInstructions);
            }
Exemple #4
0
            public byte GetInstruction(uint i)
            {
                byte   byteInstruction = 0;
                ushort nInstructions   = 0;

                if (AnyComponentsHaveInstructions())
                {
                    // instructions follow the last component
                    CompositeGlyph lastCG = this;
                    CompositeGlyph nextCG = GetNextCompositeGlyph();
                    while (nextCG != null)
                    {
                        lastCG = nextCG;
                        nextCG = lastCG.GetNextCompositeGlyph();
                    }

                    uint nOffset = lastCG.m_offsetCompositeGlyph + lastCG.GetCompositeGlyphLength();

                    nInstructions = m_bufTable.GetUshort(nOffset);

                    if (i < nInstructions)
                    {
                        byteInstruction = m_bufTable.GetByte(nOffset + 2 + i);
                    }
                    else
                    {
                        throw new ArgumentException();
                    }
                }
                else
                {
                    throw new ApplicationException("WE_HAVE_INSTRUCTIONS flag is clear");
                }

                return(byteInstruction);
            }
Exemple #5
0
            public bool AnyComponentsHaveInstructions()
            {
                bool bInstructions = false;

                if ((flags & (uint)Flags.WE_HAVE_INSTRUCTIONS) != 0)
                {
                    bInstructions = true;
                }
                else
                {
                    CompositeGlyph nextCG = GetNextCompositeGlyph();
                    while (nextCG != null)
                    {
                        if ((nextCG.flags & (uint)Flags.WE_HAVE_INSTRUCTIONS) != 0)
                        {
                            bInstructions = true;
                            break;
                        }
                        nextCG = nextCG.GetNextCompositeGlyph();
                    }
                }

                return(bInstructions);
            }