public void Trump_WideNarrow_Test() { Bench(ExampleText.TRUMP, 10, new[] { new Pair <string, Func <string, string> >("StrConv", targetText => { var s = Strings.StrConv(targetText, VbStrConv.Wide, 0x411); s = Strings.StrConv(s, VbStrConv.Narrow, 0x411); return(s); }), new Pair <string, Func <string, string> >("Kanaxs", targetText => { var s = Kana.ToZenkaku(targetText); s = Kana.ToHankaku(s); return(s); }), new Pair <string, Func <string, string> >("Kanaria", targetText => { return(UcsString.From(targetText) .Wide() .Narrow() .ToString()); }), }); }
public static string toZenkaku(string s) { s = Kana.ToZenkaku(s); s = KanaEx.ToZenkakuKana(s); s = toNormalizedHyphen(s); return(s); }
// 複数行テキストの追加(改行で文字列分割) public void AppendMultiLineComment(PdfContentByte pdfContentByte, string font, float fontSize, string text, float x, float y, float boxWidth, float boxHeight, int lines, float leading, string orientation = HORIZONTAL, float scale = 100f, int cyan = 0, int magenta = 0, int yellow = 0, int black = 255, int alignment = Element.ALIGN_LEFT) { var bf = BaseFont.CreateFont(font, BaseFont.IDENTITY_H, BaseFont.EMBEDDED); pdfContentByte.SetFontAndSize(bf, fontSize); pdfContentByte.SetHorizontalScaling(scale); pdfContentByte.SetCMYKColorFill(cyan, magenta, yellow, black); char[] separator = new char[] { '\r', '\n' }; string[] comments = text.Split(separator, StringSplitOptions.RemoveEmptyEntries); // 横書きのパターン if (orientation == HORIZONTAL) { HorizontalText.SetMinScale(pdfContentByte, bf, comments, fontSize, boxWidth, scale); // y = y + boxHeight - leading; for (int i = 0; comments.Length > i; i++) { if (i >= lines) { break; } string comment = comments[i]; HorizontalText.ShowTextH(pdfContentByte, x, y, comment, alignment, 0); y -= leading; } } // 縦書きのパターン else { float vScale = VerticalText.GetMinVerticalScaling(comments, fontSize, boxHeight); x = VerticalText.GetAlignedXV(x + boxWidth, fontSize) - leading; y -= fontSize * vScale; pdfContentByte.BeginText(); for (int i = 0; comments.Length > i; i++) { if (i >= lines) { break; } string comment = comments[i]; VerticalText.MakeVerticalLine(pdfContentByte, Kana.ToZenkaku(comment), x, y, fontSize, alignment, vScale, tatechuyoko: true, isShugo: true); x -= leading; } pdfContentByte.EndText(); } }
// 1行テキストの追加 public float Append(PdfContentByte pdfContentByte, string text, float x, float y, float boxWidth, float boxHeight, float fontSize, string font, int alignment = 0, int cyan = 0, int magenta = 0, int yellow = 0, int black = 255, float rotation = 0, float scale = 100f, string orientation = HORIZONTAL) { if (orientation == HORIZONTAL) { float ScaledWidth = HorizontalText.SetFontH(pdfContentByte, font, fontSize, text, boxWidth, cyan, magenta, yellow, black, scale); HorizontalText.ShowTextH(pdfContentByte, x, y, text, alignment, rotation); return(ScaledWidth + x); } else { VerticalText.SetFontV(pdfContentByte, font, fontSize, text, cyan, magenta, yellow, black); pdfContentByte.SetHorizontalScaling(100f); float alignedY = VerticalText.ShowTextV(pdfContentByte, Kana.ToZenkaku(text), x, y, fontSize, boxHeight, alignment); return(alignedY); } }
public JapaneseCalendarLibrary(DateTime originalDate, bool treatFirstYearSpecially, bool makeNumbersFullWidth) { // originalDate is not null because it came from OutSystems as a Date Type value and it doesn't have null DateTime. // The minimum value of Date Type is #1900-01-01# var japaneseCalendar = new JapaneseCalendar(); this.Era = japaneseCalendar.GetEra(originalDate); this.EraText = ERA_TEXTS[this.Era]; this.YearInEra = japaneseCalendar.GetYear(originalDate); this.YearInEraText = (this.YearInEra == 1 && treatFirstYearSpecially ? "元年" : this.YearInEra + "年"); if (makeNumbersFullWidth) { this.YearInEraText = Kana.ToZenkaku(this.YearInEraText); } this.DateText = $"{this.EraText}{this.YearInEraText}{originalDate.Month}月{originalDate.Day}日"; if (makeNumbersFullWidth) { this.DateText = Kana.ToZenkaku(this.DateText); } }
//Wide-Narrow Converter Wrapper static internal string ToWide(this string str) => Kana.ToZenkaku(str);