public SpanArea(FontState fontState, int xPosition, int yPosition, int allocationWidth, int maxHeight, int columnCount, int columnGap) : base(fontState, xPosition, yPosition, allocationWidth, maxHeight, Position.ABSOLUTE) { this.contentRectangleWidth = allocationWidth; this.columnCount = columnCount; this.columnGap = columnGap; int columnWidth = (allocationWidth - columnGap * (columnCount - 1)) / columnCount; for (int columnIndex = 0; columnIndex < columnCount; columnIndex++) { int colXPosition = (xPosition + columnIndex * (columnWidth + columnGap)); int colYPosition = yPosition; ColumnArea colArea = new ColumnArea(fontState, colXPosition, colYPosition, columnWidth, maxHeight, columnCount); addChild(colArea); colArea.setColumnIndex(columnIndex + 1); } }
public AreaContainer(FontState fontState, int xPosition, int yPosition, int allocationWidth, int maxHeight, int position) : base(fontState, allocationWidth, maxHeight) { this.xPosition = xPosition; this.yPosition = yPosition; this.position = position; }
public ColumnArea(FontState fontState, int xPosition, int yPosition, int allocationWidth, int maxHeight, int columnCount) : base(fontState, xPosition, yPosition, allocationWidth, maxHeight, Position.ABSOLUTE) { this.maxColumns = columnCount; this.setAreaName("normal-flow-ref.-area"); }
public Area(FontState fontState, int allocationWidth, int maxHeight) { setFontState(fontState); this.allocationWidth = allocationWidth; this.contentRectangleWidth = allocationWidth; this.maxHeight = maxHeight; this.markers = new ArrayList(); this.returnedBy = new Hashtable(); }
public ImageArea(FontState fontState, FonetImage img, int AllocationWidth, int width, int height, int startIndent, int endIndent, int align) : base(fontState, width, 0, 0, 0) { this.currentHeight = height; this.contentRectangleWidth = width; this.height = height; this.image = img; this.align = align; }
public FontState GetFontState(FontInfo fontInfo) { if (fontState == null) { string fontFamily = properties.GetProperty("font-family").GetString(); string fontStyle = properties.GetProperty("font-style").GetString(); string fontWeight = properties.GetProperty("font-weight").GetString(); int fontSize = properties.GetProperty("font-size").GetLength().MValue(); int fontVariant = properties.GetProperty("font-variant").GetEnum(); fontState = new FontState(fontInfo, fontFamily, fontStyle, fontWeight, fontSize, fontVariant); } return fontState; }
public BlockArea(FontState fontState, int allocationWidth, int maxHeight, int startIndent, int endIndent, int textIndent, int align, int alignLastLine, int lineHeight) : base(fontState, allocationWidth, maxHeight) { this.startIndent = startIndent; this.endIndent = endIndent; this.textIndent = textIndent; this.contentRectangleWidth = allocationWidth - startIndent - endIndent; this.align = align; this.alignLastLine = alignLastLine; this.lineHeight = lineHeight; if (fontState != null) { this.halfLeading = (lineHeight - fontState.FontSize) / 2; } }
public void Reset(FontState fontState, bool useKerning) { // This assumes that *all* CIDFonts use a /ToUnicode mapping //----------------------------------------------- _fontState = fontState; String name = fontState.FontName; _font = (Fonet.Render.Pdf.Fonts.Font)fontState.FontInfo.GetFontByName(name); kerningAvailable = false; kerning = null; _emDiff = _x = _y = 0; _useEmDiff = false; _tmpstBuilder.Length = 0; //----------------------------------------------- if (_useMultibyte = _font.MultiByteFont) { startText = '<'; endText = '>'; } else { startText = '('; endText = ')'; } _tmpstBuilder.Length = 0; //-- //kerning //TODO: add OpenType Layout Features // If no options are supplied, by default we do not enable kerning if (useKerning) { kerning = fontState.Kerning; if (kerning != null && (kerning.Count > 0)) { kerningAvailable = true; } } }
public BodyAreaContainer(FontState fontState, int xPosition, int yPosition, int allocationWidth, int maxHeight, int position, int columnCount, int columnGap) : base(fontState, allocationWidth, maxHeight) { this.xPosition = xPosition; this.yPosition = yPosition; this.position = position; this.columnCount = columnCount; this.columnGap = columnGap; beforeFloatRefAreaHeight = 0; footnoteRefAreaHeight = 0; mainRefAreaHeight = maxHeight - beforeFloatRefAreaHeight - footnoteRefAreaHeight; beforeFloatReferenceArea = new AreaContainer(fontState, xPosition, yPosition, allocationWidth, beforeFloatRefAreaHeight, Position.ABSOLUTE); beforeFloatReferenceArea.setAreaName("before-float-reference-area"); this.addChild(beforeFloatReferenceArea); mainReferenceArea = new AreaContainer(fontState, xPosition, yPosition, allocationWidth, mainRefAreaHeight, Position.ABSOLUTE); mainReferenceArea.setAreaName("main-reference-area"); this.addChild(mainReferenceArea); int footnoteRefAreaYPosition = yPosition - mainRefAreaHeight; footnoteReferenceArea = new AreaContainer(fontState, xPosition, footnoteRefAreaYPosition, allocationWidth, footnoteRefAreaHeight, Position.ABSOLUTE); footnoteReferenceArea.setAreaName("footnote-reference-area"); this.addChild(footnoteReferenceArea); }
public Area(FontState fontState) { setFontState(fontState); this.markers = new ArrayList(); this.returnedBy = new Hashtable(); }
public int AddLeader(BlockArea ba, FontState fontState, float red, float green, float blue, int leaderPattern, int leaderLengthMinimum, int leaderLengthOptimum, int leaderLengthMaximum, int ruleThickness, int ruleStyle, int leaderPatternWidth, int leaderAlignment) { LineArea la = ba.getCurrentLineArea(); if (la == null) { return -1; } la.changeFont(fontState); la.changeColor(red, green, blue); if (leaderLengthOptimum <= (la.getRemainingWidth())) { la.AddLeader(leaderPattern, leaderLengthMinimum, leaderLengthOptimum, leaderLengthMaximum, ruleStyle, ruleThickness, leaderPatternWidth, leaderAlignment); } else { la = ba.createNextLineArea(); if (la == null) { return -1; } la.changeFont(fontState); la.changeColor(red, green, blue); if (leaderLengthMinimum <= la.getContentWidth()) { la.AddLeader(leaderPattern, leaderLengthMinimum, leaderLengthOptimum, leaderLengthMaximum, ruleStyle, ruleThickness, leaderPatternWidth, leaderAlignment); } else { FonetDriver.ActiveDriver.FireFonetWarning( "Leader doesn't fit into line, it will be clipped to fit."); la.AddLeader(leaderPattern, la.getRemainingWidth(), leaderLengthOptimum, leaderLengthMaximum, ruleStyle, ruleThickness, leaderPatternWidth, leaderAlignment); } } return 1; }
public static int addText(BlockArea ba, FontState fontState, float red, float green, float blue, int wrapOption, LinkSet ls, int whiteSpaceCollapse, char[] data, int start, int end, TextState textState, int vAlign) { if (fontState.FontVariant == FontVariant.SMALL_CAPS) { FontState smallCapsFontState; try { int smallCapsFontHeight = (int)(((double)fontState.FontSize) * 0.8d); smallCapsFontState = new FontState(fontState.FontInfo, fontState.FontFamily, fontState.FontStyle, fontState.FontWeight, smallCapsFontHeight, FontVariant.NORMAL); } catch (FonetException ex) { smallCapsFontState = fontState; FonetDriver.ActiveDriver.FireFonetError( "Error creating small-caps FontState: " + ex.Message); } char c; bool isLowerCase; int caseStart; FontState fontStateToUse; for (int i = start; i < end; ) { caseStart = i; c = data[i]; isLowerCase = (Char.IsLetter(c) && Char.IsLower(c)); while (isLowerCase == (Char.IsLetter(c) && Char.IsLower(c))) { if (isLowerCase) { data[i] = Char.ToUpper(c); } i++; if (i == end) { break; } c = data[i]; } if (isLowerCase) { fontStateToUse = smallCapsFontState; } else { fontStateToUse = fontState; } int index = addRealText(ba, fontStateToUse, red, green, blue, wrapOption, ls, whiteSpaceCollapse, data, caseStart, i, textState, vAlign); if (index != -1) { return index; } } return -1; } return addRealText(ba, fontState, red, green, blue, wrapOption, ls, whiteSpaceCollapse, data, start, end, textState, vAlign); }
protected static int addRealText(BlockArea ba, FontState fontState, float red, float green, float blue, int wrapOption, LinkSet ls, int whiteSpaceCollapse, char[] data, int start, int end, TextState textState, int vAlign) { int ts, te; char[] ca; ts = start; te = end; ca = data; LineArea la = ba.getCurrentLineArea(); if (la == null) { return start; } la.changeFont(fontState); la.changeColor(red, green, blue); la.changeWrapOption(wrapOption); la.changeWhiteSpaceCollapse(whiteSpaceCollapse); la.changeVerticalAlign(vAlign); ba.setupLinkSet(ls); ts = la.addText(ca, ts, te, ls, textState); while (ts != -1) { la = ba.createNextLineArea(); if (la == null) { return ts; } la.changeFont(fontState); la.changeColor(red, green, blue); la.changeWrapOption(wrapOption); la.changeWhiteSpaceCollapse(whiteSpaceCollapse); ba.setupLinkSet(ls); ts = la.addText(ca, ts, te, ls, textState); } return -1; }
public void changeFont(FontState fontState) { this.currentFontState = fontState; }
public LineArea(FontState fontState, int lineHeight, int halfLeading, int allocationWidth, int startIndent, int endIndent, LineArea prevLineArea) : base(fontState) { this.currentFontState = fontState; this.lineHeight = lineHeight; this.nominalFontSize = fontState.FontSize; this.nominalGlyphHeight = fontState.Ascender - fontState.Descender; this.placementOffset = fontState.Ascender; this.contentRectangleWidth = allocationWidth - startIndent - endIndent; this.fontState = fontState; this.allocationHeight = this.nominalGlyphHeight; this.halfLeading = this.lineHeight - this.allocationHeight; this.startIndent = startIndent; this.endIndent = endIndent; if (prevLineArea != null) { IEnumerator e = prevLineArea.pendingAreas.GetEnumerator(); Box b = null; bool eatMoreSpace = true; int eatenWidth = 0; while (eatMoreSpace) { if (e.MoveNext()) { b = (Box)e.Current; if (b is InlineSpace) { InlineSpace isp = (InlineSpace)b; if (isp.isEatable()) { eatenWidth += isp.getSize(); } else { eatMoreSpace = false; } } else { eatMoreSpace = false; } } else { eatMoreSpace = false; b = null; } } while (b != null) { pendingAreas.Add(b); if (e.MoveNext()) { b = (Box)e.Current; } else { b = null; } } pendingWidth = prevLineArea.getPendingWidth() - eatenWidth; } }
public override Status Layout(Area area) { if (!(area is BlockArea)) { FonetDriver.ActiveDriver.FireFonetError( "Text outside block area" + new String(ca, start, length)); return new Status(Status.OK); } if (this.marker == MarkerStart) { string fontFamily = this.parent.properties.GetProperty("font-family").GetString(); string fontStyle = this.parent.properties.GetProperty("font-style").GetString(); string fontWeight = this.parent.properties.GetProperty("font-weight").GetString(); int fontSize = this.parent.properties.GetProperty("font-size").GetLength().MValue(); int fontVariant = this.parent.properties.GetProperty("font-variant").GetEnum(); int letterSpacing = this.parent.properties.GetProperty("letter-spacing").GetLength().MValue(); this.fs = new FontState(area.getFontInfo(), fontFamily, fontStyle, fontWeight, fontSize, fontVariant, letterSpacing); ColorType c = this.parent.properties.GetProperty("color").GetColorType(); this.red = c.Red; this.green = c.Green; this.blue = c.Blue; this.verticalAlign = this.parent.properties.GetProperty("vertical-align").GetEnum(); this.wrapOption = this.parent.properties.GetProperty("wrap-option").GetEnum(); this.whiteSpaceCollapse = this.parent.properties.GetProperty("white-space-collapse").GetEnum(); this.ts = new TextState(); ts.setUnderlined(underlined); ts.setOverlined(overlined); ts.setLineThrough(lineThrough); this.marker = this.start; } int orig_start = this.marker; this.marker = addText((BlockArea)area, fs, red, green, blue, wrapOption, this.GetLinkSet(), whiteSpaceCollapse, ca, this.marker, length, ts, verticalAlign); if (this.marker == -1) { return new Status(Status.OK); } else if (this.marker != orig_start) { return new Status(Status.AREA_FULL_SOME); } else { return new Status(Status.AREA_FULL_NONE); } }
private void setFontState(FontState fontState) { this.fontState = fontState; }