internal void InternalUIDrawGlyph(ref InternalUIDrawCommand parameters, ref Vector2 fontSize, ref Glyph glyph, float x, float y, float nextx) { if (char.IsWhiteSpace((char)glyph.Character)) { return; } var xShift = x + glyph.Subrect.Width / 2f; var yShift = y + GetBaseOffsetY(fontSize.Y) + glyph.Offset.Y + glyph.Subrect.Height / 2f; var xScaledShift = xShift / parameters.FontScale.X; var yScaledShift = yShift / parameters.FontScale.Y; var worldMatrix = parameters.WorldMatrix; worldMatrix.M41 += worldMatrix.M11 * xScaledShift + worldMatrix.M21 * yScaledShift; worldMatrix.M42 += worldMatrix.M12 * xScaledShift + worldMatrix.M22 * yScaledShift; worldMatrix.M43 += worldMatrix.M13 * xScaledShift + worldMatrix.M23 * yScaledShift; var elementSize = new Vector3(glyph.Subrect.Width / parameters.FontScale.X, glyph.Subrect.Height / parameters.FontScale.Y, 0); RectangleF sourceRectangle = glyph.Subrect; parameters.Batch.DrawImage(Textures[glyph.BitmapIndex], null, ref worldMatrix, ref sourceRectangle, ref elementSize, ref nullVector4, ref parameters.Color, parameters.DepthBias, ImageOrientation.AsIs, Swizzle, parameters.SnapText); }
internal void InternalDrawGlyph(ref InternalDrawCommand parameters, ref Vector2 fontSize, ref Glyph glyph, float x, float y, float nextx) { if (char.IsWhiteSpace((char)glyph.Character) || glyph.Subrect.Width == 0 || glyph.Subrect.Height == 0) { return; } var spriteEffects = parameters.SpriteEffects; var offset = new Vector2(x, y + GetBaseOffsetY(fontSize.Y) + glyph.Offset.Y); Vector2.Modulate(ref offset, ref AxisDirectionTable[(int)spriteEffects & 3], out offset); Vector2.Add(ref offset, ref parameters.Origin, out offset); offset.X = (float)Math.Round(offset.X); offset.Y = (float)Math.Round(offset.Y); if (spriteEffects != SpriteEffects.None) { // For mirrored characters, specify bottom and/or right instead of top left. var glyphRect = new Vector2(glyph.Subrect.Right - glyph.Subrect.Left, glyph.Subrect.Top - glyph.Subrect.Bottom); Vector2.Modulate(ref glyphRect, ref AxisIsMirroredTable[(int)spriteEffects & 3], out offset); } var destination = new RectangleF(parameters.Position.X, parameters.Position.Y, parameters.Scale.X, parameters.Scale.Y); RectangleF?sourceRectangle = glyph.Subrect; parameters.SpriteBatch.DrawSprite(Textures[glyph.BitmapIndex], ref destination, true, ref sourceRectangle, parameters.Color, parameters.Rotation, ref offset, spriteEffects, ImageOrientation.AsIs, parameters.Depth, Swizzle, true); }
internal void InternalUIDrawGlyph(ref InternalUIDrawCommand parameters, ref Vector2 requestedFontSize, ref Glyph glyph, float x, float y, float nextx, ref Vector2 auxiliaryScaling) { if (char.IsWhiteSpace((char)glyph.Character)) { return; } // Skip items with null size var elementSize = new Vector2(auxiliaryScaling.X * glyph.Subrect.Width / parameters.RealVirtualResolutionRatio.X, auxiliaryScaling.Y * glyph.Subrect.Height / parameters.RealVirtualResolutionRatio.Y); if (elementSize.Length() < MathUtil.ZeroTolerance) { return; } var xShift = x; var yShift = y + (GetBaseOffsetY(requestedFontSize.Y) + glyph.Offset.Y * auxiliaryScaling.Y); if (parameters.SnapText) { xShift = (float)Math.Round(xShift); yShift = (float)Math.Round(yShift); } var xScaledShift = xShift / parameters.RealVirtualResolutionRatio.X; var yScaledShift = yShift / parameters.RealVirtualResolutionRatio.Y; var worldMatrix = parameters.Matrix; worldMatrix.M41 += worldMatrix.M11 * xScaledShift + worldMatrix.M21 * yScaledShift; worldMatrix.M42 += worldMatrix.M12 * xScaledShift + worldMatrix.M22 * yScaledShift; worldMatrix.M43 += worldMatrix.M13 * xScaledShift + worldMatrix.M23 * yScaledShift; worldMatrix.M11 *= elementSize.X; worldMatrix.M12 *= elementSize.X; worldMatrix.M13 *= elementSize.X; worldMatrix.M21 *= elementSize.Y; worldMatrix.M22 *= elementSize.Y; worldMatrix.M23 *= elementSize.Y; RectangleF sourceRectangle = glyph.Subrect; parameters.Batch.DrawCharacter(Textures[glyph.BitmapIndex], ref worldMatrix, ref sourceRectangle, ref parameters.Color, parameters.DepthBias, Swizzle); }