Exemplo n.º 1
0
        public DigitalFont()
        {
            Glyphs.Add('0', Zero());
            Glyphs.Add('1', One());
            Glyphs.Add('2', Two());
            Glyphs.Add('3', Three());
            Glyphs.Add('4', Four());
            Glyphs.Add('5', Five());
            Glyphs.Add('6', Six());
            Glyphs.Add('7', Seven());
            Glyphs.Add('8', Eight());
            Glyphs.Add('9', Nine());
            Glyphs.Add(':', Colon());
            Glyphs.Add('-', Dash());
            Glyphs.Add('/', Slash());
            Glyphs.Add('\\', Backslash());

            Glyphs.Add('F', F());
            Glyphs.Add('P', P());
            Glyphs.Add('A', A());
            Glyphs.Add('M', M());
            Glyphs.Add('S', S());

            Glyphs.Add(' ', Space());
            Glyphs.Add('\t', Tab());
        }
Exemplo n.º 2
0
        public void SaveMcmFile(string filePath)
        {
            using (StreamWriter sw = new StreamWriter(filePath))
            {
                sw.Write("MAX7456");

                foreach (var glyph in Glyphs.OrderBy(g => g.Id))
                {
                    int glyphGlyphDataLength = glyph.GlyphData.Length;
                    for (int i = 0; i < 256; i++)
                    {
                        if (i % 4 == 0)
                        {
                            sw.Write("\n");
                        }

                        if (i >= glyphGlyphDataLength)
                        {
                            sw.Write("01");
                            continue;
                        }

                        sw.Write(String.Format("{0}{1}", (glyph.GlyphData[i] >> 1) & 1, glyph.GlyphData[i] & 1));
                    }
                }
                sw.Close();
            }
        }
Exemplo n.º 3
0
        public void LoadData()
        {
            //File.Seek(0);

            UnitsPerEm = File.GetUint16();
            XMin       = File.GetInt16();
            YMin       = File.GetInt16();
            XMax       = File.GetInt16();
            YMax       = File.GetInt16();

            var c = File.GetInt32();

            for (int i = 0; i < c; i++)
            {
                var g = new CGLFGlyph();

                g.YMin = File.GetInt16();
                g.YMax = File.GetInt16();
                g.XMax = File.GetInt16();
                g.XMin = File.GetInt16();

                var triangleCount = File.GetInt32();

                for (int j = 0; j < triangleCount; j++)
                {
                    var at      = new Point(File.GetInt32(), File.GetInt32());
                    var bt      = new Point(File.GetInt32(), File.GetInt32());
                    var ct      = new Point(File.GetInt32(), File.GetInt32());
                    var trianle = new Triangle(at, bt, ct);

                    g.Triangles.Add(trianle);
                    Glyphs.Add(g);
                }
            }
        }
Exemplo n.º 4
0
        public static void LoadGlyphs()
        {
            // Construct a directory of Glyphs
            var glyphDirectory = new DirectoryInfo(Path.Combine(Path.GetDirectoryName(Assembly), "Glyphs"));

            // Loop through all of the directories and map the glyphs to their appropriate libraries
            foreach (var directory in glyphDirectory.EnumerateDirectories())
            {
                // Instantiate the dictionary with the name of the library
                Glyphs.Add(directory.Name, new Dictionary <string, LazyImage>());
                // Iterate through all of the glyphs in this dictionary
                foreach (var glyph in directory.EnumerateFiles("*.png", SearchOption.AllDirectories))
                {
                    try
                    {
                        // Created a lazily loaded glyph that points to the appropriate path
                        Glyphs[directory.Name].Add(Path.GetFileNameWithoutExtension(glyph.Name), new LazyImage {
                            Path = new Uri(glyph.FullName, UriKind.RelativeOrAbsolute)
                        });
                    }
                    catch (Exception)
                    {
                        // An error occurred when creating the glyph, ignore it (it will be handled in the provider)
                    }
                }
            }
        }
