Beispiel #1
1
        /// <summary>
        /// Installs font on the user's system and adds it to the registry so it's available on the next session
        /// Your font must be included in your project with its build path set to 'Content' and its Copy property
        /// set to 'Copy Always'
        /// </summary>
        /// <param name="contentFontName">Your font to be passed as a resource (i.e. "myfont.tff")</param>
        private static void RegisterFont(string contentFontName)
        {
            DirectoryInfo dirWindowsFolder = Directory.GetParent(Environment.GetFolderPath(Environment.SpecialFolder.System));

            // Concatenate Fonts folder onto Windows folder.
            string strFontsFolder = Path.Combine(dirWindowsFolder.FullName, "Fonts");

            // Creates the full path where your font will be installed
            var fontDestination = Path.Combine(strFontsFolder, contentFontName);

            if (!File.Exists(fontDestination))
            {
                // Copies font to destination
                System.IO.File.Copy(Path.Combine(System.IO.Directory.GetCurrentDirectory(), contentFontName), fontDestination);

                // Retrieves font name
                // Makes sure you reference System.Drawing
                PrivateFontCollection fontCol = new PrivateFontCollection();
                fontCol.AddFontFile(fontDestination);
                var actualFontName = fontCol.Families[0].Name;

                //Add font
                AddFontResource(fontDestination);
                //Add registry entry   
                Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts",
        actualFontName, contentFontName, RegistryValueKind.String);
            }
        }
Beispiel #2
1
        public Form1()
        {
            InitializeComponent();
            rand = new Random();
            dataGrid = new Grid("TileMap.csv");
            Controls.Add(dataGrid);
            sound = new System.Windows.Media.MediaPlayer();
            sound.Open(new Uri("pacmanDubHeavy.mp3", UriKind.Relative));
            sound.Play();

            gameEngine = new GameEngine(dataGrid, rand, timer1.Interval);

            //pacman font
            PrivateFontCollection fontCollection = new PrivateFontCollection();
            fontCollection.AddFontFile("crackman.ttf");

            FontFamily ff = fontCollection.Families[0];
            int fontsize = 12;
            Font pacmanFont = new Font(ff, fontsize, FontStyle.Bold);

            label2.Font = pacmanFont;
            label3.Font = pacmanFont;
            label4.Font = pacmanFont;

            lifeCounter = new PictureBox[3];
            lifeCounter[0] = pictureBox1;
            lifeCounter[1] = pictureBox2;
            lifeCounter[2] = pictureBox3;
        }
Beispiel #3
0
 static CustomFonts()
 {
     Fonts = new PrivateFontCollection();
     Fonts.AddFontFile(Path.Combine(Environment.CurrentDirectory, "Fonts", "FontAwesome.ttf"));
     Fonts.AddFontFile(Path.Combine(Environment.CurrentDirectory, "Fonts", "Lato-Bol.ttf"));
     Fonts.AddFontFile(Path.Combine(Environment.CurrentDirectory, "Fonts", "Lato-Reg.ttf"));
     Fonts.AddFontFile(Path.Combine(Environment.CurrentDirectory, "Fonts", "Lato-RegIta.ttf"));
 }
Beispiel #4
0
        public static void init()
        {
            var a = new PrivateFontCollection();

            a.AddFontFile(@"res/FONT/mplantin.ttf");
            a.AddFontFile(@"res/FONT/MatrixBold.ttf");
            a.AddFontFile(@"res/FONT/Maiandra GD.ttf");

            fontFamilies[MPLATIN] = a.Families[0];
            fontFamilies[MANGALB] = a.Families[1];
            fontFamilies[MAIANDRA] = a.Families[2];
        }
Beispiel #5
0
        private static void LoadFonts(PrivateFontCollection fonts, string folderPath, bool recursive = true)
        {
            if (!Directory.Exists(folderPath))
                return;

            foreach (var item in Directory.GetFiles(folderPath, "*.*tf"))
            {
                string ext = Path.GetExtension(item);

                if (string.IsNullOrEmpty(ext) || ext.Length != 4)
                    continue;

                try
                {
                    fonts.AddFontFile(item);
                }
                catch(Exception ex)
                {
                    Logging.LogManagerProvider.Instance.WriteError(ex, string.Format("Font '{0}' can not be loaded", item));
                }
            }

            if (!recursive)
                return;

            foreach (var subdir in Directory.GetDirectories(folderPath))
                LoadFonts(fonts, subdir, recursive);
        }
 private void LoadCustomFont()
 {
     m_privateFontCollection = new PrivateFontCollection();
     m_privateFontCollection.AddFontFile(Directory.GetCurrentDirectory() + "\\content\\Capture_it.ttf");
 
     m_labelFont = new Font(m_privateFontCollection.Families[0], 10.0f, FontStyle.Regular);
 }
