public void DrawString(ulong stage, CoordinateSpace target, string text, Colour colour, float fontSize, Vector2 position, TextJustify justify, float depth, int layer, bool usKerningsWhereAvaliable = true) { var fntFamily = _fontManager.SystemFont; DrawString(stage, ref target, ref text, colour, ref fontSize, ref position, ref justify, ref depth, ref layer, fntFamily, ref usKerningsWhereAvaliable); }
public void DrawString(IDrawStage stage, CoordinateSpace target, string text, Colour colour, float fontSize, Vector2 position, TextJustify justify, float depth, int layer, IFont font = null, bool usKerningsWhereAvaliable = true) { var fntFamily = font == null ? _fontManager.SystemFont : _fontManager.RetrieveFont(font.Id); DrawString(stage.Id, ref target, ref text, colour, ref fontSize, ref position, ref justify, ref depth, ref layer, fntFamily, ref usKerningsWhereAvaliable); }
public TextEffects() { font = new FontAttributes(); horiz_align = TextJustify.center; vert_align = VerticalAlign.center; mirror = false; }
public TextEffects(float textSize) { font = new FontAttributes(); font.Size = new SizeF(textSize, textSize); horiz_align = TextJustify.center; vert_align = VerticalAlign.center; mirror = false; }
private SKTextAlign GetAlignment(TextJustify textJustify) { switch (textJustify) { case TextJustify.Center: return(SKTextAlign.Center); case TextJustify.Left: return(SKTextAlign.Left); case TextJustify.Right: return(SKTextAlign.Right); default: return(SKTextAlign.Left); } }
/* * private Item FindItem(List<Item> source, string key) { * * foreach (Item item in source) * { * if (item.Key == key) * { * return item; * } * } * return null; * } */ /* * private void DrawTime() * { * Item timeitem = FindItem(PdfPassJson.EventTicket.HeaderFields, "datetime"); * string time = timeitem?.Label; * string date = timeitem?.Value; * DrawProperty(time, date, TextJustify.Right, 7.9, 10.6); * return; * } */ private void DrawProperty(string label, string value, TextJustify textalign, double posX, double posY) { // translate coordinate origin to the center of the picture Contents.SetColorNonStroking(Color.Black); Contents.DrawText(ArialNormal, 16.0, posX, posY, textalign, label); // save graphics state Contents.SaveGraphicsState(); // change nonstroking (fill) color to purple Contents.SetColorNonStroking(Color.White); // Draw second line of heading text // arguments: Handwriting font, Font size 30 point, Position X=4.25", Y=9.0" // Text Justify: Center (text center will be at X position) Contents.DrawText(ArialNormal, 24.0, posX, posY - 0.4, textalign, value); // restore graphics sate (non stroking color will be restored to default) Contents.RestoreGraphicsState(); return; }
//////////////////////////////////////////////////////////////////// // Calculate text horizontal position //////////////////////////////////////////////////////////////////// private double TextHorPos ( out TextJustify Justify ) { if ((Style.Alignment & (ContentAlignment.TopLeft | ContentAlignment.MiddleLeft | ContentAlignment.BottomLeft)) != 0) { Justify = TextJustify.Left; return(ClientLeft); } if ((Style.Alignment & (ContentAlignment.TopRight | ContentAlignment.MiddleRight | ContentAlignment.BottomRight)) != 0) { Justify = TextJustify.Right; return(ClientRight); } if ((Style.Alignment & (ContentAlignment.TopCenter | ContentAlignment.MiddleCenter | ContentAlignment.BottomCenter)) != 0) { Justify = TextJustify.Center; return(0.5 * (ClientLeft + ClientRight)); } Justify = TextJustify.Left; return(ClientLeft); }
//////////////////////////////////////////////////////////////////// // Draw barcode text //////////////////////////////////////////////////////////////////// private void DrawBarcodeText( PdfFont Font, Double FontSize, Double CenterPos, Double TopPos, TextJustify Justify, String Text ) { // test for non printable characters Int32 Index; for(Index = 0; Index < Text.Length && Text[Index] >= ' ' && Text[Index] <= '~'; Index++); if(Index < Text.Length) { StringBuilder Str = new StringBuilder(Text); for(; Index < Text.Length; Index++) if(Str[Index] < ' ' || Str[Index] > '~') Str[Index] = ' '; Text = Str.ToString(); } // draw the text DrawText(Font, FontSize, CenterPos, TopPos - Font.Ascent(FontSize), Justify, Text); return; }
//////////////////////////////////////////////////////////////////// /// <summary> /// Draw web link with one line of text /// </summary> /// <param name="Page">Current page</param> /// <param name="Font">Font</param> /// <param name="FontSize">Font size</param> /// <param name="TextAbsPosX">Text absolute position X</param> /// <param name="TextAbsPosY">Text absolute position Y</param> /// <param name="Justify">Text justify enumeration.</param> /// <param name="DrawStyle">Draw style enumeration</param> /// <param name="TextColor">Color</param> /// <param name="Text">Text</param> /// <param name="WebLink">Web link</param> /// <returns>Text width</returns> /// <remarks> /// The position arguments are in relation to the /// bottom left corner of the paper. /// </remarks> //////////////////////////////////////////////////////////////////// public Double DrawWebLink( PdfPage Page, PdfFont Font, Double FontSize, // in points Double TextAbsPosX, Double TextAbsPosY, TextJustify Justify, DrawStyle DrawStyle, Color TextColor, String Text, String WebLink ) { Double Width = DrawText(Font, FontSize, TextAbsPosX, TextAbsPosY, Justify, DrawStyle, TextColor, Text); if(Width == 0.0) return(0.0); // adjust position switch(Justify) { // right case TextJustify.Right: TextAbsPosX -= Width; break; // center case TextJustify.Center: TextAbsPosX -= 0.5 * Width; break; } Page.AddWebLink(TextAbsPosX, TextAbsPosY - Font.DescentPlusLeading(FontSize), TextAbsPosX + Width, TextAbsPosY + Font.AscentPlusLeading(FontSize), WebLink); return(Width); }
//////////////////////////////////////////////////////////////////// /// <summary> /// Draw text with special effects /// </summary> /// <param name="Font">Font</param> /// <param name="FontSize">Font size</param> /// <param name="PosX">Position X</param> /// <param name="PosY">Position Y</param> /// <param name="Justify">Text justify enumeration</param> /// <param name="OutlineWidth">Outline width</param> /// <param name="StrokingColor">Stoking (outline) color</param> /// <param name="NonStokingColor">Non stroking (fill) color</param> /// <param name="Text">Text</param> /// <returns>Text width</returns> //////////////////////////////////////////////////////////////////// public Double DrawText( PdfFont Font, Double FontSize, // in points Double PosX, Double PosY, TextJustify Justify, Double OutlineWidth, Color StrokingColor, Color NonStokingColor, String Text ) { // text is null or empty if(String.IsNullOrEmpty(Text)) return(0); // add font code to current list of font codes AddToUsedResources(Font); // save graphics state SaveGraphicsState(); // create text position adjustment array based on kerning information KerningAdjust[] KernArray = Font.TextKerning(Text); // text width Double Width = KernArray == null ? Font.TextWidth(FontSize, Text) : Font.TextKerningWidth(FontSize, KernArray); // adjust position switch(Justify) { // right case TextJustify.Right: PosX -= Width; break; // center case TextJustify.Center: PosX -= 0.5 * Width; break; } // special effects TextRendering TR = TextRendering.Fill; if(!StrokingColor.IsEmpty) { SetLineWidth(OutlineWidth); SetColorStroking(StrokingColor); TR = TextRendering.Stroke; } if(!NonStokingColor.IsEmpty) { SetColorNonStroking(NonStokingColor); TR = StrokingColor.IsEmpty ? TextRendering.Fill : TextRendering.FillStroke; } // draw text initialization ContentsString.AppendFormat(NFI.PeriodDecSep, "BT {0} {1} Td{2} {3} Tf {4} Tr ", ToPt(PosX), ToPt(PosY), Font.ResourceCode, Round(FontSize), (Int32) TR); // draw text if(KernArray == null) { ContentsString.AppendFormat("{0} Tj ET\n", Font.PdfText(Text)); } // draw text with kerning else { ContentsString.Append("["); Int32 LastStr = KernArray.Length - 1; for(Int32 Index = 0; Index < LastStr; Index++) { KerningAdjust KA = KernArray[Index]; ContentsString.AppendFormat(NFI.PeriodDecSep, "{0}{1}", Font.PdfText(KA.Text), (Single) (1000.0 * (-KA.Adjust))); } // last string ContentsString.AppendFormat("{0}]TJ ET\n", Font.PdfText(KernArray[LastStr].Text)); } // restore graphics state RestoreGraphicsState(); // exit return(Width); }
//////////////////////////////////////////////////////////////////// // Draw text width draw style //////////////////////////////////////////////////////////////////// /// <summary> /// Draw one line of text with text justification, drawing style and color /// </summary> /// <param name="Font">Font</param> /// <param name="FontSize">Font size</param> /// <param name="PosX">Position X</param> /// <param name="PosY">Position Y</param> /// <param name="Justify">Text justify enumeration</param> /// <param name="DrawStyle">Drawing style enumeration</param> /// <param name="TextColor">Color</param> /// <param name="Text">Text</param> /// <returns>Text width</returns> public Double DrawText( PdfFont Font, Double FontSize, // in points Double PosX, Double PosY, TextJustify Justify, DrawStyle DrawStyle, Color TextColor, String Text ) { // text is null or empty if(String.IsNullOrEmpty(Text)) return(0); // text width Double TextWidth = 0; // we have color if(TextColor != Color.Empty) { // save graphics state SaveGraphicsState(); // change non stroking color SetColorNonStroking(TextColor); } // not subscript or superscript if((DrawStyle & (DrawStyle.Subscript | DrawStyle.Superscript)) == 0) { // draw text string TextWidth = DrawText(Font, FontSize, PosX, PosY, Justify, Text); // not regular style if(DrawStyle != DrawStyle.Normal) { // change stroking color if(TextColor != Color.Empty) SetColorStroking(TextColor); // adjust position switch(Justify) { // right case TextJustify.Right: PosX -= TextWidth; break; // center case TextJustify.Center: PosX -= 0.5 * TextWidth; break; } // underline if((DrawStyle & DrawStyle.Underline) != 0) { Double UnderlinePos = PosY + Font.UnderlinePosition(FontSize); DrawLine(PosX, UnderlinePos, PosX + TextWidth, UnderlinePos, Font.UnderlineWidth(FontSize)); } // strikeout if((DrawStyle & DrawStyle.Strikeout) != 0) { Double StrikeoutPos = PosY + Font.StrikeoutPosition(FontSize); DrawLine(PosX, StrikeoutPos, PosX + TextWidth, StrikeoutPos, Font.StrikeoutWidth(FontSize)); } } } // subscript or superscript else { // subscript if((DrawStyle & (DrawStyle.Subscript | DrawStyle.Superscript)) == DrawStyle.Subscript) { // subscript font size and location PosY -= Font.SubscriptPosition(FontSize); FontSize = Font.SubscriptSize(FontSize); // draw text string TextWidth = DrawText(Font, FontSize, PosX, PosY, Justify, Text); } // superscript if((DrawStyle & (DrawStyle.Subscript | DrawStyle.Superscript)) == DrawStyle.Superscript) { // superscript font size and location PosY += Font.SuperscriptPosition(FontSize); FontSize = Font.SuperscriptSize(FontSize); // draw text string TextWidth = DrawText(Font, FontSize, PosX, PosY, Justify, Text); } } // we have color if(TextColor != Color.Empty) { // save graphics state RestoreGraphicsState(); } // return text width return(TextWidth); }
//////////////////////////////////////////////////////////////////// /// <summary> /// Draw one line of text /// </summary> /// <param name="Font">Font</param> /// <param name="FontSize">Font size</param> /// <param name="PosX">Position X</param> /// <param name="PosY">Position Y</param> /// <param name="Justify">Text justify enumeration</param> /// <param name="Text">Text</param> /// <returns>Text width</returns> //////////////////////////////////////////////////////////////////// public Double DrawText( PdfFont Font, Double FontSize, // in points Double PosX, Double PosY, TextJustify Justify, String Text ) { // text is null or empty if(String.IsNullOrEmpty(Text)) return(0); // add font code to current list of font codes AddToUsedResources(Font); // text width Double Width = Font.TextWidth(FontSize, Text); // adjust position switch(Justify) { // right case TextJustify.Right: PosX -= Width; break; // center case TextJustify.Center: PosX -= 0.5 * Width; break; } // draw text ContentsString.AppendFormat(NFI.PeriodDecSep, "BT{0} {1} Tf {2} {3} Td{4}Tj ET\n", Font.ResourceCode, Round(FontSize), ToPt(PosX), ToPt(PosY), Font.PdfText(Text)); // return text width return(Width); }
public double DrawText(PdfFont font, double FontSize, double PosX, double PosY, TextJustify just, string Text) { Text = RemoveHTMLTagsAndIllegalChars(Text); return(cont.DrawText(font, FontSize, PosX, PosY, just, Text)); }
//////////////////////////////////////////////////////////////////// /// <summary> /// Draw barcode /// </summary> /// <param name="PosX">Position X</param> /// <param name="PosY">Position Y</param> /// <param name="Justify">Barcode justify (using TextJustify enumeration)</param> /// <param name="BarWidth">Narrow bar width</param> /// <param name="BarcodeHeight">Barcode height</param> /// <param name="Barcode">Derived barcode class</param> /// <param name="TextFont">Text font</param> /// <param name="FontSize">Text font size</param> /// <returns>Barcode width</returns> /// <remarks> /// <para> /// PosX can be the left, centre or right side of the barcode. /// The Justify argument controls the meaning of PosX. /// PosY is the position of the bottom side of the barcode. /// If optional text is displayed it will be /// displayed below PosY. If optional text is wider than the /// barcode it will be extended to the left and right sides /// of the barcode. /// </para> /// <para> /// The BarWidth argument is the width of the narrow bar. /// </para> /// <para> /// The BarcodeHeight argument is the height of the barcode /// excluding optional text. /// </para> /// <para> /// Set Barcode to one of the derived classes. /// This library supports: Barcode128, Barcode39 and BarcodeEAN13. /// Note BarcodeEAN13 supports Barcode UPC-A. /// </para> /// <para> /// Barcode text is optional. If TextFont and FontSize are omitted /// no text will be drawn under the barcode. If TextFont and /// FontSize are specified the barcode text will be displayed /// under the barcode. It will be horizontally centered in relation /// to the barcode. /// </para> /// <para> /// Barcode text is displayed below PosY. Make sure to leave /// space under the barcode. /// </para> /// </remarks> //////////////////////////////////////////////////////////////////// public Double DrawBarcode( Double PosX, Double PosY, TextJustify Justify, Double BarWidth, Double BarcodeHeight, Barcode Barcode, PdfFont TextFont = null, Double FontSize = 0.0 ) { return(DrawBarcode(PosX, PosY, Justify, BarWidth, BarcodeHeight, Color.Black, Barcode, TextFont, FontSize)); }
public double GetWrappedTextHeight(PdfFont font, double fontSize, double PosX, double PosY, double wrapWidth, TextJustify just, string text, double?newPageY = null) { text = RemoveHTMLTagsAndIllegalChars(text); TextBox box = new TextBox(wrapWidth); box.AddText(font, fontSize, text); return(box.BoxHeight + .15); //necessary adjustment found through guess-and-check }
public double DrawWrappedText(PdfFont font, double fontSize, double PosX, double PosY, double wrapWidth, TextJustify just, string text, double?newPageY = null) { text = RemoveHTMLTagsAndIllegalChars(text); TextBox box = new TextBox(wrapWidth); try { box.AddText(font, fontSize, text); } catch (Exception xcptn) { Debug.WriteLine("DrawWrappedText exception: " + xcptn.Message); Debug.WriteLine(" text: " + text); } if (drawY < box.BoxHeight) { appendPageBreak(); PosY = newPageY.GetValueOrDefault(drawY); } Double y = PosY; if (just == TextJustify.Center) { PosX += (wrapWidth - box.BoxWidth) / 2; } cont.DrawText(PosX, ref y, 0.0, 0, box); return(box.BoxHeight); }
//////////////////////////////////////////////////////////////////// // Calculate text horizontal position //////////////////////////////////////////////////////////////////// private Double TextHorPos( out TextJustify Justify ) { if((Style.Alignment & (ContentAlignment.TopLeft | ContentAlignment.MiddleLeft | ContentAlignment.BottomLeft)) != 0) { Justify = TextJustify.Left; return(ClientLeft); } if((Style.Alignment & (ContentAlignment.TopRight | ContentAlignment.MiddleRight | ContentAlignment.BottomRight)) != 0) { Justify = TextJustify.Right; return(ClientRight); } if((Style.Alignment & (ContentAlignment.TopCenter | ContentAlignment.MiddleCenter | ContentAlignment.BottomCenter)) != 0) { Justify = TextJustify.Center; return(0.5 * (ClientLeft + ClientRight)); } Justify = TextJustify.Left; return(ClientLeft); }
//////////////////////////////////////////////////////////////////// /// <summary> /// Draw barcode /// </summary> /// <param name="PosX">Position X</param> /// <param name="PosY">Position Y</param> /// <param name="Justify">Barcode justify (using TextJustify enumeration)</param> /// <param name="BarWidth">Narrow bar width</param> /// <param name="BarHeight">Barcode height</param> /// <param name="BarColor">Barcode color</param> /// <param name="Barcode">Derived barcode class</param> /// <param name="TextFont">Text font</param> /// <param name="FontSize">Text font size</param> /// <returns>Barcode width</returns> /// <remarks> /// <para> /// PosX can be the left, centre or right side of the barcode. /// The Justify argument controls the meaning of PosX. /// PosY is the position of the bottom side of the barcode. /// If optional text is displayed it will be /// displayed below PosY. If optional text is wider than the /// barcode it will be extended to the left and right sides /// of the barcode. /// </para> /// <para> /// The BarWidth argument is the width of the narrow bar. /// </para> /// <para> /// The BarcodeHeight argument is the height of the barcode /// excluding optional text. /// </para> /// <para> /// Set Barcode to one of the derived classes. /// This library supports: Barcode128, Barcode39 and BarcodeEAN13. /// Note BarcodeEAN13 supports Barcode UPC-A. /// </para> /// <para> /// Barcode text is optional. If TextFont and FontSize are omitted /// no text will be drawn under the barcode. If TextFont and /// FontSize are specified the barcode text will be displayed /// under the barcode. It will be horizontally centered in relation /// to the barcode. /// </para> /// <para> /// Barcode text is displayed below PosY. Make sure to leave /// space under the barcode. /// </para> /// <para> /// If color other than black is given make sure there is /// a good contrast to white. /// </para> /// </remarks> //////////////////////////////////////////////////////////////////// public Double DrawBarcode( Double PosX, Double PosY, TextJustify Justify, Double BarWidth, Double BarHeight, Color BarColor, Barcode Barcode, PdfFont TextFont = null, Double FontSize = 0.0 ) { // save graphics state SaveGraphicsState(); // set barcode color SetColorNonStroking(BarColor); // barcode width Double TotalWidth = BarWidth * Barcode.TotalWidth; // switch for adjustment switch(Justify) { case TextJustify.Center: PosX -= 0.5 * TotalWidth; break; case TextJustify.Right: PosX -= TotalWidth; break; } // initial bar position Double BarPosX = PosX; // initialize bar color to black Boolean Bar = true; // all barcodes except EAN-13 or UPC-A if(Barcode.GetType() != typeof(BarcodeEAN13)) { // loop for all bars for(Int32 Index = 0; Index < Barcode.BarCount; Index++) { // bar width in user units Double Width = BarWidth * Barcode.BarWidth(Index); // draw black bars if(Bar) DrawRectangle(BarPosX, PosY, Width, BarHeight, PaintOp.Fill); // update bar position and color BarPosX += Width; Bar = !Bar; } // display text if font is specified if(TextFont != null) DrawBarcodeText(TextFont, FontSize, PosX + 0.5 * TotalWidth, PosY, TextJustify.Center, Barcode.Text); } // EAN-13 or UPC-A else { // loop for all bars for(Int32 Index = 0; Index < Barcode.BarCount; Index++) { // bar width in user units Double Width = BarWidth * Barcode.BarWidth(Index); // adjust vertical position Double DeltaY = Index < 7 || Index >= 27 && Index < 32 || Index >= 52 ? 0.0 : 5 * BarWidth; // draw black bars if(Bar) DrawRectangle(BarPosX, PosY + DeltaY, Width, BarHeight - DeltaY, PaintOp.Fill); // update bar position and color BarPosX += Width; Bar = !Bar; } // display text if font is specified if(TextFont != null) { // substrings positions Double PosX1 = PosX - 2.0 * BarWidth; Double PosX2 = PosX + 27.5 * BarWidth; Double PosX3 = PosX + 67.5 * BarWidth; Double PosX4 = PosX + 97.0 * BarWidth; Double PosY1 = PosY + 5.0 * BarWidth; // UPC-A if(Barcode.Text.Length == 12) { DrawBarcodeText(TextFont, FontSize, PosX1, PosY1, TextJustify.Right, Barcode.Text.Substring(0, 1)); DrawBarcodeText(TextFont, FontSize, PosX2, PosY1, TextJustify.Center, Barcode.Text.Substring(1, 5)); DrawBarcodeText(TextFont, FontSize, PosX3, PosY1, TextJustify.Center, Barcode.Text.Substring(6, 5)); DrawBarcodeText(TextFont, FontSize, PosX4, PosY1, TextJustify.Left, Barcode.Text.Substring(11)); } // EAN-13 else { DrawBarcodeText(TextFont, FontSize, PosX1, PosY1, TextJustify.Right, Barcode.Text.Substring(0, 1)); DrawBarcodeText(TextFont, FontSize, PosX2, PosY1, TextJustify.Center, Barcode.Text.Substring(1, 6)); DrawBarcodeText(TextFont, FontSize, PosX3, PosY1, TextJustify.Center, Barcode.Text.Substring(7)); } } } // restore graphics state RestoreGraphicsState(); // return width return(TotalWidth); }
private void DrawString(string text, Vector2 position, TextJustify justify, float fontSize, Colour colour, float depth, int layer = 0, CoordinateSpace coordinateSpace = CoordinateSpace.Screen) { var fntFamily = _fontManager.SystemFont; var fnt = fntFamily.SubFontAtSize(fontSize); var lineHeight = fontSize * (fnt.LineHeight / fnt.Size); float strLength = 0.0f; if (justify == TextJustify.Centre || justify == TextJustify.Right) { strLength = MeasureString(text, fontSize, fntFamily); } var x_curr = position.X; var y_curr = position.Y + (0.5f * fontSize); var scalar = fontSize / fnt.Size; if (justify == TextJustify.Right || justify == TextJustify.Centre) { switch (justify) { case TextJustify.Right: x_curr -= strLength; break; case TextJustify.Centre: x_curr -= 0.5f * strLength; break; } } var startx = (int)x_curr; //this forces pixel line ups.. maybe this is a toggle later for (var c = 0; c < text.Length; c++) { var ch = text[c]; //Deal with specials (f***s up string measure and justify for now) switch (ch) { case '\n': x_curr = startx; y_curr -= lineHeight; continue; case '\t': x_curr += fontSize; continue; } int xPosKerningAdjust = 0; if (c != 0 && fnt.HasKernings) { var lastCh = text[c - 1]; if (fnt.Kernings.ContainsKey(lastCh)) { var d0 = fnt.Kernings[lastCh]; if (d0.ContainsKey(ch)) { xPosKerningAdjust = d0[ch]; } } } FontCharacter chr; if (fnt.Characters.ContainsKey(ch)) { chr = fnt.Characters[ch]; } else { chr = fnt.Characters['?']; } var page = chr.Page; var tex = fnt.Textures[page]; var ww = chr.Width * scalar; var hh = chr.Height * scalar; var x0 = x_curr + (scalar * (chr.XOffset + xPosKerningAdjust)); var x1 = x0 + ww; var y0 = y_curr - (scalar * chr.YOffset); var y1 = y0 - hh; var xt0 = chr.X0; var yt0 = chr.Y0; var xt1 = chr.X1; var yt1 = chr.Y1; Draw(coordinateSpace, colour, new Vertex2D[] { new Vertex2D { Position = new Vector2(x0, y0), TexCoord0 = new Vector2(xt0, yt0), TexCoord1 = Vector2.Zero, TexWeighting = 1.0f, Colour = Colour.White }, new Vertex2D { Position = new Vector2(x1, y0), TexCoord0 = new Vector2(xt1, yt0), TexCoord1 = Vector2.Zero, TexWeighting = 1.0f, Colour = Colour.White }, new Vertex2D { Position = new Vector2(x0, y1), TexCoord0 = new Vector2(xt0, yt1), TexCoord1 = Vector2.Zero, TexWeighting = 1.0f, Colour = Colour.White }, new Vertex2D { Position = new Vector2(x1, y1), TexCoord0 = new Vector2(xt1, yt1), TexCoord1 = Vector2.Zero, TexWeighting = 1.0f, Colour = Colour.White }, }, new int[] { 0, 1, 2, 2, 1, 3 }, depth, layer, FillType.Textured, tex.Id); x_curr += scalar * chr.XAdvance; } }
public void DrawText(string strText, TextJustify justification, int iTopLoc, int iLetterWidth, int iLetterHeight, int iPictX, int iPictY) { int iPrintStart; switch (justification) { case TextJustify.Left: iPrintStart = 100; break; case TextJustify.Center: iPrintStart = (int)((_iMaxX - strText.Length * iLetterWidth) / 2.0); break; case TextJustify.Right: iPrintStart = _iMaxX - 100 - strText.Length * iLetterWidth; break; default: return; } for (var i = 0; i < strText.Length; i++) { DrawLetter(strText[i], (int)((iPrintStart + i * iLetterWidth) / (double)_iMaxX * iPictX), (int)(iTopLoc / (double)_iMaxY * iPictY), (int)(iLetterWidth / (double)_iMaxX * iPictX), (int)(iLetterHeight / (double)_iMaxY * iPictY)); } }
public static void JustifiedLabel(Vector2 position, TextJustify justify) { IEnumerable<TextJustify.WordInfo> words = justify.GetWordsInfo(); float xPos = position.x; justify.Recalculate(); foreach (TextJustify.WordInfo word in words) { Rect pos = new Rect(xPos, position.y, word.width, justify.Style.fontSize); GUI.Label(pos, word.word, justify.Style); xPos += word.width + word.nextSpacing; } }