Exemplo n.º 1
0
        public static FontFile Load(string filename)
        {
            IFontLoader fontLoader = GetFontLoader(filename);
            FontFile    fontFile   = fontLoader.ReadFile(filename);

            return(fontFile);
        }
Exemplo n.º 2
0
        static (bool success, Typeface typeface) TryGetFromAssets(this string fontName)
        {
            //First check Alias
            var(hasFontAlias, fontPostScriptName) = FontRegistrar.HasFont(fontName);
            if (hasFontAlias)
            {
                return(true, Typeface.CreateFromFile(fontPostScriptName));
            }

            var isAssetFont = IsAssetFontFamily(fontName);

            if (isAssetFont)
            {
                return(LoadTypefaceFromAsset(fontName));
            }

            var folders = new[]
            {
                "",
                "Fonts/",
                "fonts/",
            };


            //copied text
            var fontFile = FontFile.FromString(fontName);

            if (!string.IsNullOrWhiteSpace(fontFile.Extension))
            {
                var(hasFont, fontPath) = FontRegistrar.HasFont(fontFile.FileNameWithExtension());
                if (hasFont)
                {
                    return(true, Typeface.CreateFromFile(fontPath));
                }
            }
            else
            {
                foreach (var ext in FontFile.Extensions)
                {
                    var formated = fontFile.FileNameWithExtension(ext);
                    var(hasFont, fontPath) = FontRegistrar.HasFont(formated);
                    if (hasFont)
                    {
                        return(true, Typeface.CreateFromFile(fontPath));
                    }

                    foreach (var folder in folders)
                    {
                        formated = $"{folder}{fontFile.FileNameWithExtension()}#{fontFile.PostScriptName}";
                        var result = LoadTypefaceFromAsset(formated);
                        if (result.success)
                        {
                            return(result);
                        }
                    }
                }
            }

            return(false, null);
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="fntFilePath"></param>
        /// <param name="fontTexturePath"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public static BitmapFontRenderer AddBMFont(string fntFilePath, string fontTexturePath, string name)
        {
            if (!fontRenderers.ContainsKey(name))
            {
                string _fntFilePath     = System.IO.Path.Combine(SceneManager.GameProject.ProjectPath, fntFilePath);
                string _textureFilePath = System.IO.Path.Combine(SceneManager.GameProject.ProjectPath, fontTexturePath);

#if WINDOWS
                if (File.Exists(_fntFilePath) && File.Exists(_textureFilePath))
#elif WINRT
                if (MetroHelper.AppDataFileExists(_fntFilePath) && MetroHelper.AppDataFileExists(_textureFilePath))
#endif
                {
                    FontFile  fontFile    = FontLoader.Load(_fntFilePath);
                    Texture2D fontTexture = TextureLoader.FromFile(_textureFilePath);

                    BitmapFontRenderer fr = new BitmapFontRenderer(fontFile, fontTexture);
                    fontRenderers[name] = fr;

                    return(fr);
                }
            }

            return(null);
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            var v = Assembly.GetExecutingAssembly().GetName().Version;

            version = new Version(v.Major, v.Minor, v.Build);
            Project.currentYafcVersion          = version;
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                NativeLibrary.SetDllImportResolver(typeof(SDL).Assembly, DllResolver);
                NativeLibrary.SetDllImportResolver(typeof(Ui).Assembly, DllResolver);
                NativeLibrary.SetDllImportResolver(typeof(LuaContext).Assembly, DllResolver);
            }

            Ui.Start();
            Font.header = new Font(new FontFile("Data/Roboto-Light.ttf"), 2f);
            var regular = new FontFile("Data/Roboto-Regular.ttf");

            Font.subheader = new Font(regular, 1.5f);
            Font.text      = new Font(regular, 1f);
            var window = new WelcomeScreen();

            Analysis.RegisterAnalysis(Milestones.Instance);
            Analysis.RegisterAnalysis(AutomationAnalysis.Instance);
            Analysis.RegisterAnalysis(CostAnalysis.Instance);
            Ui.MainLoop();
        }
