protected override void GetGlyphPosImpl(ActualFont actualFont, char[] buffer,
                                                int startAt, int len,
                                                List <GlyphPlan> glyphPlans)
        {
            NativeFont nativeFont = actualFont as NativeFont;

            if (nativeFont == null)
            {
                nativeFont = ResolveForNativeFont(actualFont);
            }

            unsafe
            {
                //TODO: review proper array size here
                int          lim = len * 2;
                ProperGlyph *properGlyphArray = stackalloc ProperGlyph[lim];
                fixed(char *head = &buffer[0])
                {
                    //we use font shaping engine here
                    NativeMyFontsLib.MyFtShaping(
                        nativeFont.NativeFontFace.HBFont,
                        head,
                        buffer.Length,
                        properGlyphArray);
                }

                //copy from proper glyph to
                //create glyph plan

                for (int i = 0; i < lim; ++i)
                {
                    ProperGlyph propGlyph = properGlyphArray[i];
                    if (propGlyph.codepoint == 0)
                    {
                        //finish , just return
                        return;
                    }
                    GlyphPlan plan = new GlyphPlan((ushort)propGlyph.codepoint);
                    plan.advX = propGlyph.x_advance;
                    glyphPlans.Add(plan);
                }
            }
        }
Example #2
0
 public static unsafe extern int MyFtShaping(IntPtr my_hb_ft_font,
                                             char *text,
                                             int charCount,
                                             ProperGlyph *properGlyphs);