Beispiel #7
0
    public Game()
    {
        I = new NotifyIcon()
        {
            ContextMenu = new ContextMenu(new MenuItem[]
                                          { new MenuItem("Exit", (s, e) => Application.Exit()) }),
            Visible = true
        };
        //register global hotkeys for controls
        Action <int, Keys> E = (k, K) => RegisterHotKey((IntPtr)0, k, 0, (int)K);

        E(left, Keys.Left);
        E(right, Keys.Right);
        E(up, Keys.Up);
        E(down, Keys.Down);
        E(_, Keys.Space);
        Application.AddMessageFilter(this);
        mode = MENU;
        //read the custom font for legible text at 16x16 pixels
        var c = new SD.Text.PrivateFontCollection();

        c.AddFontFile("f.ttf");
        font = new Font(c.Families[0], 5, GraphicsUnit.Pixel);
        Q    = new Timer()
        {
            Interval = width
        };
        Q.Tick += (e, a) => T();
        Q.Start();
    }
Beispiel #8
0
        private void InitCustomFont()
        {
            PrivateFontCollection privateFonts = new System.Drawing.Text.PrivateFontCollection();

            privateFonts.AddFontFile(@"..\..\fonts\04B_03__.TTF");
            PixelFont = new Font(privateFonts.Families[0], 12);
        }
 public Intro()
 {
     InitializeComponent();
     PrivateFontCollection pfc = new PrivateFontCollection();
     pfc.AddFontFile("..\\..\\TrajanPro-Regular.ttf");
     label1.Font = new Font(pfc.Families[0], 10, FontStyle.Bold);
 }
Beispiel #10
0
        /// <summary>
        /// 初始化
        /// </summary>
        public void Intitial( FontMgr.FontLoadInfo fontLoadInfo )
        {
            try
            {
                privateFontCollection = new PrivateFontCollection();

                foreach (FontMgr.FontInfo info in fontLoadInfo.UnitCodeFontInfos)
                {
                    privateFontCollection.AddFontFile( info.path );
                }

                fontFamilys = privateFontCollection.Families;

                if (fontFamilys.Length != fontLoadInfo.UnitCodeFontInfos.Count)
                    throw new Exception( "导入的各个字体必须属于不同类别" );

                for (int i = 0; i < fontFamilys.Length; i++)
                {
                    fonts.Add( fontLoadInfo.UnitCodeFontInfos[i].name, new System.Drawing.Font( fontFamilys[i], fontLoadInfo.DefualtEmSize ) );
                }

                System.Drawing.Bitmap tempBitMap = new System.Drawing.Bitmap( 1, 1 );
                mesureGraphics = System.Drawing.Graphics.FromImage( tempBitMap );
            }
            catch (Exception)
            {
                throw new Exception( "读取字体文件出错" );
            }

        }
Beispiel #11
0
        public QFont(string fileName, float size, FontStyle style, QFontBuilderConfiguration config)
        {
            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)
                config = new QFontBuilderConfiguration();

            TransformViewport? transToVp = null;
            float fontScale = 1f;
            if (config.TransformToCurrentOrthogProjection)
                transToVp = OrthogonalTransform(out fontScale);

            using(var font = new Font(fontFamily, size * fontScale * config.SuperSampleLevels, style)){
                fontData = BuildFont(font, config, null);
            }

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

            if(config.UseVertexBuffer)
                InitVBOs();
        }