Exemplo n.º 5
0
    public void InitializeFont()
    {
        if (fontConfig != null && fontMaterials.Length > 0)
        {
            _fontFile = FontLoader.LoadFromString(fontConfig.text);
            if (_fontFile.Pages.Count != fontMaterials.Length)
            {
                Debug.LogError("Materials count don't match!");
                return;
            }

            _indexLists = new List <List <int> >();
            for (int i = 0; i < _fontFile.Pages.Count; ++i)
            {
                _indexLists.Add(new List <int>());
            }

            _textureSize = new Vector2(_fontFile.Common.ScaleW, _fontFile.Common.ScaleH);
            _charMap     = new Dictionary <int, SpriteChar>();
            for (int i = 0; i < _fontFile.Chars.Count; ++i)
            {
                SpriteChar sc   = new SpriteChar();
                Rect       rect = new Rect(_fontFile.Chars[i].X, _fontFile.Chars[i].Y, _fontFile.Chars[i].Width, _fontFile.Chars[i].Height);
                sc.fontChar = _fontFile.Chars[i];
                sc.rect     = rect;
                _charMap.Add(_fontFile.Chars[i].ID, sc);
            }

            Debug.Log("Font Initialized");
        }
    }
Exemplo n.º 6
0
 public override int GetHashCode()
 {
     unchecked
     {
         return(((FontFile != null ? FontFile.GetHashCode() : 0) * 397) ^ (Name != null ? Name.GetHashCode() : 0));
     }
 }
Exemplo n.º 7
0
        private static string CleanseFontName(string fontName)
        {
            //First check Alias
            (bool hasFontAlias, string fontPostScriptName) = FontRegistrar.HasFont(fontName);
            if (hasFontAlias)
            {
                return(fontPostScriptName);
            }

            FontFile fontFile = FontFile.FromString(fontName);

            if (!string.IsNullOrWhiteSpace(fontFile.Extension))
            {
                (bool hasFont, string filePath) = FontRegistrar.HasFont(fontFile.FileNameWithExtension());
                if (hasFont)
                {
                    return(filePath ?? fontFile.PostScriptName);
                }
            }
            else
            {
                foreach (string ext in FontFile.Extensions)
                {
                    string formated = fontFile.FileNameWithExtension(ext);
                    (bool hasFont, string filePath) = FontRegistrar.HasFont(formated);
                    if (hasFont)
                    {
                        return(filePath);
                    }
                }
            }

            return(fontFile.PostScriptName);
        }
Exemplo n.º 8
0
        static string CleanseFontName(string fontName)
        {
            var fontFile = FontFile.FromString(fontName);

            if (!string.IsNullOrWhiteSpace(fontFile.Extension))
            {
                var(hasFont, _) = FontRegistrar.HasFont(fontFile.FileNameWithExtension());
                if (hasFont)
                {
                    return(fontFile.PostScriptName);
                }
            }
            else
            {
                foreach (var ext in FontFile.Extensions)
                {
                    var formated = fontFile.FileNameWithExtension(ext);
                    var(hasFont, filePath) = FontRegistrar.HasFont(formated);
                    if (hasFont)
                    {
                        return(fontFile.PostScriptName);
                    }
                }
            }
            return(fontFile.PostScriptName);
        }
Exemplo n.º 9
0
        private List <byte> GetBitmapFromGrid(FontFile fontFile, Glyph glyph)
        {
            List <byte> returnValue = new List <byte>();

            if (glyph != null)
            {
                (int baseline, int topRow, int bottomRow) = this.GetGlyphParameters(fontFile, glyph);

                for (int row = topRow; row <= bottomRow; row++)
                {
                    byte b = 0;

                    for (int column = 0; column < glyph.Width; column++)
                    {
                        Border border = this.GetBorderObject(row, column);
                        byte   bit    = ((BorderTag)border.Tag).IsOn ? (byte)1 : (byte)0;
                        b = (byte)((b << 1) + bit);
                    }

                    returnValue.Add(b);
                }
            }

            return(returnValue);
        }
