Exemple #1
0
 public FontAtlas(int w, int h, int count)
 {
     Width  = w;
     Height = h;
     Nodes  = (FontAtlasNode *)CRuntime.malloc((ulong)(sizeof(FontAtlasNode) * count));
     CRuntime.memset(Nodes, 0, (ulong)(sizeof(FontAtlasNode) * count));
     count          = 0;
     NodesCount     = count;
     Nodes[0].X     = 0;
     Nodes[0].Y     = 0;
     Nodes[0].Width = (short)w;
     NodesNumber++;
 }
Exemple #2
0
        public int InsertNode(int idx, int x, int y, int w)
        {
            if (NodesNumber + 1 > NodesCount)
            {
                NodesCount = NodesCount == 0 ? 8 : NodesCount * 2;
                Nodes      = (FontAtlasNode *)CRuntime.realloc(Nodes, (ulong)(sizeof(FontAtlasNode) * NodesCount));
                if (Nodes == null)
                {
                    return(0);
                }
            }

            for (var i = NodesNumber; i > idx; i--)
            {
                Nodes[i] = Nodes[i - 1];
            }
            Nodes[idx].X     = (short)x;
            Nodes[idx].Y     = (short)y;
            Nodes[idx].Width = (short)w;
            NodesNumber++;
            return(1);
        }