/// <summary> /// Add a letter to the layouter. /// </summary> /// <param name="c">The letter to add.</param> /// <param name="g">The atlas glyph corresponding to the letter.</param> /// <returns>The draw position of the letter.</returns> public override Vector2 AddLetter(char c, out AtlasGlyph g) { if (_newLineIndices.IndexOf(_counter) != -1) { NewLine(); } _counter++; return(base.AddLetter(c, out g)); }
/// <summary> /// Add a letter to the layouter. /// </summary> /// <param name="c">The letter to add.</param> /// <param name="g">The atlas glyph corresponding to the letter.</param> /// <returns>The draw position of the letter.</returns> public virtual Vector2 AddLetter(char c, out AtlasGlyph g) { Vector2 position = GetNextGlyphPosition(c, out Vector2 drawPosition, out g); _pen = position; if (g == null) { return(position); } _pen.X += g.Advance; return(drawPosition); }
/// <summary> /// Returns the position of the next glyph. /// </summary> /// <param name="pen">The position of the pen.</param> /// <param name="c">The character which is the next glyph.</param> /// <param name="drawPosition">The position to draw the character at.</param> /// <param name="g">The atlas glyph corresponding to the provided character, or null if none.</param> /// <returns>The position of the next glyph along the pen.</returns> public Vector2 GetNextGlyphPosition(Vector2 pen, char c, out Vector2 drawPosition, out AtlasGlyph g) { var result = new Vector2(pen.X, pen.Y); drawPosition = Vector2.Zero; g = null; if (c == '\n') { result.X = 0; result.Y += _atlas.FontHeight + LineGap; } else { if (!_atlas.Glyphs.TryGetValue(c, out g)) { if (!_hasZeroGlyph) { return(result); } g = _atlas.Glyphs[(char)0]; } drawPosition = result; drawPosition.Y += g.YBearing; drawPosition.X = g.XMin + drawPosition.X; } return(result); }
/// <summary> /// Returns the position of the next glyph. /// </summary> /// <param name="c">The character which is the next glyph.</param> /// <param name="drawPosition">The position to draw the character at.</param> /// <param name="g">The atlas glyph corresponding to the provided character, or null if none.</param> /// <returns>The position of the next glyph along the pen.</returns> public Vector2 GetNextGlyphPosition(char c, out Vector2 drawPosition, out AtlasGlyph g) { return(GetNextGlyphPosition(_pen, c, out drawPosition, out g)); }