예제 #1
0
        private void Build()
        {
            characters.Sort();

            for (int i = 0; i < characters.Count; i++)
            {
                for (int j = i + 1; j < characters.Count; j++)
                {
                    if (characters[j] == characters[i])
                    {
                        characters.RemoveAt(j--);
                    }
                }
            }

            glyphs.Clear();
            sheets.Clear();

            using (Font font = CreateFont())
                using (FontRasterizer rasterizer = new FontRasterizer())
                    using (KerningHelper kerner = new KerningHelper(font))
                    {
                        lineHeight = font.Height;
                        foreach (char ch in characters)
                        {
                            GlyphInfo glyph = rasterizer.Rasterize(font, ch);

                            kerner.GetGlyphKerningInfo(glyph);

                            glyphs.Add(glyph);
                        }
                    }

            foreach (GlyphInfo glyph in glyphs)
            {
                char c = char.ToUpper(glyph.Character);
                if (c == glyph.Character)
                {
                    continue;
                }

                GlyphInfo upper = glyphs.Find(delegate(GlyphInfo g) { return(g.Character == c); });
                glyph.SmallCap  = upper;
            }

            glyphs.Sort(delegate(GlyphInfo a, GlyphInfo b) { return(a.Character.CompareTo(b.Character)); });

            sheets = new GlyphPacker(maxImageSize).PackGlyphs(glyphs);
        }
예제 #2
0
		private void Build()
		{
			characters.Sort();

			for( int i = 0; i < characters.Count; i++ )
			{
				for( int j = i + 1; j < characters.Count; j++ )
				{
					if( characters[j] == characters[i] )
						characters.RemoveAt( j-- );
				}
			}

			glyphs.Clear();
			sheets.Clear();

			using( Font font = CreateFont() )
			using( FontRasterizer rasterizer = new FontRasterizer() )
			using( KerningHelper kerner = new KerningHelper( font ) )
			{
				lineHeight = font.Height;
				foreach( char ch in characters )
				{
					GlyphInfo glyph = rasterizer.Rasterize( font, ch );

					kerner.GetGlyphKerningInfo( glyph );

					glyphs.Add( glyph );
				}
			}

			foreach( GlyphInfo glyph in glyphs )
			{
				char c = char.ToUpper( glyph.Character );
				if( c == glyph.Character )
					continue;

				GlyphInfo upper = glyphs.Find( delegate( GlyphInfo g ) { return g.Character == c; } );
				glyph.SmallCap = upper;
			}

			glyphs.Sort( delegate( GlyphInfo a, GlyphInfo b ) { return a.Character.CompareTo( b.Character ); } );

			sheets = new GlyphPacker( maxImageSize ).PackGlyphs( glyphs );
		}