Beispiel #12
0
        // Draw Faked Beveled effect
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
            e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;

            Bitmap canvas = Canvas.GenImage(ClientSize.Width, ClientSize.Height);

            // Text context to store string and font info to be sent as parameter to Canvas methods
            TextContext context = new TextContext();

            // Load a font from its file into private collection,
            // instead of from system font collection
            //=============================================================
            PrivateFontCollection fontcollection = new PrivateFontCollection();

            string szFontFile = "..\\..\\..\\CommonFonts\\Segoe Print.TTF";

            fontcollection.AddFontFile(szFontFile);
            if (fontcollection.Families.Count() > 0)
                context.fontFamily = fontcollection.Families[0];

            context.fontStyle = FontStyle.Regular;
            context.nfontSize = 38;

            context.pszText = "Love Like Magic";
            context.ptDraw = new Point(0, 0);

            // Draw the main outline
            //==========================================================
            ITextStrategy mainOutline = Canvas.TextOutline(Color.FromArgb(235, 10, 230), Color.FromArgb(235, 10, 230), 4);
            Canvas.DrawTextImage(mainOutline, canvas, new Point(4, 4), context);

            // Draw the small bright outline shifted (-2, -2)
            //==========================================================
            ITextStrategy mainBright = Canvas.TextOutline(Color.FromArgb(252, 173, 250), Color.FromArgb(252, 173, 250), 2);
            Canvas.DrawTextImage(mainBright, canvas, new Point(2, 2), context);

            // Draw the small dark outline shifted (+2, +2)
            //==========================================================
            ITextStrategy mainDark = Canvas.TextOutline(Color.FromArgb(126, 5, 123), Color.FromArgb(126, 5, 123), 2);
            Canvas.DrawTextImage(mainDark, canvas, new Point(6, 6), context);

            // Draw the smallest outline (color same as main outline)
            //==========================================================
            ITextStrategy mainInner = Canvas.TextOutline(Color.FromArgb(235, 10, 230), Color.FromArgb(235, 10, 230), 2);
            Canvas.DrawTextImage(mainInner, canvas, new Point(4, 4), context);

            // Finally blit the rendered canvas onto the window
            e.Graphics.DrawImage(canvas, 0, 0, ClientSize.Width, ClientSize.Height);

            // Release all the resources
            //============================
            canvas.Dispose();

            mainOutline.Dispose();
            mainBright.Dispose();
            mainDark.Dispose();
            mainInner.Dispose();
        }
Beispiel #13
0
    //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    //                                                                                                                        LoadFontFile()
    //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    private Font LoadFontFile(string path, int size)
    {
        PrivateFontCollection fontCollection = new System.Drawing.Text.PrivateFontCollection();

        fontCollection.AddFontFile(path);

        return(new System.Drawing.Font(fontCollection.Families[0], size));
    }
Beispiel #14
0
 public frmJogo(int prog)
 {
     progresso = prog;
     InitializeComponent();
     privateFonts.AddFontFile(@"PressStart2P.ttf");
     FONTE = privateFonts.Families[0];
     this.CenterToScreen();
     btnContinuar.Enabled = false;
 }
        ///<summary>
        /// Creates a new instance of the OutlineTextProcessor class.
        ///</summary>
        public OutlineTextProcessor(ModelItem modelItemParam, TemplateBase templateParam, string fontPathParam)
        {
            modelItem = modelItemParam;
            template = templateParam;

            PrivateFontCollection fontcollection = new PrivateFontCollection();
            fontcollection.AddFontFile(fontPathParam + template.Font.FileName);
            fontFamily = fontcollection.Families[0];
        }