Exemplo n.º 5
0
        public override Glyph GetGlyph(char c)
        {
            Glyph glyph;

            if (!Glyphs.TryGetValue(c, out glyph))
            {
                uint glyphIndex = Face.GetCharIndex(c);
                if (glyphIndex == 0)
                {
                    return(null);
                }

                byte[] bufferData;
                Face.LoadGlyph(glyphIndex, LoadFlags.Default, LoadTarget.Normal);
                if (Face.Glyph.Metrics.Width == 0)
                {
                    bufferData = new Byte[0];
                }
                else
                {
                    Face.Glyph.RenderGlyph(RenderMode.Normal);
                    bufferData = Face.Glyph.Bitmap.BufferData;
                }
                glyph = new TTFGlyph(c, glyphIndex, bufferData, Face.Glyph.Metrics, Face.Glyph.BitmapLeft, Graphics);
                Glyphs.Add(c, glyph);
            }

            return(glyph);
        }
        private SourceViewerForm(Form parent,string path,ArrayList lines)
        {
            if (m_glyphs == null)
            {
                m_glyphs = new Glyphs();
            }

            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            m_lineOffset=new int[lines.Count];
            int index=0;
            int c=0;
            StringBuilder sb = new StringBuilder();
            foreach(string line in lines)
            {
                m_lineOffset[c++] = index;
                string lineNoStr = String.Format(CultureInfo.InvariantCulture, "{0,4}:",c);
                sb.Append(lineNoStr);
                sb.Append(line).Append((char)13).Append((char)10);
                index += lineNoStr.Length+line.Length+1;
            }
            richText.Text = sb.ToString();
            MdiParent = parent;
            Visible=true;

            Text = path;
            Debug.Assert(!m_sourceList.Contains(path));
            m_sourceList.Add(path,this);
        }
Exemplo n.º 7
0
        // ---------------------------- FillCanvas ----------------------------
        /// <summary>
        ///   Fills the canvas with predefined glyphs.</summary>
        /// <param name="canvas1">
        ///   The canvas to fill.</param>
        static private void FillCanvas(Canvas canvas1)
        {
            canvas1.Width  = 96 * 8.5;
            canvas1.Height = 96 * 11;
            string fontsPath = Directory.GetCurrentDirectory() + @"\Fonts\";

            Glyphs glyph = new Glyphs();

            glyph.FontUri             = new Uri(fontsPath + "T2Embed.TTF");
            glyph.FontRenderingEmSize = 32;
            glyph.StyleSimulations    = StyleSimulations.None;
            glyph.IsSideways          = false;
            glyph.BidiLevel           = 0;
            Canvas.SetTop(glyph, 0);
            Canvas.SetLeft(glyph, 0);
            glyph.Fill          = Brushes.DarkBlue;
            glyph.UnicodeString = "TopLeft";
            canvas1.Children.Add(glyph);

            glyph                     = new Glyphs();
            glyph.FontUri             = new Uri(fontsPath + "T2Embez.TTF");
            glyph.FontRenderingEmSize = 32;
            glyph.StyleSimulations    = StyleSimulations.None;
            glyph.IsSideways          = false;
            glyph.BidiLevel           = 0;
            Canvas.SetTop(glyph, 0);
            Canvas.SetLeft(glyph, 520);
            glyph.Fill          = Brushes.BurlyWood;
            glyph.UnicodeString = "TopRight";
            canvas1.Children.Add(glyph);
        }
Exemplo n.º 8
0
        public Vector4 DrawString(SpriteBatch batch, Vector2 location, string text, Color color, float scale, float depth)
        {
            var loc     = location;
            var maxLocX = loc.X;

            for (int i = 0; i < text.Length; i++)
            {
                char c = text [i];
                if (c == '\n')
                {
                    loc.X  = location.X;
                    loc.Y += scale * Glyphs [' '].Height;
                }
                else
                {
                    if (!Glyphs.ContainsKey(c))
                    {
                        c = '?';
                    }
                    var rect = Glyphs [c];
                    rect.X += TextureOffsetX;
                    rect.Y += TextureOffsetY;
                    if (batch != null)
                    {
                        batch.Draw(Texture, loc, rect, color, 0.0f, Vector2.Zero, scale, SpriteEffects.None, depth);
                    }
                    loc.X  += scale * rect.Width;
                    maxLocX = Math.Max(loc.X, maxLocX);
                }
            }
            return(new Vector4(location, maxLocX, loc.Y + scale * Glyphs [' '].Height));
        }
