Beispiel #1
0
 public DictArray(float[] values)
 {
     foreach (float f in values)
     {
         A.Add(new DictNumber(f));
     }
 }
Beispiel #2
0
        /// <summary>
        /// Creates a copy of a list with the items in random order.
        /// </summary>
        /// <param name="list">
        /// The list to copy.
        /// </param>
        /// <param name="randNumGen">
        /// An object that generates random numbers.
        /// </param>
        /// <returns>
        /// A copy of the list with its items shuffled (their order in the
        /// list is random).
        /// </returns>
        public static Generic.IList <T> Shuffle <T>(Generic.IList <T> list,
                                                    System.Random randomNumGen)
        {
            if (list == null)
            {
                return(null);
            }
            Require.ArgumentNotNull(randomNumGen);

            //  List of item indexes.
            Generic.List <int> indexes = new Generic.List <int>(list.Count);
            for (int i = 0; i < list.Count; ++i)
            {
                indexes.Add(i);
            }

            Generic.List <T> shuffledList = new Generic.List <T>(list.Count);
            while (indexes.Count > 0)
            {
                //  Randomly pick a remaining item in the list
                int indexOfIndex = randomNumGen.Next(indexes.Count);
                int index        = indexes[indexOfIndex];
                indexes.RemoveAt(indexOfIndex);
                shuffledList.Add(list[index]);
            }

            return(shuffledList);
        }
Beispiel #3
0
        // -- Private Methods --

        /**
         * Returns an array of all the TileMaps object under a given node.
         */
        private static Generic.List <TileMap> FindTilemapsUnder(Node root)
        {
            // Prepare the return list.
            Generic.List <TileMap> output = new Generic.List <TileMap>();

            // Loop through all the children nodes.
            foreach (Node child in root.GetChildren())
            {
                // If the object is a TileMap.
                if (child is TileMap)
                {
                    // Add it to the result list.
                    output.Add(child as TileMap);
                }

                // If the object has any children.
                if (child.GetChildCount() > 0)
                {
                    // Add its sub-tilemaps to the list.
                    output.AddRange(FindTilemapsUnder(child));
                }
            }

            // Return the list.
            return(output);
        }
Beispiel #4
0
 public void AddEdge(Edge edge)
 {
     if (!Edges.Contains(edge))
     {
         Edges.Add(edge);
     }
 }
Beispiel #5
0
 public void AddPoint(Vector2 point)
 {
     if (!Points.Contains(point))
     {
         Points.Add(point);
     }
 }
