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]; FontService1.CalculateGlyphAdvancePos(mybuffer, 0, len, GetFont(), glyphPositions); //Root.IFonts.CalculateGlyphAdvancePos(mybuffer, 0, len, GetFont(), glyphPositions); //TextServices.IFonts.CalculateGlyphAdvancePos(mybuffer, 0, len, GetFont(), glyphPositions); } //--------- this.SetSize(size.Width, size.Height); //--------- MarkHasValidCalculateSize(); }
Size CalculateDrawingStringSize(char[] buffer, int length) { RequestFont fontInfo = GetFont(); return(FontService1.MeasureString(buffer, 0, length, fontInfo)); //return this.Root.IFonts.MeasureString(buffer, 0, // length, fontInfo); }