Exemple #1
0
        public IEnumerable <BakedQuad> GetTextQuads(IEnumerable <string> strs,
                                                    float lineAscender, float lineDescender, float lineGap,
                                                    int hAlign, int vAlign)
        {
            if (strs == null)
            {
                throw new ArgumentNullException("strs");
            }

            float y0 = 0, y1, yPosition = 0;

            y1 = BakedCharCollection.GetVerticalTextHeight(strs, lineAscender, lineDescender, lineGap);
            BakedCharCollection.OffsetTextPositionForAlignment(y0, y1, ref yPosition, vAlign);

            foreach (var str in strs)
            {
                yPosition += lineAscender;

                float sx0, sy0, sx1, sy1, sxPosition = 0, syPosition = yPosition;
                if (GetTextBounds(str, out sx0, out sy0, out sx1, out sy1))
                {
                    BakedCharCollection.OffsetTextPositionForAlignment
                        (sx0, sx1, ref sxPosition, hAlign);

                    foreach (var ch in str)
                    {
                        var quad = GetBakedQuad(ch, ref sxPosition, ref syPosition);
                        if (quad.IsEmpty)
                        {
                            continue;
                        }

                        yield return(quad);
                    }
                }

                yPosition += lineGap - lineDescender;
            }
        }