internal void InternalUIDraw(ref StringProxy text, ref InternalUIDrawCommand drawCommand) { var fontSize = new Vector2(drawCommand.FontSize * drawCommand.FontScale.Y); // we don't want to have letters with non uniform ratio var scaledSize = new Vector2(drawCommand.Size.X * drawCommand.FontScale.X, drawCommand.Size.Y * drawCommand.FontScale.Y); ForEachGlyph(ref text, ref fontSize, InternalUIDrawGlyph, ref drawCommand, drawCommand.Alignment, true, scaledSize); }
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 InternalUIDraw(CommandList commandList, ref StringProxy text, ref InternalUIDrawCommand drawCommand) { // TODO SignedDistanceFieldFont might allow non-uniform scaling var fontSize = new Vector2(drawCommand.FontSize * drawCommand.FontScale.Y); // we don't want to have letters with non uniform ratio var scaledSize = new Vector2(drawCommand.Size.X * drawCommand.FontScale.X, drawCommand.Size.Y * drawCommand.FontScale.Y); ForEachGlyph(commandList, ref text, ref fontSize, internalUIDrawGlyphAction, ref drawCommand, drawCommand.Alignment, true, scaledSize); }
internal void InternalUIDraw(CommandList commandList, ref StringProxy text, ref InternalUIDrawCommand drawCommand) { // We don't want to have letters with non uniform ratio var requestedFontSize = new Vector2(drawCommand.RequestedFontSize * drawCommand.RealVirtualResolutionRatio.Y); var textBoxSize = drawCommand.TextBoxSize * drawCommand.RealVirtualResolutionRatio; ForEachGlyph(commandList, ref text, ref requestedFontSize, internalUIDrawGlyphAction, ref drawCommand, drawCommand.Alignment, true, textBoxSize); }
internal void InternalUIDraw(ref StringProxy text, ref InternalUIDrawCommand drawCommand) { if (!IsDynamic && (drawCommand.FontScale.X != 1 || drawCommand.FontScale.Y != 1)) // ensure that static font are not scaled internally { drawCommand.SnapText = false; // we don't want snapping of the resolution of the screen does not match virtual resolution. (character alignment problems) drawCommand.FontScale = Vector2.One; } var fontSize = drawCommand.FontSize * drawCommand.FontScale; var scaledSize = new Vector2(drawCommand.Size.X * drawCommand.FontScale.X, drawCommand.Size.Y * drawCommand.FontScale.Y); ForEachGlyph(ref text, ref fontSize, InternalUIDrawGlyph, ref drawCommand, drawCommand.Alignment, true, scaledSize); }
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; } var realVirtualResolutionRatio = requestedFontSize / parameters.RequestedFontSize; // Skip items with null size var elementSize = new Vector2( auxiliaryScaling.X * glyph.Subrect.Width / realVirtualResolutionRatio.X, auxiliaryScaling.Y * glyph.Subrect.Height / realVirtualResolutionRatio.Y); if (elementSize.LengthSquared() < 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 / realVirtualResolutionRatio.X; var yScaledShift = yShift / 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.M44 += worldMatrix.M14 * xScaledShift + worldMatrix.M24 * yScaledShift; worldMatrix.M11 *= elementSize.X; worldMatrix.M12 *= elementSize.X; worldMatrix.M13 *= elementSize.X; worldMatrix.M14 *= elementSize.X; worldMatrix.M21 *= elementSize.Y; worldMatrix.M22 *= elementSize.Y; worldMatrix.M23 *= elementSize.Y; worldMatrix.M24 *= elementSize.Y; RectangleF sourceRectangle = glyph.Subrect; parameters.Batch.DrawCharacter(Textures[glyph.BitmapIndex], ref worldMatrix, ref sourceRectangle, ref parameters.Color, parameters.DepthBias, swizzle); }
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; } // Skip items with null size var elementSize = new Vector2(glyph.Subrect.Width / parameters.FontScale.X, glyph.Subrect.Height / parameters.FontScale.Y); if (elementSize.Length() < MathUtil.ZeroTolerance) { return; } var xShift = x; var yShift = y + GetBaseOffsetY(fontSize.Y) + glyph.Offset.Y; if (parameters.SnapText) { xShift = (float)Math.Round(xShift); yShift = (float)Math.Round(yShift); } var xScaledShift = xShift / parameters.FontScale.X; var yScaledShift = yShift / parameters.FontScale.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); }