Tests/GlueTestProject/GlueTestProject/GlueTestProject/GumCore/BitmapFont.cs
/// <summary>
/// Used for rendering directly to screen with an atlased texture.
/// </summary>
Used for rendering directly to screen with an atlased texture.
Used for rendering directly to screen with an atlased texture .
public void RenderAtlasedTextureToScreen(List<string> lines, HorizontalAlignment horizontalAlignment,
            float textureToRenderHeight, Color color, float rotation, float fontScale, SystemManagers managers, SpriteRenderer spriteRenderer,
            object objectRequestingChange)
        {
            var textObject = (Text)objectRequestingChange;
            var point = new Point();
            int requiredWidth;
            int requiredHeight;
            List<int> widths = new List<int>();
            GetRequiredWidthAndHeight(lines, out requiredWidth, out requiredHeight, widths);
            int lineNumber = 0;
            if (mCharRect == null) mCharRect = new LineRectangle(managers);
            var yoffset = 0f;
            if (textObject.VerticalAlignment == Graphics.VerticalAlignment.Center)
            {
                yoffset = (textObject.EffectiveHeight - textureToRenderHeight) / 2.0f;
            }
            else if (textObject.VerticalAlignment == Graphics.VerticalAlignment.Bottom)
            {
                yoffset = textObject.EffectiveHeight - textureToRenderHeight * fontScale;
            }
            foreach (string line in lines)
            {
                point.X = mOutlineThickness;
                if (horizontalAlignment == HorizontalAlignment.Right)
                {
                    point.X = (int)(textObject.Width - widths[lineNumber] * fontScale);
                }
                else if (horizontalAlignment == HorizontalAlignment.Center)
                {
                    point.X = (int)(textObject.Width - widths[lineNumber] * fontScale) / 2;
                }
                foreach (char c in line)
                {
                    Rectangle destRect;
                    int pageIndex;
                    var sourceRect = GetCharacterRect(c, lineNumber, ref point, out destRect, out pageIndex, textObject.FontScale);
                    var origin = new Point((int)textObject.X, (int)(textObject.Y + yoffset));
                    var rotate = (float)-(textObject.Rotation * System.Math.PI / 180f);
                    var rotatingPoint = new Point(origin.X + destRect.X, origin.Y + destRect.Y);
                    MathFunctions.RotatePointAroundPoint(new Point(origin.X, origin.Y), ref rotatingPoint, rotate);
                    mCharRect.X = rotatingPoint.X;
                    mCharRect.Y = rotatingPoint.Y;
                    mCharRect.Width = destRect.Width;
                    mCharRect.Height = destRect.Height;
                    if(textObject.Parent != null)
                    {
                        mCharRect.X += textObject.Parent.GetAbsoluteX();
                        mCharRect.Y += textObject.Parent.GetAbsoluteY();
                    }
                    Sprite.Render(managers, spriteRenderer, mCharRect, mTextures[0], color, sourceRect, false, false, rotation,
                        treat0AsFullDimensions: false, objectCausingRenering: objectRequestingChange);
                }
                point.X = 0;
                lineNumber++;
            }
        }
public void RenderAtlasedTextureToScreen ( List < string > lines , HorizontalAlignment horizontalAlignment , float textureToRenderHeight , Color color , float rotation , float fontScale , SystemManagers managers , SpriteRenderer spriteRenderer , object objectRequestingChange ) { var textObject = ( Text ) objectRequestingChange ; var point = new Point ( ) ; int requiredWidth ; int requiredHeight ; List < int > widths = new List < int > ( ) ; GetRequiredWidthAndHeight ( lines , out requiredWidth , out requiredHeight , widths ) ; int lineNumber = 0 ; if ( mCharRect == null ) mCharRect = new LineRectangle ( managers ) ; var yoffset = 0f ; if ( textObject . VerticalAlignment == Graphics . VerticalAlignment . Center ) { yoffset = ( textObject . EffectiveHeight - textureToRenderHeight ) / 2.0f ; } else if ( textObject . VerticalAlignment == Graphics . VerticalAlignment . Bottom ) { yoffset = textObject . EffectiveHeight - textureToRenderHeight * fontScale ; } foreach ( string line in lines ) { point . X = mOutlineThickness ; if ( horizontalAlignment == HorizontalAlignment . Right ) { point . X = ( int ) ( textObject . Width - widths [ lineNumber ] * fontScale ) ; } else if ( horizontalAlignment == HorizontalAlignment . Center ) { point . X = ( int ) ( textObject . Width - widths [ lineNumber ] * fontScale ) / 2 ; } foreach ( char c in line ) { Rectangle destRect ; int pageIndex ; var sourceRect = GetCharacterRect ( c , lineNumber , ref point , out destRect , out pageIndex , textObject . FontScale ) ; var origin = new Point ( ( int ) textObject . X , ( int ) ( textObject . Y + yoffset ) ) ; var rotate = ( float ) - ( textObject . Rotation * System . Math . PI / 180f ) ; var rotatingPoint = new Point ( origin . X + destRect . X , origin . Y + destRect . Y ) ; MathFunctions . RotatePointAroundPoint ( new Point ( origin . X , origin . Y ) , ref rotatingPoint , rotate ) ; mCharRect . X = rotatingPoint . X ; mCharRect . Y = rotatingPoint . Y ; mCharRect . Width = destRect . Width ; mCharRect . Height = destRect . Height ; if ( textObject . Parent != null ) { mCharRect . X += textObject . Parent . GetAbsoluteX ( ) ; mCharRect . Y += textObject . Parent . GetAbsoluteY ( ) ; } Sprite . Render ( managers , spriteRenderer , mCharRect , mTextures [ 0 ] , color , sourceRect , false , false , rotation , treat0AsFullDimensions : false , objectCausingRenering : objectRequestingChange ) ; } point . X = 0 ; lineNumber ++ ; } }
Used for rendering directly to screen with an atlased texture.
Used for rendering directly to screen with an atlased texture .
// scoot over to leave room for the outline
lines
List<string>
horizontalAlignment
HorizontalAlignment
textureToRenderHeight
float
color
Color
rotation
float
fontScale
float
managers
SystemManagers
spriteRenderer
SpriteRenderer
objectRequestingChange
object