Example #1
0
        public TextBlockRenderer(SpriteRenderer sprite, String fontName, FontWeight fontWeight,
                                 FontStyle fontStyle, FontStretch fontStretch, float fontSize)
        {
            AssertDevice();
            IncRefCount();
            Sprite   = sprite;
            FontSize = fontSize;

            Monitor.Enter(sprite.Device);
            try {
                _rtp = new RenderTargetProperties {
                    HorizontalDpi       = 96,
                    VerticalDpi         = 96,
                    Type                = RenderTargetType.Default,
                    PixelFormat         = new PixelFormat(Format.R8G8B8A8_UNorm, AlphaMode.Premultiplied),
                    MinimumFeatureLevel = FeatureLevel.Direct3D10
                };

                Font = ((Factory)WriteFactory).CreateTextFormat(fontName, fontWeight, fontStyle, fontStretch, fontSize,
                                                                CultureInfo.CurrentCulture.Name);
            } finally {
                Monitor.Exit(sprite.Device);
            }

            CreateCharTable(0);
        }
Example #2
0
        public TextBlockRenderer(SpriteRenderer sprite, String fontName, SlimDX.DirectWrite.FontWeight fontWeight, SlimDX.DirectWrite.FontStyle fontStyle, FontStretch fontStretch, float fontSize)
        {
            Sprite      = sprite;
            FontSize    = fontSize;
            D3DDevice11 = ModelEx.DeviceManager.Instance.device;
            System.Threading.Monitor.Enter(D3DDevice11);
            rtp = new RenderTargetProperties()
            {
                HorizontalDpi       = 96,
                VerticalDpi         = 96,
                Type                = RenderTargetType.Default,
                PixelFormat         = new PixelFormat(Format.R8G8B8A8_UNorm, AlphaMode.Premultiplied),
                MinimumFeatureLevel = FeatureLevel.Direct3D10
            };

            Font = ModelEx.FontManager.Instance.WriteFactory.CreateTextFormat(fontName, fontWeight, fontStyle, fontStretch, fontSize, CultureInfo.CurrentCulture.Name);
            System.Threading.Monitor.Exit(D3DDevice11);
            CreateCharTable(0);
        }
Example #3
0
        public TextBlockRenderer(SpriteRenderer sprite, [CanBeNull] IFontCollectionProvider collection, string fontName, FontWeight fontWeight,
                                 FontStyle fontStyle, FontStretch fontStretch, float fontSize, int kerningAdjustment = 0)
        {
            AssertDevice();
            IncRefCount();
            Sprite            = sprite;
            FontSize          = fontSize;
            KerningAdjustment = kerningAdjustment;

            Monitor.Enter(sprite.Device);
            try {
                _rtp = new RenderTargetProperties {
                    HorizontalDpi       = 96,
                    VerticalDpi         = 96,
                    Type                = RenderTargetType.Default,
                    PixelFormat         = new PixelFormat(Format.R8G8B8A8_UNorm, AlphaMode.Premultiplied),
                    MinimumFeatureLevel = FeatureLevel.Direct3D10
                };

                if (collection != null)
                {
                    _fcp = collection;
                    var c = collection.GetCollection(WriteFactory);
                    Font = WriteFactory.CreateTextFormat(fontName, c, fontWeight, fontStyle, fontStretch, fontSize,
                                                         CultureInfo.CurrentCulture.Name);
                }
                else
                {
                    Font = WriteFactory.CreateTextFormat(fontName, fontWeight, fontStyle, fontStretch, fontSize, CultureInfo.CurrentCulture.Name);
                }
            } finally {
                Monitor.Exit(sprite.Device);
            }

            CreateCharTable(0);
        }
Example #4
0
 public TextBlockRenderer(SpriteRenderer sprite, string fontName, FontWeight fontWeight,
                          FontStyle fontStyle, FontStretch fontStretch, float fontSize, int kerningAdjustment = 0)
     : this(sprite, null, fontName, fontWeight, fontStyle, fontStretch, fontSize, kerningAdjustment)
 {
 }