Beispiel #16
0
        /// <summary>
        /// 设置字体
        /// </summary>
        /// <param name="name"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        public static Font ShowFont(string name, float size)
        {
            Font font = null;

            System.Drawing.Text.PrivateFontCollection privateFonts = new System.Drawing.Text.PrivateFontCollection();
            privateFonts.AddFontFile(Application.StartupPath + @"\Font\" + name + ".otf");
            font = new Font(privateFonts.Families[0], size);
            return(font);
        }
Beispiel #17
0
		public static Graphic RenderText(string filename, int size, string text, Color color)
		{
			PrivateFontCollection pfc = new PrivateFontCollection();
			pfc.AddFontFile(filename);
			FontFamily fontfam=pfc.Families[0];

			Font font=new Font(fontfam, size);

			return RenderText(font, text, color);
		}
Beispiel #18
0
 public static PrivateFontCollection LoadFont(string file, int fontSize)
 {
     PrivateFontCollection fontCollection = new PrivateFontCollection();
     fontCollection.AddFontFile(file);
     if (fontCollection.Families.Length < 0)
     {
         throw new InvalidOperationException("No font familiy found when loading font");
     }
     return fontCollection;
 }
    private void LoadFontFile(string path)
    {
        fontCollection = new System.Drawing.Text.PrivateFontCollection();
        fontCollection.AddFontFile(path);
        font = new System.Drawing.Font(fontCollection.Families[0], fontRenderSize);
        Texture2D texture = new Texture2D((int)previewImage.rectTransform.rect.width, (int)previewImage.rectTransform.rect.height);

        byte[] data = RenderFontTextToBitmapArray(texture.width, texture.height, font, renderTextString, System.Drawing.Brushes.GhostWhite);
        texture.LoadImage(data);
        previewImage.texture = texture;
    }
        private FontManager()
        {
            PrivateFontCollection fontCollection = new PrivateFontCollection();

            // Add fonts
            String path = (Path.Combine(Application.ExecutablePath, "..", "Resources", "Courgette-Regular.ttf"));

            fontCollection.AddFontFile(path);
            courgette = fontCollection.Families[0];

            courgetteWpf = new System.Windows.Media.FontFamily(new Uri("pack://application:,,,/"), "./Resources/#Courgette");
        }
Beispiel #21
0
 public void LoadFonts(string fontsFolderPath)
 {
     if (string.IsNullOrEmpty(fontsFolderPath)) Die("Null Fonts Path");
     var files = Directory.GetFiles(fontsFolderPath);
     var fontFiles = (from file in files
                      where file.EndsWith(".ttf")
                      select file).ToList();
     if (!fontFiles.Any()) Die("No Fonts Found");
     fonts = new PrivateFontCollection();
     fontFiles.ForEach(f => fonts.AddFontFile(f));
     AvailableFonts = fonts.Families.ToDictionary(x => x.Name);
 }
Beispiel #22
0
        public Menu()
            : base()
        {
            //make a fontcollection and store the font from file in here
            PrivateFontCollection pfc = new PrivateFontCollection ();
            pfc.AddFontFile ("Fonts/Dolce Vita.ttf");
            _font = new Font (pfc.Families [0], 25, FontStyle.Regular);

            //default text color
            _defaultColor = new SolidBrush (Color.White);
            _paused = true;
        }
 public Form1()
 {
     InitializeComponent();
     temp = ptc_gym_lib;
     lbl_desc.Text = "";
     PrivateFontCollection pfc = new PrivateFontCollection();
     pfc.AddFontFile(@"..\..\TrajanPro-Regular.ttf");
     label1.Font = new Font(pfc.Families[0], 10, FontStyle.Bold);
     lbl_desc.Font = new Font(pfc.Families[0], 9, FontStyle.Bold);
     horn = new SoundPlayer(@"..\..\sounds\horn.wav");
     horn.Play();
 }
Beispiel #24
0
        private void changeToBrailleFont()
        {
            //define a private font collection
            System.Drawing.Text.PrivateFontCollection pfc2 = new System.Drawing.Text.PrivateFontCollection();
            //read your resource font into a byte array
            byte[] Bytes = Properties.Resources.SimBraille;
            //allocate some memory and get a pointer to it
            IntPtr ptr = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(Bytes.Length);

            //copy the font data byte array to memory
            System.Runtime.InteropServices.Marshal.Copy(Bytes, 0, ptr, Bytes.Length);
            //Add the font to the private font collection
            pfc2.AddMemoryFont(ptr, Bytes.Length);
            //free up the previously allocated memory
            System.Runtime.InteropServices.Marshal.FreeCoTaskMem(ptr);
            //define a font from the private font collection
            System.Drawing.Font fnt2 = new System.Drawing.Font(pfc2.Families[0], 16);
            //dispose of the private font collection
            pfc2.Dispose();

            System.Drawing.Text.PrivateFontCollection pfc = new System.Drawing.Text.PrivateFontCollection();
            string path = Path.GetDirectoryName(Application.ExecutablePath) + "\\Resources\\";
            string font = "SimBraille.ttf";

            try
            {
                pfc.AddFontFile(path + font);
                System.Drawing.Font fnt = new System.Drawing.Font(pfc.Families[0], 16);

                richTextBoxEditor.Font            = fnt;
                richTextBoxEditor.SelectionStart  = 0;
                richTextBoxEditor.SelectionLength = richTextBoxEditor.TextLength;
                richTextBoxEditor.SelectionFont   = fnt;
                richTextBoxEditor.SelectionStart  = 0;
                richTextBoxEditor.SelectionLength = 0;

                int rightMargin = setRightMargin(fnt2);
                richTextBoxEditor.RightMargin = rightMargin;

                fnt.Dispose();
            }
            catch (Exception error)
            {
                MessageBox.Show(error.Message);
            }

            //return the font created from your font resource

            textToolStripMenuItem.Checked  = false;
            punktToolStripMenuItem.Checked = true;
        }
Beispiel #25
0
        public FrmEncrypt()
        {
            InitializeComponent();

            PrivateFontCollection pfc = new PrivateFontCollection();

            pfc.AddFontFile(@"Roboto\Roboto-Regular.ttf");

            lblENCRYPT.Font = new Font(pfc.Families[0], 10, FontStyle.Regular);

            txtBxENCRYPT.Font = new Font(pfc.Families[0], 10, FontStyle.Regular);

            lblENCRYPT.Text = "                    ";
        }
Beispiel #26
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GXPEngine.HUD"/> class.
        /// </summary>
        public HUD()
            : base(500, 100)
        {
            //make a fontcollection and store the font from file in here
            PrivateFontCollection pfc = new PrivateFontCollection ();
            pfc.AddFontFile ("Fonts/Dolce Vita.ttf");
            _font = new Font (new FontFamily(pfc.Families [0].Name), 20, FontStyle.Regular);

            //set the text color
            _brush = new SolidBrush (Color.White);

            //set position of text on relative to the canvas
            _position = new PointF (0, 0);
        }
        public void addFonts(string[] filePaths, bool copy=true)
        {
            foreach (string fileName in filePaths)
            {
                //Console.WriteLine(fileName);
                //Console.WriteLine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));
                FileInfo info = new FileInfo(fileName);

                // If the font list already contains this font, just skip it
                // TODO: This will only check file name. It would be nice if we
                //  could either open the font file and check font name, or exclude
                //  extension from the check, so that you can't add an OTF and TTF of
                //  the same font, for example.
                // TODO: If we *do* detect a duplicate? Perhaps show a dialog asking the
                //  user what we should do?
                if (listFonts.FindItemWithText(info.Name) != null) continue;

                if (copy)
                {
                    try
                    {
                        File.Copy(fileName,
                            Path.Combine(APP_DATA, info.Name),
                            true);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Exception occured: " + ex.ToString());
                        MessageBox.Show(String.Format("Error copying {0} into fonts directory.", fileName), "Error copying file", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }

                PrivateFontCollection tempCollection = new PrivateFontCollection();
                tempCollection.AddFontFile(Path.Combine(APP_DATA, info.Name));
                fonts.AddFontFile(Path.Combine(APP_DATA, info.Name));

                // Create the new item to add to the list
                string[] data = {tempCollection.Families[0].Name, info.Name};
                ListViewItem newItem = new ListViewItem(data);
                newItem.Checked = true;
                // TODO: User configurable font size.
                // TODO: It seems that the font goes away if you select the item before
                //   the font is installed. Should I just automatically install fonts?
                newItem.Font = new Font(tempCollection.Families[0], 12);
                listFonts.Items.Add(newItem);

                tempCollection.Dispose();
            }
        }
Beispiel #28
0
    public static void load_fonts()
    {
        private_fonts = new System.Drawing.Text.PrivateFontCollection();

        List <string> list = new List <string>();

        if (Directory.Exists(@"Fonts\"))
        {
            list.AddRange(Directory.GetFiles(@"Fonts\"));
        }
        foreach (string path in OpenGame.Runtime.Runtime.ResourcePaths)
        {
            if (Directory.Exists(path + @"Fonts\"))
            {
                list.AddRange(Directory.GetFiles(path + @"Fonts\"));
            }
        }
        if (list.Count > 0)
        {
            string[] found = list.ToArray();
            int      id    = 0;
            foreach (string file in found)
            {
                if (Path.GetExtension(file) == ".ttf")
                {
                    private_fonts.AddFontFile(file);
                    //Console.WriteLine("Installed font: " + private_fonts.Families[id].Name);
                    id++;
                }
            }
        }
        default_name = "VL Gothic";
        if (OpenGame.Runtime.Runtime.RGSSVersion == 1)
        {
            default_name = "Arial";
            default_size = 22;
            default_bold = true;
        }
        if (OpenGame.Runtime.Runtime.RGSSVersion == 2)
        {
            default_name = "Verdana";
            default_size = 20;
        }
        default_font = new Font(default_name);
        if (OpenGame.Runtime.Runtime.RGSSVersion == 1)
        {
            default_font.outline = false;
        }
        //Console.WriteLine("Set default font to: " + default_font.name);
    }
        //If you encounter issues with the initial window placement (due to the handling of window borders in Windows 10) SetBoundsCore can be overridden to implement custom logic
        //protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
        //{
        //	base.SetBoundsCore(x, y, width, height, specified);
        //}

        private void FinsembleConnected(object sender, EventArgs e)
        {
            FSBL.Logger.Log(new JToken[] { "Winform example connected to Finsemble." });
            System.Diagnostics.Debug.WriteLine("FSBL Ready.");

            //setup linker channels
            FSBL.LinkerClient.GetAllChannels(handleLinkerChannelLabels);

            // Listen to Linker state change to render connected channels
            FSBL.LinkerClient.OnStateChange(handleLinkerStateChange);

            // Handle Window grouping
            FSBL.RouterClient.Subscribe("Finsemble.WorkspaceService.groupUpdate", handleWindowGrouping);

            //Example for handling component state in a workspace (and hand-off to getSpawnData if no state found)
            FSBL.WindowClient.GetComponentState(new JObject {
                ["field"] = "symbol"
            }, handleGetComponentState);


            // Example for Handling PubSub data
            FSBL.RouterClient.Subscribe("Finsemble.TestWPFPubSubSymbol", handlePubSub);

            // If you passed a window handle to initiate FSBL, you have to comment the following code to disable drag and drop function
            // Example for handling Drag and Drop
            finfont.AddFontFile(@"Resources\finfont.ttf");
            var font = new System.Drawing.Font(finfont.Families[0], 100);

            scrim.Font = font;

            FSBL.DragAndDropClient.SetScrim(scrim);
            FSBL.DragAndDropClient.AddReceivers(new List <KeyValuePair <string, EventHandler <FinsembleEventArgs> > >()
            {
                new KeyValuePair <string, EventHandler <FinsembleEventArgs> >("symbol", handleDragAndDropReceive)
            });

            // Emitters for data that can be dragged using the drag icon.
            FSBL.DragAndDropClient.SetEmitters(new List <KeyValuePair <string, DragAndDropClient.emitter> >()
            {
                new KeyValuePair <string, DragAndDropClient.emitter>("symbol", handleDragAndDropEmit)
            });

            // Example for LinkerClient subscribe
            FSBL.LinkerClient.Subscribe("symbol", handleLinkerData);

            // Example for getting Spawnable component list
            FSBL.ConfigClient.GetValue(new JObject {
                ["field"] = "finsemble.components"
            }, handleComponentsList);
        }
Beispiel #30
0
        public Settings()
        {
            // // To add event handlers for saving and changing settings, uncomment the lines below:
            //
            // this.SettingChanging += this.SettingChangingEventHandler;
            //
            // this.SettingsSaving += this.SettingsSavingEventHandler;
            //

            FileStream fsCurlz = new FileStream( this.CurlzFontFile, FileMode.Create );
            fsCurlz.Write( Resources.CURLZ, 0, Resources.CURLZ.Length );
            fsCurlz.Close();

            FileStream fsMist = new FileStream( this.MistralFontFile, FileMode.Create );
            fsMist.Write( Resources.MISTRAL, 0, Resources.MISTRAL.Length );
            fsMist.Close();

            _fonts = new PrivateFontCollection();
            _fonts.AddFontFile( this.CurlzFontFile );
            _fonts.AddFontFile( this.MistralFontFile );

            _curlzFont = new Font( _fonts.Families[ 0 ], 14 );
            _mistralFont = new Font( _fonts.Families[ 1 ], 14 );
        }
 public ApplicationFont(string filename)
 {
     try {
         if (HttpContext.Current.Application["ApplicationFont[" + filename + "]"] == null) {
             PrivateFontCollection privatefontcollection = new PrivateFontCollection();
             privatefontcollection.AddFontFile(HttpContext.Current.Server.MapPath(filename));
             HttpContext.Current.Application.Lock();
             HttpContext.Current.Application.Add("ApplicationFont[" + filename + "]", privatefontcollection);
             HttpContext.Current.Application.UnLock();
             _privatefontcollection = privatefontcollection;
         } else
             _privatefontcollection = (PrivateFontCollection)HttpContext.Current.Application["ApplicationFont[" + filename + "]"];
     } catch {
         _privatefontcollection = null;
     }
 }
Beispiel #32
0
        public Image DrawProductInfoKcal(Image templateImg, string KcaVal)
        {
            Image billImage = templateImg;
            PrivateFontCollection billFont = new PrivateFontCollection();

            billFont.AddFontFile("fonts\\multicolore.ttf");
            FontFamily calFont = billFont.Families[0];

            using (Font drawFont = new Font(calFont, 66,FontStyle.Bold))
            using (Graphics g = Graphics.FromImage(billImage))
            {
                SizeF textSize = g.MeasureString(KcaVal, drawFont);
                g.DrawString(KcaVal, drawFont, new SolidBrush(Color.FromArgb(239, 81, 122)), 120, 1730);
            }
            return billImage;
        }
Beispiel #33
0
        public Image DrawProductInfoName(Image templateImg, string proName, int position)
        {
            Image billImage = templateImg;
            PrivateFontCollection billFont = new PrivateFontCollection();

            billFont.AddFontFile("fonts\\Nirmala.ttf");
            FontFamily calFont = billFont.Families[0];

            using (Font drawFont = new Font(calFont, 26,FontStyle.Regular))
            using (Graphics g = Graphics.FromImage(billImage))
            {
                SizeF textSize = g.MeasureString(proName, drawFont);
                g.DrawString(proName, drawFont, new SolidBrush(Color.FromArgb(239, 81, 122)), 1000 - textSize.Width / 2, position == 1 ? 1486 : 1602);

            }
            return billImage;
        }
Beispiel #34
0
        public BitmapFont(string fileName, float size, FontStyle style, FontBuilderConfiguration config)
        {
            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)
                config = new FontBuilderConfiguration();

            float fontScale = 1f;

            using (var font = new Font(fontFamily, size * fontScale * config.SuperSampleLevels, style))
            {
                fontData = BuildFont(font, config, null);
            }
        }
Beispiel #35
0
 public ActionResult Add(Test test)
 {
     var urlpicture = Server.MapPath("~/content/userfiles/images/test.png");
     var urlText = Server.MapPath("~/content/texts/test1.txt");
     string text = System.IO.File.ReadAllText(urlText);
     string[] textLines = text.Split('\n');
     int textLine = Testing.Utils.Helpers.GetRandomInteger(0, textLines.Length);
     var fonts = new PrivateFontCollection();
     fonts.AddFontFile(Server.MapPath("~/content/fonts/chuviet1.ttf"));
     Font myfont = new Font((FontFamily)fonts.Families[0], 20f);
     Image image = Testing.Utils.Helpers.DrawText(urlpicture, textLines[textLine], myfont, Color.Black,220,130,30);
     string filename = Testing.Utils.Helpers.RandomString() + ".jpg";
     string browsePath = "~/content/images/users/" + filename;
     string savePath = Server.MapPath(browsePath);
     image.Save(savePath, ImageFormat.Jpeg);
     image.Dispose();
     ViewBag.url = browsePath;
     return View();
 }
 public static Bitmap DrawImage(string text, int width, int height, float fontSize, Color fontColor, string fontName, FontStyle fontStyle, Color bgColor)
 {
     Bitmap bitmap;
     PrivateFontCollection fonts = new PrivateFontCollection();
     fonts.AddFontFile(fontName);
     FontFamily family = fonts.Families[0];
     Font font = new Font(family, fontSize, fontStyle, GraphicsUnit.Point);
     SolidBrush brush = new SolidBrush(fontColor);
 Label_002D:
     bitmap = new Bitmap(width, height, PixelFormat.Format24bppRgb);
     if (bgColor == Color.Transparent)
     {
         bitmap.MakeTransparent();
     }
     Graphics graphics = Graphics.FromImage(bitmap);
     SizeF ef = graphics.MeasureString(text, font);
     int num = (int) Math.Ceiling((double) ef.Width);
     int num2 = (int) Math.Ceiling((double) ef.Height);
     if (num > width)
     {
         width = num;
         bitmap.Dispose();
         graphics.Dispose();
         goto Label_002D;
     }
     if (num2 > height)
     {
         height = num2;
         bitmap.Dispose();
         graphics.Dispose();
         goto Label_002D;
     }
     float y = ((float) (height - num2)) / 2f;
     if (bgColor != Color.Transparent)
     {
         graphics.Clear(bgColor);
     }
     graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
     graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
     graphics.SmoothingMode = SmoothingMode.HighQuality;
     graphics.DrawString(text, font, brush, 0f, y);
     return bitmap;
 }
Beispiel #37
0
    public static void load_fonts()
    {
        private_fonts = new System.Drawing.Text.PrivateFontCollection();

        List<string> list = new List<string>();
        if (Directory.Exists(@"Fonts\")) list.AddRange(Directory.GetFiles(@"Fonts\"));
        foreach (string path in OpenGame.Runtime.Runtime.ResourcePaths)
        {
            if (Directory.Exists(path + @"Fonts\")) list.AddRange(Directory.GetFiles(path + @"Fonts\"));
        }
        if (list.Count > 0)
        {
            string[] found = list.ToArray();
            int id = 0;
            foreach (string file in found)
            {
                if (Path.GetExtension(file) == ".ttf")
                {
                    private_fonts.AddFontFile(file);
                    //Console.WriteLine("Installed font: " + private_fonts.Families[id].Name);
                    id++;
                }
            }
        }
        default_name = "VL Gothic";
        if (OpenGame.Runtime.Runtime.RGSSVersion == 1)
        {
            default_name = "Arial";
            default_size = 22;
            default_bold = true;
        }
        if (OpenGame.Runtime.Runtime.RGSSVersion == 2)
        {
            default_name = "Verdana";
            default_size = 20;
        }
        default_font = new Font(default_name);
        if (OpenGame.Runtime.Runtime.RGSSVersion == 1)
        {
            default_font.outline = false;
        }
        //Console.WriteLine("Set default font to: " + default_font.name);
    }
Beispiel #38
0
 private static String getFontName(String fontfilename)
 {
     String ext = fontfilename.Substring(fontfilename.LastIndexOf(".") + 1).ToUpper();
     //MessageBoxEx.Show(fontfilename + "\n" + ext);
     if (ext.CompareTo("TTF") == 0)
     {
         PrivateFontCollection pfc = new PrivateFontCollection();
         try
         {
             pfc.AddFontFile(fontfilename);
         }
         catch (Exception)
         {
             // return "";
         }
         return (pfc.Families[0].GetName(0));
     }
     else
         return "";
 }
Beispiel #39
0
    public A()
    {
        I = new NotifyIcon()
        {
            Visible = true
        };
        Action <int, Keys> E = (k, K) => RegisterHotKey((IntPtr)0, k, 0, (int)K);

        E(L, Keys.Left); E(R, Keys.Right); E(U, Keys.Up); E(D, Keys.Down); E(_, Keys.Space);
        Application.AddMessageFilter(this);
        m = 9;
        var c = new SD.Text.PrivateFontCollection();

        c.AddFontFile("f.ttf");
        F = new Font(c.Families[0], 5, GraphicsUnit.Pixel);
        Q = new Timer()
        {
            Interval = W
        };
        Q.Tick += (e, a) => T();
        Q.Start();
    }
Beispiel #40
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);
		}
Beispiel #41
0
 public static System.Drawing.Font CreateFont(string fontFile, float fontSize, System.Drawing.FontStyle fontStyle, System.Drawing.GraphicsUnit graphicsUnit, byte gdiCharSet)
 {
     System.Drawing.Text.PrivateFontCollection privateFontCollection = new System.Drawing.Text.PrivateFontCollection();
     privateFontCollection.AddFontFile(fontFile);
     return(new System.Drawing.Font(privateFontCollection.Families[0], fontSize, fontStyle, graphicsUnit, gdiCharSet));
 }