protected override bool IsChunkAtWordBoundary(TextChunk chunk, TextChunk previousChunk) { ITextChunkLocation curLoc = chunk.GetLocation(); ITextChunkLocation prevLoc = previousChunk.GetLocation(); if (curLoc.GetStartLocation().Equals(curLoc.GetEndLocation()) || prevLoc.GetEndLocation().Equals(prevLoc.GetStartLocation ())) { return(false); } return(curLoc.DistParallelEnd() - prevLoc.DistParallelStart() > (curLoc.GetCharSpaceWidth() + prevLoc.GetCharSpaceWidth ()) / 2.0f); }
protected internal virtual bool IsChunkAtWordBoundary(TextChunk chunk, TextChunk previousChunk) { return(chunk.GetLocation().IsAtWordBoundary(previousChunk.GetLocation())); }
public virtual void EventOccurred(IEventData data, EventType type) { if (type.Equals(EventType.RENDER_TEXT)) { TextRenderInfo renderInfo = (TextRenderInfo)data; LineSegment segment = renderInfo.GetBaseline(); if (renderInfo.GetRise() != 0) { // remove the rise from the baseline - we do this because the text from a super/subscript render operations should probably be considered as part of the baseline of the text the super/sub is relative to Matrix riseOffsetTransform = new Matrix(0, -renderInfo.GetRise()); segment = segment.TransformBy(riseOffsetTransform); } if (useActualText) { CanvasTag lastTagWithActualText = lastTextRenderInfo != null? FindLastTagWithActualText(lastTextRenderInfo.GetCanvasTagHierarchy()) : null; if (lastTagWithActualText != null && lastTagWithActualText == FindLastTagWithActualText(renderInfo.GetCanvasTagHierarchy())) { // Merge two text pieces, assume they will be in the same line TextChunk lastTextChunk = locationalResult[locationalResult.Count - 1]; Vector mergedStart = new Vector( Math.Min(lastTextChunk.GetLocation().GetStartLocation().Get(0), segment.GetStartPoint().Get(0)), Math.Min(lastTextChunk.GetLocation().GetStartLocation().Get(1), segment.GetStartPoint().Get(1)), Math.Min(lastTextChunk.GetLocation().GetStartLocation().Get(2), segment.GetStartPoint().Get(2))); Vector mergedEnd = new Vector( Math.Max(lastTextChunk.GetLocation().GetEndLocation().Get(0), segment.GetEndPoint().Get(0)), Math.Max(lastTextChunk.GetLocation().GetEndLocation().Get(1), segment.GetEndPoint().Get(1)), Math.Max(lastTextChunk.GetLocation().GetEndLocation().Get(2), segment.GetEndPoint().Get(2))); TextChunk merged = new TextChunk( lastTextChunk.GetText(), tclStrat.CreateLocation(renderInfo, new LineSegment(mergedStart, mergedEnd))); locationalResult[locationalResult.Count - 1] = merged; } else { string actualText = renderInfo.GetActualText(); TextChunk tc = new TextChunk( actualText ?? renderInfo.GetText(), tclStrat.CreateLocation(renderInfo, segment)); locationalResult.Add(tc); } } else { TextChunk tc = new TextChunk( renderInfo.GetText(), tclStrat.CreateLocation(renderInfo, segment)); locationalResult.Add(tc); } lastTextRenderInfo = renderInfo; } }