Beispiel #1
0
        /// <summary>
        /// read latest layout output into outputGlyphPlanList
        /// </summary>
        public static void ReadOutput(this GlyphLayout glyphLayout, List <GlyphPlan> outputGlyphPlanList)
        {
            GlyphPosStream glyphPositions  = glyphLayout._glyphPositions; //from opentype's layout result,
            int            finalGlyphCount = glyphPositions.Count;
            //------------------------
            IPixelScaleLayout pxscaleLayout = glyphLayout.PxScaleLayout;

            if (pxscaleLayout != null)
            {
                //use custom pixel scale layout engine

                pxscaleLayout.SetFont(glyphLayout.Typeface, glyphLayout.FontSizeInPoints);
                pxscaleLayout.Layout(glyphPositions, outputGlyphPlanList);
            }
            else
            {
                //default scale
                float  pxscale = glyphLayout.PixelScale;
                double cx      = 0;
                short  cy      = 0;
                for (int i = 0; i < finalGlyphCount; ++i)
                {
                    GlyphPos glyph_pos = glyphPositions[i];
                    float    advW      = glyph_pos.advanceW * pxscale;
                    float    exact_x   = (float)(cx + glyph_pos.OffsetX * pxscale);
                    float    exact_y   = (float)(cy + glyph_pos.OffsetY * pxscale);

                    outputGlyphPlanList.Add(new GlyphPlan(
                                                glyph_pos.glyphIndex,
                                                exact_x,
                                                exact_y,
                                                advW));
                    cx += advW;
                }
            }
        }