Exemplo n.º 1
0
 public void GetGlyphsRightAligned()
 {
     var fontData = new FontDescription(ContentLoader.Load<Font>("Verdana12").Data);
     var textConverter = new TextConverter(fontData.GlyphDictionary, fontData.PixelLineHeight);
     var glyphs = textConverter.GetRenderableGlyphs("A a a aaa", HorizontalAlignment.Right);
     Assert.AreEqual(8, glyphs.Length);
 }
Exemplo n.º 2
0
 protected override void OnClick(EventArgs e)
 {
     var fod = new FontDialog();
     fod.Font = SelectedFont.CreateFont();
     if(fod.ShowDialog() == DialogResult.OK) {
         SelectedFont = FontDescription.FromFont(fod.Font);
     }
 }
Exemplo n.º 3
0
		public void ToStringTest()
		{
			var fontDataType = typeof(FontDescription);
			var expected = fontDataType.Namespace + "." + fontDataType.Name +
				", Font Family=Verdana, Font Size=12";
			var fontData = new FontDescription(ContentLoader.Load<Font>("Verdana12").Data);
			Assert.AreEqual(expected, fontData.ToString());
		}
Exemplo n.º 4
0
		public void LoadFontData()
		{
			var fontData = new FontDescription(ContentLoader.Load<Font>("Verdana12").Data);
			Assert.AreEqual("Verdana", fontData.FontFamilyName);
			Assert.AreEqual(12, fontData.SizeInPoints);
			Assert.AreEqual("AddOutline", fontData.Style);
			Assert.AreEqual(16, fontData.PixelLineHeight);
			Assert.AreEqual("Verdana12Font", fontData.FontMapName);
			Assert.AreEqual(new Size(128, 128), fontData.FontMapPixelSize);
			Assert.AreEqual(new Rectangle(0, 0, 1, 16), fontData.GlyphDictionary[' '].UV);
			Assert.AreEqual(7.34875f, fontData.GlyphDictionary[' '].AdvanceWidth);
		}
Exemplo n.º 5
0
		public void GetGlyphDrawAreaAndUVs()
		{
			var fontData = new FontDescription(ContentLoader.Load<Font>("Verdana12").Data);
			fontData.Generate("", HorizontalAlignment.Center);
			Assert.AreEqual(0, fontData.Glyphs.Length);
			fontData.Generate("\n", HorizontalAlignment.Center);
			Assert.AreEqual(0, fontData.Glyphs.Length);
			fontData.Generate(" ", HorizontalAlignment.Center);
			Assert.AreEqual(1, fontData.Glyphs.Length);
			GlyphDrawData glyphA = fontData.Glyphs[0];
			Assert.AreEqual(glyphA.UV,
				Rectangle.BuildUVRectangle(new Rectangle(0, 0, 1, 16), new Size(128, 128)));
			Assert.AreEqual(new Rectangle(0, 0, 1, 16), glyphA.DrawArea);
		}
Exemplo n.º 6
0
        private void CreateExEnOutput(NuclexSpriteFontContent spriteFontContent, FontDescription input, ContentProcessorContext context)
        {
            ExEnFontWriter.CreateOutputDirectory(input.Identity);

            ExEnFontWriter.WriteTexture(spriteFontContent, true, context,
                                        ExEnFontWriter.AssetOutputFilename(input.Identity, context, "-exenfont.png"));
            ExEnFontWriter.WriteMetrics(spriteFontContent, context,
                                        ExEnFontWriter.AssetOutputFilename(input.Identity, context, "-exenfont.exenfont"));

            // Retina Display
            input.BecomeAt2x();
            NuclexSpriteFontContent spriteFontContentAt2x = base.Process(input, context);

            ExEnFontWriter.WriteTexture(spriteFontContentAt2x, true, context,
                                        ExEnFontWriter.AssetOutputFilename(input.Identity, context, "*****@*****.**"));
            ExEnFontWriter.WriteMetrics(spriteFontContentAt2x, context,
                                        ExEnFontWriter.AssetOutputFilename(input.Identity, context, "*****@*****.**"));
        }
Exemplo n.º 7
0
        public CodecsChoiceDialog()
        {
            this.Build();

            Image img = new Image(System.IO.Path.Combine(Config.ImagesDir, "longomatch-pro-small.png"));

            buttonOKimage.Pixbuf = img.Value;

            titlelabel.ModifyFont(FontDescription.FromString(Config.Style.Font + " 14"));

            // Configure URL handler for the links
            label1.SetLinkHandler(url => {
                try {
                    System.Diagnostics.Process.Start(url);
                } catch {
                }
            });
        }
Exemplo n.º 8
0
        void aquireResources()
        {
            if (videoWidth == 0 || videoHeight == 0)
            {
                throw new VideoPlayerException("Cannot instantiate D3D surface with a width or height of 0 pixels");
            }

            D3D.Format pixelFormat = makeFourCC('Y', 'V', '1', '2');

            offscreen = D3D.Surface.CreateOffscreenPlain(device,
                                                         videoWidth,
                                                         videoHeight,
                                                         pixelFormat,
                                                         D3D.Pool.Default);

            screenShot = D3D.Surface.CreateOffscreenPlain(device,
                                                          videoWidth,
                                                          videoHeight,
                                                          D3D.Format.A8R8G8B8,
                                                          D3D.Pool.Default);

            backBuffer = device.GetBackBuffer(0, 0);

            FontDescription fontDescription = new FontDescription();

            fontDescription.FaceName = "TimesNewRoman";
            fontDescription.Height   = 15;

            infoFont = new D3D.Font(device, fontDescription);

            fontDescription          = new FontDescription();
            fontDescription.FaceName = "Arial";

            videoDestRect = getVideoDestRect(backBuffer);

            fontDescription.Height = videoDestRect.Height / 14;

            fontDescription.Quality = FontQuality.Antialiased;

            subtitleShadowOffset = fontDescription.Height / 18;
            subtitleBottomMargin = videoDestRect.Height / 12;

            subtitleFont = new D3D.Font(device, fontDescription);
        }
        /// <summary>
        /// return the size of the text
        /// </summary>
        /// <param name="e"></param>
        /// <param name="Text"></param>
        /// <param name="buttonBase"></param>
        /// <param name="textRect"></param>
        /// <param name="NewTextAli"></param>
        /// <param name="isMultiLine"></param>
        /// <returns></returns>
        private static Size GetTextSize(PaintEventArgs e, String Text, FontDescription font, ref Rectangle textRect, bool isMultiLine)
        {
            Size textExt = new Size();

            // Rinat: I used ContentAlignment.MiddleRight for the calculation because if we use ContentAlignment.MiddleCenter
            // then GuiUtils.CalcTextRect() returns wrong results. The problem is that the height returned by GuiUtils.CalcTextRect()
            // will be of a single line always.
            int flags = (int)Utils.GetTextFlags(ContentAlignment.MiddleRight, /*wordWrap*/ true, isMultiLine,
                                                /*AddNoPrefixFlag*/ false, /*AddNoClipping*/ true,
                                                /*rightToLeft*/ false);

            NativeWindowCommon.RECT retCalcTextRect;
            Utils.CalcTextRect(e.Graphics, textRect, font, Text, flags, out retCalcTextRect);

            textExt.Width  = retCalcTextRect.right - retCalcTextRect.left;
            textExt.Height = retCalcTextRect.bottom - retCalcTextRect.top;

            return(textExt);
        }
