'''' 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 Arabic text on a GcBitmap.PublicClassArabicTextFunctionGenerateImage(ByVal pixelSize AsSize,ByVal dpi AsSingle,ByVal opaque AsBoolean,OptionalByVal sampleParams AsString() = Nothing) AsGcBitmap Dim Text = "العربية أكبر لغات المجموعة السامية من حيث عدد المتحدثين، وإحدى أكثر اللغات انتشارًا في العالم، يتحدثها أكثر من 422 مليون نسمة،1 ويتوزع متحدثوها في المنطقة المعروفة باسم الوطن العربي، بالإضافة إلى العديد من المناطق الأخرى المجاورة كالأحواز وتركيا وتشاد ومالي والسنغالوارتيرياوللغة العربية أهمية قصوى لدى أتباع الديانة الإسلامية، فهي لغة مصدري التشريع الأساسيين في الإسلام: القرآن، والأحاديث النبوية المروية عن النبي محمد، ولا تتم الصلاة في الإسلام (وعبادات أخرى) إلا بإتقان بعض من كلمات هذه اللغة. والعربية هي أيضًا لغة طقسية رئيسية لدى عدد من الكنائس المسيحية في العالم العربي، كما كتبت بها الكثير من أهم الأعمال الدينية والفكرية اليهودية في العصور الوسطى. وأثّر انتشار الإسلام، وتأسيسه دولًا، أرتفعت مكانة اللغة العربية، وأصبحت لغة السياسة والعلم والأدب لقرون طويلة في الأراضي التي حكمها المسلمون، وأثرت العربية، تأثيرًا مباشرًا أو غير مباشر على كثير من اللغات الأخرى في العالم الإسلامي، كالتركية والفارسية والأرديةوالالبانية واللغات الأفريقية الاخرى واللغات الأوروبية مثل الروسية والإنجليزية والفرنسية والأسبانية والايطالية والألمانية.كما انها تدرس بشكل رسمى او غير رسمى في الدول الاسلامية والدول الأفريقية المحادية للوطن العربى."Dim ia = NewImageAlign(ImageAlignHorz.Left, ImageAlignVert.Top, True, True, False, False, False) Dim bmp = NewGcBitmap(pixelSize.Width, pixelSize.Height, True, dpi, dpi)Using g = bmp.CreateGraphics(Color.White) g.Renderer.Multithreaded = True Dim tl = g.CreateTextLayout() tl.FirstLineIndent = 18 tl.ParagraphSpacing = 6 tl.TextAlignment = TextAlignment.Justified tl.RightToLeft = TrueDim fnt AsGCTEXT.FontDim fpath = Path.Combine("Resources", "Fonts", "times.ttf")IfFile.Exists(fpath) Then fnt = GCTEXT.Font.FromFile(fpath)Else fnt = FontCollection.SystemFonts.FindFamilyName("Times New Roman")EndIfDim tf = NewTextFormat() With { .Font = fnt, .FontSize = 14 } '' Repeat test text to fill a few columnsFor i = 0To3 tl.Append(Text, tf) tl.AppendLine()Next '' Layout text in 3 columns'' (The logic/code in this sample Is identical to JapaneseColumnsConstNCOLS = 3Dim margin = 48.0FDim gap = 24.0FDim colWid = (bmp.Width - margin * 2 - gap * (NCOLS - 1)) / NCOLS tl.MaxWidth = bmp.Width tl.MaxHeight = bmp.Height tl.MarginTop = margin tl.MarginBottom = margin tl.MarginRight = margin tl.MarginLeft = margin + (colWid + 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:Dim rect1 = NewObjectRect(bmp.Width - margin - 315, margin, 320, 320)Dim rect2 = NewObjectRect(margin + 133, margin + 80, 177, 133)Dim rect3 = NewObjectRect(margin, bmp.Height - margin - 400, 400, 385) tl.ObjectRects = New List(OfObjectRect)() From {rect1, rect2, rect3} '' 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 { .RestMarginRight = margin + (colWid + gap) * nextcol, .RestMarginLeft = margin + (colWid + 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 rect1.Height -= 5 rect2.Left += 10 rect3.Width -= 10 Using img = Util.ImageFromFile(Path.Combine("Resources", "Images", "reds.jpg")) g.DrawImage(img, rect1.ToRectangleF(), Nothing, ia)EndUsingUsing img = Util.ImageFromFile(Path.Combine("Resources", "Images", "firth.jpg")) g.DrawImage(img, rect2.ToRectangleF(), Nothing, ia)EndUsingUsing img = Util.ImageFromFile(Path.Combine("Resources", "Images", "purples.jpg")) g.DrawImage(img, rect3.ToRectangleF(), Nothing, ia)EndUsing '' Draw border around the whole image g.DrawRectangle(NewRectangleF(0, 0, bmp.Width, bmp.Height), Color.DarkSlateBlue, 4)EndUsingReturn bmpEndFunctionEndClass