Esempio n. 1
0
 public GlyphString(GlyphString copy)
 {
     Glyphs = new List <Glyph>();
     foreach (var v in copy.Glyphs)
     {
         Glyphs.Add(new Glyph(v));
     }
 }
        GlyphString BuildGlyphs()
        {
            //We have to copy these because if we modify them we change the unique id of this metaresource
            GlyphString glyphs = new GlyphString();

            foreach (Glyph g in Glyphs.Glyphs)
            {
                glyphs.Glyphs.Add(new Glyph(g));
            }

            foreach (Glyph g in new List <Glyph>(glyphs.Glyphs))
            {
                g.Position += new Vector3(Offset.X, Offset.Y, 0);

                if (Overflow == TextOverflow.Truncate)
                {
                    if (g.Position.X + g.Size.X >= Size.X)
                    {
                        glyphs.Glyphs.Remove(g);
                    }
                    else if (g.Position.Y + g.Size.Y >= Size.Y)
                    {
                        glyphs.Glyphs.Remove(g);
                    }
                    else if (g.Position.X < 0)
                    {
                        glyphs.Glyphs.Remove(g);
                    }
                    else if (g.Position.Y < 0)
                    {
                        glyphs.Glyphs.Remove(g);
                    }
                }
                else if (Overflow == TextOverflow.Hide)
                {
                    Vector2 oldSize = g.Size;

                    if (g.Position.X >= Size.X)
                    {
                        glyphs.Glyphs.Remove(g);
                    }
                    else if (g.Position.X + g.Size.X >= Size.X)
                    {
                        g.Size.X = Size.X - g.Position.X; g.UVMax.X = g.UVMin.X + (g.UVMax.X - g.UVMin.X) * g.Size.X / oldSize.X;
                    }

                    if (g.Position.Y >= Size.Y)
                    {
                        glyphs.Glyphs.Remove(g);
                    }
                    else if (g.Position.Y + g.Size.Y >= Size.Y)
                    {
                        g.Size.Y = Size.Y - g.Position.Y; g.UVMax.Y = g.UVMin.Y + (g.UVMax.Y - g.UVMin.Y) * g.Size.Y / oldSize.Y;
                    }

                    if (g.Position.X + g.Size.X < 0)
                    {
                        glyphs.Glyphs.Remove(g);
                    }
                    else if (g.Position.X < 0)
                    {
                        g.Size.X = g.Size.X + g.Position.X; g.Position.X = 0; g.UVMin.X = g.UVMax.X - (g.UVMax.X - g.UVMin.X) * g.Size.X / oldSize.X;
                    }

                    if (g.Position.Y + g.Size.Y < 0)
                    {
                        glyphs.Glyphs.Remove(g);
                    }
                    else if (g.Position.Y < 0)
                    {
                        g.Size.Y = g.Size.Y + g.Position.Y; g.Position.Y = 0; g.UVMin.Y = g.UVMax.Y - (g.UVMax.Y - g.UVMin.Y) * g.Size.Y / oldSize.Y;
                    }
                }
            }
            foreach (Glyph g in new List <Glyph>(glyphs.Glyphs))
            {
                g.Position = new Vector3((int)g.Position.X, (int)g.Position.Y, (int)g.Position.Z);
            }

            return(glyphs);
        }
 public GlyphsGraphic()
 {
     Glyphs   = new GlyphString();
     Overflow = TextOverflow.Ignore;
 }