Ejemplo n.º 1
0
        void GenerateContourOutput(IContourBuilder tx, Contour contour)
        {
            List <Vertex> points = contour.flattenPoints;
            int           j      = points.Count;

            if (j == 0)
            {
                return;
            }
            //-------------------------------------------------
            //Bounds controlBounds = this.OriginalGlyphControlBounds;



            //walk along the edge in the contour to generate new edge output
            float pxscale = _pxScale;


#if DEBUG
            //            dbugWriteLine("===begin===" + fit_x_offset);
            //            if (!dbugUseHorizontalFitValue)
            //            {
            //                fit_x_offset = 0;
            //            }
#endif

            //-------------------------------------------------
            //fineSubPixelRenderingOffset = 0.33f;

            //-------------------------------------------------

            //TODO: review here
            float fit_x, fit_y;
            points[0].GetFitXY(pxscale, out fit_x, out fit_y);
            //
            tx.MoveTo(fit_x, fit_y);
#if DEBUG
            // dbugWriteOutput("M", fit_x, fit_x + fit_x_offset, fit_y);
#endif
            //2. others
            for (int i = 1; i < j; ++i)
            {
                //try to fit to grid
                points[i].GetFitXY(pxscale, out fit_x, out fit_y);
                tx.LineTo(fit_x, fit_y);
#if DEBUG
                //for debug
                //dbugWriteOutput("L", fit_x, fit_x + fit_x_offset, fit_y);
#endif
            }
            //close
            tx.CloseContour();
#if DEBUG
            //dbugWriteLine("===end===");
#endif
        }
Ejemplo n.º 2
0
        /// <summary>
        /// generate output with specific pixel scale
        /// </summary>
        /// <param name="tx"></param>
        /// <param name="pxScale"></param>
        public void GenerateOutput(IContourBuilder tx, float pxScale)
        {
            if (_contours == null)
            {
                return;                    //blank
            }
#if DEBUG
            this.EnableGridFit = dbugTestNewGridFitting;
#endif
            EnableGridFit = false;//temp fix, disable this value

            if (_pxScale != pxScale)
            {
                //new scale need to adjust fit value again
                _needAdjustGridFitValues = true;
            }
            //
            _pxScale = pxScale;
            //
            if (EnableGridFit)
            {
                if (_needRefreshBoneGroup)
                {
                    //change scale not affect the grid fit ***
                    AnalyzeBoneGroups(GridBoxWidth, GridBoxHeight);
                    _needRefreshBoneGroup = false;
                }
                //
                if (_needAdjustGridFitValues)
                {
                    ReCalculateFittingValues();
                    _needAdjustGridFitValues = false;
                }
            }

            if (tx != null)
            {
                List <Contour> contours = _contours;
                int            j        = contours.Count;
                tx.BeginRead(j);
                for (int i = 0; i < j; ++i)
                {
                    //generate in order of contour
                    GenerateContourOutput(tx, contours[i]);
                }
                tx.EndRead();
            }
        }
Ejemplo n.º 3
0
 public GlyphTranslatorToContourBuilder(IContourBuilder b) => _b = b;