UIFont.Trim C# (CSharp) Méthode

Trim() private méthode

Trim the glyphs, making sure they never go past the trimmed texture bounds.
private Trim ( ) : void
Résultat void
    void Trim()
    {
        Texture tex = mAtlas.texture;

        if (tex != null && mSprite != null)
        {
            Rect full = NGUIMath.ConvertToPixels(mUVRect, texture.width, texture.height, true);
            Rect trimmed = (mAtlas.coordinates == UIAtlas.Coordinates.TexCoords) ?
                NGUIMath.ConvertToPixels(mSprite.outer, tex.width, tex.height, true) : mSprite.outer;

            int xMin = Mathf.RoundToInt(trimmed.xMin - full.xMin);
            int yMin = Mathf.RoundToInt(trimmed.yMin - full.yMin);
            int xMax = Mathf.RoundToInt(trimmed.xMax - full.xMin);
            int yMax = Mathf.RoundToInt(trimmed.yMax - full.yMin);

            mFont.Trim(xMin, yMin, xMax, yMax);
        }
    }

Usage Example

 public void Validate()
 {
     Host        = string.IsNullOrWhiteSpace(Host) ? DEFAULT_HOST : Host.Trim();
     Port        = Math.Min(Math.Max(Port, (ushort)1), ushort.MaxValue);
     GameFont    = string.IsNullOrWhiteSpace(GameFont) ? DEFAULT_FONT : GameFont.Trim();
     UIFont      = string.IsNullOrWhiteSpace(UIFont) ? DEFAULT_UI_FONT : UIFont.Trim();
     ChatLines   = Math.Min(Math.Max(ChatLines, 10), 500);
     IntroImages = new List <string>(IntroImages?.Distinct() ?? new List <string>());
 }