Ejemplo n.º 1
0
            private int GetShapeableSymbolsWidth(TextShapeableSymbols textRun)
            {
                int result      = 0;
                int text_length = textRun.Length;

                int[]           advance_widths = new int[text_length];
                GCHandle        pin_handle;
                CharacterBuffer char_buf = textRun.CharacterBufferReference.CharacterBuffer;

                unsafe
                {
                    IntPtr run_characters = char_buf.PinAndGetCharacterPointer(textRun.CharacterBufferReference.OffsetToFirstChar, out pin_handle);
                    try
                    {
                        fixed(int *widths_ptr = advance_widths)
                        {
                            textRun.GetAdvanceWidthsUnshaped((char *)run_characters.ToPointer(), text_length, TextFormatterImp.ToIdeal, widths_ptr);
                        }
                    }
                    finally
                    {
                        char_buf.UnpinCharacterPointer(pin_handle);
                    }
                }

                for (int i = 0; i < text_length; i++)
                {
                    result += advance_widths[i];
                }

                return(result);
            }