Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ MeasureString()

Vector2 ReLogic.Graphics.DynamicSpriteFont.MeasureString ( string text)
inline

Definition at line 233 of file DynamicSpriteFont.cs.

234 {
235 //IL_000e: Unknown result type (might be due to invalid IL or missing references)
236 //IL_0013: Unknown result type (might be due to invalid IL or missing references)
237 //IL_0008: Unknown result type (might be due to invalid IL or missing references)
238 //IL_0161: Unknown result type (might be due to invalid IL or missing references)
239 //IL_0172: Unknown result type (might be due to invalid IL or missing references)
240 //IL_005a: Unknown result type (might be due to invalid IL or missing references)
241 //IL_0079: Unknown result type (might be due to invalid IL or missing references)
242 //IL_007e: Unknown result type (might be due to invalid IL or missing references)
243 //IL_00a5: Unknown result type (might be due to invalid IL or missing references)
244 //IL_00aa: Unknown result type (might be due to invalid IL or missing references)
245 //IL_00b2: Unknown result type (might be due to invalid IL or missing references)
246 //IL_00e6: Unknown result type (might be due to invalid IL or missing references)
247 //IL_00ed: Unknown result type (might be due to invalid IL or missing references)
248 //IL_00f7: Unknown result type (might be due to invalid IL or missing references)
249 //IL_0101: Unknown result type (might be due to invalid IL or missing references)
250 //IL_0109: Unknown result type (might be due to invalid IL or missing references)
251 if (text.Length == 0)
252 {
253 return Vector2.Zero;
254 }
256 zero.Y = LineSpacing;
257 float val = 0f;
258 int num = 0;
259 float num2 = 0f;
260 bool flag = true;
261 foreach (char c in text)
262 {
263 switch (c)
264 {
265 case '\n':
266 val = Math.Max(zero.X + Math.Max(num2, 0f), val);
267 num2 = 0f;
268 zero = Vector2.Zero;
269 zero.Y = LineSpacing;
270 flag = true;
271 num++;
272 continue;
273 case '\r':
274 continue;
275 }
276 SpriteCharacterData characterData = GetCharacterData(c);
277 Vector3 kerning = characterData.Kerning;
278 if (flag)
279 {
280 kerning.X = Math.Max(kerning.X, 0f);
281 }
282 else
283 {
284 zero.X += CharacterSpacing + num2;
285 }
286 zero.X += kerning.X + kerning.Y;
287 num2 = kerning.Z;
288 zero.Y = Math.Max(zero.Y, characterData.Padding.Height);
289 flag = false;
290 }
291 zero.X += Math.Max(num2, 0f);
292 zero.Y += num * LineSpacing;
293 zero.X = Math.Max(zero.X, val);
294 return zero;
295 }
SpriteCharacterData GetCharacterData(char character)
static byte Max(byte val1, byte val2)
Definition Math.cs:738

References ReLogic.Graphics.DynamicSpriteFont.CharacterSpacing, ReLogic.Graphics.DynamicSpriteFont.GetCharacterData(), ReLogic.Graphics.DynamicSpriteFont.LineSpacing, System.Math.Max(), System.text, Microsoft.Xna.Framework.Vector3.X, Microsoft.Xna.Framework.Vector3.Y, Microsoft.Xna.Framework.Vector3.Z, and Microsoft.Xna.Framework.Vector2.Zero.

Referenced by ReLogic.Graphics.DynamicSpriteFont.CreateCroppedText(), Terraria.GameContent.UI.WorkshopPublishingIndicator.Draw(), Terraria.UI.Chat.TextSnippet.GetStringLength(), ReLogic.Graphics.DynamicSpriteFont.InternalDraw(), and Terraria.GameContent.UI.Elements.UIText.InternalSetText().