public override void UpdateRunWidth() { //*** var textBufferSpan = new Typography.Text.TextBufferSpan(_mybuffer); //TODO: review here, //1. if mybuffer lenght is not changed,we don't need to alloc new array? _outputUserCharAdvances = new int[_mybuffer.Length]; if (_renderVxFormattedString != null) { _renderVxFormattedString.Dispose(); _renderVxFormattedString = null; } var measureResult = new TextSpanMeasureResult(); measureResult.outputXAdvances = _outputUserCharAdvances; if (_content_unparsed) { //parse the content first if (_lineSegs == null) { _lineSegs = new TextPrinterLineSegmentList <TextPrinterLineSegment>(); } _lineSegs.Clear(); // if (s_wordVistor == null) { s_wordVistor = new TextPrinterWordVisitor(); } s_wordVistor.SetLineSegmentList(_lineSegs); RunStyle.BreakToLineSegments(textBufferSpan, s_wordVistor); s_wordVistor.SetLineSegmentList(null); //BreakToLineSegs(textBufferSpan); } _content_unparsed = false; RunStyle.CalculateUserCharGlyphAdvancePos(textBufferSpan, _lineSegs, ref measureResult); SetSize(measureResult.outputTotalW, measureResult.lineHeight); InvalidateGraphics(); }
Size MeasureCopyRunLength(CopyRun copyRun) { //IAdvanceTextService txServices = GlobalTextService.AdvanceTextService; char[] mybuffer = copyRun.RawContent; //if (txServices.SupportsWordBreak) //{ var textBufferSpan = new Typography.Text.TextBufferSpan(mybuffer); _lineSegs.Clear(); _wordVisitor.SetLineSegmentList(_lineSegs); Typography.Text.GlobalTextService.TxtClient.BreakToLineSegments(textBufferSpan, _wordVisitor); var result = new TextSpanMeasureResult(); result.outputXAdvances = new int[mybuffer.Length]; Typography.Text.GlobalTextService.TxtClient.CalculateUserCharGlyphAdvancePos(textBufferSpan, _lineSegs, DefaultRunStyle.ReqFont, ref result); return(new Size(result.outputTotalW, result.lineHeight)); //} //else //{ // var textBufferSpan = new Typography.Text.TextBufferSpan(mybuffer); // var result = new TextSpanMeasureResult(); // result.outputXAdvances = new int[mybuffer.Length]; // txServices.CalculateUserCharGlyphAdvancePos(textBufferSpan, // DefaultRunStyle.ReqFont, // ref result); // return new Size(result.outputTotalW, result.lineHeight); //} }