Example #1
0
		/**
		 * format a script area. This is an area with a base, and
		 * optional super and subscript areas.
		 */
		public static Area Script(IFormattingContext context, Area baseArea, 
			Area subArea, Length subMinShift, Area superArea, Length superMinShift) 
		{
			// we might have a italic base where we have an overhang at the top, in this
			// case we need to add a space for the script elements 
			float right = baseArea.RightEdge;

			// index where to put script elements
			int scriptIndex;

			// horz area, length = 2, base + scripts or length = 3: base + space + scripts
			Area[] horz;
			float subShift, superShift;

			if(right < 0)
			{
				scriptIndex = 2;
				horz = new Area[3];
				horz[1] = new HorizontalSpaceArea(-right);
			}
			else
			{
				scriptIndex = 1;
				horz = new Area[2];
			}		

			// set the base
			horz[0] = baseArea;

			CalculateScriptShift(context, 
				baseArea.BoundingBox,
				subArea != null ? subArea.BoundingBox : BoundingBox.New(), 
				subMinShift, 
				superArea != null ? superArea.BoundingBox : BoundingBox.New(), 
				superMinShift, 
				out subShift, out superShift);        
		
			// the script areas go in an overlap area
			if(subArea != null && superArea != null) 
			{
				Area[] overlap = new Area[2];
				overlap[0] = Shift(-subShift, subArea);
				overlap[1] = Shift(superShift, superArea);
				horz[scriptIndex] = Overlap(overlap);
			}
			else if(subArea != null) 
			{
				horz[scriptIndex] = Shift(-subShift, subArea);
			}
			else if(superArea != null) 
			{
				horz[scriptIndex] = Shift(superShift, superArea);
			}
			else 
			{
				// no script areas, this is not good, but deal with it anyway
				Debug.WriteLine("Warning, no script areas while create a script area, creating default glyph area");
				horz[scriptIndex] = String(context, "?");
			}

			// make a horizontal area out of these
			return Horizontal(horz);
		}
Example #2
0
        /**
         * format a script area. This is an area with a base, and
         * optional super and subscript areas.
         */
        public static Area Script(IFormattingContext context, Area baseArea,
                                  Area subArea, Length subMinShift, Area superArea, Length superMinShift)
        {
            // we might have a italic base where we have an overhang at the top, in this
            // case we need to add a space for the script elements
            float right = baseArea.RightEdge;

            // index where to put script elements
            int scriptIndex;

            // horz area, length = 2, base + scripts or length = 3: base + space + scripts
            Area[] horz;
            float  subShift, superShift;

            if (right < 0)
            {
                scriptIndex = 2;
                horz        = new Area[3];
                horz[1]     = new HorizontalSpaceArea(-right);
            }
            else
            {
                scriptIndex = 1;
                horz        = new Area[2];
            }

            // set the base
            horz[0] = baseArea;

            CalculateScriptShift(context,
                                 baseArea.BoundingBox,
                                 subArea != null ? subArea.BoundingBox : BoundingBox.New(),
                                 subMinShift,
                                 superArea != null ? superArea.BoundingBox : BoundingBox.New(),
                                 superMinShift,
                                 out subShift, out superShift);

            // the script areas go in an overlap area
            if (subArea != null && superArea != null)
            {
                Area[] overlap = new Area[2];
                overlap[0]        = Shift(-subShift, subArea);
                overlap[1]        = Shift(superShift, superArea);
                horz[scriptIndex] = Overlap(overlap);
            }
            else if (subArea != null)
            {
                horz[scriptIndex] = Shift(-subShift, subArea);
            }
            else if (superArea != null)
            {
                horz[scriptIndex] = Shift(superShift, superArea);
            }
            else
            {
                // no script areas, this is not good, but deal with it anyway
                Debug.WriteLine("Warning, no script areas while create a script area, creating default glyph area");
                horz[scriptIndex] = String(context, "?");
            }

            // make a horizontal area out of these
            return(Horizontal(horz));
        }