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) { var c = collection.GetCollection(WriteFactory); if (c.FindFamilyName(fontName) == -1) { fontName = c[0].FamilyNames.get_String(0); } 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); }
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) { }