public void FlowText(FlowLayoutSource flowSource, FlowLayoutSink flowSink)
        {
            // Reflow all the text, from source to sink.
            if (!isTextAnalysisComplete_)
            {
                throw new Exception("FlowLayout: Text analysis in not complete");
            }

            // Determine the font line height, needed by the flow source.
            FontMetrics fontMetrics = fontFace_.Metrics;
            float       fontHeight  = (fontMetrics.Ascent + fontMetrics.Descent + fontMetrics.LineGap) * fontEmSize_ / fontMetrics.DesignUnitsPerEm;

            // Set initial cluster position to beginning of text.
            ClusterPosition cluster = new ClusterPosition();

            SetClusterPosition(ref cluster, 0);
            RectangleF      rect;
            ClusterPosition nextCluster;

            // Iteratively pull rect's from the source,
            // and push as much text will fit to the sink.
            while (cluster.textPosition < text_.Length)
            {
                // Pull the next rect from the source.
                if (!flowSource.GetNextRect(fontHeight, out rect))
                {
                    break;
                }

                if (rect.Right - rect.Left <= 0)
                {
                    break; // Stop upon reaching zero sized rects.
                }
                // Fit as many clusters between breakpoints that will go in.
                if (!FitText(ref cluster, text_.Length, rect.Right - rect.Left, out nextCluster))
                {
                    break;
                }

                // Push the glyph runs to the sink.
                if (!ProduceGlyphRuns(flowSink, ref rect, ref cluster, ref nextCluster))
                {
                    break;
                }

                cluster = nextCluster;
            }
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CustomLayoutForm"/> class.
        /// </summary>
        public CustomLayoutForm()
        {
            InitializeComponent();

            try
            {
                InitDirect2DAndDirectWrite();
            }
            catch (Exception ex)
            {
                LogException(ex);
                Environment.Exit(1);
            }

            flowLayoutSource = new FlowLayoutSource();
            flowLayoutSink = new FlowLayoutSink();
            flowLayout = new FlowLayout(FactoryDWrite);

            SetLayoutText(LayoutText.Latin);
            SetLayoutShape(FlowShape.Circle);

            panel1.Paint += RenderControlPaint;
            panel1.Resize += RenderControlResize;
        }
示例#3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CustomLayoutForm"/> class.
        /// </summary>
        public CustomLayoutForm()
        {
            InitializeComponent();

            try
            {
                InitDirect2DAndDirectWrite();
            }
            catch (Exception ex)
            {
                LogException(ex);
                Environment.Exit(1);
            }

            flowLayoutSource = new FlowLayoutSource();
            flowLayoutSink   = new FlowLayoutSink();
            flowLayout       = new FlowLayout(FactoryDWrite);

            SetLayoutText(LayoutText.Latin);
            SetLayoutShape(FlowShape.Circle);

            panel1.Paint  += RenderControlPaint;
            panel1.Resize += RenderControlResize;
        }
示例#4
0
        public void FlowText(FlowLayoutSource flowSource, FlowLayoutSink flowSink)
        {
            // Reflow all the text, from source to sink.
            if (!isTextAnalysisComplete_)
                throw new Exception("FlowLayout: Text analysis in not complete");

            // Determine the font line height, needed by the flow source.
            FontMetrics fontMetrics = fontFace_.Metrics;
            float fontHeight = (fontMetrics.Ascent + fontMetrics.Descent + fontMetrics.LineGap) * fontEmSize_ / fontMetrics.DesignUnitsPerEm;

            // Set initial cluster position to beginning of text.
            ClusterPosition cluster = new ClusterPosition();
            SetClusterPosition(ref cluster, 0);
            RectangleF rect;
            ClusterPosition nextCluster;

            // Iteratively pull rect's from the source,
            // and push as much text will fit to the sink.
            while (cluster.textPosition < text_.Length)
            {
                // Pull the next rect from the source.
                if (!flowSource.GetNextRect(fontHeight, out rect))
                    break;

                if (rect.Right - rect.Left <= 0)
                    break; // Stop upon reaching zero sized rects.

                // Fit as many clusters between breakpoints that will go in.
                if (!FitText(ref cluster, text_.Length, rect.Right - rect.Left, out nextCluster))
                    break;

                // Push the glyph runs to the sink.
                if (!ProduceGlyphRuns(flowSink, ref rect, ref cluster, ref nextCluster))
                    break;

                cluster = nextCluster;
            }
        }