Exemplo n.º 9
0
        // ...on the way to handle Indices...
        private void WriteGlyphsInternal(Glyphs glyphs, string text)
        {
            GlyphIndicesComplexity complexity = GlyphIndicesComplexity.None;

            if (glyphs.Indices != null)
            {
                complexity = glyphs.Indices.Complexity;
            }
            complexity = GlyphIndicesComplexity.ClusterMapping;
            switch (complexity)
            {
            case GlyphIndicesComplexity.None:
                break;

            case GlyphIndicesComplexity.DistanceOnly:
                WriteGlyphs_DistanceOnly(glyphs);
                break;

            case GlyphIndicesComplexity.GlyphIndicesAndDistanceOnly:
                break;

            case GlyphIndicesComplexity.ClusterMapping:
                WriteGlyphs_ClusterMapping(glyphs);
                break;
            }
        }
Exemplo n.º 10
0
        public override void Update(TimeSpan time)
        {
            base.Update(time);

            Surface.Clear();

            Surface.Print(1, 0, "Selected Item Details");
            Surface.Fill(0, 1, Width, FrameColor, null, Glyphs.GetGlyph('─'));

            Surface.Fill(1, 3, 15, BackColor, BackColor, null);

            if (Stack == null)
            {
                return;
            }

            DrawName();

            var itemImage = imagesFactory.GetImage(Stack.TopItem);

            if (itemImage != null)
            {
                Surface.DrawImage(3, 6, itemImage, Color.White, BackColor);
            }

            if (Stack.TopItem is IDescriptionProvider descriptionProvider)
            {
                var imageHeight  = itemImage?.Height ?? 0;
                var descriptionY = 6 + 1 + imageHeight;
                DrawDescription(descriptionY, descriptionProvider);
            }
        }
Exemplo n.º 11
0
        private void Write(Glyphs visual)
        {
            var gr = visual.ToGlyphRun();


            Point p = TransformPoint(visual, new Point(visual.OriginX, visual.OriginY));



            //PDFFont font = page.Document.CreateObject<PDFFont>();
            //page.Resources.Font["F1"] = font;
            //font.Subtype = "Type1";
            //font.BaseFont = "Helvetica";
            //font.Encoding = "MacRomanEncoding";
            Page.Resources.HasText = true;


            Page.ContentStream.WriteLine("BT");


            Page.ContentStream.WriteLine("/{0} {1} Tf", GetFont(Page.Resources, gr.GlyphTypeface), gr.FontRenderingEmSize);
            Page.ContentStream.WriteLine("{0} {1} Td", p.X, p.Y);

            if (visual.Fill != null)
            {
                WriteFill(visual.Fill);
            }

            Page.ContentStream.WriteLine("({0}) Tj", Encode(visual.UnicodeString));
            Page.ContentStream.WriteLine("ET");
        }
Exemplo n.º 12
0
        public override void DoLayout()
        {
            var i = _number;

            while (i > 0)
            {
                var num = i % 10;
                var gl  = new DigitGlyph(0, 0, num, _scale);
                AddGlyph(gl);
                i = i / 10;
            }
            Glyphs.Reverse();

            var cx = 0f;

            for (int j = 0, k = Glyphs.Count; j < k; j++)
            {
                var g = Glyphs[j];
                g.X        = cx;
                g.Y        = 0;
                g.Renderer = Renderer;
                g.DoLayout();
                cx += g.Width;
            }
            Width = cx;
        }
