Esempio n. 1
0
        /**
         * create an area that formats a string.
         */
        public static Area String(IFormattingContext context, String str)
        {
            Area      result   = null;
            float     fontSize = context.Size;
            ArrayList list     = null;
            int       start    = 0;

            if (str.Length == 1)
            {
                result = str[0] > '\x7f' ? GlyphFactory.GetGlyph(context, fontSize, str[0]) :
                         new StringArea(context, str);
            }
            else
            {
                start = 0;
                for (int i = 0; i < str.Length; i++)
                {
                    if (str[i] > '\x7f')
                    {
                        if (list == null)
                        {
                            list = new ArrayList();
                        }
                        list.Add(new StringArea(context, str.Substring(start, i - start)));
                        list.Add(GlyphFactory.GetGlyph(context, fontSize, str[i]));
                        start = i + 1;
                    }
                }

                if (list != null)
                {
                    result = Horizontal((Area[])list.ToArray(typeof(Area)));
                }
                else
                {
                    result = new StringArea(context, str);
                }
            }
            return(result);
        }
Esempio n. 2
0
        /**
         * create a new glyph area.
         */

        public static Area GetGlyph(IFormattingContext ctx, float pointSize, char c)
        {
            GlyphFactory gf = Instance;

            Area result = null;

            Debug.WriteLine(String.Format("searching for a glyph for character 0x{0:x}", (uint)c));
            for (int i = 0; i < gf.maps.Length; i++)
            {
                if ((result = gf.maps[i].GetGlyph(ctx, pointSize, c)) != null)
                {
                    return(result);
                }
            }

            if (result == null)
            {
                Debug.WriteLine("no glyph found, returning default area");
                result = new StringArea(ctx, "?");
            }
            return(result);
        }
Esempio n. 3
0
		/**
		 * create an area that formats a string.
		 */
		public static Area String(IFormattingContext context, String str) 
		{
			Area result = null;
			float fontSize = context.Size;
			ArrayList list = null;
			int start = 0;
			
			if(str.Length == 1)
			{
				result = str[0] > '\x7f' ? GlyphFactory.GetGlyph(context, fontSize, str[0]) :
					new StringArea(context, str);
			}
			else
			{
				start = 0;
				for(int i = 0; i < str.Length; i++)
				{
					if(str[i] > '\x7f')
					{
						if(list == null) { list = new ArrayList(); }
						list.Add(new StringArea(context, str.Substring(start, i - start)));
						list.Add(GlyphFactory.GetGlyph(context, fontSize, str[i]));
						start = i + 1;
					}
				}
				
				if(list != null)
				{
					result = Horizontal((Area[])list.ToArray(typeof(Area)));
				}
				else
				{
					result = new StringArea(context, str);
				}
			}
			return result;
		}
Esempio n. 4
0
		/**
		 * create a new glyph area.
		 */
    public static Area GetGlyph(IFormattingContext ctx, float pointSize, char c)
		{
      GlyphFactory gf = Instance;

			Area result = null;

			Debug.WriteLine(String.Format("searching for a glyph for character 0x{0:x}", (uint)c));
			for(int i = 0; i < gf.maps.Length; i++)
			{
				if((result = gf.maps[i].GetGlyph(ctx, pointSize, c)) != null)
					return result;
			}

			if(result == null)
			{
				Debug.WriteLine("no glyph found, returning default area");
				result = new StringArea(ctx, "?");             
			}
			return result;
		}