예제 #1
0
        /// <summary>
        /// read latest layout output
        /// </summary>
        /// <param name="glyphLayout"></param>
        /// <param name="readDel"></param>
        public static void ReadOutput(this GlyphLayout glyphLayout, GlyphReadOutputDelegate readDel)
        {
            Typeface        typeface       = glyphLayout.Typeface;
            List <GlyphPos> glyphPositions = glyphLayout._glyphPositions;
            //3.read back
            int   finalGlyphCount = glyphPositions.Count;
            int   cx = 0;
            short cy = 0;

            PositionTechnique posTech    = glyphLayout.PositionTechnique;
            ushort            prev_index = 0;

            for (int i = 0; i < finalGlyphCount; ++i)
            {
                GlyphPos glyphPos = glyphPositions[i];
                //----------------------------------
                switch (posTech)
                {
                default: throw new NotSupportedException();

                case PositionTechnique.None:
                    readDel(i, new GlyphPlan(glyphPos.glyphIndex, cx, cy, glyphPos.advWidth));
                    break;

                case PositionTechnique.OpenFont:
                    readDel(i, new GlyphPlan(
                                glyphPos.glyphIndex,
                                cx + glyphPos.xoffset,
                                (short)(cy + glyphPos.yoffset),
                                glyphPos.advWidth));
                    break;

                case PositionTechnique.Kerning:

                    if (i > 0)
                    {
                        cx += typeface.GetKernDistance(prev_index, glyphPos.glyphIndex);
                    }
                    readDel(i, new GlyphPlan(
                                prev_index = glyphPos.glyphIndex,
                                cx,
                                cy,
                                glyphPos.advWidth));

                    break;
                }
                cx += glyphPos.advWidth;
            }
        }
예제 #2
0
        /// <summary>
        /// read latest layout output
        /// </summary>
        /// <param name="glyphLayout"></param>
        /// <param name="readDel"></param>
        public static void ReadOutput(this GlyphLayout glyphLayout, GlyphReadOutputDelegate readDel)
        {
            throw new NotSupportedException();

            //Typeface typeface = glyphLayout.Typeface;
            //List<GlyphPos> glyphPositions = glyphLayout._glyphPositions;
            ////3.read back
            //int finalGlyphCount = glyphPositions.Count;
            //int cx = 0;
            //short cy = 0;

            //PositionTechnique posTech = glyphLayout.PositionTechnique;
            //ushort prev_index = 0;
            //for (int i = 0; i < finalGlyphCount; ++i)
            //{

            //    GlyphPos glyphPos = glyphPositions[i];
            //    //----------------------------------
            //    switch (posTech)
            //    {
            //        default: throw new NotSupportedException();
            //        case PositionTechnique.None:
            //            readDel(i, new GlyphPlan(glyphPos.glyphIndex, cx, cy, glyphPos.AdvWidth));
            //            break;
            //        case PositionTechnique.OpenFont:
            //            readDel(i, new GlyphPlan(
            //                glyphPos.glyphIndex,
            //                cx + glyphPos.xoffset,
            //                (short)(cy + glyphPos.yoffset),
            //                glyphPos.AdvWidth));
            //            break;
            //        case PositionTechnique.Kerning:

            //            if (i > 0)
            //            {
            //                cx += typeface.GetKernDistance(prev_index, glyphPos.glyphIndex);
            //            }
            //            readDel(i, new GlyphPlan(
            //                 prev_index = glyphPos.glyphIndex,
            //               cx,
            //               cy,
            //               glyphPos.AdvWidth));

            //            break;
            //    }
            //    cx += glyphPos.AdvWidth;
            //}
        }
예제 #3
0
 public static void Layout(this GlyphLayout glyphLayout, char[] str, int startAt, int len, GlyphReadOutputDelegate readDel)
 {
     glyphLayout.Layout(str, startAt, len);
     glyphLayout.ReadOutput(readDel);
 }