Exemplo n.º 10
0
        public void LoadContent(ContentManager cm)
        {
            //Start by loading all textures
            //playerTexture = cm.Load<Texture2D>("player.png");
            // fontTexture = cm.Load<Texture2D>("basicFont.png");

            thirstTexture = cm.Load <Texture2D>("waterBottle.png");

            hungerTexture = cm.Load <Texture2D>("apple.png");


            string fontFilePath = Path.Combine(cm.RootDirectory, "Fonts/font.fnt");

            fontFile     = FontLoader.Load(fontFilePath);
            fontTexture  = cm.Load <Texture2D>("Fonts/font_0.png");
            fontRenderer = new FontRenderer(fontFile, fontTexture);


            sizingRectangle = new Rectangle(0, 0, 211, 40);
            displays        = new List <Display>();
            //addDisplay(0, 0,


            //testing
            //displays.Add(new Display(0, 0, "12S red"));

            //Then assign textures to NPCs depending on their tag
            // thePlayer.sprite = playerTexture;
        }
Exemplo n.º 11
0
            public static void Save(Stream stream, FontFile file)
            {
                XmlSerializer serializer = new XmlSerializer(typeof(FontFile));
                StreamWriter  textWriter = new StreamWriter(stream);

                serializer.Serialize(textWriter, file);
                textWriter.Close();
            }
Exemplo n.º 12
0
            public static FontFile LoadFromString(string text)
            {
                XmlSerializer deserializer = new XmlSerializer(typeof(FontFile));
                TextReader    textReader   = new StringReader(text);
                FontFile      file         = (FontFile)deserializer.Deserialize(textReader);

                //textReader.Close();
                return(file);
            }
Exemplo n.º 13
0
            public static FontFile Load(Stream stream)
            {
                XmlSerializer deserializer = new XmlSerializer(typeof(FontFile));
                TextReader    textReader   = new StreamReader(stream);
                FontFile      file         = (FontFile)deserializer.Deserialize(textReader);

                textReader.Close();
                return(file);
            }
Exemplo n.º 14
0
            public static string SaveToString(FontFile file)
            {
                XmlSerializer serializer = new XmlSerializer(typeof(FontFile));
                var           sb         = new StringBuilder();
                TextWriter    textWriter = new StringWriter(sb);

                serializer.Serialize(textWriter, file);
                return(sb.ToString());
                //textWriter.Close();
            }
Exemplo n.º 15
0
 public bool MoveNext()
 {
     if (CurrentFontFile == null)
     {
         CurrentFontFile = _fontFile;
         return true;
     }
     CurrentFontFile = null;
     return false;
 }
Exemplo n.º 16
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Returns HashCode</returns>
 public override int GetHashCode()
 {
     return(String.Format("{0}|{1}|{2}|{3}|{4}",
                          BackgroundFile?.GetHashCode() ?? 0,
                          ColorFile?.GetHashCode() ?? 0,
                          FontFile?.GetHashCode() ?? 0,
                          Name?.GetHashCode() ?? 0,
                          this.Version.GetHashCode()
                          ).GetHashCode());
 }
Exemplo n.º 17
0
        private static void OnLanguageChange(LocalizedContentManager.LanguageCode code)
        {
            if (_characterMap != null)
            {
                _characterMap.Clear();
            }
            else
            {
                _characterMap = new Dictionary <char, FontChar>();
            }
            if (fontPages != null)
            {
                fontPages.Clear();
            }
            else
            {
                fontPages = new List <Texture2D>();
            }
            switch (code)
            {
            case LocalizedContentManager.LanguageCode.ja:
                FontFile      = loadFont("Fonts\\Japanese");
                fontPixelZoom = 1.75f;
                break;

            case LocalizedContentManager.LanguageCode.zh:
                FontFile      = loadFont("Fonts\\Chinese");
                fontPixelZoom = 1.5f;
                break;

            case LocalizedContentManager.LanguageCode.ru:
                FontFile      = loadFont("Fonts\\Russian");
                fontPixelZoom = 3f;
                break;

            case LocalizedContentManager.LanguageCode.th:
                FontFile      = loadFont("Fonts\\Thai");
                fontPixelZoom = 1.5f;
                break;

            case LocalizedContentManager.LanguageCode.ko:
                FontFile      = loadFont("Fonts\\Korean");
                fontPixelZoom = 1.5f;
                break;
            }
            foreach (FontChar fontCharacter in FontFile.Chars)
            {
                char c = (char)fontCharacter.ID;
                _characterMap.Add(c, fontCharacter);
            }
            foreach (FontPage fontPage in FontFile.Pages)
            {
                fontPages.Add(Game1.content.Load <Texture2D>("Fonts\\" + fontPage.File));
            }
        }
