Exemple #1
0
        public FontBitmap GetResizedBitmap(int width, int height, BakedCharCollection bakedChars)
        {
            var bitmap = GetResizedBitmap(width, height);

            if (bakedChars != null)
            {
                bakedChars.BakeWidth = bitmap.Width; bakedChars.BakeHeight = bitmap.Height;
            }
            return(bitmap);
        }
        public FontBitmap BakeFontBitmap(float pixelHeight, char firstCodepoint,
                                         char lastCodepoint, out BakedCharCollection characters)
        {
            if (lastCodepoint < firstCodepoint)
            {
                var tmp = lastCodepoint;
                lastCodepoint  = firstCodepoint;
                firstCodepoint = tmp;
            }

            return(BakeFontBitmap(pixelHeight, firstCodepoint,
                                  lastCodepoint - firstCodepoint + 1, out characters));
        }
        public FontBitmap BakeFontBitmap(float pixelHeight, char firstCodepoint,
                                         int characterCount, out BakedCharCollection characters, bool shrinkToMinimalHeight)
        {
            if (characterCount < 0)
            {
                throw new ArgumentOutOfRangeException("characterCount");
            }

            var charArray = new BakedChar[characterCount]; int minimalHeight;
            var bitmap = BakeFontBitmap(pixelHeight, firstCodepoint, charArray, out minimalHeight);

            if (shrinkToMinimalHeight)
            {
                bitmap.Height = minimalHeight; bitmap = bitmap.GetTrimmedBitmap();
            }

            characters = new BakedCharCollection(firstCodepoint, charArray, bitmap.Width, bitmap.Height);
            return(bitmap);
        }
Exemple #4
0
        public IEnumerable <BakedQuad> GetTextQuads(IEnumerable <string> strs,
                                                    float lineAscender, float lineDescender, float lineGap,
                                                    int hAlign, int vAlign)
        {
            if (strs == null)
            {
                throw new ArgumentNullException("strs");
            }

            float y0 = 0, y1, yPosition = 0;

            y1 = BakedCharCollection.GetVerticalTextHeight(strs, lineAscender, lineDescender, lineGap);
            BakedCharCollection.OffsetTextPositionForAlignment(y0, y1, ref yPosition, vAlign);

            foreach (var str in strs)
            {
                yPosition += lineAscender;

                float sx0, sy0, sx1, sy1, sxPosition = 0, syPosition = yPosition;
                if (GetTextBounds(str, out sx0, out sy0, out sx1, out sy1))
                {
                    BakedCharCollection.OffsetTextPositionForAlignment
                        (sx0, sx1, ref sxPosition, hAlign);

                    foreach (var ch in str)
                    {
                        var quad = GetBakedQuad(ch, ref sxPosition, ref syPosition);
                        if (quad.IsEmpty)
                        {
                            continue;
                        }

                        yield return(quad);
                    }
                }

                yPosition += lineGap - lineDescender;
            }
        }
Exemple #5
0
 public FontBitmap GetResizedBitmapPow2(BakedCharCollection bakedChars)
 {
     return(GetResizedBitmap(RoundUpToPow2(Width), RoundUpToPow2(Height), bakedChars));
 }
Exemple #6
0
 public FontBitmap BakeFontBitmap(float pixelHeight, out BakedCharCollection characters)
 {
     return BakeFontBitmap(pixelHeight, out characters, false);
 }
Exemple #7
0
        public FontBitmap BakeFontBitmap(float pixelHeight, char firstCodepoint,
            int characterCount, out BakedCharCollection characters, bool shrinkToMinimalHeight)
        {
            if (characterCount < 0) { throw new ArgumentOutOfRangeException("characterCount"); }

            var charArray = new BakedChar[characterCount]; int minimalHeight;
            var bitmap = BakeFontBitmap(pixelHeight, firstCodepoint, charArray, out minimalHeight);
            if (shrinkToMinimalHeight) { bitmap.Height = minimalHeight; bitmap = bitmap.GetTrimmedBitmap(); }

            characters = new BakedCharCollection(firstCodepoint, charArray, bitmap.Width, bitmap.Height);
            return bitmap;
        }
Exemple #8
0
 public FontBitmap BakeFontBitmap(float pixelHeight, char firstCodepoint,
     int characterCount, out BakedCharCollection characters)
 {
     return BakeFontBitmap(pixelHeight, firstCodepoint, characterCount,
         out characters, false);
 }
Exemple #9
0
        public FontBitmap BakeFontBitmap(float pixelHeight, char firstCodepoint,
            char lastCodepoint, out BakedCharCollection characters)
        {
            if (lastCodepoint < firstCodepoint)
            {
                var tmp = lastCodepoint;
                lastCodepoint = firstCodepoint;
                firstCodepoint = tmp;
            }

            return BakeFontBitmap(pixelHeight, firstCodepoint,
                lastCodepoint - firstCodepoint + 1, out characters);
        }
Exemple #10
0
 public FontBitmap BakeFontBitmap(float pixelHeight, out BakedCharCollection characters,
     bool shrinkToMinimalHeight)
 {
     return BakeFontBitmap(pixelHeight, char.MinValue, char.MaxValue, out characters,
         shrinkToMinimalHeight);
 }
 public FontBitmap BakeFontBitmap(float pixelHeight, char firstCodepoint,
                                  int characterCount, out BakedCharCollection characters)
 {
     return(BakeFontBitmap(pixelHeight, firstCodepoint, characterCount,
                           out characters, false));
 }
 public FontBitmap BakeFontBitmap(float pixelHeight, out BakedCharCollection characters,
                                  bool shrinkToMinimalHeight)
 {
     return(BakeFontBitmap(pixelHeight, char.MinValue, char.MaxValue, out characters,
                           shrinkToMinimalHeight));
 }
 public FontBitmap BakeFontBitmap(float pixelHeight, out BakedCharCollection characters)
 {
     return(BakeFontBitmap(pixelHeight, out characters, false));
 }