Beispiel #1
0
 private void GetTextParameters(string textToBuild, Rect textRect, FontFile.FontSize fontSize, RectAlignment alignment, out TextCache cachedText, out float scale, out float textWidth, out Rect realTextRect)
 {
     realTextRect = textRect;
     scale        = 1f;
     textWidth    = 0f;
     if (!string.IsNullOrEmpty(textToBuild))
     {
         cachedText = gui.textCache.GetCached((fontSize, textToBuild, uint.MaxValue));
         textWidth  = gui.PixelsToUnits(cachedText.texRect.w);
         if (textWidth > realTextRect.Width)
         {
             scale = realTextRect.Width / textWidth;
         }
         else
         {
             realTextRect = ImGui.AlignRect(textRect, alignment, textWidth, textRect.Height);
         }
     }
     else
     {
         realTextRect = ImGui.AlignRect(textRect, alignment, 0f, textRect.Height);
         cachedText   = null;
     }
 }