Esempio n. 1
0
        void RenderByGlyphName(string selectedGlyphName)
        {
            //---------------------------------------------
            //this version only render with MiniAgg**
            //---------------------------------------------

            painter.Clear(PixelFarm.Drawing.Color.White);
            painter.UseSubPixelLcdEffect = _contourAnalysisOpts.LcdTechnique;
            painter.FillColor            = PixelFarm.Drawing.Color.Black;

            selectedTextPrinter                   = _devVxsTextPrinter;
            selectedTextPrinter.Typeface          = _basicOptions.Typeface;
            selectedTextPrinter.FontSizeInPoints  = _basicOptions.FontSizeInPoints;
            selectedTextPrinter.ScriptLang        = _basicOptions.ScriptLang;
            selectedTextPrinter.PositionTechnique = _basicOptions.PositionTech;

            selectedTextPrinter.HintTechnique  = _glyphRenderOptions.HintTechnique;
            selectedTextPrinter.EnableLigature = _glyphRenderOptions.EnableLigature;

            //test print 3 lines
#if DEBUG
            GlyphDynamicOutline.dbugTestNewGridFitting    = _contourAnalysisOpts.EnableGridFit;
            GlyphDynamicOutline.dbugActualPosToConsole    = _contourAnalysisOpts.WriteFitOutputToConsole;
            GlyphDynamicOutline.dbugUseHorizontalFitValue = _contourAnalysisOpts.UseHorizontalFitAlignment;
#endif


            float x_pos = 0, y_pos = 100;
            var   glyphPlanList = new Typography.TextLayout.UnscaledGlyphPlanList();


            //in this version
            //create a glyph-plan manully
            ushort selectedGlyphIndex =
                glyphNameListUserControl1.Typeface.GetGlyphIndexByName(selectedGlyphName);

            glyphPlanList.Append(
                new Typography.TextLayout.UnscaledGlyphPlan(0, selectedGlyphIndex, 0, 0, 0));

            var seq = new Typography.TextLayout.GlyphPlanSequence(
                glyphPlanList,
                0, 1);
            selectedTextPrinter.DrawFromGlyphPlans(seq, x_pos, y_pos);

            char[] printTextBuffer = this.txtInputChar.Text.ToCharArray();
            float  lineSpacingPx   = selectedTextPrinter.FontLineSpacingPx;
            for (int i = 0; i < 1; ++i)
            {
                selectedTextPrinter.DrawString(printTextBuffer, x_pos, y_pos);
                y_pos -= lineSpacingPx;
            }


            //copy from Agg's memory buffer to gdi
            PixelFarm.CpuBlit.Imaging.BitmapHelper.CopyToGdiPlusBitmapSameSize(destImg, winBmp);
            g.Clear(System.Drawing.Color.White);
            g.DrawImage(winBmp, new System.Drawing.Point(10, 0));
        }
Esempio n. 2
0
        public float CalculateWidth()
        {
            UnscaledGlyphPlanList plans = glyphBuffer;
            int   end   = startAt + len;
            float width = 0;

            for (int i = startAt; i < end; ++i)
            {
                width += plans[i].AdvanceX;
            }
            return(width);
        }
Esempio n. 3
0
        /// <summary>
        /// generate scaled from unscale glyph size to specific scale
        /// </summary>
        /// <param name="glyphPositions"></param>
        /// <param name="pxscale"></param>
        /// <param name="outputGlyphPlanList"></param>
        public static void GenerateUnscaledGlyphPlans(IGlyphPositions glyphPositions, UnscaledGlyphPlanList outputGlyphPlanList)
        {
            //user can implement this with some 'PixelScaleEngine'

            int finalGlyphCount = glyphPositions.Count;

            for (int i = 0; i < finalGlyphCount; ++i)
            {
                short  input_offset, offsetX, offsetY, advW; //all from pen-pos
                ushort glyphIndex = glyphPositions.GetGlyph(i, out input_offset, out offsetX, out offsetY, out advW);

                outputGlyphPlanList.Append(new UnscaledGlyphPlan(
                                               input_offset,
                                               glyphIndex,
                                               advW,
                                               offsetX,
                                               offsetY
                                               ));
            }
        }
Esempio n. 4
0
 internal GlyphPlanSequence(UnscaledGlyphPlanList glyphBuffer, int startAt, int len)
 {
     this.glyphBuffer = glyphBuffer;
     this.startAt     = startAt;
     this.len         = (ushort)len;
 }