'''' This code is part of Document Solutions for Imaging demos.'' Copyright (c) MESCIUS inc. All rights reserved.''ImportsSystem.IOImportsSystem.DrawingImportsGrapeCity.Documents.DrawingImportsGrapeCity.Documents.TextImportsGrapeCity.Documents.ImagingImports GCTEXT = GrapeCity.Documents.Text '' This sample shows how to draw Japanese text on a GcBitmap.PublicClassJapaneseTextFunctionGenerateImage(ByVal pixelSize AsSize,ByVal dpi AsSingle,ByVal opaque AsBoolean,OptionalByVal sampleParams AsString() = Nothing) AsGcBitmap Dim Text = "日本語(にほんご、にっぽんご)は、主として、日本列島で使用されてきた言語である。日本手話を母語とする者などを除いて、ほぼ全ての日本在住者は日本語を第一言語とする。日本国は法令上、公用語を明記していないが、事実上の公用語となっており、学校教育の「国語」で教えられる。使用者は、日本国内を主として約\uFF11億\uFF13千万人。日本語の文法体系や音韻体系を反映する手話として日本語対応手話がある。"Dim ia = NewImageAlign(ImageAlignHorz.Left, ImageAlignVert.Top, True, True, True, False, False) Dim pageWidth = pixelSize.WidthDim pageHeight = pixelSize.Height Dim bmp = NewGcBitmap(pixelSize.Width, pixelSize.Height, True, dpi, dpi)Using g = bmp.CreateGraphics(Color.White) g.Renderer.Multithreaded = True '' The TextLayout that will hold And render the text:Dim tl = g.CreateTextLayout() tl.FirstLineIndent = 18 tl.ParagraphSpacing = 6 tl.FlowDirection = FlowDirection.VerticalRightToLeft tl.TextAlignment = TextAlignment.JustifiedDim tf = NewTextFormat() With { .Font = GCTEXT.Font.FromFile(Path.Combine("Resources", "Fonts", "NotoSansJP-Regular.ttf")), .FontSize = 14 }'' Repeat sample text to fill the pageFor i = 0To11 tl.Append(Text, tf) tl.AppendLine()Next '' Layout text in 4 horizontal columns '' (The logic/code in this sample Is identical to ArabicText)ConstNCOLS = 4Dim margin = 36.0FDim gap = 18.0FDim colHeight = (pageHeight - margin * 2 - gap * (NCOLS - 1)) / NCOLS tl.MaxWidth = pageWidth tl.MaxHeight = pageHeight tl.MarginLeft = margin tl.MarginRight = margin tl.MarginTop = margin tl.MarginBottom = margin + (colHeight + gap) * (NCOLS - 1)'' We can specify arbitrary rectangles for the text to flow around.'' In this case, we add 3 areas to draw some images: tl.ObjectRects = New List(OfObjectRect)() From {NewObjectRect(pageWidth - margin - 267, margin, 267, 200),NewObjectRect(margin + 100, margin + 60, 133, 100),NewObjectRect(margin, pageHeight - margin - 301, 200, 301) }Using clouds = Util.ImageFromFile(Path.Combine("Resources", "Images", "clouds.jpg")) g.DrawImage(clouds, tl.ObjectRects(0).ToRectangleF(), Nothing, ia)EndUsingUsing firth = Util.ImageFromFile(Path.Combine("Resources", "Images", "firth.jpg")) g.DrawImage(firth, tl.ObjectRects(1).ToRectangleF(), Nothing, ia)EndUsingUsing lavender = Util.ImageFromFile(Path.Combine("Resources", "Images", "lavender.jpg")) g.DrawImage(lavender, tl.ObjectRects(2).ToRectangleF(), Nothing, ia)EndUsing '' THE call: it calculates the glyphs needed To draw the text, And lays it out: tl.PerformLayout(True) For col = 0ToNCOLS - 1Dim nextcol = If(col < NCOLS - 1, col + 1, 0)'' TextSplitOptions tell TextLayout.Split() how to layout the remaining text.'' In this case we advance from column to column by updating top And bottom margins:Dim tso = NewTextSplitOptions(tl) With { .RestMarginTop = margin + (colHeight + gap) * nextcol, .RestMarginBottom = margin + (colHeight + gap) * (NCOLS - 1 - nextcol) }Dim rest AsTextLayout = NothingDim split = tl.Split(tso, rest) g.DrawTextLayout(tl, PointF.Empty)If (split <> SplitResult.Split) ThenExitForEndIf tl = restNext '' Draw border around the whole image g.DrawRectangle(NewRectangleF(0, 0, bmp.Width, bmp.Height), Color.DarkSlateBlue, 4)EndUsingReturn bmpEndFunctionEndClass