Exemplo n.º 18
0
        private static void OnLanguageChange(LocalizedContentManager.LanguageCode code)
        {
            if (SpriteTextHelper._characterMap != null)
            {
                SpriteTextHelper._characterMap.Clear();
            }
            else
            {
                SpriteTextHelper._characterMap = new Dictionary <char, FontChar>();
            }
            if (SpriteTextHelper.fontPages != null)
            {
                SpriteTextHelper.fontPages.Clear();
            }
            else
            {
                SpriteTextHelper.fontPages = new List <Texture2D>();
            }
            switch (code)
            {
            case LocalizedContentManager.LanguageCode.ja:
                SpriteTextHelper.FontFile = SpriteTextHelper.LoadFont("Fonts\\Japanese");
                SpriteText.fontPixelZoom  = 1.75f;
                break;

            case LocalizedContentManager.LanguageCode.ru:
                SpriteTextHelper.FontFile = SpriteTextHelper.LoadFont("Fonts\\Russian");
                SpriteText.fontPixelZoom  = 3f;
                break;

            case LocalizedContentManager.LanguageCode.zh:
                SpriteTextHelper.FontFile = SpriteTextHelper.LoadFont("Fonts\\Chinese");
                SpriteText.fontPixelZoom  = 1.5f;
                break;

            case LocalizedContentManager.LanguageCode.th:
                SpriteTextHelper.FontFile = SpriteTextHelper.LoadFont("Fonts\\Thai");
                SpriteText.fontPixelZoom  = 1.5f;
                break;

            case LocalizedContentManager.LanguageCode.ko:
                SpriteTextHelper.FontFile = SpriteTextHelper.LoadFont("Fonts\\Korean");
                SpriteText.fontPixelZoom  = 1.5f;
                break;
            }
            foreach (FontChar fontChar in SpriteTextHelper.FontFile.Chars)
            {
                char id = (char)fontChar.ID;
                SpriteTextHelper._characterMap.Add(id, fontChar);
            }
            foreach (FontPage page in SpriteTextHelper.FontFile.Pages)
            {
                SpriteTextHelper.fontPages.Add(Game1.content.Load <Texture2D>("Fonts\\" + page.File));
            }
        }
Exemplo n.º 19
0
        private static void SetUpCharacterMap()
        {
            if (!LocalizedContentManager.CurrentLanguageLatin && SpriteTextHelper._characterMap == null)
            {
                SpriteTextHelper._characterMap = new Dictionary <char, FontChar>();
                SpriteTextHelper.fontPages     = new List <Texture2D>();
                switch (LocalizedContentManager.CurrentLanguageCode)
                {
                case LocalizedContentManager.LanguageCode.ja:
                    SpriteTextHelper.FontFile = SpriteTextHelper.LoadFont("Fonts\\Japanese");
                    SpriteText.fontPixelZoom  = 1.75f;
                    break;

                case LocalizedContentManager.LanguageCode.ru:
                    SpriteTextHelper.FontFile = SpriteTextHelper.LoadFont("Fonts\\Russian");
                    SpriteText.fontPixelZoom  = 3f;
                    break;

                case LocalizedContentManager.LanguageCode.zh:
                    SpriteTextHelper.FontFile = SpriteTextHelper.LoadFont("Fonts\\Chinese");
                    SpriteText.fontPixelZoom  = 1.5f;
                    break;

                case LocalizedContentManager.LanguageCode.th:
                    SpriteTextHelper.FontFile = SpriteTextHelper.LoadFont("Fonts\\Thai");
                    SpriteText.fontPixelZoom  = 1.5f;
                    break;

                case LocalizedContentManager.LanguageCode.ko:
                    SpriteTextHelper.FontFile = SpriteTextHelper.LoadFont("Fonts\\Korean");
                    SpriteText.fontPixelZoom  = 1.5f;
                    break;
                }
                foreach (FontChar fontChar in SpriteTextHelper.FontFile.Chars)
                {
                    char id = (char)fontChar.ID;
                    SpriteTextHelper._characterMap.Add(id, fontChar);
                }

                foreach (FontPage page in SpriteTextHelper.FontFile.Pages)
                {
                    SpriteTextHelper.fontPages.Add(Game1.content.Load <Texture2D>("Fonts\\" + page.File));
                }
                LocalizedContentManager.OnLanguageChange += new LocalizedContentManager.LanguageChangedHandler(SpriteTextHelper.OnLanguageChange);
            }
            else
            {
                if (!LocalizedContentManager.CurrentLanguageLatin || (double)SpriteText.fontPixelZoom >= 3.0)
                {
                    return;
                }
                SpriteText.fontPixelZoom = 3f;
            }
        }
