Ejemplo n.º 1
0
        public PdfDocument(Models.Document documentTemplate, string outputFile)
        {
            // Create Colors
            foreach (Models.Typography.Color bColor in documentTemplate.Colors)
            {
                Color itextColor = new Color(bColor);
                Colors.Add(itextColor);
            }

            // Create Fonts
            foreach (Models.Typography.Font bFont in documentTemplate.Fonts)
            {
                foreach (Models.Typography.FontStyle bFontStyle in bFont.Styles)
                {
                    FontStyle itextFontStyle =
                        new FontStyle(bFontStyle);
                    Fonts.Add(itextFontStyle);
                }
            }

            try
            {
                CreatePages(documentTemplate, outputFile);
                SetDocumentProperties(documentTemplate);

                _itextDocument.Close();
                _itextPDFWriter.Close();
            }
            catch (IOException iox)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        public void InitFont(GUIFontConfiguration config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            if (String.IsNullOrEmpty(config.Tag))
            {
                throw new ArgumentException("config.Tag must not be null or empty.");
            }

            if (Fonts.ContainsKey(config.Tag))
            {
                this.LogWarning("Font was already loaded: {0}", config.Tag);
                return;
            }

            config.ScaleFactor = Owner.ScaleFactor;

            IGUIFont font = null;

            if (!String.IsNullOrEmpty(config.Path))
            {
                font = FontManager.CreateFont(config);
                if (font == null)
                {
                    this.LogWarning("Failed to load font: {0}", config.Tag);
                }
            }

            // Add even when font is null, which means: loading failed
            Fonts.Add(config.Tag, font);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            // Load the object textures into the textures dictionary
            Textures.Add("Spaceship", this.Content.Load <Texture2D>("Spaceship"));
            Textures.Add("Bullet", this.Content.Load <Texture2D>("Bullet"));
            Textures.Add("Rock1", this.Content.Load <Texture2D>("Rock1"));
            Textures.Add("Rock2", this.Content.Load <Texture2D>("Rock2"));
            Textures.Add("Rock3", this.Content.Load <Texture2D>("Rock3"));
            Textures.Add("Star", this.Content.Load <Texture2D>("Star"));
            Textures.Add("SmokeParticle", this.Content.Load <Texture2D>("SmokeParticle"));

            // Load fonts
            Fonts.Add("Miramonte", this.Content.Load <SpriteFont>("Miramonte"));

            // Load sounds
            SoundEffects.Add("BulletSound", Content.Load <SoundEffect>("BulletSound"));
            SoundEffects.Add("HyperspaceOut", Content.Load <SoundEffect>("HyperspaceOut"));
            SoundEffects.Add("HyperspaceIn", Content.Load <SoundEffect>("HyperspaceIn"));
            SoundEffects.Add("RockExplosion", Content.Load <SoundEffect>("RockExplosion"));
            SoundEffects.Add("SpaceshipExplosion", Content.Load <SoundEffect>("SpaceshipExplosion"));
            SoundEffects.Add("Thruster", Content.Load <SoundEffect>("Thruster"));

            // Reset the game
            ResetGame();
        }
Ejemplo n.º 4
0
        internal static void LoadEmbeddedFont()
        {
            //var auxList = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceNames();
#if WINDOWS_UWP || WINDOWS_UAP
            var assembly = new ColoredString().GetType().GetTypeInfo().Assembly;
#else
            var assembly = Assembly.GetExecutingAssembly();
#endif
            var resourceNameFont  = "SadConsole.Resources.IBM_ext.font";
            var resourceNameImage = "SadConsole.Resources.IBM8x16_NoPadding_extended.png";

            using (Stream stream = assembly.GetManifestResourceStream(resourceNameFont))
                using (StreamReader sr = new StreamReader(stream))
                {
                    Settings.LoadingEmbeddedFont = true;
                    Global.SerializerPathHint    = "";
                    var masterFont = (FontMaster)Newtonsoft.Json.JsonConvert.DeserializeObject(
                        sr.ReadToEnd(),
                        typeof(FontMaster),
                        new Newtonsoft.Json.JsonSerializerSettings()
                    {
                        TypeNameHandling = Newtonsoft.Json.TypeNameHandling.All
                    });

                    using (Stream fontStream = assembly.GetManifestResourceStream(resourceNameImage))
                        masterFont.Image = Texture2D.FromStream(Global.GraphicsDevice, fontStream);

                    masterFont.ConfigureRects();
                    Fonts.Add(masterFont.Name, masterFont);
                    FontDefault = masterFont.GetFont(Font.FontSizes.One);

                    Settings.LoadingEmbeddedFont = false;
                }
        }
Ejemplo n.º 5
0
        internal static void LoadEmbeddedAssets()
        {
            ResourceManager manager = new ResourceManager("Punk.Resources.Embeds", typeof(Engine).Assembly);

            var embed = "Punk.Embeds/";

            using (MemoryStream stream = new MemoryStream((byte[])manager.GetObject("DefaultFont")))
            {
                Fonts.Add(embed + "DefaultFont.ttf", new Font(new MemoryStream(stream.ToArray())));
            }

            var images = new string[]
            {
                "console_debug",
                "console_logo",
                "console_output",
                "console_pause",
                "console_play",
                "console_step"
            };

            foreach (string image in images)
            {
                using (MemoryStream stream = new MemoryStream())
                {
                    Drawing.Bitmap img = (Drawing.Bitmap)manager.GetObject(image);
                    img.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
                    stream.Close();

                    Textures.Add(embed + image + ".png", new Texture(new MemoryStream(stream.ToArray())));              //	wat
                }
            }
        }
Ejemplo n.º 6
0
 public void TryAddFont(Tuple <string, Font> font_data)
 {
     if (false == Fonts.ContainsKey(font_data.Item1))
     {
         Fonts.Add(font_data.Item1, font_data.Item2);
     }
 }
Ejemplo n.º 7
0
        public IAssetPlugin AddFont(IBaseFont font, List <FontTag> fontTags)
        {
            if (!CanAddFont(font))
            {
                return(this);
            }

            //convert the filename so the platform would understand this
            ConvertFontFileNameForPlatform(ref font);
            Fonts.Add(font.Name, font);

            //for each tag, add a font
            if (fontTags != null && fontTags.Count > 0)
            {
                if (FontsTagged != null)
                {
                    if (!FontsTagged.ContainsKey(font.Name))
                    {
                        FontsTagged[font.Name] = new List <FontTag>();
                    }
                    FontsTagged[font.Name].AddRange(fontTags);
                }
            }
            return(this);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Loads a font from a file and adds it to the <see cref="Fonts"/> collection.
        /// </summary>
        /// <param name="font">The font file to load.</param>
        /// <returns>A master font that you can generate a usable font from.</returns>
        public static FontMaster LoadFont(string font)
        {
            //if (!File.Exists(font))
            //{
            //    font = Path.Combine(Path.Combine(Path.GetDirectoryName(Path.GetFullPath(font)), "fonts"), Path.GetFileName(font));
            //    if (!File.Exists(font))
            //        throw new Exception($"Font does not exist: {font}");
            //}

            //FontPathHint = Path.GetDirectoryName(Path.GetFullPath(font));
            try
            {
                var masterFont = SadConsole.Serializer.Load <FontMaster>(font, false);

                if (Fonts.ContainsKey(masterFont.Name))
                {
                    Fonts.Remove(masterFont.Name);
                }

                Fonts.Add(masterFont.Name, masterFont);
                return(masterFont);
            }
            catch (System.Runtime.Serialization.SerializationException e)
            {
                throw;
            }
        }
Ejemplo n.º 9
0
 private void AddDefaultStyles()
 {
     Fonts.Add(new Font("Calibri", size: 11));
     Fills.Add(new Fill(new PatternFill(FillPattern.None, null, null), null));
     Fills.Add(new Fill(new PatternFill(FillPattern.Gray125, null, null), null));
     Borders.Add(new Border());
     CellFormats.Add(new CellFormat(null, 0, 0, 0, 0));
 }
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            Fonts.Add("Kootenay", Content.Load <SpriteFont>("Kootenay"));

            ResetGame();
        }
Ejemplo n.º 11
0
 internal bool LoadFont(string name, string path)
 {
     if (!Fonts.ContainsKey(name))
     {
         Fonts.Add(name, Load <SpriteFont>(path));
         return(true);
     }
     return(false);
 }
Ejemplo n.º 12
0
            /// <summary>
            /// for adding an TMP_FontAsset while it is still in an assetbundle
            /// </summary>
            /// <param name="fontFile">the assetbundle file</param>
            public static void Add(byte[] fontFile)
            {
                var fonts = UnityEngine.AssetBundle.LoadFromMemory(fontFile).LoadAllAssets <TMPro.TMP_FontAsset>();

                foreach (var font in fonts)
                {
                    Fonts.Add(font);
                }
            }
Ejemplo n.º 13
0
        public void LoadFonts()
        {
            // total: 1
            var i = 1;

            Fonts.Add(new ContentData <SpriteFont>(i++, "Fonts/Font_01", _content));

            Log.Info("CitySim", $"Fonts: {i}");
        }
Ejemplo n.º 14
0
        public DisplayViewModel(IOutputService outputServce)
        {
            OutputService = outputServce;

            foreach (System.Drawing.FontFamily font in System.Drawing.FontFamily.Families)
            {
                Fonts.Add(font.Name);
            }
        }
Ejemplo n.º 15
0
        public void LoadFonts()
        {
            // total: 1
            var i = 1;

            Fonts.Add(new ContentData <SpriteFont>(i++, "Fonts/Font_01", _content));

            Console.WriteLine($"Fonts: {i}");
        }
        public LettertypeChaos()
        {
            InitializeComponent();

            foreach (FontFamily f in System.Drawing.FontFamily.Families)
            {
                Fonts.Add(new Font(f.Name, 13));
            }
        }
Ejemplo n.º 17
0
        private Font GetFont(float size, bool isBold)
        {
            var font = Fonts.FirstOrDefault(x => x.Size == size && (isBold ? x.Style == FontStyle.Bold : x.Style == FontStyle.Regular));

            if (font == null)
            {
                font = new Font(FontInfo.FontName, size, (isBold ? FontStyle.Bold : FontStyle.Regular));
                Fonts.Add(font);
            }
            return(font);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            // Load game content
            Fonts.Add("WascoSans", Content.Load <SpriteFont>("WascoSans"));

            // Reset the game
            ResetGame();
        }
        public PlantxtViewPage()
        {
            InitializeComponent();
            var fonts = Microsoft.Graphics.Canvas.Text.CanvasTextFormat.GetSystemFontFamilies();

            // Put the individual fonts in the list
            foreach (string font in fonts)
            {
                Fonts.Add(new Tuple <string, FontFamily>(font, new FontFamily(font)));
            }
        }
Ejemplo n.º 20
0
 private void AddFont(string fileDirectory, string key = null)
 {
     if (key == null)
     {
         Fonts.Add(fileDirectory, _content.Load <SpriteFont>(fileDirectory));
     }
     else
     {
         Fonts.Add(key, _content.Load <SpriteFont>(fileDirectory));
     }
 }
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            // Load resources
            Textures.Add("Crosshair", Content.Load <Texture2D>("Crosshair"));
            Fonts.Add("Miramonte", Content.Load <SpriteFont>("Miramonte"));

            ResetGame();
        }
