private List <GlyphSheet> LayoutSheets(Queue <GlyphInfo> glyphs)
        {
            List <GlyphSheet> ret = new List <GlyphSheet>();

            //ToDo: sort?

            while (glyphs.Count != 0)
            {
                GlyphSheet currSheet = new GlyphSheet(imageSize);

                int y;
                for (y = 0; glyphs.Count != 0 && y < imageSize.Height;)
                {
                    int availY = imageSize.Height - y;
                    int maxY   = 0;

                    for (int x = 0; glyphs.Count != 0 && x < imageSize.Width;)
                    {
                        GlyphInfo glyph = glyphs.Peek();

                        //see if we have room to add anything height-wise
                        if (glyph.GlyphDataSize.Height > availY)
                        {
                            //no, break out
                            break;
                        }

                        //find out where we'll be
                        int newX = x + glyph.GlyphDataSize.Width;

                        if (newX > imageSize.Width)
                        {
                            //no room, break on to the next room
                            break;
                        }

                        //don't let the next row stomp on this
                        if (glyph.GlyphDataSize.Height > maxY)
                        {
                            maxY = glyph.GlyphDataSize.Height;
                        }

                        glyph.Sheet          = currSheet;
                        glyph.SheetRectangle = new Rectangle(x, y, glyph.GlyphDataSize.Width, glyph.GlyphDataSize.Height);
                        currSheet.Glyphs.Add(glyph);

                        //advance to the next character
                        glyphs.Dequeue();
                        x = newX + padding;
                    }

                    y += maxY + padding;
                }

                if (y == 0)
                {
                    continue;
                }

                //see if we can cut off the bottom of the image
                if (y < currSheet.SheetDataSize.Height / 2)
                {
                    int targetH = currSheet.SheetDataSize.Height / 2;
                    while (y < targetH / 2)
                    {
                        targetH /= 2;
                    }

                    GlyphSheet newSheet = new GlyphSheet(new Size(currSheet.SheetDataSize.Width, targetH));

                    newSheet.Glyphs.AddRange(currSheet.Glyphs);
                    foreach (GlyphInfo glyph in newSheet.Glyphs)
                    {
                        glyph.Sheet = newSheet;
                    }

                    currSheet = newSheet;
                }

                ret.Add(currSheet);
            }

            return(ret);
        }
		private List<GlyphSheet> LayoutSheets( Queue<GlyphInfo> glyphs )
		{
			List<GlyphSheet> ret = new List<GlyphSheet>();

			//ToDo: sort?

			while( glyphs.Count != 0 )
			{
				GlyphSheet currSheet = new GlyphSheet( imageSize );

				int y;
				for( y = 0; glyphs.Count != 0 && y < imageSize.Height; )
				{
					int availY = imageSize.Height - y;
					int maxY = 0;

					for( int x = 0; glyphs.Count != 0 && x < imageSize.Width; )
					{
						GlyphInfo glyph = glyphs.Peek();

						//see if we have room to add anything height-wise
						if( glyph.GlyphDataSize.Height > availY )
							//no, break out
							break;

						//find out where we'll be
						int newX = x + glyph.GlyphDataSize.Width;

						if( newX > imageSize.Width )
							//no room, break on to the next room
							break;

						//don't let the next row stomp on this
						if( glyph.GlyphDataSize.Height > maxY )
							maxY = glyph.GlyphDataSize.Height;

						glyph.Sheet = currSheet;
						glyph.SheetRectangle = new Rectangle( x, y, glyph.GlyphDataSize.Width, glyph.GlyphDataSize.Height );
						currSheet.Glyphs.Add( glyph );

						//advance to the next character
						glyphs.Dequeue();
						x = newX + padding;
					}

					y += maxY + padding;
				}

				if( y == 0 )
					continue;

				//see if we can cut off the bottom of the image
				if( y < currSheet.SheetDataSize.Height / 2 )
				{
					int targetH = currSheet.SheetDataSize.Height / 2;
					while( y < targetH / 2 )
						targetH /= 2;

					GlyphSheet newSheet = new GlyphSheet( new Size( currSheet.SheetDataSize.Width, targetH ) );

					newSheet.Glyphs.AddRange( currSheet.Glyphs );
					foreach( GlyphInfo glyph in newSheet.Glyphs )
						glyph.Sheet = newSheet;

					currSheet = newSheet;
				}

				ret.Add( currSheet );
			}

			return ret;
		}