public virtual void TestUpperCaseSymbol() { StringBuilder builder = new StringBuilder(); for (int i = 1; i <= 25; i++) { builder.Append(GreekAlphabetNumbering.ToGreekAlphabetNumber(i, true, true)); } // Symbol font use regular WinAnsi codes for greek letters. NUnit.Framework.Assert.AreEqual("ABGDEZHQIKLMNXOPRSTUFCYWAA", builder.ToString()); }
public virtual void TestLowerCaseSymbol() { StringBuilder builder = new StringBuilder(); for (int i = 1; i <= 25; i++) { builder.Append(GreekAlphabetNumbering.ToGreekAlphabetNumber(i, false, true)); } // Symbol font use regular WinAnsi codes for greek letters. NUnit.Framework.Assert.AreEqual("abgdezhqiklmnxoprstufcywaa", builder.ToString()); }
public virtual void TestLowerCase() { StringBuilder builder = new StringBuilder(); for (int i = 1; i <= 25; i++) { builder.Append(GreekAlphabetNumbering.ToGreekAlphabetNumber(i, false)); } // 25th symbol is `αα`, i.e. alphabet has 24 letters. NUnit.Framework.Assert.AreEqual("αβγδεζηθικλμνξοπρστυφχψωαα", builder.ToString()); }
public virtual void TestUpperCase() { StringBuilder builder = new StringBuilder(); for (int i = 1; i <= 25; i++) { builder.Append(GreekAlphabetNumbering.ToGreekAlphabetNumber(i, true)); } // 25th symbol is `AA`, i.e. alphabet has 24 letters. NUnit.Framework.Assert.AreEqual("ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΑΑ", builder.ToString()); }
private IRenderer CreateListSymbolRenderer(int index, IRenderer renderer) { Object defaultListSymbol = GetListItemOrListProperty(renderer, this, Property.LIST_SYMBOL); if (defaultListSymbol is Text) { return(SurroundTextBullet(new TextRenderer((Text)defaultListSymbol))); } else { if (defaultListSymbol is Image) { return(new ImageRenderer((Image)defaultListSymbol)); } else { if (defaultListSymbol is ListNumberingType) { ListNumberingType numberingType = (ListNumberingType)defaultListSymbol; String numberText; switch (numberingType) { case ListNumberingType.DECIMAL: { numberText = index.ToString(); break; } case ListNumberingType.DECIMAL_LEADING_ZERO: { numberText = (index < 10 ? "0" : "") + index.ToString(); break; } case ListNumberingType.ROMAN_LOWER: { numberText = RomanNumbering.ToRomanLowerCase(index); break; } case ListNumberingType.ROMAN_UPPER: { numberText = RomanNumbering.ToRomanUpperCase(index); break; } case ListNumberingType.ENGLISH_LOWER: { numberText = EnglishAlphabetNumbering.ToLatinAlphabetNumberLowerCase(index); break; } case ListNumberingType.ENGLISH_UPPER: { numberText = EnglishAlphabetNumbering.ToLatinAlphabetNumberUpperCase(index); break; } case ListNumberingType.GREEK_LOWER: { numberText = GreekAlphabetNumbering.ToGreekAlphabetNumber(index, false, true); break; } case ListNumberingType.GREEK_UPPER: { numberText = GreekAlphabetNumbering.ToGreekAlphabetNumber(index, true, true); break; } case ListNumberingType.ZAPF_DINGBATS_1: { numberText = JavaUtil.CharToString((char)(index + 171)); break; } case ListNumberingType.ZAPF_DINGBATS_2: { numberText = JavaUtil.CharToString((char)(index + 181)); break; } case ListNumberingType.ZAPF_DINGBATS_3: { numberText = JavaUtil.CharToString((char)(index + 191)); break; } case ListNumberingType.ZAPF_DINGBATS_4: { numberText = JavaUtil.CharToString((char)(index + 201)); break; } default: { throw new InvalidOperationException(); } } Text textElement = new Text(GetListItemOrListProperty(renderer, this, Property.LIST_SYMBOL_PRE_TEXT) + numberText + GetListItemOrListProperty(renderer, this, Property.LIST_SYMBOL_POST_TEXT)); IRenderer textRenderer; // Be careful. There is a workaround here. For Greek symbols we first set a dummy font with document=null // in order for the metrics to be taken into account correctly during layout. // Then on draw we set the correct font with actual document in order for the font objects to be created. if (numberingType == ListNumberingType.GREEK_LOWER || numberingType == ListNumberingType.GREEK_UPPER || numberingType == ListNumberingType.ZAPF_DINGBATS_1 || numberingType == ListNumberingType.ZAPF_DINGBATS_2 || numberingType == ListNumberingType.ZAPF_DINGBATS_3 || numberingType == ListNumberingType.ZAPF_DINGBATS_4) { String constantFont = (numberingType == ListNumberingType.GREEK_LOWER || numberingType == ListNumberingType .GREEK_UPPER) ? StandardFonts.SYMBOL : StandardFonts.ZAPFDINGBATS; textRenderer = new _TextRenderer_211(constantFont, textElement); try { textRenderer.SetProperty(Property.FONT, PdfFontFactory.CreateFont(constantFont)); } catch (System.IO.IOException) { } } else { textRenderer = new TextRenderer(textElement); } return(SurroundTextBullet(textRenderer)); } else { if (defaultListSymbol is IListSymbolFactory) { return(SurroundTextBullet(((IListSymbolFactory)defaultListSymbol).CreateSymbol(index, this, renderer).CreateRendererSubTree ())); } else { if (defaultListSymbol == null) { return(null); } else { throw new InvalidOperationException(); } } } } } }
/// <summary>Resolves a counter.</summary> /// <param name="counterName">the counter name</param> /// <param name="listSymbolType">the list symbol type</param> /// <param name="scope">the scope</param> /// <returns> /// the counter value as a /// <see cref="System.String"/> /// </returns> public virtual String ResolveCounter(String counterName, String listSymbolType, INode scope) { IDictionary <String, int?> scopeCounters = FindSuitableScopeMap(scope, counterName); int?counterValue = scopeCounters != null?scopeCounters.Get(counterName) : null; if (counterValue == null) { return(null); } else { // TODO we do that to print a logger message. We might want to reconsider and silently reset to 0 in the future if (listSymbolType == null) { return(counterValue.ToString()); } else { if (CssConstants.NONE.Equals(listSymbolType)) { return(""); } else { if (CssConstants.DISC.Equals(listSymbolType)) { return(DISC_SYMBOL); } else { if (CssConstants.SQUARE.Equals(listSymbolType)) { return(SQUARE_SYMBOL); } else { if (CssConstants.CIRCLE.Equals(listSymbolType)) { return(CIRCLE_SYMBOL); } else { if (CssConstants.UPPER_ALPHA.Equals(listSymbolType) || CssConstants.UPPER_LATIN.Equals(listSymbolType)) { return(EnglishAlphabetNumbering.ToLatinAlphabetNumberUpperCase((int)counterValue)); } else { if (CssConstants.LOWER_ALPHA.Equals(listSymbolType) || CssConstants.LOWER_LATIN.Equals(listSymbolType)) { return(EnglishAlphabetNumbering.ToLatinAlphabetNumberLowerCase((int)counterValue)); } else { if (CssConstants.LOWER_ROMAN.Equals(listSymbolType)) { return(counterValue <= MAX_ROMAN_NUMBER?RomanNumbering.ToRomanLowerCase((int)counterValue) : counterValue .ToString()); } else { if (CssConstants.UPPER_ROMAN.Equals(listSymbolType)) { return(counterValue <= MAX_ROMAN_NUMBER?RomanNumbering.ToRomanUpperCase((int)counterValue) : counterValue .ToString()); } else { if (CssConstants.DECIMAL_LEADING_ZERO.Equals(listSymbolType)) { return((counterValue < 10 ? "0" : "") + counterValue.ToString()); } else { if (CssConstants.LOWER_GREEK.Equals(listSymbolType)) { return(GreekAlphabetNumbering.ToGreekAlphabetNumberLowerCase((int)counterValue)); } else { if (CssConstants.GEORGIAN.Equals(listSymbolType)) { return(GeorgianNumbering.ToGeorgian((int)counterValue)); } else { if (CssConstants.ARMENIAN.Equals(listSymbolType)) { return(ArmenianNumbering.ToArmenian((int)counterValue)); } else { return(counterValue.ToString()); } } } } } } } } } } } } } } }
/// <summary>Converts number according to given glyph style.</summary> /// <param name="glyphStyle">style of the glyphs</param> /// <param name="number">number to be converted</param> /// <returns>converted number</returns> public static String ConvertNumberAccordingToGlyphStyle(CounterDigitsGlyphStyle glyphStyle, int number) { if (glyphStyle == null) { return(number.ToString()); } switch (glyphStyle) { case CounterDigitsGlyphStyle.NONE: { return(""); } case CounterDigitsGlyphStyle.DISC: { return(DISC_SYMBOL); } case CounterDigitsGlyphStyle.SQUARE: { return(SQUARE_SYMBOL); } case CounterDigitsGlyphStyle.CIRCLE: { return(CIRCLE_SYMBOL); } case CounterDigitsGlyphStyle.UPPER_ALPHA_AND_LATIN: { return(number > 0 ? EnglishAlphabetNumbering.ToLatinAlphabetNumberUpperCase(number) : number.ToString()); } case CounterDigitsGlyphStyle.LOWER_ALPHA_AND_LATIN: { return(number > 0 ? EnglishAlphabetNumbering.ToLatinAlphabetNumberLowerCase(number) : number.ToString()); } case CounterDigitsGlyphStyle.LOWER_GREEK: { return(number > 0 ? GreekAlphabetNumbering.ToGreekAlphabetNumberLowerCase(number) : number.ToString()); } case CounterDigitsGlyphStyle.LOWER_ROMAN: { return(number <= MAX_ROMAN_NUMBER?RomanNumbering.ToRomanLowerCase(number) : number.ToString()); } case CounterDigitsGlyphStyle.UPPER_ROMAN: { return(number <= MAX_ROMAN_NUMBER?RomanNumbering.ToRomanUpperCase(number) : number.ToString()); } case CounterDigitsGlyphStyle.DECIMAL_LEADING_ZERO: { return((number < 10 ? "0" : "") + number.ToString()); } case CounterDigitsGlyphStyle.GEORGIAN: { return(GeorgianNumbering.ToGeorgian(number)); } case CounterDigitsGlyphStyle.ARMENIAN: { return(ArmenianNumbering.ToArmenian(number)); } default: { return(number.ToString()); } } }
protected internal virtual IRenderer MakeListSymbolRenderer(int index, IRenderer renderer) { Object defaultListSymbol = renderer.GetProperty <Object>(Property.LIST_SYMBOL); if (defaultListSymbol is Text) { return(new TextRenderer((Text)defaultListSymbol)); } else { if (defaultListSymbol is Image) { return(new ImageRenderer((Image)defaultListSymbol)); } else { if (defaultListSymbol is ListNumberingType) { ListNumberingType numberingType = (ListNumberingType)defaultListSymbol; String numberText; switch (numberingType) { case ListNumberingType.DECIMAL: { numberText = index.ToString(); break; } case ListNumberingType.ROMAN_LOWER: { numberText = RomanNumbering.ToRomanLowerCase(index); break; } case ListNumberingType.ROMAN_UPPER: { numberText = RomanNumbering.ToRomanUpperCase(index); break; } case ListNumberingType.ENGLISH_LOWER: { numberText = EnglishAlphabetNumbering.ToLatinAlphabetNumberLowerCase(index); break; } case ListNumberingType.ENGLISH_UPPER: { numberText = EnglishAlphabetNumbering.ToLatinAlphabetNumberUpperCase(index); break; } case ListNumberingType.GREEK_LOWER: { numberText = GreekAlphabetNumbering.ToGreekAlphabetNumberLowerCase(index); break; } case ListNumberingType.GREEK_UPPER: { numberText = GreekAlphabetNumbering.ToGreekAlphabetNumberUpperCase(index); break; } case ListNumberingType.ZAPF_DINGBATS_1: { numberText = iText.IO.Util.JavaUtil.CharToString((char)(index + 171)); break; } case ListNumberingType.ZAPF_DINGBATS_2: { numberText = iText.IO.Util.JavaUtil.CharToString((char)(index + 181)); break; } case ListNumberingType.ZAPF_DINGBATS_3: { numberText = iText.IO.Util.JavaUtil.CharToString((char)(index + 191)); break; } case ListNumberingType.ZAPF_DINGBATS_4: { numberText = iText.IO.Util.JavaUtil.CharToString((char)(index + 201)); break; } default: { throw new InvalidOperationException(); } } Text textElement = new Text(renderer.GetProperty <String>(Property.LIST_SYMBOL_PRE_TEXT) + numberText + renderer .GetProperty <String>(Property.LIST_SYMBOL_POST_TEXT)); IRenderer textRenderer; // Be careful. There is a workaround here. For Greek symbols we first set a dummy font with document=null // in order for the metrics to be taken into account correctly during layout. // Then on draw we set the correct font with actual document in order for the font objects to be created. if (numberingType == ListNumberingType.GREEK_LOWER || numberingType == ListNumberingType.GREEK_UPPER || numberingType == ListNumberingType.ZAPF_DINGBATS_1 || numberingType == ListNumberingType.ZAPF_DINGBATS_2 || numberingType == ListNumberingType.ZAPF_DINGBATS_3 || numberingType == ListNumberingType.ZAPF_DINGBATS_4) { String constantFont = (numberingType == ListNumberingType.GREEK_LOWER || numberingType == ListNumberingType .GREEK_UPPER) ? FontConstants.SYMBOL : FontConstants.ZAPFDINGBATS; textRenderer = new _TextRenderer_201(constantFont, textElement); try { textRenderer.SetProperty(Property.FONT, PdfFontFactory.CreateFont(constantFont)); } catch (System.IO.IOException) { } } else { textRenderer = new TextRenderer(textElement); } return(textRenderer); } else { throw new InvalidOperationException(); } } } }