Ejemplo n.º 22
0
        /* ----------------------------------------------------------------- */
        ///
        /// Converter
        ///
        /// <summary>
        /// Initializes a new instance of the Converter class with the
        /// specified format.
        /// </summary>
        ///
        /// <param name="format">Target format.</param>
        /// <param name="io">I/O handler.</param>
        /// <param name="supported">Collection of supported formats.</param>
        ///
        /* ----------------------------------------------------------------- */
        protected Converter(Format format, IO io, IEnumerable <Format> supported)
        {
            if (!supported.Contains(format))
            {
                throw new NotSupportedException(format.ToString());
            }

            IO     = io;
            Format = format;
            Fonts.Add(Environment.GetFolderPath(Environment.SpecialFolder.Fonts));
        }
Ejemplo n.º 23
0
        }                                               // Write string to Str Buffer ( for Tj )

        public void FlushStrBuffer()
        {
            if (StrBuffer.Count == 0)
            {
                return;
            }

            if (LastFont != CurFont || LastFontSize != FontSize)
            {
                if (!Fonts.Contains(CurFont.Obj))
                {
                    Fonts.Add(CurFont.Obj);
                }
                TSW("/F" + CurFont.Obj + " " + FontSize + " Tf");
                LastFont     = CurFont;
                LastFontSize = FontSize;
            }

            bool useHex = false;

            foreach (byte b in StrBuffer)
            {
                if (b < 32 || b >= 128)
                {
                    useHex = true; break;
                }
            }

            if (useHex)
            {
                TS.WriteByte((byte)'<');
                foreach (byte b in StrBuffer)
                {
                    int x = b >> 4; x += x < 10 ? 48 : 55; TS.WriteByte((byte)x);
                    x = b & 15;  x += x < 10 ? 48 : 55; TS.WriteByte((byte)x);
                }
                TSW("> Tj");
            }
            else
            {
                TS.WriteByte((byte)'(');
                foreach (byte b in StrBuffer)
                {
                    if (b == (byte)'(' || b == (byte)')' || b == (byte)'\\')
                    {
                        TS.WriteByte((byte)'\\');
                    }
                    TS.WriteByte(b);
                }
                TSW(") Tj");
            }
            StrBuffer.Clear();
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Controls the process of loading the assets from an archive file into memory. This function first determines
        /// how many assets there are to load. The way it does this is a little juvenile, so I'm sure I'm going to need
        /// a more sophisticated method for doing this. It's accomplished by performing a LINQ query against the entry
        /// collection to determine the number of entries that have a file extension. Variable aspects about this are
        /// currently not considered, such as the kind of extension or the full path of the asset (this one in particular
        /// would require that the structure of the archive be well defined before hand).
        ///
        /// There's another potential caveat here in that numAssetsLoaded is incremented in this method, and is done
        /// so directly after a call to an asynchronous operation. The increment of this counter may not accurately reflect
        /// the loading efforts done behind the scenes, and may result in future checks that rely on this measurement to be
        /// inaccurate. Further testing will need performed to verify that this actually is the case.
        ///
        /// While this method is running, the status of its loading can be monitored by calling methods through the public
        /// properties. There may be a better way of doing this, but like other things, it'll require a bit more
        /// research.
        ///
        /// When this method completes, each asset bank contained in the AssetManager should be populated with the resources
        /// located within the archive that was provided to this method.
        /// </summary>
        /// <param name="archiveFileName">The path to an archive file that contains assets one wishes to load.</param>
        public void LoadAssets(String archiveFileName)
        {
            try {
                ZipArchive archive = ZipFile.OpenRead(archiveFileName);

                // I have no idea if this is going to freaking work.
                numAssetsToLoad = archive.Entries.SelectMany(s => s.Name).Where(s => s.ToString().Split(new Char[] { '.' }).Length > 1).ToList().Count;

                foreach (ZipArchiveEntry entry in archive.Entries)
                {
                    String[] fname = entry.Name.Split(new Char[] { '.' });
                    if (fname.Length > 1)
                    {
                        switch (fname[1])
                        {
                        case "png":
                        case "jpg":
                        case "jpeg":
                            Textures.Add(fname[0], (CopyAssetMem <Texture>(entry)).Result);
                            //numAssetsLoaded++;
                            break;

                        case "otf":
                            Fonts.Add(fname[0], (CopyAssetMem <Font>(entry)).Result);
                            //numAssetsLoaded++;
                            break;

                        case "ogg":
                            Songs.Add(fname[0], (CopyAssetMem <Music>(entry)).Result);
                            //numAssetsLoaded++;
                            break;

                        case "wav":
                            SoundEffects.Add(fname[0], (CopyAssetMem <SoundBuffer>(entry)).Result);
                            //numAssetsLoaded++;
                            break;

                        default:
                            /*
                             * This could cause a problem where the number of assets to load won't match the expected
                             * amount, and could result in a false positive sent to the caller. In production code,
                             * this would be removed since all kinds of assets would be known and contained in the archive.
                             */
                            break;
                        }
                    }
                }
            } catch (Exception e) {
                Console.WriteLine(e.Message);
                Environment.Exit(-99);
            }
        }
        public void SetFont(MusicFontStyles style, string name, double size, params string[] fontFiles)
        {
            var fontInfo = new HtmlFontInfo(name, size, fontFiles);

            if (!Fonts.ContainsKey(style))
            {
                Fonts.Add(style, fontInfo);
            }
            else
            {
                Fonts[style] = fontInfo;
            }
        }
Ejemplo n.º 26
0
 /// <summary>
 /// Carga una fuente de texto en el ContentManager y la agrega a la lista.
 /// </summary>
 /// <param name="assetName">Nombre del recurso de la fuente de texto en el Content Project.</param>
 /// <returns>Devuelve la instancia de la fuente cargada.</returns>
 /// <remarks>Si el recurso que intenta cargar ya existe se omitira su carga y se devolvera la instancia del recurso ya cargado en memoria.</remarks>
 public SpriteFont LoadFont(string assetName)
 {
     if (!Fonts.Keys.Contains(assetName))
     {
         SpriteFont font = Manager.Content.Load <SpriteFont>(assetName);
         Fonts.Add(assetName, font);
         return(font);
     }
     else
     {
         return(Fonts[assetName]);
     }
 }
Ejemplo n.º 27
0
        public static void AddFont(string name, string href)
        {
            if (Fonts.ContainsKey(name))
            {
                var hrefCurrent = MediaQueries[name];

                if (hrefCurrent.Equals(href, StringComparison.InvariantCultureIgnoreCase))
                {
                    return;
                }
            }

            Fonts.Add(name, href);
        }
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            // Load textures
            Textures.Add("Marble", Content.Load <Texture2D>("Marble"));
            Textures.Add("Balloon", Content.Load <Texture2D>("Balloon"));
            // Loat fonts
            Fonts.Add("Miramonte", Content.Load <SpriteFont>("Miramonte"));

            // Reset the game
            ResetGame();
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Load a font.
        /// </summary>
        /// <param name="filename">The filename of the font to load.</param>
        /// <returns>The loaded font.</returns>
        public static Font GetFont(string filename)
        {
            ValidateFilename(filename);

            if (Fonts.ContainsKey(filename))
            {
                return(Fonts[filename]);
            }

            Font font = new Font(filename);

            Fonts.Add(filename, font);
            return(font);
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Loads the embedded <c>IBM.font</c> files. Sets the <see cref="DefaultFont"/> property.
        /// </summary>
        /// <param name="defaultFont">An optional font to load and set as the default.</param>
        /// <remarks>
        /// If <paramref name="defaultFont"/> is <see langword="null"/>, the <see cref="EmbeddedFont"/> or <see cref="EmbeddedFontExtended"/> font is set based on the value of <see cref="Settings.UseDefaultExtendedFont"/>.
        /// </remarks>
        protected void LoadDefaultFonts(string defaultFont)
        {
            // Load the embedded fonts.
            System.Reflection.Assembly assembly = typeof(SadConsole.SadFont).Assembly;

            SadFont LoadFont(string fontName)
            {
                using Stream stream   = assembly.GetManifestResourceStream(fontName);
                using StreamReader sr = new StreamReader(stream);

                SerializerPathHint = "";

                LoadingEmbeddedFont = true;
                var masterFont = (SadFont)Newtonsoft.Json.JsonConvert.DeserializeObject(
                    sr.ReadToEnd(),
                    typeof(SadFont),
                    new Newtonsoft.Json.JsonSerializerSettings()
                {
                    TypeNameHandling = Newtonsoft.Json.TypeNameHandling.All,
                    Converters       = null
                });

                LoadingEmbeddedFont = false;

                Fonts.Add(masterFont.Name, masterFont);

                return(masterFont);
            }

            EmbeddedFont         = LoadFont("SadConsole.Resources.IBM.font");
            EmbeddedFontExtended = LoadFont("SadConsole.Resources.IBM_ext.font");

            // Configure default font
            if (string.IsNullOrEmpty(defaultFont))
            {
                if (Settings.UseDefaultExtendedFont)
                {
                    DefaultFont = EmbeddedFontExtended;
                }
                else
                {
                    DefaultFont = EmbeddedFont;
                }
            }
            else
            {
                DefaultFont = this.LoadFont(defaultFont);
            }
        }