Пример #1
0
        //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'"
        private TextRecord getStyleRecord(FontBuilder fontBuilder, double height, ref System.Drawing.Color color, int xOffset, int yOffset)
        {
            TextRecord tr = new TextRecord();

            if (fontBuilder != null)
            {
                tr.Font   = fontBuilder.tag;
                tr.Height = SwfUtils.toTwips(height);
            }

            if (!color.IsEmpty)
            {
                //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'"
                int c = SwfUtils.colorToInt(ref color);
                tr.Color = c;
            }

            if (xOffset > 0)
            {
                tr.X = xOffset;
            }

            if (yOffset > 0)
            {
                tr.Y = yOffset;
            }
            return(tr);
        }
Пример #2
0
		private void  encodeTextRecord(TextRecord record, SwfEncoder w, int type, int glyphBits, int advanceBits)
		{
			w.writeUI8(record.flags);
			
			if (record.hasFont())
			{
				w.writeUI16(dict.getId(record.font));
			}
			
			if (record.hasColor())
			{
				if (type == flash.swf.TagValues_Fields.stagDefineText2)
					encodeRGBA(record.color, w);
				else
					encodeRGB(record.color, w);
			}
			
			if (record.hasX())
			{
				w.writeSI16(record.xOffset);
			}
			
			if (record.hasY())
			{
				w.writeSI16(record.yOffset);
			}
			
			if (record.hasHeight())
			{
				w.writeUI16(record.height);
			}
			
			w.writeUI8(record.entries.Length);
			
			for (int i = 0; i < record.entries.Length; i++)
			{
				w.writeUBits(record.entries[i].Index, glyphBits);
				w.writeSBits(record.entries[i].advance, advanceBits);
			}
			w.flushBits();
		}
Пример #3
0
		//UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'"
		private TextRecord getStyleRecord(FontBuilder fontBuilder, double height, ref System.Drawing.Color color, int xOffset, int yOffset)
		{
			TextRecord tr = new TextRecord();
			if (fontBuilder != null)
			{
				tr.Font = fontBuilder.tag;
				tr.Height = SwfUtils.toTwips(height);
			}
			
			if (!color.IsEmpty)
			{
				//UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'"
				int c = SwfUtils.colorToInt(ref color);
				tr.Color = c;
			}
			
			if (xOffset > 0)
			{
				tr.X = xOffset;
			}
			
			if (yOffset > 0)
			{
				tr.Y = yOffset;
			}
			return tr;
		}
Пример #4
0
		private void  printGlyphEntries(TextRecord tr)
		{
			indent();
			for (int i = 0; i < tr.entries.Length; i++)
			{
				GlyphEntry ge = tr.entries[i];
				out_Renamed.Write(ge.Index);
				if (ge.advance >= 0)
					out_Renamed.Write('+');
				out_Renamed.Write(ge.advance);
				out_Renamed.Write(' ');
				if ((i + 1) % 10 == 0)
				{
					//UPGRADE_TODO: Method 'java.io.PrintWriter.println' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioPrintWriterprintln'"
					out_Renamed.WriteLine();
					indent();
				}
			}
			if (tr.entries.Length % 10 != 0)
			{
				//UPGRADE_TODO: Method 'java.io.PrintWriter.println' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioPrintWriterprintln'"
				out_Renamed.WriteLine();
			}
		}
Пример #5
0
		public void  printTextRecord(TextRecord tr, int tagCode)
		{
			indent();
			out_Renamed.Write("<textRecord ");
			if (tr.hasFont())
				out_Renamed.Write(" font='" + tr.font.FontName + "'");
			
			if (tr.hasHeight())
				out_Renamed.Write(" height='" + tr.height + "'");
			
			if (tr.hasX())
				out_Renamed.Write(" xOffset='" + tr.xOffset + "'");
			
			if (tr.hasY())
				out_Renamed.Write(" yOffset='" + tr.yOffset + "'");
			
			if (tr.hasColor())
				out_Renamed.Write(" color='" + (tagCode == flash.swf.TagValues_Fields.stagDefineEditText?printRGB(tr.color):printRGBA(tr.color)) + "'");
			//UPGRADE_TODO: Method 'java.io.PrintWriter.println' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioPrintWriterprintln_javalangString'"
			out_Renamed.WriteLine(">");
			
			indent_Renamed_Field++;
			printGlyphEntries(tr);
			indent_Renamed_Field--;
			indent();
			//UPGRADE_TODO: Method 'java.io.PrintWriter.println' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioPrintWriterprintln_javalangString'"
			out_Renamed.WriteLine("</textRecord>");
		}