Beispiel #6
0
        /// <summary>
        /// Utility function to enable a list of LinkExtensions
        /// </summary>
        /// <param name="baseOptions"></param>
        /// <param name="linkExtensions"></param>
        /// <param name="enable"></param>
        public static void ChangeLinkExtensionEnableStatue(/*Deployment.DeploymentBaseOptions*/ dynamic baseOptions, System.Collections.Generic.List <string> linkExtensions, bool enable)
        {
            if (linkExtensions != null && linkExtensions.Count != 0)
            {
                foreach (string linkExtObj in linkExtensions)
                {
                    RegularExpressions.Regex match       = new RegularExpressions.Regex(linkExtObj, System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                    Generic.List <object>    matchedList = new Generic.List <object>();

                    foreach (/*Deployment.DeploymentLinkExtension*/ dynamic linkExtension in baseOptions.LinkExtensions)
                    {
                        if (match.IsMatch(linkExtension.Name))
                        {
                            matchedList.Add(linkExtension);
                        }
                    }

                    if (matchedList.Count > 0)
                    {
                        foreach (/*Deployment.DeploymentLinkExtension*/ dynamic extension in matchedList)
                        {
                            extension.Enabled = enable;
                        }
                    }
                    else
                    {
                        // throw new DeploymentException(Resources.UnknownLinkExtension, disableLink);
                        //$Todo lmchen
                        //Diagnostics.Debug.Assert(false, "NYI, we should prompt user for invalid LinkExtension");
                        throw new System.InvalidOperationException("UnknowLinkExtension");
                    }
                }
            }
        }
Beispiel #7
0
        private readonly Generic.List <int> Xobjs = new Generic.List <int>(); // XObjects used by page ( typically images )

        private void NoteXobj(int objnum)
        {
            if (!Xobjs.Contains(objnum))
            {
                Xobjs.Add(objnum);
            }
        }
Beispiel #8
0
        // Encodes a string as a list of Glyph indexes.

        public override void Encode(string s, int start, int end, Generic.List <byte> buf)
        {
            for (int i = start; i < end; i += 1)
            {
                char c = s[i];
                if (c != '\n')
                {
                    int uc = c;
                    if (System.Char.IsSurrogate(c))
                    {
                        uc = char.ConvertToUtf32(s, i); i += 1;
                    }

                    int gi = XG(Index(uc));
                    if (gi >= 0) // If char not found, it is simply ignored ( in future may want a fallback mechanism ).
                    {
                        buf.Add((byte)(gi >> 8));
                        buf.Add((byte)(gi & 0xff));
                    }
                }
            }
        }
Beispiel #9
0
        bool KeepInstructions = false;                                              // Are font instructions retained ( not implemented, would need additional tables to be copied to PDF ).

        int XG(int gi)                                                              // Translates a glyph index to the subset value.
        {
            if (gi < 0)
            {
                return(gi);
            }
            int x; if (!Xlat.TryGetValue(gi, out x))

            {
                x = GList.Count; Xlat[gi] = x; GList.Add(gi);
            }

            return(x);
        }
Beispiel #10
0
        private void ResolveTokens(string s)
        {
            int index      = -1;
            int startIndex = 0;

            Generic.List <string> tokenParts = new Generic.List <string>();

            //index = s.IndexOfAny(separators, startIndex);
            while ((index = s.IndexOfAny(separators, startIndex)) > 0)
            {
                int offset = index - startIndex;
                if (offset > 0)
                {
                    tokenParts.Add(s.Substring(startIndex, index - startIndex));
                }
                tokenParts.Add(s.Substring(index, 1));

                startIndex = index + 1;
            }

            tokenParts.Add(s.Substring(startIndex));
            tokenParts.Add(string.Empty); // TODO: Simulate EOL
            tokens = tokenParts.ToArray();
        }
        //ii.Highest Card wins
        public Generic.List <int> EvaluateWinners()
        {
            Generic.List <int> winningPlayerNumbers = new Generic.List <int>();
            Generic.List <CardGameLibrary.PlayerOfCard> highestPlayersOfCards = new Generic.List <CardGameLibrary.PlayerOfCard>();
            CardGameLibrary.PlayerOfCard highestPlayerOfCards = null;

            //Initially, assign first player as highest card winner
            if (PlayerOfCardsInGame.Count > 0)
            {
                highestPlayerOfCards = PlayerOfCardsInGame[0];
                highestPlayersOfCards.Add(highestPlayerOfCards);
            }

            for (int i = 1; i < PlayerOfCardsInGame.Count; i++)
            {
                //If previous player(s) temporarily assigned
                //as highest card winner is outranked, remove
                //and add new player as currently
                //assigned highest card winner
                if (PlayerOfCardsInGame[i].PlayerScore >
                    highestPlayerOfCards.PlayerScore)
                {
                    highestPlayersOfCards.RemoveAll
                        (match => match.PlayerScore
                        == highestPlayerOfCards.PlayerScore);
                    highestPlayerOfCards = PlayerOfCardsInGame[i];
                    highestPlayersOfCards.Add(highestPlayerOfCards);
                }
                //Multiple players having cards of same rank can be co-winners
                else if (PlayerOfCardsInGame[i].PlayerScore ==
                         highestPlayerOfCards.PlayerScore)
                {
                    highestPlayerOfCards = PlayerOfCardsInGame[i];
                    highestPlayersOfCards.Add(highestPlayerOfCards);
                }
            }

            //This should be a list of at most Count == 4 for co-winner use-cases
            foreach (CardGameLibrary.PlayerOfCard playerOfCards in highestPlayersOfCards)
            {
                winningPlayerNumbers.Add(playerOfCards.PlayerNumber);
            }

            return(winningPlayerNumbers);
        }
Beispiel #12
0
        void GetCmaps()
        {
            GotoTable(Tid.cmap);
            CmapLimit = IxLimit;
            uint cmapIx = Ix;

            Ix += 2; // Skip version
            uint numberSubtables = Get16();

            for (int i = 0; i < numberSubtables; i += 1)
            {
                uint platformID         = Get16();
                uint platformSpecificID = Get16();
                uint offset             = Get32();
                if (platformID == 0 || platformID == 3 && (platformSpecificID == 1 || platformSpecificID == 10)) // Is it a Unicode cmap?
                {
                    Cmap.Add(cmapIx + offset);
                }
            }
        }
        /// <summary>
        /// Retrieving SharePoint list collection
        /// </summary>
        /// <returns> SharePoint list collection</returns>
        public async Task <Generic.List <List> > GetLists()
        {
            Generic.List <List> resultLists = new Generic.List <List>();
            IQueryable <List>   listsWithIncludedProperty = ClientObjectQueryableExtension.Include(context.Web.Lists,
                                                                                                   list => list.Id,
                                                                                                   list => list.Title,
                                                                                                   list => list.ItemCount,
                                                                                                   list => list.Fields.Include(f => f.Title, f => f.Indexed, f => f.InternalName));

            IQueryable <List> listCollection =
                listsWithIncludedProperty.Where(list => list.BaseType == BaseType.DocumentLibrary &&
                                                (list.BaseTemplate == (int)ListTemplateType.DocumentLibrary ||
                                                 list.BaseTemplate == (int)ListTemplateType.MySiteDocumentLibrary) &&
                                                list.Hidden == false);

            Generic.IEnumerable <List> lists = context.LoadQuery(listCollection);
            await ExecuteQuery();

            lists.ForEach(list => resultLists.Add(list));
            return(resultLists);
        }
Beispiel #14
0
        public override void Encode(string s, int start, int end, Generic.List <byte> buf)
        {
            System.Text.Encoding enc = System.Text.Encoding.GetEncoding(1252); // Not sure if this is right.
            int len  = end - start;
            int need = enc.GetMaxByteCount(len);

            if (need > EncBuffer.Length)
            {
                EncBuffer = Util.GetBuf(need);
            }
            int nb = enc.GetBytes(s, start, len, EncBuffer, 0);

            for (int i = 0; i < nb; i += 1)
            {
                byte b = EncBuffer[i];
                if (b != 10)
                {
                    buf.Add(b);
                }
            }
        }
Beispiel #15
0
 public void Add(TT item)
 {
     LocalList.Add(item);
     _dataSource.AddToList(Name, item);
 }
Beispiel #16
0
        private short XMin, XMax, YMin, YMax; // These are calculated by GetFontBytes.

        private byte[] GetFontBytes()         // Returns the TrueType subset file as an array of bytes.
        {
            /* Tables required in theory ( those marked '?' may not actually be needed in PDF, maxp IS needed ).
             * 'cmap' character to glyph mapping (?)
             * 'glyf' glyph data
             * 'head' font header
             * 'hmtx' horizontal metrics
             * 'hhea' horizontal header
             * 'loca' index to location
             * 'maxp' maximum profile
             * 'name' naming (?)
             * 'post' PostScript (?)
             * 'OS/2' Font validator says this is a required table (?)
             */

            TrueType.Writer tw = new TrueType.Writer(7); // glyf, head, hmtx, hhea, loca, maxp

            Generic.List <uint> locations = new Generic.List <uint>();

            // Summary values for 'head' 'hhea' and 'maxp' tables calculated as 'glyp' table is written.
            XMin = 0x7fff; XMin = 0x7fff; XMax = -0x8000; YMax = -0x8000;
            int maxContours = 0, maxPoints = 0,
                maxComponentPoints = 0, maxComponentContours = 0, maxComponentDepth = 0, maxComponentElements = 0,
                xMaxExtent = 0, minRightSideBearing = 0x7fff;
            int advanceWidthMax = -0x8000, minLeftSideBearing = 0x7fff;

            // 'glyf' table
            tw.BeginTable();
            for (int gi = 0; gi < GList.Count; gi += 1)
            {
                int sgi = GList[gi];

                TrueType.Glyph g; Inp.ReadGlyph(sgi, false, out g);
                locations.Add(tw.Offset());

                TrueType.WidthInfo w; Inp.GetGlyphWidth(sgi, out w);
                if (w.AdvanceWidth > advanceWidthMax)
                {
                    advanceWidthMax = w.AdvanceWidth;
                }
                if (w.LeftSideBearing < minLeftSideBearing)
                {
                    minLeftSideBearing = w.LeftSideBearing;
                }
                if (g.XMin < XMin)
                {
                    XMin = g.XMin;
                }
                if (g.YMin < YMin)
                {
                    YMin = g.YMin;
                }
                if (g.XMax > XMax)
                {
                    XMax = g.XMax;
                }
                if (g.YMax > YMax)
                {
                    YMax = g.YMax;
                }
                int extent = w.LeftSideBearing + (g.XMax - g.XMin);
                if (extent > xMaxExtent)
                {
                    xMaxExtent = extent;
                }
                int rsb = w.AdvanceWidth - w.LeftSideBearing - (g.XMax - g.XMin);
                if (rsb < minRightSideBearing)
                {
                    minRightSideBearing = rsb;
                }

                if (g.Contours != 0)
                {
                    if (g.Contours >= 0)
                    {
                        if (g.Contours > maxContours)
                        {
                            maxContours = g.Contours;
                        }
                        if (g.Points > maxPoints)
                        {
                            maxPoints = g.Points;
                        }

                        if (KeepInstructions)
                        {
                            tw.Write(Inp.Data, g.Pos, g.Len);
                        }
                        else
                        {
                            int off = 10 + 2 * g.Contours; /* Contours .. EndPoints */
                            tw.Write(Inp.Data, g.Pos, off);
                            tw.Put16(0);
                            off += 2 + g.InstructionLen;
                            tw.Write(Inp.Data, g.Pos + off, g.Len - off);
                        }
                    }
                    else // Compound glyph
                    {
                        tw.Write(Inp.Data, g.Pos, 10);
                        for (int i = 0; i < g.Components.Count; i += 1)
                        {
                            TrueType.Component c = g.Components[i];
                            c.GlyphIx = (uint)XG((int)c.GlyphIx);
                            tw.Put(c);
                        }

                        TrueType.GlyphStats gs; Inp.GetGlyphStats(sgi, out gs);
                        if (gs.Points > maxComponentPoints)
                        {
                            maxComponentPoints = gs.Points;
                        }
                        if (gs.Contours > maxComponentContours)
                        {
                            maxComponentContours = gs.Contours;
                        }
                        if (gs.ComponentDepth > maxComponentDepth)
                        {
                            maxComponentDepth = gs.ComponentDepth;
                        }
                        // Maximum number of components referenced at “top level” for any composite glyph.
                        if (g.Components.Count > maxComponentElements)
                        {
                            maxComponentElements = g.Components.Count;                                // Not sure what "top level" means, maybe just not recursive calc?
                        }
                    }
                }
                tw.Pad(4);
            }
            locations.Add(tw.Offset()); // Additional entry so length of final glyph is represented in locations.
            tw.EndTable(TrueType.Tid.glyf);

            // 'head' table
            tw.BeginTable();
            tw.Put32(0x00010000);     // Version
            tw.Put32(0);              // fontRevision
            tw.Put32(0);              // checkSumAdjustment
            tw.Put32(0x5F0F3CF5);     // magic number
            tw.Put16(0);              // flags
            tw.Put16(Inp.UnitsPerEm); // unitsPerEm
            tw.Put64(0);              // created
            tw.Put64(0);              // modified
            unchecked
            {
                tw.Put16((ushort)XMin);
                tw.Put16((ushort)YMin);
                tw.Put16((ushort)XMax);
                tw.Put16((ushort)YMax);
            }
            tw.Put16(0); // macStyle
            tw.Put16(7); // lowestRecPPEM
            tw.Put16(2); // fontDirectionHint
            tw.Put16(1); // indexToLocFormat
            tw.Put16(0); // glyphDataFormat
            tw.EndTable(TrueType.Tid.head);

            // 'hmtx' horizontal metrics
            tw.BeginTable();
            foreach (int gi in GList)
            {
                TrueType.WidthInfo w; Inp.GetGlyphWidth(gi, out w);
                unchecked
                {
                    tw.Put16(w.AdvanceWidth);
                    tw.Put16((uint)w.LeftSideBearing);
                }
            }
            tw.EndTable(TrueType.Tid.hmtx);

            // 'hhea' horizontal header
            tw.BeginTable();
            unchecked
            {
                tw.Put32(0x00010000);                // Fixed    version 0x00010000 (1.0)
                tw.Put16((uint)YMax);                // FWord     ascent  Distance from baseline of highest ascender
                tw.Put16((uint)YMin);                // FWord     descent Distance from baseline of lowest descender
                tw.Put16(Inp.LineGap);               // FWord     lineGap typographic line gap
                tw.Put16((uint)advanceWidthMax);     // uFWord       advanceWidthMax must be consistent with horizontal metrics
                tw.Put16((uint)minLeftSideBearing);  // FWord     minLeftSideBearing      must be consistent with horizontal metrics
                tw.Put16((uint)minRightSideBearing); // FWord     minRightSideBearing     must be consistent with horizontal metrics
                tw.Put16((uint)xMaxExtent);          // FWord     xMaxExtent      max(lsb + (xMax-xMin))
                tw.Put16(1);                         // int16     caretSlopeRise  used to calculate the slope of the caret (rise/run) set to 1 for vertical caret
                tw.Put16(0);                         // int16     caretSlopeRun   0 for vertical
                tw.Put16(0);                         // FWord     caretOffset     set value to 0 for non-slanted fonts
                tw.Put16(0);                         // int16     reserved        set value to 0
                tw.Put16(0);                         // int16     reserved        set value to 0
                tw.Put16(0);                         // int16     reserved        set value to 0
                tw.Put16(0);                         // int16     reserved        set value to 0
                tw.Put16(0);                         // int16     metricDataFormat 0 for current format
                tw.Put16((uint)GList.Count);         // uint16    numOfLongHorMetrics number of advance widths in metrics table
            }
            tw.EndTable(TrueType.Tid.hhea);

            // 'loca' table ( glyph locations )
            tw.BeginTable();
            foreach (uint loc in locations)
            {
                tw.Put32(loc);
            }
            tw.EndTable(TrueType.Tid.loca);

            // 'maxp' maximum profile table
            tw.BeginTable();
            tw.Put32(0x00010000);                 // version
            tw.Put16((uint)GList.Count);          // numGlyphs the number of glyphs in the font
            tw.Put16((uint)maxPoints);            // maxPoints       points in non-compound glyph
            tw.Put16((uint)maxContours);          // maxContours     contours in non-compound glyph
            tw.Put16((uint)maxComponentPoints);   // maxComponentPoints      points in compound glyph ( todo )
            tw.Put16((uint)maxComponentContours); // maxComponentContours    contours in compound glyph ( todo )
            tw.Put16(2);                          // maxZones        set to 2
            tw.Put16(0);                          // maxTwilightPoints       points used in Twilight Zone (Z0)
            tw.Put16(0);                          // maxStorage      number of Storage Area locations
            tw.Put16(0);                          // maxFunctionDefs number of FDEFs
            tw.Put16(0);                          // maxInstructionDefs      number of IDEFs
            tw.Put16(0);                          // maxStackElements        maximum stack depth
            tw.Put16(0);                          // maxSizeOfInstructions   byte count for glyph instructions
            tw.Put16((uint)maxComponentElements); // maxComponentElements    number of glyphs referenced at top level
            tw.Put16((uint)maxComponentDepth);    // maxComponentDepth levels of recursion, set to 0 if font has only simple glyphs
            tw.EndTable(TrueType.Tid.maxp);

            // 'cmap' table : doesn't seem to be needed by PDF ( PDF has own ToUnicode representation ), may be useful when testing.
            // WriteCmap( tw );

            // 'name' naming

            /*
             * tw.BeginTable();
             * tw.Put16(0); // UInt16 format  Format selector. Set to 0.
             * tw.Put16(0); // UInt16 count   The number of nameRecords in this name table.
             * tw.Put16(0); // UInt16 stringOffset    Offset in bytes to the beginning of the name character strings.
             * // NameRecord  nameRecord[count]       The name records array.
             * // variable name character strings The character strings of the names. Note that these are not necessarily ASCII!
             * tw.EndTable( Tid.name );
             */

            // 'post' PostScript

            /*
             * tw.BeginTable();
             * tw.Put32(0x00030000); // Fixed      format  Format of this table
             * tw.Put32(0); // Fixed       italicAngle     Italic angle in degrees
             * tw.Put16(0); // FWord       underlinePosition       Underline position
             * tw.Put16(0); // FWord       underlineThickness      Underline thickness
             * tw.Put32(0); // uint32      isFixedPitch    Font is monospaced; set to 1 if the font is monospaced and 0 otherwise (N.B., to maintain compatibility with older versions of the TrueType spec, accept any non-zero value as meaning that the font is monospaced)
             * tw.Put32(0); // uint32      minMemType42    Minimum memory usage when a TrueType font is downloaded as a Type 42 font
             * tw.Put32(0); // uint32      maxMemType42    Maximum memory usage when a TrueType font is downloaded as a Type 42 font
             * tw.Put32(0); // uint32      minMemType1     Minimum memory usage when a TrueType font is downloaded as a Type 1 font
             * tw.Put32(0); // uint32      maxMemType1     Maximum memory usage when a TrueType font is downloaded as a Type 1 font
             * tw.EndTable( Tid.post );
             */

            tw.Finish();
            byte [] result = tw.ToArray();
            // Util.WriteFile( "test.ttf", result ); // ( for debugging )
            return(result);
        }
Beispiel #17
0
        public void ReadGlyph(int gi, bool getPoints, out Glyph g)
        {
            GotoTable(Tid.loca);
            uint offset, next;

            if (IndexToLocFormat == 0)
            {
                Ix += (uint)gi * 2; offset = 2 * Get16(); next = 2 * Get16();
            }                                                                                 // Note the offsets are multiplied by 2 in the short format!
            else
            {
                Ix += (uint)gi * 4; offset = Get32(); next = Get32();
            }

            g = new Glyph();
            if (next == offset)
            {
                g.Contours = 0; g.Len = 0;
            }                                            // Empty glyph ( space )
            else
            {
                GotoTable(Tid.glyf);
                IxLimit = Ix + next;
                Ix     += offset;

                g.Pos      = (int)Ix;
                g.Contours = GetI16();
                g.XMin     = (short)GetI16();
                g.YMin     = (short)GetI16();
                g.XMax     = (short)GetI16();
                g.YMax     = (short)GetI16();

                if (g.Contours >= 0)                                     // Simple glyph
                {
                    ushort [] endPtsOfContours = new ushort[g.Contours]; // Shouldn't allocate this is !getPoints, but currently used to calculate # points.
                    uint      points           = 0;

                    if (getPoints)
                    {
                        for (int i = 0; i < g.Contours; i += 1)
                        {
                            uint ep = Get16();
                            endPtsOfContours[i] = (ushort)ep;
                        }
                        g.EndPoints = endPtsOfContours;
                        points      = (uint)g.EndPoints[g.Contours - 1] + 1;
                    }
                    else
                    {
                        Ix += (uint)(2 * (g.Contours - 1)); points = 1 + Get16();
                    }

                    g.Points = (ushort)points;
                    uint instructionLength = Get16();
                    g.InstructionLen = (int)instructionLength;

                    if (!getPoints) // Usually we don't need to parse the points.
                    {
                        Ix = IxLimit;
                    }
                    else
                    {
                        Ix += instructionLength;
                        byte [] flags = new byte[points];

                        byte flag = 0, rep = 0;
                        for (int i = 0; i < points; i += 1)
                        {
                            if (rep > 0)
                            {
                                rep -= 1;
                            }
                            else
                            {
                                flag = Get8(); if ((flag & 8) != 0)
                                {
                                    rep = Get8();
                                }
                            }
                            flags[i] = flag;
                        }
                        short [] xs = new short[points];
                        int      x  = 0;
                        for (int i = 0; i < points; i += 1)
                        {
                            flag = flags[i];
                            if ((flag & 2) != 0)
                            {
                                byte b = Get8(); if ((flag & 16) != 0)
                                {
                                    x += b;
                                }
                                else
                                {
                                    x -= b;
                                }
                            }
                            else if ((flag & 16) == 0)
                            {
                                x += GetI16();
                            }
                            xs[i] = (short)x;
                        }
                        short [] ys = new short[points];
                        int      y  = 0;
                        for (int i = 0; i < points; i += 1)
                        {
                            flag = flags[i];
                            if ((flag & 4) != 0)
                            {
                                byte b = Get8(); if ((flag & 32) != 0)
                                {
                                    y += b;
                                }
                                else
                                {
                                    y -= b;
                                }
                            }
                            else if ((flag & 32) == 0)
                            {
                                y += GetI16();
                            }
                            ys[i] = (short)y;
                        }
                        g.Flags = flags;
                        g.X     = xs;
                        g.Y     = ys;
                    }
                }
                else // Compound glyph
                {
                    Generic.List <Component> components = new Generic.List <Component>();
                    while (1 == 1)
                    {
                        uint flags = Get16();
                        uint glyphIndex = Get16();
                        uint a1, a2, s1 = 0, s2 = 0, s3 = 0, s4 = 0;
                        if ((flags & 1) != 0)
                        {
                            a1 = Get16(); a2 = Get16();
                        }
                        else
                        {
                            a1 = Get8(); a2 = Get8();
                        }
                        if ((flags & 8) != 0)
                        {
                            s1 = Get16();
                        }
                        else if ((flags & 0x40) != 0)
                        {
                            s1 = Get16(); s2 = Get16();
                        }
                        else if ((flags & 0x80) != 0)
                        {
                            s1 = Get16(); s2 = Get16(); s3 = Get16(); s4 = Get16();
                        }

                        Component nc; nc.GlyphIx = glyphIndex; nc.Flags = flags; nc.A1 = a1; nc.A2 = a2; nc.S1 = s1; nc.S2 = s2; nc.S3 = s3; nc.S4 = s4;
                        components.Add(nc);

                        if ((flags & 0x20) == 0)
                        {
                            break;
                        }
                    }
                    g.Components = components;
                }
                g.Len = (int)(Ix - g.Pos);
            }
        }
Beispiel #18
0
 internal static ComprehensionIterator[] RevertComprehensions(PythonList comprehensions) {
     Generic.List<ComprehensionIterator> comprehensionIterators =
         new Generic.List<ComprehensionIterator>();
     foreach (comprehension comp in comprehensions) {
         ComprehensionFor cf = new ComprehensionFor(expr.Revert(comp.target), expr.Revert(comp.iter));
         comprehensionIterators.Add(cf);
         foreach (expr ifs in comp.ifs) {
             comprehensionIterators.Add(new ComprehensionIf(expr.Revert(ifs)));
         }
     }
     return comprehensionIterators.ToArray();
 }
Beispiel #19
0
            internal static PythonList Convert(ComprehensionIterator[] iters) {
                Generic.List<ComprehensionFor> cfCollector =
                    new Generic.List<ComprehensionFor>();
                Generic.List<Generic.List<ComprehensionIf>> cifCollector =
                    new Generic.List<Generic.List<ComprehensionIf>>();
                Generic.List<ComprehensionIf> cif = null;
                for (int i = 0; i < iters.Length; i++) {
                    if (iters[i] is ComprehensionFor) {
                        ComprehensionFor cf = (ComprehensionFor)iters[i];
                        cfCollector.Add(cf);
                        cif = new Generic.List<ComprehensionIf>();
                        cifCollector.Add(cif);
                    } else {
                        ComprehensionIf ci = (ComprehensionIf)iters[i];
                        cif.Add(ci);
                    }
                }

                PythonList comps = new PythonList();
                for (int i = 0; i < cfCollector.Count; i++)
                    comps.Add(new comprehension(cfCollector[i], cifCollector[i].ToArray()));
                return comps;
            }