Exemplo n.º 10
0
    public MainWindow() : base(WindowType.Toplevel)
    {
        Build();
        Reset();
        FontDescription font = new FontDescription();

        font.Family = "monospace 20";
        lOutput.ModifyFont(font);
        eInput.SelectRegion(0, 0);
        eInput.ModifyFont(font);
        timer = GLib.Timeout.Add(10, () =>
        {
            if (autoStep)
            {
                Step();
            }
            return(true);
        });
    }
Exemplo n.º 11
0
        public static void SetupFontsFiles(string[] sSupportedFonts)
        {
            // First group all fonts to font families
            Dictionary <string, List <string> > tmpFontFamiliesTtfFilesDict = new Dictionary <string, List <string> >();

            foreach (var fontPathFile in sSupportedFonts)
            {
                try
                {
                    FontDescription fontDescription = FontDescription.LoadDescription(fontPathFile);
                    string          fontFamilyName  = fontDescription.FontFamily(CultureInfo.InvariantCulture);
                    Console.WriteLine(fontPathFile);

                    if (tmpFontFamiliesTtfFilesDict.TryGetValue(fontFamilyName, out List <string> familyTtfFiles))
                    {
                        familyTtfFiles.Add(fontPathFile);
                    }
                    else
                    {
                        tmpFontFamiliesTtfFilesDict.Add(fontFamilyName, new List <string> {
                            fontPathFile
                        });
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }

            // Deserialize all font families
            foreach (var fontFamily in tmpFontFamiliesTtfFilesDict)
            {
                try
                {
                    InstalledFonts.Add(fontFamily.Key.ToLower(), DeserializeFontFamily(fontFamily));
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
        }
        public void CanLoadFontCollectionDescriptionsFromPath()
        {
            FontDescription[] descriptions = FontDescription.LoadFontCollectionDescriptions(TestFonts.SimpleTrueTypeCollection);
            Assert.NotNull(descriptions);
            Assert.Equal(2, descriptions.Length);

            FontDescription description = descriptions[0];

            Assert.Equal("SixLaborsSampleAB", description.FontFamilyInvariantCulture);
            Assert.Equal("SixLaborsSampleAB regular", description.FontNameInvariantCulture);
            Assert.Equal("Regular", description.FontSubFamilyNameInvariantCulture);
            Assert.Equal(FontStyle.Regular, description.Style);

            description = descriptions[1];
            Assert.Equal("Open Sans", description.FontFamilyInvariantCulture);
            Assert.Equal("Open Sans", description.FontNameInvariantCulture);
            Assert.Equal("Regular", description.FontSubFamilyNameInvariantCulture);
            Assert.Equal(FontStyle.Regular, description.Style);
        }
        public override SpriteFontContent Process(FontDescription input, ContentProcessorContext context)
        {
            // Fallback if we aren't buiding for iOS.
            var platform = ContentHelper.GetMonoGamePlatform();

            if (platform != MonoGamePlatform.iOS)
            {
                return(base.Process(input, context));
            }

            SpriteFontContent content      = base.Process(input, context);
            FieldInfo         TextureField = typeof(SpriteFontContent).GetField("texture", BindingFlags.Instance | BindingFlags.NonPublic);
            Texture2DContent  texture      = (Texture2DContent)TextureField.GetValue(content);

            // TODO: This is a very lame way of doing this as we're getting compression artifacts twice, but is the quickest way to get
            // Compressed fonts up and running. The SpriteFontContent/Processor contains a ton
            // of sealed/internal classes riddled with private fields, so overriding CompressFontTexture
            // or even Process is tricky. This works for now, but should be replaced when the content pipeline
            // moves a bit further

            var texWidth  = texture.Faces[0][0].Width;
            var texHeight = texture.Faces[0][0].Height;

            // Resize to square, power of two if necessary.
            if (texWidth != texHeight)
            {
                texHeight = texWidth = Math.Max(texHeight, texWidth);
                var resizedBitmap = (BitmapContent)Activator.CreateInstance(typeof(PixelBitmapContent <Color>), new object[] { texWidth, texHeight });
                var textureRegion = new Rectangle(0, 0, texture.Faces[0][0].Width, texture.Faces[0][0].Height);
                BitmapContent.Copy(texture.Faces[0][0], textureRegion, resizedBitmap, textureRegion);

                texture.Faces[0].Clear();
                texture.Faces[0].Add(resizedBitmap);
            }
            else
            {
                texture.ConvertBitmapType(typeof(PixelBitmapContent <Color>));
            }

            MGTextureProcessor.ConvertToPVRTC(texture, 1, true, MGCompressionMode.PVRTCFourBitsPerPixel);

            return(content);
        }
        private void SetupPersonalManagers()
        {
            if (_counterparty?.SalesManager != null)
            {
                labelSalesManager.Visible  = true;
                prefixSalesManager.Visible = true;
                labelSalesManager.Markup   = _counterparty?.SalesManager.GetPersonNameWithInitials();
                prefixSalesManager.ModifyFont(FontDescription.FromString("9"));
                prefixSalesManager.QueueResize();
            }
            else
            {
                labelSalesManager.Visible  = false;
                prefixSalesManager.Visible = false;
            }

            if (_counterparty?.Accountant != null)
            {
                labelAccountant.Visible  = true;
                prefixAccountant.Visible = true;
                labelAccountant.Markup   = _counterparty?.Accountant.GetPersonNameWithInitials();
            }
            else
            {
                labelAccountant.Visible  = false;
                prefixAccountant.Visible = false;
            }

            if (_counterparty?.BottlesManager != null)
            {
                labelBottlesManager.Visible  = true;
                prefixBottlesManager.Visible = true;
                labelBottlesManager.Markup   = _counterparty?.BottlesManager.GetPersonNameWithInitials();
                prefixBottlesManager.ModifyFont(FontDescription.FromString("9"));
                prefixBottlesManager.QueueResize();
            }
            else
            {
                labelBottlesManager.Visible  = false;
                prefixBottlesManager.Visible = false;
            }
        }
Exemplo n.º 15
0
        public ProcessOutput()
        {
            this.ShadowType         = ShadowType.Out;
            treeView                = new TreeView();
            treeView.Selection.Mode = Gtk.SelectionMode.Single;

            treeView.Model = outputModel;

            FontDescription customFont = Pango.FontDescription.FromString(MainClass.Settings.ConsoleTaskFont);

            treeView.ModifyFont(customFont);

            TreeViewColumn tvcName = new TreeViewColumn(MainClass.Languages.Translate("Name"), new CellRendererText(), "text", 0);

            tvcName.MinWidth = 100;
            treeView.AppendColumn(tvcName);
            TreeViewColumn tvcState = new TreeViewColumn(MainClass.Languages.Translate("Stat"), new CellRendererText(), "text", 1);

            tvcState.MinWidth = 100;
            treeView.AppendColumn(tvcState);
            TreeViewColumn tvcMessage = new TreeViewColumn(MainClass.Languages.Translate("Message"), new CellRendererText(), "text", 2);

            tvcMessage.MinWidth = 100;
            treeView.AppendColumn(tvcMessage);
            TreeViewColumn tvcPlace = new TreeViewColumn(MainClass.Languages.Translate("Place"), new CellRendererText(), "text", 3);

            tvcPlace.MinWidth = 100;
            treeView.AppendColumn(tvcPlace);

            treeView.HeadersVisible  = true;
            treeView.EnableTreeLines = true;

            treeView.RowActivated += new RowActivatedHandler(OnRowActivate);
            treeView.EnableSearch  = false;
            treeView.HasFocus      = false;

            outputDispatcher = new GLib.TimeoutHandler(OutputDispatchHandler);

            this.Add(treeView);

            this.ShowAll();
        }
Exemplo n.º 16
0
        public SynchronizationWidget()
        {
            this.Build();

            zoomscale.CanFocus         = false;
            zoomscale.Adjustment.Lower = 0;
            zoomscale.Adjustment.Upper = 100;

            zoomoutimage.Pixbuf = Helpers.Misc.LoadIcon("longomatch-zoom-out", 14);
            zoominimage.Pixbuf  = Helpers.Misc.LoadIcon("longomatch-zoom-in", 14);

            // Only main cam has audio for now
            main_cam_audio_button_image.Pixbuf = Helpers.Misc.LoadIcon("longomatch-control-volume-hi", IconSize.Button);
            sec_cam_audio_button_image.Pixbuf  = Helpers.Misc.LoadIcon("longomatch-control-volume-off", IconSize.Button);
            main_cam_audio_button.Active       = true;
            sec_cam_audio_button.Active        = false;

            // We control visibility of those widgets, they are hidden at startup
            sec_cam_vbox.NoShowAll           = true;
            sec_cam_didactic_label.NoShowAll = true;

            timerule        = new Timerule(new WidgetWrapper(timerulearea));
            camerasTimeline = new CamerasTimeline(new WidgetWrapper(timelinearea));
            camerasLabels   = new CamerasLabels(new WidgetWrapper(labelsarea));

            // Set some sane defaults
            labels_vbox.WidthRequest = StyleConf.TimelineLabelsWidth;
            // We need to align the timerule and the beginning of labels list
            timerulearea.HeightRequest = StyleConf.TimelineCameraHeight;

            main_cam_label.ModifyFont(FontDescription.FromString(Config.Style.Font + " bold 14"));
            sec_cam_label.ModifyFont(FontDescription.FromString(Config.Style.Font + " bold 14"));

            main_cam_playerbin.Mode = PlayerViewOperationMode.Synchronization;
            sec_cam_playerbin.Mode  = PlayerViewOperationMode.Synchronization;

            ConnectSignals();

            LongoMatch.Gui.Helpers.Misc.SetFocus(this, false);

            menu = new PeriodsMenu();
        }
Exemplo n.º 17
0
    public MainWindow() : base(Gtk.WindowType.Toplevel)
    {
        Build();

        // Build dictionary mapping a command to each button
        CommandButtons.Add(ButtonUp, missile.CMD_UP);
        CommandButtons.Add(ButtonDown, missile.CMD_DOWN);
        CommandButtons.Add(ButtonCW, missile.CMD_CW);
        CommandButtons.Add(ButtonCCW, missile.CMD_CCW);
        CommandButtons.Add(ButtonFire, missile.CMD_FIRE);

        // Get last server name from the registry (if available)
        ServerName.Text     = (String)Registry.GetValue(RegistryKey, ServerName.Name, null);
        ServerName.IsFocus  = true;
        ServerName.Position = -1;

        if (File.Exists("C:/ProgramData/MuntsTechnologies/tablet.txt"))
        {
            // Maximize the main window
            this.Maximize();

            // Make everything larger
            FontDescription TabletFont    = FontDescription.FromString("18");
            uint            TabletSpacing = 30;

            label1.ModifyFont(TabletFont);
            ServerName.ModifyFont(TabletFont);

            table1.RowSpacing        = TabletSpacing;
            table1.ColumnSpacing     = TabletSpacing;
            alignment2.LeftPadding   = TabletSpacing;
            alignment2.RightPadding  = TabletSpacing;
            alignment2.BottomPadding = TabletSpacing;

            foreach (var b in CommandButtons.Keys)
            {
                b.Child.ModifyFont(TabletFont);
                b.WidthRequest  = 2 * b.WidthRequest;
                b.HeightRequest = 2 * b.HeightRequest;
            }
        }
    }
Exemplo n.º 18
0
        internal void OnLoad()
        {
            NativeImport.SetWindowLong(this.Handle, DrawFactory.GWL_EXSTYLE,
                                       (IntPtr)(NativeImport.GetWindowLong(this.Handle, DrawFactory.GWL_EXSTYLE) ^ DrawFactory.WS_EX_LAYERED ^ DrawFactory.WS_EX_TRANSPARENT));

            NativeImport.SetLayeredWindowAttributes(this.Handle, 0, 255, DrawFactory.LWA_ALPHA);

            if (IsInitialised == false)
            {
                PresentParameters presentParameters = new PresentParameters();
                presentParameters.Windowed         = true;
                presentParameters.SwapEffect       = SwapEffect.Discard;
                presentParameters.BackBufferFormat = Format.A8R8G8B8;

                DrawFactory.device = new Device(DrawFactory.D3D, 0, DeviceType.Hardware, this.Handle, CreateFlags.HardwareVertexProcessing, presentParameters);

                DrawFactory.drawLine          = new Line(DrawFactory.device);
                DrawFactory.drawBoxLine       = new Line(DrawFactory.device);
                DrawFactory.drawCircleLine    = new Line(DrawFactory.device);
                DrawFactory.drawFilledBoxLine = new Line(DrawFactory.device);
                DrawFactory.drawTriLine       = new Line(DrawFactory.device);

                FontDescription fontDescription = new FontDescription()
                {
                    FaceName        = "Fixedsys Regular",
                    CharacterSet    = FontCharacterSet.Default,
                    Height          = 20,
                    Weight          = FontWeight.Bold,
                    MipLevels       = 0,
                    OutputPrecision = FontPrecision.Default,
                    PitchAndFamily  = FontPitchAndFamily.Default,
                    Quality         = FontQuality.ClearType
                };

                DrawFactory.font = new SharpDX.Direct3D9.Font(DrawFactory.device, fontDescription);
                DrawFactory.InitialiseCircleDrawing(DrawFactory.device);

                IsInitialised = true;

                OnDraw();
            }
        }
Exemplo n.º 19
0
        /// <summary>Create a font object</summary>
        public Font CreateFont(Device device, int height, int width, FontWeight weight, int mip, bool italic,
                               CharacterSet charSet, Precision outputPrecision, FontQuality quality, PitchAndFamily pandf, string fontName)
        {
            // Create the font description
            FontDescription desc = new FontDescription();

            desc.Height          = height;
            desc.Width           = width;
            desc.Weight          = weight;
            desc.MipLevels       = mip;
            desc.IsItalic        = italic;
            desc.CharSet         = charSet;
            desc.OutputPrecision = outputPrecision;
            desc.Quality         = quality;
            desc.PitchAndFamily  = pandf;
            desc.FaceName        = fontName;

            // return the font
            return(CreateFont(device, desc));
        }
Exemplo n.º 20
0
        private VisualInline(Inline inline, string text, FontDescription font, Color foreColor, Color?backColor, Size size)
        {
            Inline    = inline;
            Text      = text;
            BackColor = backColor;
            Size      = size;

            var run = inline as Run;

            if (run != null && run.Link != null)
            {
                Font      = new FontDescription(inline.Font, inline.Font.Style | FontStyle.Underline);
                ForeColor = Color.FromArgb(0x33, 0x33, 0xff);
            }
            else
            {
                Font      = font;
                ForeColor = foreColor;
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// calc text rect
        /// use ContentAlignment.MiddleRight for the calculation because if we use ContentAlignment.MiddleCenter
        /// then GuiUtils.CalcTextRect() returns wrong results. The problem is that the height returned by GuiUtils.CalcTextRect()
        /// will be of a single line always.
        ///
        /// </summary>
        /// <param name="g"></param>
        /// <param name="rect"></param>
        /// <param name="font"></param>
        /// <param name="text"></param>
        /// <param name="flags"></param>
        /// <param name="retCalcTextRect"></param>
        public static void CalcTextRect(Graphics g, Rectangle rect, FontDescription font, String text, int flags, out NativeWindowCommon.RECT retCalcTextRect)
        {
            IntPtr hdc1;
            IntPtr hFont1;

            hdc1 = g.GetHdc();

            hFont1 = font.FontHandle;

            NativeWindowCommon.SelectObject(hdc1, hFont1);
            retCalcTextRect        = new NativeWindowCommon.RECT();
            retCalcTextRect.left   = rect.Left;
            retCalcTextRect.right  = rect.Right;
            retCalcTextRect.top    = rect.Top;
            retCalcTextRect.bottom = rect.Bottom;
            int calcRectFlags = (int)(TextFormatFlags)flags | 0x400; // TextFormatFlags.CalcRect == 0x400 == DT_CALCRECT

            NativeWindowCommon.DrawText(hdc1, text, text.Length, ref retCalcTextRect, calcRectFlags);
            g.ReleaseHdc(hdc1);
        }
Exemplo n.º 22
0
        public void LoadFontDescription()
        {
            var writer = new BigEndianBinaryWriter();

            writer.WriteTrueTypeFileHeader(1, 0, 0, 0);
            writer.WriteTableHeader("name", 0, 28, 999);
            writer.WriteNameTable(
                new Dictionary <WellKnownIds.NameIds, string>
            {
                { WellKnownIds.NameIds.FullFontName, "name" },
                { WellKnownIds.NameIds.FontSubfamilyName, "sub" },
                { WellKnownIds.NameIds.FontFamilyName, "fam" }
            });

            var description = FontDescription.LoadDescription(writer.GetStream());

            Assert.Equal("name", description.FontNameInvariantCulture);
            Assert.Equal("sub", description.FontSubFamilyNameInvariantCulture);
            Assert.Equal("fam", description.FontFamilyInvariantCulture);
        }
Exemplo n.º 23
0
        void SetFont()
        {
            // TODO: Add font property to ICompletionWidget;
            if (itemFont != null)
            {
                itemFont.Dispose();
            }
            itemFont = FontService.GetFontDescription("Editor").Copy();
            var provider = CompletionWidget as ITextEditorDataProvider;

            if (provider != null)
            {
                var newSize = (itemFont.Size * provider.GetTextEditorData().Options.Zoom);
                if (newSize > 0)
                {
                    itemFont.Size          = (int)newSize;
                    layout.FontDescription = itemFont;
                }
            }
        }
        public void FontMeasuring()
        {
            var fontMetadata = new FontMetadata("Test", "Default", 10.0f, FontStyle.Regular, 10, FontStretch.Normal);
            var bitmap       = new Image <Rgba32>(200, 200);
            var glyphDict    = new Dictionary <char, GlyphLayout>();

            AddGlyph(glyphDict, new GlyphLayout('a', null, new Vector2(10.0f, 10.0f), new Vector2(0.0f, 0.0f), 3.0f));
            AddGlyph(glyphDict, new GlyphLayout('b', null, new Vector2(8.0f, 10.0f), new Vector2(0.0f, 0.0f), 4.0f));
            AddGlyph(glyphDict, new GlyphLayout('g', null, new Vector2(5.0f, 11.0f), new Vector2(0.5f, 1.0f), 5.0f));
            AddGlyph(glyphDict, new GlyphLayout('!', null, new Vector2(3.0f, 12.0f), new Vector2(0.0f, -1.0f), 2.0f));
            var glyphs          = new Glyphs(glyphDict);
            var fontDescription = new FontDescription(fontMetadata, bitmap, glyphs);

            Assert.Equal(new Vector2(6.0f, 10.0f), fontDescription.MeasureString("aa"));
            Assert.Equal(new Vector2(12.0f, 20.0f), fontDescription.MeasureString("aa", 2.0f));
            Assert.Equal(new Vector2(7.0f, 10.0f), fontDescription.MeasureString("ab"));
            Assert.Equal(new Vector2(17.0f, 12.0f), fontDescription.MeasureString("abgg"));
            Assert.Equal(new Vector2(25.0f, 30.0f), fontDescription.MeasureString("gg", 2.5f));
            Assert.Equal(new Vector2(4.0f, 11.0f), fontDescription.MeasureString("!!"));
        }
Exemplo n.º 25
0
        public void FontClientIsScalable()
        {
            tlog.Debug(tag, $"FontClientIsScalable START");

            using (FontDescription description = new FontDescription())
            {
                description.Path = ttf_path;

                var testingTarget = new FontClient(FontClient.Instance);
                Assert.IsNotNull(testingTarget, "Return a null object of FontClient");
                Assert.IsInstanceOf <FontClient>(testingTarget, "Should be an instance of FontClient type.");

                var result = testingTarget.IsScalable(description);
                Assert.IsNotNull(result);

                testingTarget.Dispose();
            }

            tlog.Debug(tag, $"FontClientIsScalable END (OK)");
        }
Exemplo n.º 26
0
        public void InitDeviceResources()
        {
            sprite  = new Sprite(_device);
            sprite2 = new Sprite(_device);

            tx       = TextureCreator.FromBitmap(_device, txb);
            tcircle  = TextureCreator.FromBitmap(_device, tcircleb);
            tecircle = TextureCreator.FromBitmap(_device, tecircleb);
            hcursor  = TextureCreator.FromBitmap(_device, hcursorb);
            vcursor  = TextureCreator.FromBitmap(_device, vcursorb);
            hvcursor = TextureCreator.FromBitmap(_device, hvcursorb);

            FontDescription fontDescription = new FontDescription()
            {
                Height          = 18,
                Italic          = false,
                CharacterSet    = FontCharacterSet.Ansi,
                FaceName        = "Microsoft Sans Serif",
                MipLevels       = 0,
                OutputPrecision = FontPrecision.TrueType,
                PitchAndFamily  = FontPitchAndFamily.Default,
                Quality         = FontQuality.Antialiased,
                Weight          = FontWeight.Regular
            };

            FontDescription fontDescriptionBold = new FontDescription()
            {
                Height          = 18,
                Italic          = false,
                CharacterSet    = FontCharacterSet.Ansi,
                FaceName        = "Microsoft Sans Serif",
                MipLevels       = 0,
                OutputPrecision = FontPrecision.TrueType,
                PitchAndFamily  = FontPitchAndFamily.Default,
                Quality         = FontQuality.Antialiased,
                Weight          = FontWeight.Bold
            };

            font     = new Font(_device, fontDescription);
            fontBold = new Font(_device, fontDescriptionBold);
        }
Exemplo n.º 27
0
        private IEnumerable <FontDescription> GetDescriptionsForAsset(FontDefinition definition)
        {
            var fontNames = string.IsNullOrEmpty(definition.FontName) ? "Arial" : definition.FontName;

            foreach (var fontName in fontNames.Split(','))
            {
                var fontDesc = new FontDescription(
                    fontName,
                    definition.FontSize,
                    definition.Spacing,
                    FontDescriptionStyle.Regular,
                    definition.UseKerning);

                if (definition.CharacterRanges == null || definition.CharacterRanges.Length == 0)
                {
                    // Add the entire ASCII range of characters to the sprite font.
                    for (var c = 0; c < 256; c++)
                    {
                        fontDesc.Characters.Add((char)c);
                    }
                }
                else
                {
                    foreach (var range in definition.CharacterRanges)
                    {
                        for (var c = range.Start; c <= range.End; c++)
                        {
                            fontDesc.Characters.Add((char)c);
                        }
                    }
                }

#if PLATFORM_LINUX
                fontDesc.Identity = new ContentIdentity
                {
                    SourceFilename = "/usr/share/fonts/truetype/dummy.spritefont"
                };
#endif
                yield return(fontDesc);
            }
        }
Exemplo n.º 28
0
        public void DrawLabel(int position, string label)
        {
            var layout = new Pango.Layout(this.PangoContext);

            layout.FontDescription = FontDescription.FromString("Tahoma 16");
            layout.SetMarkup(label);

            int width, height;

            layout.GetPixelSize(out width, out height);
            if (width != 0 && height != 0)
            {
                _labelPixmap = new Pixmap(GdkWindow, width, height, -1);
                CalculateXandY(position, width, height);
                _labelPixmap.DrawDrawable(_gc, _pixmap, _labelX, _labelY, 0, 0,
                                          width, height);
                _labelPixmap.DrawLayout(_gc, 0, 0, layout);

                QueueDraw();
            }
        }
Exemplo n.º 29
0
        public override SpriteFontContent Process(FontDescription input, ContentProcessorContext context)
        {
            input_   = input;
            context_ = context;
            SpriteFontContent ret = base.Process(input, context);

            System.Reflection.PropertyInfo pi = ret.GetType().GetProperty("Texture", System.Reflection.BindingFlags.NonPublic
                                                                          | System.Reflection.BindingFlags.Instance);
            if (pi != null)
            {
                if (!AddOutline(pi.GetValue(ret, null) as Texture2DContent))
                {
                    throw new System.FormatException("The format of the bitmap is not recognized.");
                }
            }
            else
            {
                context.Logger.LogWarning("http://msdn.microsoft.com/", input.Identity, "Could not get property 'Texture'");
            }
            return(ret);
        }
Exemplo n.º 30
0
        public FontDescription GetNextSizeLarger(FontDescription desc)
        {
            List <int> sizes = _fontSizes[desc.FontName];

            int index = 0;

            for (index = 0; index < sizes.Count; index++)
            {
                if (sizes[index] == desc.FontSize)
                {
                    break;
                }
            }

            if (index < sizes.Count - 1)
            {
                index++;
            }

            return(_fonts[desc.FontName][sizes[index]]);
        }
Exemplo n.º 31
0
        /* We are going to align the header so that an image takes up the left,
         * and a VBox with general media data takes up the right.			*/
        private HBox BuildHeader()
        {
            var h        = new HBox(false, 5);
            var imagebox = new VBox();
            var databox  = new VBox();

            // let's fetch the cover
            try {
                var stream = Original.GetCover().Result;
                var cover  = new Pixbuf(stream, 113, 159);
                imagebox.PackStart(new Image(cover), false, false, 0);
            }
            catch (Exception e) {
                Debug.WriteLine("Render failed! " + e.Message);
            }
            finally {
                h.PackStart(imagebox, false, false, 0);
            }

            // build the title
            var font = new FontDescription()
            {
                Weight = Weight.Bold,
                Size   = (int)(14 * Pango.Scale.PangoScale)
            };
            var title = new Label(Program.GetTitle(Original));

            title.ModifyFont(font);
            databox.PackStart(title, true, false, 0);

            // For keeping track of episodes (optional)
            databox.Add(EpisodeCounter);

            // For other various media data
            databox.Add(HeaderTable);

            // compile it all together
            h.PackEnd(databox, true, true, 0);
            return(h);
        }
Exemplo n.º 32
0
        public void UpdateNativeView()
        {
            if (_currentInputWidget == null)
            {
                // If the input widget does not exist, we don't need to update it.
                return;
            }

            var textBox = _owner.TextBox;

            if (textBox == null)
            {
                // The parent TextBox must exist as source of properties.
                return;
            }

            EnsureWidget(textBox);

            var fontDescription = new FontDescription
            {
                Weight       = textBox.FontWeight.ToPangoWeight(),
                AbsoluteSize = textBox.FontSize * Scale.PangoScale,
            };

#pragma warning disable CS0612 // Type or member is obsolete
            _currentInputWidget.OverrideFont(fontDescription);
#pragma warning restore CS0612 // Type or member is obsolete

            switch (_currentInputWidget)
            {
            case Entry entry:
                UpdateEntryProperties(entry, textBox);
                break;

            case TextView textView:
                UpdateTextViewProperties(textView, textBox);
                break;
            }
        }
Exemplo n.º 33
0
        private ScrolledWindow CreateMultilineTextBox(string txt)
        {
            var textView = new TextView();

            textView.Buffer.Text   = txt;
            textView.Editable      = false;
            textView.CursorVisible = false;
            textView.ModifyFont(FontDescription.FromString(PlatformUtils.IsMacOS ? "Quicksand 10" : "Quicksand 8"));
            textView.WrapMode = Gtk.WrapMode.WordChar;
            textView.Show();

            var scroll = new ScrolledWindow(null, null);

            scroll.HscrollbarPolicy = PolicyType.Never;
            scroll.VscrollbarPolicy = PolicyType.Automatic;
            scroll.HeightRequest    = GtkUtils.ScaleGtkWidget(400);
            scroll.ShadowType       = ShadowType.EtchedIn;
            scroll.Show();
            scroll.Add(textView);

            return(scroll);
        }
Exemplo n.º 34
0
        RefactoringPreviewTooltipWindow(Ide.Editor.TextEditor editor, CodeAction codeAction)
        {
            this.editor          = editor;
            this.documentContext = documentContext = editor.DocumentContext;
            this.codeAction      = codeAction;
            TransientFor         = IdeApp.Workbench.RootWindow;
            var font = Xwt.Drawing.Font.FromName(DefaultSourceEditorOptions.Instance.FontName);

            if (font != null)
            {
                fontDescription      = font.ToPangoFont();
                fontDescription.Size = (int)(fontDescription.Size * 0.8f);
            }
            else
            {
                LoggingService.LogError("Error loading font : " + DefaultSourceEditorOptions.Instance.FontName);
            }

            using (var metrics = PangoContext.GetMetrics(fontDescription, PangoContext.Language)) {
                lineHeight = (int)Math.Ceiling(0.5 + (metrics.Ascent + metrics.Descent) / Pango.Scale.PangoScale);
            }
        }
Exemplo n.º 35
0
        static internal void Initialize(Device device)
        {
            _debugTexts = new List <string>();
            _debugLog   = new List <debugTexts>();
            _device     = device;

            // Initialize the Font
            FontDescription fontDescription = new FontDescription()
            {
                Height          = _textHeight,
                Italic          = false,
                CharacterSet    = FontCharacterSet.Ansi,
                FaceName        = "Console",
                MipLevels       = 0,
                OutputPrecision = FontPrecision.TrueType,
                PitchAndFamily  = FontPitchAndFamily.Default,
                Quality         = FontQuality.Antialiased,
                Weight          = FontWeight.SemiBold
            };

            _debugTextFont = new Font(device, fontDescription);
        }
Exemplo n.º 36
0
		/// <summary>
		/// Initializes a new instance of the <see cref= "T:WorldWind.Renderable.TiledPlacenameSet"/> class.
		/// </summary>
		/// <param name="name"></param>
		/// <param name="parentWorld"></param>
		/// <param name="altitude"></param>
		/// <param name="maximumDisplayAltitude"></param>
		/// <param name="minimumDisplayAltitude"></param>
		/// <param name="placenameListFilePath"></param>
		/// <param name="fontDescription"></param>
		/// <param name="color"></param>
		/// <param name="iconFilePath"></param>
		public TiledPlacenameSet(
			string name, 
			World parentWorld,
			double altitude,
			double maximumDisplayAltitude,
			double minimumDisplayAltitude,
			string placenameListFilePath,
			FontDescription fontDescription,
			System.Drawing.Color color,
			string iconFilePath
			) : base(name, parentWorld.Position, Quaternion.RotationYawPitchRoll(0,0,0))
		{
			m_parentWorld = parentWorld;
			m_altitude = altitude;
			m_maximumDistanceSq = maximumDisplayAltitude*maximumDisplayAltitude;
			m_minimumDistanceSq = minimumDisplayAltitude*minimumDisplayAltitude;
			m_placenameListFilePath = placenameListFilePath;
			m_fontDescription = fontDescription;
			m_color = color.ToArgb();
			m_iconFilePath = iconFilePath;
			
			// Set default render priority
			m_renderPriority = RenderPriority.Placenames;
		}
Exemplo n.º 37
0
        void init()
        {
            Microsoft.DirectX.Direct3D.PresentParameters pps = new Microsoft.DirectX.Direct3D.PresentParameters();
            pps.SwapEffect = Microsoft.DirectX.Direct3D.SwapEffect.Discard;
            pps.Windowed = true;
            pps.BackBufferCount = 1;
            pps.PresentationInterval = PresentInterval.One;
            pps.BackBufferFormat = Format.A8R8G8B8;

            if (GameWindow == null)
            {
                //pps.BackBufferWidth = GameControl.Width;
                //pps.BackBufferHeight = GameControl.Height;
                D3DDev = new Microsoft.DirectX.Direct3D.Device(0, Microsoft.DirectX.Direct3D.DeviceType.Hardware, GameControl, Microsoft.DirectX.Direct3D.CreateFlags.SoftwareVertexProcessing, pps);
            }
            else
            {
                //pps.BackBufferWidth = GameWindow.Width;
                //pps.BackBufferHeight = GameWindow.Height;
                D3DDev = new Microsoft.DirectX.Direct3D.Device(0, Microsoft.DirectX.Direct3D.DeviceType.Hardware, GameWindow, Microsoft.DirectX.Direct3D.CreateFlags.SoftwareVertexProcessing, pps);
            }
            D3DDev.VertexFormat = CustomVertex.PositionColoredTextured.Format;

            //D3DDev.ShowCursor(false);

            DSoundDev = new Microsoft.DirectX.DirectSound.Device();
            if (GameWindow == null)
            {
                DSoundDev.SetCooperativeLevel(GameControl, Microsoft.DirectX.DirectSound.CooperativeLevel.Normal);
            }
            else
            {
                DSoundDev.SetCooperativeLevel(GameWindow, Microsoft.DirectX.DirectSound.CooperativeLevel.Normal);
            }

            DKeyboardDev = new Microsoft.DirectX.DirectInput.Device(Microsoft.DirectX.DirectInput.SystemGuid.Keyboard);
            DKeyboardDev.Acquire();

            DMouseDev = new Microsoft.DirectX.DirectInput.Device(Microsoft.DirectX.DirectInput.SystemGuid.Mouse);
            DMouseDev.Acquire();

            VertexBuffer = new VertexBuffer(typeof(CustomVertex.PositionColoredTextured), 6, D3DDev, Usage.None, CustomVertex.PositionColoredTextured.Format, Pool.Managed);

            D3DDev.SetStreamSource(0, VertexBuffer, 0);
            D3DDev.TextureState[0].AlphaOperation = TextureOperation.Modulate;

            Sprite = new Sprite(D3DDev);

            FontDescription fd = new FontDescription();
            fd.FaceName = "新宋体";
            fd.Height = -12;
            Font2D = new Microsoft.DirectX.Direct3D.Font(D3DDev, fd);

            Font3D = new System.Drawing.Font("新宋体", 12);
        }
Exemplo n.º 38
0
		public void GetGlyphsForMultilineText()
		{
			var fontData = new FontDescription(ContentLoader.Load<Font>("Verdana12").Data);
			fontData.Generate(" \n \n ", HorizontalAlignment.Center);
			Assert.AreEqual(3, fontData.Glyphs.Length);
		}
Exemplo n.º 39
0
        FontAsset IAssetManager.LoadFont(string assetName, float fontSize, FontWeight weight, FontStyle style, FontStretch stretch)
        {
            Debug.Assert(!String.IsNullOrEmpty(assetName), "Must provide a valid font name");
            Debug.Assert(fontSize > .9999, "Font size must be larger than 1");
            var desc = new FontDescription(assetName, fontSize);
            TextFormat font;

            if (_fontResources.TryGetValue(desc, out font) && !font.IsDisposed)
                return new FontAsset(font);

            FontCollection collection;
            int i = 0;
            if (_embeddedFonts.FindFamilyName(assetName, out i)) {
                collection = _embeddedFonts;
            } else if (_systemFonts.FindFamilyName(assetName, out i)) {
                collection = _systemFonts;
            } else {
                collection = _systemFonts;
                assetName = FallbackFontFamilyName;
            }
            font = new TextFormat(
                _dwriteFactory,
                assetName,
                collection,
                weight,
                style,
                stretch,
                fontSize);

            _fontResources.AddOrUpdate(desc, font, (key, oldValue) => {
                if (!oldValue.IsDisposed)
                    oldValue.Dispose();
                return font;
            });
            return new FontAsset(font);
        }
            private void GetCoordLayoutDetails(Pango.
							    Context context,
							    FontDescription
							    font)
            {
                if (!showCoords)
                  {
                      fontwidth = 0;
                      fontheight = 0;
                      return;
                  }
                layoutx = new Pango.Layout[8];
                layouty = new Pango.Layout[8];
                char chx = 'a';
                char chy = '1';
                fontwidth = 0;
                fontheight = 0;
                for (int i = 0; i < layoutx.Length;
                     i++, chx++, chy++)
                  {
                      Pango.Layout layout;
                      layoutx[i] = layout =
                          new Pango.Layout (context);
                      layout.FontDescription = font;
                      layout.SetText (chx.ToString ());
                      int w, h;
                      layout.GetSize (out w, out h);
                      h = (int) Math.Round (h /
                                Pango.Scale.
                                PangoScale);
                      if (h > fontheight)
                          fontheight = h;

                      layouty[i] = layout =
                          new Pango.Layout (context);
                      layout.FontDescription = font;
                      layout.SetText (chy.ToString ());
                      layout.GetSize (out w, out h);
                      w = (int) Math.Round (w /
                                Pango.Scale.
                                PangoScale);
                      if (w > fontwidth)
                          fontwidth = w;
                  }
            }
Exemplo n.º 41
0
        /// <summary>
        /// Creates a font.
        /// </summary>
        internal Font CreateFont( string familyName, float emSize, System.Drawing.FontStyle style )
        {
            try
            {
                FontDescription description = new FontDescription();
                description.FaceName = familyName;
                description.Height = (int)(1.9*emSize);

                if(style == System.Drawing.FontStyle.Regular)
                    return CreateFont( description );
                if((style & System.Drawing.FontStyle.Italic) != 0)
                    description.IsItalic = true;
                if((style & System.Drawing.FontStyle.Bold) != 0)
                    description.Weight = FontWeight.Heavy;
                description.Quality = FontQuality.AntiAliased;
                return CreateFont( description );
            }
            catch
            {
                Log.Write(Log.Levels.Error, "FONT", string.Format("Unable to load '{0}' {2} ({1}em)",
                    familyName, emSize, style ) );
                return defaultDrawingFont;
            }
        }
Exemplo n.º 42
0
        public void Render1()
        {
            dx_device.Clear(ClearFlags.Target | ClearFlags.ZBuffer | ClearFlags.Stencil, Color.Blue, 1.0f, 0);

            dx_device.BeginScene();
            dx_device.SetTexture(0, m_Tex);

            dx_device.SetTransform(TransformType.World, m_Camera.m_World);
            dx_device.SetTransform(TransformType.View, m_Camera.m_View);
            dx_device.SetTransform(TransformType.Projection, m_Camera.m_Projection);

            // 원래 객체를 그린다.
            dx_device.RenderState.ShadeMode = ShadeMode.Gouraud;
            dx_device.RenderState.CullMode = Cull.None;
            dx_device.RenderState.ZBufferWriteEnable = true;
            dx_device.RenderState.StencilEnable = false;
            dx_device.RenderState.AlphaBlendEnable = false;
            //            m_Objects[4].render(dx_device);

            // 그림자 영역을 그린다.
            dx_device.RenderState.ZBufferWriteEnable = false;
            dx_device.RenderState.StencilEnable = true;
            dx_device.RenderState.ShadeMode = ShadeMode.Flat;
            dx_device.RenderState.StencilFunction = Compare.Always;
            dx_device.RenderState.StencilZBufferFail = StencilOperation.Keep;
            dx_device.RenderState.StencilFail = StencilOperation.Keep;
            dx_device.RenderState.ReferenceStencil = 1;
            dx_device.RenderState.StencilMask = -1;
            dx_device.RenderState.StencilWriteMask = -1;
            dx_device.RenderState.StencilPass = StencilOperation.Increment;
            dx_device.RenderState.AlphaBlendEnable = true;
            dx_device.RenderState.SourceBlend = Blend.Zero;
            dx_device.RenderState.DestinationBlend = Blend.One;

            dx_device.Transform.World = m_Camera.m_ShadowWorld;
            m_Objects[4].render(dx_device);
            dx_device.Transform.World = m_Camera.m_World;

            // 원래 객체를 그린다.
            dx_device.RenderState.ShadeMode = ShadeMode.Gouraud;
            dx_device.RenderState.CullMode = Cull.None;
            dx_device.RenderState.ZBufferWriteEnable = true;
            dx_device.RenderState.StencilEnable = false;
            dx_device.RenderState.AlphaBlendEnable = false;
            m_Objects[0].render(dx_device);
            m_Objects[1].render(dx_device);
            m_Objects[4].render(dx_device);

            // 그림자에 해당하는 부분을 다시 그린다.
            dx_device.RenderState.ZBufferEnable = true;
            dx_device.RenderState.ZBufferWriteEnable = false;
            dx_device.RenderState.StencilEnable = true;
            dx_device.RenderState.AlphaBlendEnable = true;
            dx_device.RenderState.SourceBlend = Blend.SourceAlpha;
            dx_device.RenderState.DestinationBlend = Blend.InvSourceAlpha;

            dx_device.TextureState[0].ColorArgument1 = TextureArgument.TextureColor;
            dx_device.TextureState[0].ColorArgument2 = TextureArgument.Constant;
            dx_device.TextureState[0].ColorOperation = TextureOperation.SelectArg2;
            dx_device.TextureState[0].AlphaArgument1 = TextureArgument.TextureColor;
            dx_device.TextureState[0].AlphaArgument2 = TextureArgument.Diffuse;
            dx_device.TextureState[0].AlphaOperation = TextureOperation.Modulate;

            dx_device.RenderState.ReferenceStencil = 1;
            dx_device.RenderState.StencilFunction = Compare.LessEqual;
            dx_device.RenderState.StencilPass = StencilOperation.Keep;

            m_Objects[0].render(dx_device);

            dx_device.TextureState[0].ColorArgument1 = TextureArgument.TextureColor;
            dx_device.TextureState[0].ColorArgument2 = TextureArgument.Diffuse;
            dx_device.TextureState[0].ColorOperation = TextureOperation.Modulate;
            dx_device.TextureState[0].AlphaArgument1 = TextureArgument.TextureColor;
            dx_device.TextureState[0].AlphaArgument2 = TextureArgument.Diffuse;
            dx_device.TextureState[0].AlphaOperation = TextureOperation.Modulate;

            dx_device.RenderState.ShadeMode = ShadeMode.Gouraud;
            dx_device.RenderState.CullMode = Cull.None;
            dx_device.RenderState.ZBufferWriteEnable = true;
            dx_device.RenderState.StencilEnable = false;
            dx_device.RenderState.AlphaBlendEnable = false;

            FontDescription desc = new FontDescription();
            Microsoft.DirectX.Direct3D.Font fnt = new Microsoft.DirectX.Direct3D.Font(dx_device, desc);

            fnt.DrawText(null, m_Camera.ToString() + "\n"
                + m_Cursor.ToString() + "\n"
                + m_Camera.getPicking(m_Cursor.m_MousePoint, dx_device.Viewport) + "\n"
                + m_Count, new Point(5, 5), Color.White);

            m_Count = (m_Count + 1) % 10000;

            fnt.Dispose();

            dx_device.EndScene();

            dx_device.Present();
        }
Exemplo n.º 43
0
        /// <summary>
        /// Creates a font.
        /// </summary>
        internal Font CreateFont( FontDescription description )
        {
            try
            {
                description.Quality = FontQuality.Default;

                // TODO: Improve font cache
                string hash = description.ToString();//.GetHashCode(); returned hash codes are not correct

                Font font = (Font)fontList[ hash ];
                if(font!=null)
                    return font;

                font = new Font( this.device, description );
                //newDrawingFont.PreloadText("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXRZ");
                fontList.Add( hash, font );
                return font;
            }
            catch
            {
                Log.Write(Log.Levels.Error, "FONT", string.Format("Unable to load '{0}' (Height: {1})", description.FaceName, description.Height) );
                return defaultDrawingFont;
            }
        }
Exemplo n.º 44
0
        private static FontDescription getDisplayFont(XPathNodeIterator iter)
        {
            FontDescription fd = new FontDescription();

            if (iter.MoveNext()) {
                fd.FaceName = getInnerTextFromFirstChild(iter.Current.Select("Family"));
                fd.Height = (int) (float.Parse(getInnerTextFromFirstChild(iter.Current.Select("Size")))*1.5f);

                XPathNodeIterator styleIter = iter.Current.Select("Style");
                if (styleIter.Count > 0) {
                    styleIter.MoveNext();

                    string isBoldString = getInnerTextFromFirstChild(styleIter.Current.Select("IsBold"));
                    string isItalicString = getInnerTextFromFirstChild(styleIter.Current.Select("IsItalic"));

                    if (isBoldString != null) {
                        bool isBold = ParseBool(isBoldString);
                        if (isBold) {
                            fd.Weight = FontWeight.Bold;
                        }
                    }

                    if (isItalicString != null) {
                        bool isItalic = ParseBool(isItalicString);
                        if (isItalic) {
                            fd.IsItalic = isItalic;
                        }
                    }
                }
                else {
                    fd.Weight = FontWeight.Regular;
                }
            }

            return fd;
        }
Exemplo n.º 45
0
        /// <summary>
        /// ��������
        /// </summary>
        public Font CreateFont(string familyName, float emSize, FontStyle style)
        {
            try {
                FontDescription description = new FontDescription();
                description.FaceName = familyName;
                description.Height = (int) (1.9*emSize);

                if (style == FontStyle.Regular) {
                    return CreateFont(description);
                }
                if ((style & FontStyle.Italic) != 0) {
                    description.IsItalic = true;
                }
                if ((style & FontStyle.Bold) != 0) {
                    description.Weight = FontWeight.Heavy;
                }

                return CreateFont(description);
            }
            catch {
                Log.Write("FONT", string.Format("Unable to load '{0}' {2} ({1}em)", familyName, emSize, style));
                return DefaultDrawingFont;
            }
        }
Exemplo n.º 46
0
        /// <summary>Create a font object</summary>
        public Font CreateFont(Device device, int height, int width, FontWeight weight, int mip, bool italic,
            CharacterSet charSet, Precision outputPrecision, FontQuality quality, PitchAndFamily pandf, string fontName)
        {
            // Create the font description
            FontDescription desc = new FontDescription();
            desc.Height = height;
            desc.Width = width;
            desc.Weight = weight;
            desc.MipLevels = mip;
            desc.IsItalic = italic;
            desc.CharSet = charSet;
            desc.OutputPrecision = outputPrecision;
            desc.Quality = quality;
            desc.PitchAndFamily = pandf;
            desc.FaceName = fontName;

            // return the font
            return CreateFont(device, desc);
        }
Exemplo n.º 47
0
		public void GetTextParser()
		{
			var fontData = new FontDescription(ContentLoader.Load<Font>("Verdana12").Data);
			parser = new TextParser(fontData.GlyphDictionary, ' ');
		}
Exemplo n.º 48
0
        /// <summary>Create a font object</summary>
        public Font CreateFont(Device device, FontDescription desc)
        {
            // Search the cache first
            foreach(FontDescription fd in fontCache.Keys)
            {
                if ( (string.Compare(fd.FaceName, desc.FaceName, true) == 0) &&
                    fd.CharSet == desc.CharSet &&
                    fd.Height == desc.Height &&
                    fd.IsItalic == desc.IsItalic &&
                    fd.MipLevels == desc.MipLevels &&
                    fd.OutputPrecision == desc.OutputPrecision &&
                    fd.PitchAndFamily == desc.PitchAndFamily &&
                    fd.Quality == desc.Quality &&
                    fd.Weight == desc.Weight &&
                    fd.Width == desc.Width)
                {
                    // A match was found, return that
                    return fontCache[fd] as Font;
                }
            }

            // Couldn't find anything in the cache, create one
            Font f = new Font(device, desc);
            // Create a new entry
            fontCache.Add(desc, f);

            // return the new font
            return f;
        }
Exemplo n.º 49
0
		/// <summary>
		/// Initializes a new instance of the <see cref= "T:WorldWind.Renderable.TiledPlacenameSet"/> class.
		/// </summary>
		/// <param name="name"></param>
		/// <param name="parentWorld"></param>
		/// <param name="altitude"></param>
		/// <param name="maximumDisplayAltitude"></param>
		/// <param name="minimumDisplayAltitude"></param>
		/// <param name="placenameBaseUrl"></param>
        /// <param name="labelfield">Field in Feature type used as PlacenameLabel</param>
		/// <param name="fontDescription"></param>
		/// <param name="color"></param>
		/// <param name="iconFilePath"></param>
		public TiledWFSPlacenameSet(
			string name, 
			World parentWorld,
			double altitude,
			double maximumDisplayAltitude,
			double minimumDisplayAltitude,
			string placenameBaseUrl,
            string typename,
            string labelfield,
			FontDescription fontDescription,
			System.Drawing.Color color,
			string iconFilePath,
			Cache cache
			) : base(name, parentWorld.Position, Quaternion.RotationYawPitchRoll(0,0,0))
		{
		    m_name = name;
			m_parentWorld = parentWorld;
			m_altitude = altitude;
			m_maximumDistanceSq = maximumDisplayAltitude*maximumDisplayAltitude;
			m_minimumDistanceSq = minimumDisplayAltitude*minimumDisplayAltitude;
			m_placenameBaseUrl = placenameBaseUrl;
            m_typename = typename;
            m_labelfield = labelfield;
			m_fontDescription = fontDescription;
			m_color = color.ToArgb();
			m_iconFilePath = iconFilePath;
			m_cache = cache;
			
			// Set default render priority
			m_renderPriority = RenderPriority.Placenames;
		}
Exemplo n.º 50
0
        private void InitD3D()
        {
            _dxDevice = new Device(DriverType.Hardware, DeviceCreationFlags.Debug | DeviceCreationFlags.BgraSupport, FeatureLevel.Level_10_0);

            EnsureOutputBuffers();

            FontDescription fontDesc = new FontDescription
                                           {
                                               Height = 24,
                                               Width = 0,
                                               Weight = 0,
                                               MipLevels = 1,
                                               IsItalic = false,
                                               CharacterSet = FontCharacterSet.Default,
                                               Precision = FontPrecision.Default,
                                               Quality = FontQuality.Default,
                                               PitchAndFamily = FontPitchAndFamily.Default | FontPitchAndFamily.DontCare,
                                               FaceName = "Times New Roman"
                                           };

            _dxFont = new Font(_dxDevice, fontDesc);

            _textureManager = new DxTextureManager(_dxDevice);

            //            _dxEffect = new DxEffect(_dxDevice);
            _dxCube = new DxCube(_dxDevice);
            CrateKinectPointsRenderer(KinectPointsRendererType.Billboard);

            ShaderResourceView texArray = _textureManager.CreateTexArray("flares", @"Assets\flare0.dds");
            _fire = new DxParticleSystemRenderer(_dxDevice, texArray, 500);

            _dxDevice.Flush();
        }
Exemplo n.º 51
0
		public void Init()
		{
			fontDescription = new FontDescription(ContentLoader.Load<Font>("Verdana12").Data);
			textWrapper = new TextWrapper(fontDescription.GlyphDictionary, ' ', fontDescription.PixelLineHeight);
		}
Exemplo n.º 52
0
        /// <summary>
        /// ��������
        /// </summary>
        public Font CreateFont(FontDescription description)
        {
            try {
                if (World.Settings.AntiAliasedText) {
                    description.Quality = FontQuality.ClearTypeNatural;
                }
                else {
                    description.Quality = FontQuality.Default;
                }

                string hash = description.ToString(); //.GetHashCode(); returned hash codes are not correct

                Font font = _fontList[hash] as Font;
                if (font != null) {
                    return font;
                }

                font = new Font(this.Device, description);
                _fontList.Add(hash, font);
                return font;
            }
            catch {
                Log.Write("FONT", string.Format("Unable to load '{0}' (Height: {1})", description.FaceName, description.Height));
                return DefaultDrawingFont;
            }
        }