AcManager.Tools.Objects.FontObject.BitmapForChar C# (CSharp) Метод

BitmapForChar() приватный Метод

private BitmapForChar ( char c ) : System.Windows.Media.Imaging.CroppedBitmap
c char
Результат System.Windows.Media.Imaging.CroppedBitmap
        public CroppedBitmap BitmapForChar(char c) {
            if (!_fontBitmapLoaded) {
                _fontBitmapLoaded = true;
                _fontBitmapImage = UriToCachedImageConverter.Convert(FontBitmap);
            }

            if (!_fontListLoaded) {
                _fontListLoaded = true;

                try {
                    _fontList = File.ReadAllLines(Location).Select(line => double.Parse(line, CultureInfo.InvariantCulture)).ToList();
                } catch (Exception e) {
                    Logging.Warning("File damaged: " + e);
                }
            }

            if (_fontBitmapImage == null || _fontList == null) {
                return null;
            }

            var i = CharToId(c);
            var x = _fontList[i];
            var width = (i + 1 == _fontList.Count ? 1d : _fontList[i + 1]) - x;

            if (x + width <= 0d || x >= 1d) return null;
            if (x < 0) {
                width += x;
                x = 0d;
            }

            width = Math.Min(width, 1d - x);

            var rect = new Int32Rect((int)(x * _fontBitmapImage.PixelWidth), 0, (int)(width * _fontBitmapImage.PixelWidth), _fontBitmapImage.PixelHeight);
            return new CroppedBitmap(_fontBitmapImage, rect);
        }