Exemplo n.º 20
0
        public FontRenderer (FontFile fontFile, Texture2D fontTexture)
        {
                _fontFile = fontFile;
                _texture = fontTexture;
                _characterMap = new Dictionary<char, FontChar>();

                foreach(var fontCharacter in _fontFile.Chars)
                {
                        char c = (char)fontCharacter.ID;
                        _characterMap.Add(c, fontCharacter);
                }
        }
Exemplo n.º 21
0
        public void LoadFile(string path)
        {
            if (path == null)
            {
                return;
            }

            // Check if its a PCK
            if (path.ToLowerInvariant().Contains(".pck"))
            {
                LoadFontPCK(path);
                return;
            }

            // Check if file is valid and make sure FilePath is the .code
            if (path.ToLowerInvariant().Contains("_data.tex") || path.ToLowerInvariant().Contains(".code"))
            {
                FilePath = path.Replace("_data.tex", ".code");
            }
            else
            {
                MessageBox.Show($"Unknown file type\n{path}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            // Recreate Objects
            FontImageTexFile           = new TEXFile();
            FontCodeFile               = new FontFile();
            FontCodeFile.MonospaceOnly = MonospaceOnly;

            try
            {
                // Load Font TEX
                FontImageTexFile.Load(FilePath.Replace(".code", "_data.tex"));
                UI_FontImage.Source = ImageTools.ConvertToSource(FontImageTexFile.CreateBitmap());
            }
            catch
            {
                MessageBox.Show("Failed to load Texture!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            LastIndex  = -1;
            HoverIndex = -1;

            // Load FontCode
            FontCodeFile.Load(FilePath);

            // Reload
            ReloadUI();

            UI_SaveButton.IsEnabled = true;
        }
Exemplo n.º 22
0
        private void Load(string filename)
        {
            XmlSerializer deserializer = new XmlSerializer(typeof(FontFile));
            TextReader    textReader   = new StreamReader(filename);
            FontFile      file         = (FontFile)deserializer.Deserialize(textReader);

            textReader.Close();
            foreach (var fontCharacter in file.Chars)
            {
                char c = (char)fontCharacter.ID;
                _characterMap.Add(c, new BmpFontChar(fontCharacter));
            }
        }
Exemplo n.º 23
0
        public override FontFile Handle(string line, FontFile fontFile)
        {
            Dictionary <string, string> dict = CreateDictionary(line, "page");

            var fontPage = new FontPage
            {
                ID   = Convert.ToInt32(dict["id"]),
                File = dict["file"]
            };

            fontFile.Pages.Add(fontPage);

            return(fontFile);
        }
Exemplo n.º 24
0
        static IEnumerable <string> GetAllFontPossibilities(string fontFamily)
        {
            const string path = "Assets/Fonts/";

            string[] extensions = new[]
            {
                ".ttf",
                ".otf",
            };

            var fontFile = FontFile.FromString(fontFamily);
            //If the extension is provided, they know what they want!
            var hasExtension = !string.IsNullOrWhiteSpace(fontFile.Extension);

            if (hasExtension)
            {
                var(hasFont, filePath) = FontRegistrar.HasFont(fontFile.FileNameWithExtension());
                if (hasFont)
                {
                    var formated = $"{filePath}#{fontFile.GetPostScriptNameWithSpaces()}";
                    yield return(formated);

                    yield break;
                }
                else
                {
                    yield return($"{path}{fontFile.FileNameWithExtension()}");
                }
            }
            foreach (var ext in extensions)
            {
                var(hasFont, filePath) = FontRegistrar.HasFont(fontFile.FileNameWithExtension(ext));
                if (hasFont)
                {
                    var formatted = $"{filePath}#{fontFile.GetPostScriptNameWithSpaces()}";
                    yield return(formatted);

                    yield break;
                }
            }

            //Always send the base back
            yield return(fontFamily);

            foreach (var ext in extensions)
            {
                var formatted = $"{path}{fontFile.FileNameWithExtension(ext)}#{fontFile.GetPostScriptNameWithSpaces()}";
                yield return(formatted);
            }
        }
Exemplo n.º 25
0
        static void Main(string[] args)
        {
            YafcLib.Init();
            YafcLib.RegisterDefaultAnalysis();
            Ui.Start();
            Font.header = new Font(new FontFile("Data/Roboto-Light.ttf"), 2f);
            var regular = new FontFile("Data/Roboto-Regular.ttf");

            Font.subheader = new Font(regular, 1.5f);
            Font.text      = new Font(regular, 1f);
            var window = new WelcomeScreen();

            Ui.MainLoop();
        }
Exemplo n.º 26
0
        private static void setUpCharacterMap()
        {
            if (!LocalizedContentManager.CurrentLanguageLatin && _characterMap == null)
            {
                _characterMap = new Dictionary <char, FontChar>();
                fontPages     = new List <Texture2D>();
                switch (LocalizedContentManager.CurrentLanguageCode)
                {
                case LocalizedContentManager.LanguageCode.ja:
                    FontFile      = loadFont("Fonts\\Japanese");
                    fontPixelZoom = 1.75f;
                    break;

                case LocalizedContentManager.LanguageCode.zh:
                    FontFile      = loadFont("Fonts\\Chinese");
                    fontPixelZoom = 1.5f;
                    break;

                case LocalizedContentManager.LanguageCode.ru:
                    FontFile      = loadFont("Fonts\\Russian");
                    fontPixelZoom = 3f;
                    break;

                case LocalizedContentManager.LanguageCode.th:
                    FontFile      = loadFont("Fonts\\Thai");
                    fontPixelZoom = 1.5f;
                    break;

                case LocalizedContentManager.LanguageCode.ko:
                    FontFile      = loadFont("Fonts\\Korean");
                    fontPixelZoom = 1.5f;
                    break;
                }
                foreach (FontChar fontCharacter in FontFile.Chars)
                {
                    char c = (char)fontCharacter.ID;
                    _characterMap.Add(c, fontCharacter);
                }
                foreach (FontPage fontPage in FontFile.Pages)
                {
                    fontPages.Add(Game1.content.Load <Texture2D>("Fonts\\" + fontPage.File));
                }
                LocalizedContentManager.OnLanguageChange += OnLanguageChange;
            }
            else if (LocalizedContentManager.CurrentLanguageLatin && fontPixelZoom < 3f)
            {
                fontPixelZoom = 3f;
            }
        }
Exemplo n.º 27
0
        protected void DrawGlyph(FontFile fontFile, Glyph glyph)
        {
            this.ClearGrid();

            if (glyph != null)
            {
                // ***
                // *** Simulate the GFS drawing of this glyph. The cursor would
                // *** be positioned in the bottom left corner of where the
                // *** character would be drawn.
                // ***
                (int baseline, int topRow, int bottomRow) = this.GetGlyphParameters(fontFile, glyph);

                for (int i = 0; i < fontFile.FontHeight; i++)
                {
                    if (i >= topRow && i <= bottomRow)
                    {
                        int byteIndex = i - (fontFile.FontHeight + glyph.yOffset - 1);

                        if (byteIndex >= 0 && byteIndex < glyph.FontBitmap.Count())
                        {
                            byte b = glyph.FontBitmap[byteIndex];
                            int  x = glyph.xOffset;

                            // ***
                            // *** Check each bit.
                            // ***
                            for (int bi = glyph.Width - 1; bi >= 0; bi--)
                            {
                                byte mask = (byte)(1 << bi);
                                bool isOn = (byte)(b & mask) != 0;
                                this.SetPixel(i, x, isOn, isOn ? Colors.Red : Colors.White);

                                x++;
                            }
                        }
                    }
                    else
                    {
                        for (int j = 0; j < glyph.Width; j++)
                        {
                            this.SetPixel(i, j, false, Colors.LightGray, true);
                        }
                    }
                }

                this.SetPixel(baseline, glyph.xOffset + glyph.xAdvance, false, Color.FromArgb(32, 0, 0, 255), true);
            }
        }
Exemplo n.º 28
0
        public static WixEntity[] GetFontFiles()
        {
            var consolaFont = new FontFile(@"..\Computator.NET.Core\Static\fonts\consola.ttf")
            {
                NeverOverwrite = false,
                TrueType       = true,
            };
            var cambriaFont = new FontFile(@"..\Computator.NET.Core\Static\fonts\cambria.ttc")
            {
                NeverOverwrite = false,
                TrueType       = true,
            };

            return(new WixEntity[] { consolaFont, cambriaFont });
        }
Exemplo n.º 29
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="contentManager"></param>
        private void LoadContent(ContentManager contentManager)
        {
            var definitionPath = string.Format("{0}_{1}.fnt", Name, Style);

            using (var contents = File.OpenRead(Path.Combine(contentManager.RootDirectory, definitionPath)))
                _definition = FontLoader.Load(contents);

            // We need to support multiple texture pages for more than plain ASCII text.
            _textures = new Texture2D[_definition.Pages.Count];
            for (int i = 0; i < _definition.Pages.Count; i++)
            {
                var texturePath = string.Format("{0}_{1}_{2}.png", Name, Style, i);
                _textures[i] = contentManager.Load <Texture2D>(texturePath);
            }
        }
Exemplo n.º 30
0
        protected (int, int, int) GetGlyphParameters(FontFile fontFile, Glyph glyph)
        {
            (int baseline, int topRow, int bottomRow) = (0, 0, 0);

            // ***
            // *** Simulate the GFS drawing of this glyph. The cursor would
            // *** be positioned in the bottom left corner of where the
            // *** character would be drawn.
            // ***
            baseline  = fontFile.FontHeight - 1;
            topRow    = baseline + glyph.yOffset;
            bottomRow = topRow + glyph.Height - 1;

            return(baseline, topRow, bottomRow);
        }
Exemplo n.º 31
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="contentManager"></param>
        private void LoadContent(ContentManager contentManager)
        {
            var definitionPath = string.Format("{0}_{1}.fnt", Name, Style);
            using (var contents = File.OpenRead(Path.Combine(contentManager.RootDirectory, definitionPath)))
                _definition = FontLoader.Load(contents);

            if (_textures != null)
            {
                for (int i = 0; i < _textures.Length; i++)
                {
                    _textures[i].Dispose();
                }
            }

            // We need to support multiple texture pages for more than plain ASCII text.
            _textures = new Texture2D[_definition.Pages.Count];
            for (int i = 0; i < _definition.Pages.Count; i++)
            {
                var texturePath = string.Format("{0}_{1}_{2}.png", Name, Style, i);
                _textures[i] = contentManager.Load<Texture2D>(texturePath);
            }
        }
Exemplo n.º 32
0
			public static string SaveToString ( FontFile file )
			{
				XmlSerializer serializer = new XmlSerializer( typeof( FontFile ) );
				var sb = new StringBuilder();
				TextWriter textWriter = new StringWriter( sb );
				serializer.Serialize( textWriter, file );
				return sb.ToString();
				//textWriter.Close();
			}
Exemplo n.º 33
0
 public static void Save( Stream stream, FontFile file )
 {
     XmlSerializer serializer = new XmlSerializer( typeof( FontFile ) );
     StreamWriter textWriter = new StreamWriter( stream );
     serializer.Serialize( textWriter, file );
     textWriter.Close();
 }