Пример #6
0
        /// <summary> </summary>
        /// <param name="fontBuilder">FontBuilder
        /// </param>
        /// <param name="height">double
        /// </param>
        /// <param name="text">String
        /// </param>
        /// <param name="color">Color
        /// </param>
        /// <param name="xOffset">int
        /// </param>
        /// <param name="yOffset">int
        /// </param>
        /// <throws>  IOException </throws>
        /// <summary> add text</summary>
        //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'"
        public virtual void  add(FontBuilder fontBuilder, double height, System.String text, ref System.Drawing.Color color, int xOffset, int yOffset)
        {
            fontBuilders.Add(fontBuilder);

            //UPGRADE_ISSUE: Constructor 'java.io.BufferedReader.BufferedReader' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaioBufferedReaderBufferedReader_javaioReader'"
            System.IO.StreamReader reader = new BufferedReader(new System.IO.StringReader(text));
            System.String          line;
            char[] chars;
            int    yCount   = 0;
            double t_width  = 0.0f;
            double t_height = 0.0f;

            while (true)
            {
                line = reader.ReadLine();
                // Make sure we don't create empty TextRecords
                // A empty textRecord will crash Flash Player. Player Bug#57644
                if ((line == null) || (line.Length == 0))
                {
                    break;
                }

                //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'"
                TextRecord tr = getStyleRecord(fontBuilder, height, ref color, xOffset, (int)(yOffset + yCount * height * flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL));

                chars      = line.ToCharArray();
                tr.entries = new GlyphEntry[chars.Length];
                double w = 0;
                for (int i = 0; i < chars.Length; i++)
                {
                    char c = chars[i];
                    // preilly: According to Sherman Gong, we need to clone the font GlyphEntry, so
                    // that the advance value can be mapped from the font's logical scale to the
                    // text's physical scale.
                    GlyphEntry ge = (GlyphEntry)fontBuilder.getGlyph(c).Clone();
                    //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                    ge.advance    = (int)((ge.advance / 1024f) * tr.height);
                    tr.entries[i] = ge;
                    w            += ge.advance;
                }
                if (w > t_width)
                {
                    t_width = w;
                }
                tag.records.Add(tr);
                yCount++;
            }
            t_height = yCount * height;

            double x1 = 0;
            double y1 = 0;
            double x2 = x1 + t_width;
            double y2 = y1 + t_height;

            x1 = x1 * flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL;
            x2 = x2 * flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL;
            y1 = y1 * flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL;
            y2 = y2 * flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL;

            /**
             *  If the values are greater than Max_value, then
             *  the results are not to be trusted.
             */
            if (x1 > System.Int32.MaxValue)
            {
                x1 = 0;
            }
            if (x2 > System.Int32.MaxValue)
            {
                x2 = 0;
            }
            if (y1 > System.Int32.MaxValue)
            {
                y1 = 0;
            }
            if (y2 > System.Int32.MaxValue)
            {
                y2 = 0;
            }

            //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
            tag.bounds = new Rect((int)x1, (int)x2, (int)y1, (int)y2);
        }
Пример #7
0
        /// <summary> Description:  This version is the same as the straight add function
        /// The difference is that we use java layout class to
        /// calculate the bounding box.
        ///
        /// </summary>
        /// <param name="fontBuilder">FontBuilder
        /// </param>
        /// <param name="height">     double
        /// </param>
        /// <param name="text">       String
        /// </param>
        /// <param name="color">      Color
        /// </param>
        /// <param name="xOffset">    int
        /// </param>
        /// <param name="yOffset">    int
        /// </param>
        /// <param name="bounds">     Rectangle2D
        /// </param>
        /// <throws>  IOException </throws>
        //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'"
        public virtual void  addWithLayout(FontBuilder fontBuilder, double height, System.String text, ref System.Drawing.Color color, int xOffset, int yOffset, ref System.Drawing.RectangleF bounds)
        {
            fontBuilders.Add(fontBuilder);

            //UPGRADE_ISSUE: Constructor 'java.io.BufferedReader.BufferedReader' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaioBufferedReaderBufferedReader_javaioReader'"
            System.IO.StreamReader reader = new BufferedReader(new System.IO.StringReader(text));
            System.String          line;
            char[] chars;
            int    yCount = 0;

            while (true)
            {
                line = reader.ReadLine();
                // Make sure we don't create empty TextRecords
                // A empty textRecord will crash Flash Player. Player Bug #102948
                if ((line == null) || (line.Length == 0))
                {
                    break;
                }
                //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'"
                TextRecord tr = getStyleRecord(fontBuilder, height, ref color, xOffset, (int)(yOffset + yCount * height * flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL));

                chars      = line.ToCharArray();
                tr.entries = new GlyphEntry[chars.Length];
                for (int i = 0; i < chars.Length; i++)
                {
                    char       c  = chars[i];
                    GlyphEntry ge = (GlyphEntry)fontBuilder.getGlyph(c).Clone();
                    //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                    ge.advance    = (int)((ge.advance / 1024f) * tr.height);
                    tr.entries[i] = ge;
                }
                tag.records.Add(tr);
                yCount++;
            }

            /**
             *  on JDK1.4.x the bounds.getMinX() can returns values > bounds.getMaxX()
             *  and also return values > Interger.MAX_VALUE which can cause many
             *  problems when we encode the the position valures in the tagEncoder.
             *
             *  So we stay away from the getMinx, getMinxY methods, and also
             *  double check everything here.
             *
             */

            double x1          = (double)bounds.X;
            double y1          = (double)bounds.Y;
            double rect_width  = (double)bounds.Width;
            double rect_height = (double)bounds.Height;
            double x2          = x1 + rect_width;
            double y2          = y1 + rect_height;

            x1 = x1 * flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL;
            x2 = x2 * flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL;
            y1 = y1 * flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL;
            y2 = y2 * flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL;

            /**
             *  If the values are greater than Max_value, then
             *  the results are not to be trusted.
             */
            if (x1 > System.Int32.MaxValue)
            {
                x1 = 0;
            }
            if (x2 > System.Int32.MaxValue)
            {
                x2 = 0;
            }
            if (y1 > System.Int32.MaxValue)
            {
                y1 = 0;
            }
            if (y2 > System.Int32.MaxValue)
            {
                y2 = 0;
            }

            //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
            tag.bounds = new Rect((int)x1, (int)x2, (int)y1, (int)y2);
        }