Exemplo n.º 13
0
        public object DeepCopy()
        {
            var newTable = (GlyfTable)MemberwiseClone();

            newTable.Glyphs = Glyphs.Select(glyph => (Glyph)glyph.DeepCopy()).ToList();
            return(newTable);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Function to build the list of glyphs for the font.
        /// </summary>
        /// <param name="glyphData">The glyph data used to create the glyphs.</param>
        /// <param name="kerningData">The kerning information used to handle spacing adjustment between glyphs.</param>
        private void GenerateGlyphs(Dictionary <char, GlyphInfo> glyphData, Dictionary <char, ABC> kerningData)
        {
            foreach (KeyValuePair <char, GlyphInfo> glyph in glyphData)
            {
                int advance = 0;

                if (kerningData.TryGetValue(glyph.Key, out ABC kernData))
                {
                    advance = kernData.A + (int)kernData.B + kernData.C;
                }

                // For whitespace, we add a dummy glyph (no texture, offset, etc...).
                if (char.IsWhiteSpace(glyph.Key))
                {
                    Glyphs.Add(new GorgonGlyph(glyph.Key, glyph.Value.Region.Width)
                    {
                        Offset = DX.Point.Zero
                    });
                    continue;
                }

                var newGlyph = new GorgonGlyph(glyph.Key, advance)
                {
                    Offset        = glyph.Value.Offset,
                    OutlineOffset = HasOutline ? glyph.Value.OutlineOffset : DX.Point.Zero
                };

                // Assign the texture to each glyph (and its outline if needed).
                newGlyph.UpdateTexture(glyph.Value.Texture, glyph.Value.Region, HasOutline ? glyph.Value.OutlineRegion : DX.Rectangle.Empty, glyph.Value.TextureArrayIndex);

                Glyphs.Add(newGlyph);
            }
        }
Exemplo n.º 15
0
        void BuildGlyphs()
        {
            if (Glyphs == null)
            {
                Glyphs = new List <Glyph>();
            }

            Glyphs.Clear();
            float innerWidth  = Size.X - Border.X * 2;
            float innerHeight = Size.Y - Border.Y * 2;

            Glyphs.Add(GetGlyph(Orientation.TopLeft, new Vector3(0, 0, 0), new Vector2(Border.X, Border.Y), TextureSize));
            Glyphs.Add(GetGlyph(Orientation.Top, new Vector3(Border.X, 0, 0), new Vector2(innerWidth, Border.Y), TextureSize));
            Glyphs.Add(GetGlyph(Orientation.TopRight, new Vector3(Border.X + innerWidth, 0, 0), new Vector2(Border.X, Border.Y), TextureSize));
            Glyphs.Add(GetGlyph(Orientation.Left, new Vector3(0, Border.Y, 0), new Vector2(Border.X, innerHeight), TextureSize));
            Glyphs.Add(GetGlyph(Orientation.Right, new Vector3(Border.X + innerWidth, Border.Y, 0), new Vector2(Border.X, innerHeight), TextureSize));
            Glyphs.Add(GetGlyph(Orientation.BottomLeft, new Vector3(0, Border.Y + innerHeight, 0), new Vector2(Border.X, Border.Y), TextureSize));
            Glyphs.Add(GetGlyph(Orientation.Bottom, new Vector3(Border.X, Border.Y + innerHeight, 0), new Vector2(innerWidth, Border.Y), TextureSize));
            Glyphs.Add(GetGlyph(Orientation.BottomRight, new Vector3(Border.X + innerWidth, Border.Y + innerHeight, 0), new Vector2(Border.X, Border.Y), TextureSize));

            if (BackgroundStyle == BorderBackgroundStyle.Inner)
            {
                Glyphs.Add(GetGlyph(Orientation.Center, new Vector3(Border.X, Border.Y, 0), new Vector2(innerWidth, innerHeight), TextureSize));
            }
            else
            {
                Glyphs.Add(GetGlyph(Orientation.Center, new Vector3(0, 0, 0), new Vector2(Border.X, Border.Y), TextureSize));
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// 递归,获取最子级 文字,查找大夫位置
        /// </summary>
        /// <param name="canvas"></param>
        /// <param name="searchText"></param>
        /// <returns></returns>
        private xps_search_point GetGlyphs(Canvas canvas, string searchText)
        {
            xps_search_point p = new xps_search_point(0, 0, 11);

            for (int i = 0; i < canvas.Children.Count; i++)
            {
                UIElement DocFpUiElem = canvas.Children[i];
                if (DocFpUiElem is Glyphs)
                {
                    Glyphs gps     = (Glyphs)DocFpUiElem;
                    string strMark = gps.UnicodeString;   //找到位置
                    if (strMark.Trim() == searchText)
                    {
                        p = new xps_search_point(gps.OriginX, gps.OriginY, gps.FontRenderingEmSize);
                        break;
                    }
                    textBox1.Text += strMark;
                }
                else if (DocFpUiElem is Canvas)
                {
                    p = GetGlyphs((Canvas)DocFpUiElem, searchText);
                }
            }
            return(p);
        }
Exemplo n.º 17
0
        // Used to open a connection to a Perforce depot
        public void CloseConnection()
        {
            if (SccService.ScmProvider != null)
            {
                BroadcastNewConnection(null);
                SccService.ScmProvider.Dispose();
                SccService.ScmProvider = null;
            }
            SuppressConnection     = false;
            SccService.ScmProvider = null;

            BroadcastNewConnection(SccService.ScmProvider);

            Cursor oldCursor = Cursor.Current;

            try
            {
                Cursor.Current = Cursors.WaitCursor;

                // now refresh the selected nodes' glyphs
                Glyphs.RefreshNodesGlyphs(null, null);

                omcConnectionComboSelChanged.Invoke(Resources.ConnectionDropDownCombo_NoConnection, IntPtr.Zero);
                omcActiveChangelistComboSelChanged.Invoke(Resources.Changelist_Default, IntPtr.Zero);
            }
            catch (Exception ex)
            {
                FileLogger.LogException("P4VsProvider.CloseConnection", ex);
            }
            finally
            {
                Cursor.Current = oldCursor;
            }
        }
Exemplo n.º 18
0
        public void Write(GamePacketWriter writer)
        {
            writer.Write(Guid);
            writer.Write(Unknown0);
            writer.Write(ItemId, 18u);
            LocationData.Write(writer);
            writer.Write(StackCount);
            writer.Write(Charges);
            writer.Write(RandomCircuitData);
            writer.Write(RandomGlyphData);
            writer.Write(ThresholdData);
            writer.Write(Durability);
            writer.Write(Unknown44);
            writer.Write(Unknown48);
            writer.Write(DyeData);
            writer.Write(DynamicFlags);
            writer.Write(ExpirationTimeLeft);

            for (uint i = 0u; i < Unknown58.Length; i++)
            {
                Unknown58[i].Write(writer);
            }

            writer.Write(Unknown70, 18u);

            writer.Write(Microchips.Count, 3u);
            Microchips.ForEach(m => writer.Write(m));
            writer.Write(Glyphs.Count, 4u);
            Glyphs.ForEach(g => writer.Write(g));
            writer.Write(Glyphs.Count, 6u);
            Unknown88.ForEach(u => u.Write(writer));

            writer.Write(Unknown8C);
        }
Exemplo n.º 19
0
 public void ToString(StringBuilder sb)
 {
     if (Glyphs.Count > 0)
     {
         Glyphs.ForEach(c => sb.Append(c.Char));
     }
 }
Exemplo n.º 20
0
        private FontGlyph InternalGetGlyph(int codepoint)
        {
            FontGlyph result;

            Glyphs.TryGetValue(codepoint, out result);

            return(result);
        }
Exemplo n.º 21
0
 public override int GetHashCode()
 {
     return(base.GetHashCode() ^
            Glyphs.GetHashCode() ^
            Texture.GetHashCode() ^
            Offset.GetHashCode() ^
            Overflow.GetHashCode());
 }
Exemplo n.º 22
0
 public override string ToString()
 {
     if (Length == 0)
     {
         return(String.Empty);
     }
     return(Glyphs.Select(g => g.Char).ToString());
 }
Exemplo n.º 23
0
 /// <summary>
 /// We usually just pass this UINT-array to the renderer
 /// </summary>
 /// <returns>The render bytes.</returns>
 public uint[] ToRenderBytes()
 {
     if (Length == 0)
     {
         return(new uint[0]);
     }
     return(Glyphs.Take(Length).Select(g => g.Glyph).ToArray());
 }
Exemplo n.º 24
0
        public int ProjectileDamage(PlayerCharacter character)
        {
            int   constant   = Main.hardMode ? character.Level / 3 : 5;
            float multiplier = Main.expertMode ? 1f : 0.65f;

            multiplier = Glyphs.Aggregate(multiplier, (current, item) => current * ((Glyph)item.modItem).DamageModifier());
            return((int)Math.Round(Math.Pow(1.04, Math.Min(130, character.Level)) * 9f * multiplier) + constant);
        }
Exemplo n.º 25
0
        public Grapheme(List <Glyph> glyphs)
        {
            Initialize();

            var glyphChain = new GlyphChain(glyphs);

            Glyphs.Add(glyphChain);
            Graph = glyphChain.ToString();
        }
Exemplo n.º 26
0
        public static StructMark ExplodeMark(Glyphs gps)
        {
            StructMark result = default(StructMark);
            string     text   = gps.UnicodeString.Replace("{", "").Replace("}", "").Replace(" ", "");

            string[] array = text.Split(new char[]
            {
                ','
            });
            result.fontSize = gps.FontRenderingEmSize;
            result.y        = gps.OriginY;
            result.type     = text.Substring(0, 1);
            if (array[0].Contains("*"))
            {
                result.locat = "E";
            }
            else
            {
                result.locat = "B";
            }
            result.val = array[0].Replace("*", "");
            if (array.Length > 1)
            {
                result.len = Convert.ToInt32(array[1]);
                if (result.type == "%")
                {
                    result.width = (double)Convert.ToInt32(array[1]);
                    if (array.Length > 2)
                    {
                        result.height = (double)Convert.ToInt32(array[2]);
                    }
                }
            }
            else
            {
                if (result.type == "#")
                {
                    result.len = 1;
                }
                else
                {
                    result.len = 255;
                }
            }
            result.x = gps.OriginX;
            if (result.type == "#" && result.locat == "E")
            {
                result.x = gps.OriginX + result.fontSize * (double)(text.Length + 1) / 2.0;
                int len = result.len;
                result.x = result.x - (double)(len * 12) - (double)((len - 1) * 7) - 2.0;
            }
            if (result.type == "$" && result.locat == "E")
            {
                result.x = gps.OriginX + result.fontSize * (double)(text.Length + 2) / 2.0;
            }
            return(result);
        }
Exemplo n.º 27
0
        private void WriteVisual(Visual fp)
        {
            lastVisual = fp;



            FixedPage f = fp as FixedPage;

            if (f != null)
            {
                return;
            }

            Canvas canvas = fp as Canvas;

            if (canvas != null)
            {
                // clip...
                Geometry g = canvas.Clip;
                if (g != null)
                {
                    Page.ContentStream.WriteLine("q");
                    PathGeometry pg = PathGeometry.CreateFromGeometry(g);
                    foreach (var item in pg.Figures)
                    {
                        Point p = TransformPoint(item.StartPoint);
                        Page.ContentStream.WriteLine("{0} {1} m", p.X, p.Y);
                        foreach (var segment in item.Segments)
                        {
                            WriteSegment(segment);
                        }
                        Page.ContentStream.WriteLine("h");
                        Page.ContentStream.WriteLine("W");
                        Page.ContentStream.WriteLine("n");
                    }
                }
                return;
            }

            Path path = fp as Path;

            if (path != null)
            {
                Write(path);
                return;
            }

            Glyphs glyphs = fp as Glyphs;

            if (glyphs != null)
            {
                Write(glyphs);
                return;
            }

            throw new NotImplementedException(fp.GetType() + " not supported.");
        }
Exemplo n.º 28
0
        private void DrawTextureAtlas(System.Drawing.Font font)
        {
            using (var g = System.Drawing.Graphics.FromImage(Image))
            {
                g.Clear(System.Drawing.Color.Transparent);
                g.SmoothingMode     = SmoothingMode.HighQuality;
                g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;

                var brString  = new SolidBrush(System.Drawing.Color.White);
                var brOutline = new SolidBrush(System.Drawing.Color.Black);

                for (int i = 0; i < chars.Length; i++)
                {
                    if (Glyphs.ContainsKey(chars[i]))
                    {
                        continue;
                    }

                    var x    = locations[i].X;
                    var y    = locations[i].Y;
                    var size = sizes[i];

                    var c = chars[i].ToString();

                    if (Outline)
                    {
                        g.DrawString(c, font, brOutline, x - 1, y, StringFormat.GenericTypographic);
                        g.DrawString(c, font, brOutline, x + 1, y, StringFormat.GenericTypographic);
                        g.DrawString(c, font, brOutline, x, y - 1, StringFormat.GenericTypographic);
                        g.DrawString(c, font, brOutline, x, y + 1, StringFormat.GenericTypographic);
                    }
                    g.DrawString(c, font, brString, x, y, StringFormat.GenericTypographic);

                    var glyph = new Glyph
                    {
                        Size = size,
                        UV   = new[]
                        {
                            new Vector2(x / Image.Width, y / Image.Height),
                            new Vector2(
                                (x + size.Width) / Image.Width,
                                (y + size.Height) / Image.Height
                                ),
                        },
                        Code = chars[i]
                    };

                    Glyphs.Add(chars[i], glyph);
                }

                brString.Dispose();
                brOutline.Dispose();
            }

            Image.Save(string.Format("{0} {1}.png", font.FontFamily.Name, (int)font.Size), ImageFormat.Png);
        }
Exemplo n.º 29
0
 public void Get(BinaryWriter writer)
 {
     writer.Write(HeaderSize);
     writer.Write(FileSize);
     writer.Write(UnknownH);
     Glyphs.Get(writer);
     writer.Write(UnknownUShort);
     writer.Write(LastPosition);
     writer.BaseStream.Position = HeaderSize;
 }
Exemplo n.º 30
0
        private void PrintStatStatus(int x, int y, PlayerStats stat, CellSurface surface)
        {
            int symbol = ' ';

            if (SelectedStat.HasValue && SelectedStat.Value == stat)
            {
                symbol = Glyphs.GetGlyph('▲');
            }
            surface.Print(x + maxStatNameLength + 5, y, new ColoredGlyph(symbol, TextHelper.PositiveValueColor.ToXna(), DefaultBackground));
        }
Exemplo n.º 31
0
 virtual protected void Awake()
 {
     map    = FindObjectOfType <Map>();
     glyphs = GetComponentInChildren <Glyphs>();
     if (glyphs)
     {
         glyphsOb = glyphs.gameObject;
         originalGlyphPosition = glyphs.transform.localPosition;
     }
 }
Exemplo n.º 32
0
        // Initialization function. called by derived ctor.

        // parent - main containing window that this source window lives inside of.
        // path - unique string identifier for source window (full pathname)
        // lines - content
        protected void BeginInit(MainForm parent)
        {
            if (m_glyphs == null)
            {
                m_glyphs = new Glyphs();
            }

            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            // Set window properties
            MdiParent = parent;
            Debug.Assert(parent == MainForm);

            // Still not visisible. We return from here, and then caller will initialize content
            // and then call EndInit().
        }
Exemplo n.º 33
0
        public FormattedTextSymbols(
            GlyphingCache glyphingCache,
            TextRun       textSymbols,
            bool          rightToLeft,
            double        scalingFactor,
            TextFormattingMode textFormattingMode,
            bool isSideways
            )
        {

            _textFormattingMode = textFormattingMode;
            _isSideways = isSideways;
            ITextSymbols  symbols = textSymbols as ITextSymbols;

            Debug.Assert(symbols != null);

            // break down a single text run into pieces
            IList<TextShapeableSymbols> shapeables = symbols.GetTextShapeableSymbols(
                glyphingCache,
                textSymbols.CharacterBufferReference,
                textSymbols.Length,
                rightToLeft,  // This is a bool indicating the RTL
                              // based on the bidi level of text (if applicable). 
                              // For FormattedTextSymbols it is equal to paragraph flow direction.

                rightToLeft,  // This is the flow direction of the paragraph as 
                              // specified by the user. DWrite needs the paragraph
                              // flow direction of the paragraph 
                              // while WPF algorithms need the RTL of the text based on 
                              // Bidi if possible.

                null, // cultureInfo
                null,  // textModifierScope
                _textFormattingMode,
                _isSideways
                );

            Debug.Assert(shapeables != null && shapeables.Count > 0);

            _rightToLeft = rightToLeft;
            _glyphs = new Glyphs[shapeables.Count];

            CharacterBuffer charBuffer = textSymbols.CharacterBufferReference.CharacterBuffer;
            int offsetToFirstChar = textSymbols.CharacterBufferReference.OffsetToFirstChar;

            int i = 0;
            int ich = 0;

            while (i < shapeables.Count)
            {
                TextShapeableSymbols current = shapeables[i] as TextShapeableSymbols;
                Debug.Assert(current != null);

                int cch = current.Length;
                int j;

                // make a separate character buffer for glyphrun persistence
                char[] charArray = new char[cch];
                for (j = 0; j < cch; j++)
                    charArray[j] = charBuffer[offsetToFirstChar + ich + j];

                if (current.IsShapingRequired)
                {
                    ushort[] clusterMap;
                    ushort[] glyphIndices;
                    int[] glyphAdvances;
                    GlyphOffset[] glyphOffsets;


                    // 





                    unsafe
                    {
                        fixed (char* fixedCharArray = &charArray[0])
                        {
                            MS.Internal.Text.TextInterface.TextAnalyzer textAnalyzer = MS.Internal.FontCache.DWriteFactory.Instance.CreateTextAnalyzer();

                            GlyphTypeface glyphTypeface = current.GlyphTypeFace;
                            DWriteFontFeature[][] fontFeatures;
                            uint[] fontFeatureRanges;
                            uint unsignedCch = checked((uint)cch);
                            LSRun.CompileFeatureSet(current.Properties.TypographyProperties, unsignedCch, out fontFeatures, out fontFeatureRanges);

                       
                            textAnalyzer.GetGlyphsAndTheirPlacements(
                                (ushort*)fixedCharArray,
                                unsignedCch,
                                glyphTypeface.FontDWrite,
                                glyphTypeface.BlankGlyphIndex,
                                false,   // no sideway support yet
                                /************************************************************************************************/
                                //
                                rightToLeft,
                                current.Properties.CultureInfo,
                                /************************************************************************************************/
                                fontFeatures,
                                fontFeatureRanges,
                                current.Properties.FontRenderingEmSize,
                                scalingFactor,
                                Util.PixelsPerDip,
                                _textFormattingMode,
                                current.ItemProps,
                                out clusterMap,
                                out glyphIndices,
                                out glyphAdvances,
                                out glyphOffsets
                                );
                        }
                        _glyphs[i] = new Glyphs(
                           current,
                           charArray,
                           glyphAdvances,
                           clusterMap,
                           glyphIndices,
                           glyphOffsets,
                           scalingFactor
                           );
                    }
                                        
                }
                else
                {
                    // shaping not required, 
                    // bypass glyphing process altogether
                    int[] nominalAdvances = new int[charArray.Length];
                    
                    unsafe
                    {
                        fixed (char* fixedCharArray = &charArray[0])
                        fixed (int* fixedNominalAdvances = &nominalAdvances[0])
                        {
                            current.GetAdvanceWidthsUnshaped(
                                fixedCharArray,
                                cch,
                                scalingFactor, // format resolution specified per em,
                                fixedNominalAdvances
                                );
                        }
                    }

                    _glyphs[i] = new Glyphs(
                        current,
                        charArray,
                        nominalAdvances,
                        scalingFactor
                        );
                }

                i++;
                ich += cch;
            }
        }