LayoutFarm.Text.EditableTextRun.UpdateRunWidth C# (CSharp) Method

UpdateRunWidth() private method

private UpdateRunWidth ( ) : void
return void
        internal override void UpdateRunWidth()
        {
            Size size;
            if (IsLineBreak)
            {
                size = CalculateDrawingStringSize(emptyline, 1);
                glyphPositions = new int[0];
            }
            else
            {
                //TODO: review here again
                int len = mybuffer.Length;
                size = CalculateDrawingStringSize(this.mybuffer, len);

                //when we update run width we should store
                //cache of each char x-advance?
                //or calculate it every time ?

                //TODO: review this,
                //if we have enough length, -> we don't need to alloc every time. 
                glyphPositions = new int[len];
                TextServices.IFonts.CalculateGlyphAdvancePos(mybuffer, 0, len, GetFont(), glyphPositions);
            }
            //---------
            this.SetSize(size.Width, size.Height);

            //---------
            MarkHasValidCalculateSize();
        }
        public override char GetChar(int index)

Usage Example

コード例 #1
0
        public EditableRun CreateEditableTextRun(char[] charBuffer)
        {
            var span = new EditableTextRun(this.Root, charBuffer, this.currentSpanStyle);

            span.UpdateRunWidth();
            return(span);
        }
All Usage Examples Of LayoutFarm.Text.EditableTextRun::UpdateRunWidth