Пример #1
0
		public NxFont (string fileName, float size, float height, FontStyle style, NxFontBuilderConfiguration config)
		{
			optionsStack = new ConcurrentStack<QFontRenderOptions> ();
			PrivateFontCollection pfc = new PrivateFontCollection();
			pfc.AddFontFile(fileName);
			var fontFamily = pfc.Families[0];

			if (!fontFamily.IsStyleAvailable(style))
				throw new ArgumentException("Font file: " + fileName + " does not support style: " +  style );

			if (config == null)
			{
				throw new ArgumentNullException ("config");
			}

			float fontScale;
			var transToVp = SetupTransformViewport (height, config.TransformToCurrentOrthogProjection, config.Transform, out fontScale);

			var internalConfig = new QFontBuilderConfiguration (config.AddDropShadow);
			internalConfig.SuperSampleLevels = config.SuperSampleLevels;
			if (internalConfig.ShadowConfig != null)
			{
				internalConfig.ShadowConfig.blurRadius = config.BlurRadius;
			}
			using(var font = new Font(fontFamily, size * fontScale * config.SuperSampleLevels, style)){
				var builder = new Builder<NxFont>(font, internalConfig);
				NxFont dropShadowFont;
				fontData = builder.BuildFontData(null, out dropShadowFont);
				DropShadow = dropShadowFont;
			}

			if (internalConfig.ShadowConfig != null)
				Options.DropShadowActive = true;
			if (transToVp != null)
				Options.TransformToViewport = transToVp;

			InitialiseGlyphRenderer(config.CharacterOutput, config.FontGlyphRenderer, config.DropShadowRenderer);
		}
Пример #2
0
		public NxFont(string fileName, float size, float height, NxFontBuilderConfiguration config) : this(fileName, size, height, FontStyle.Regular, config)
		{
		
		}