Esempio n. 1
0
        public bool TextIterNext(FontTextIterator iter, FontGlyphSquad *quad)
        {
            iter.Str = iter.Next;

            if (iter.Str.IsNullOrEmpty)
            {
                return(false);
            }

            iter.Codepoint = Char.ConvertToUtf32(iter.Str.String, iter.Str.Location);
            iter.X         = iter.NextX;
            iter.Y         = iter.NextY;
            var glyph = GetGlyph(iter.Font, iter.Codepoint, iter.iSize, iter.iBlur, iter.BitmapOption);

            if (glyph != null)
            {
                GetQuad(iter.Font, iter.PrevGlyphIndex, glyph, iter.Scale, iter.Spacing, ref iter.NextX, ref iter.NextY,
                        quad);
            }
            iter.PrevGlyphIndex = glyph != null ? glyph->Index : -1;

            if (Char.IsSurrogatePair(iter.Str.String, iter.Str.Location))
            {
                iter.Next.Location += 2;
            }
            else
            {
                ++iter.Next.Location;
            }

            return(true);
        }
Esempio n. 2
0
        public void GetQuad(Font font, int prevGlyphIndex, FontGlyph *glyph, float scale, float spacing, ref float x,
                            ref float y, FontGlyphSquad *q)
        {
            float rx   = 0;
            float ry   = 0;
            float xoff = 0;
            float yoff = 0;
            float x0   = 0;
            float y0   = 0;
            float x1   = 0;
            float y1   = 0;

            if (prevGlyphIndex != -1)
            {
                var adv = font.FontInfo.__tt_getGlyphKernAdvance(prevGlyphIndex, glyph->Index) * scale;
                x += (int)(adv + spacing + 0.5f);
            }

            xoff = (short)(glyph->XOffset + 1);
            yoff = (short)(glyph->YOffset + 1);
            x0   = glyph->X0 + 1;
            y0   = glyph->Y0 + 1;
            x1   = glyph->X1 - 1;
            y1   = glyph->Y1 - 1;
            if ((_params_.Flags & FONS_ZERO_TOPLEFT) != 0)
            {
                rx    = (int)(x + xoff);
                ry    = (int)(y + yoff);
                q->X0 = rx;
                q->Y0 = ry;
                q->X1 = rx + x1 - x0;
                q->Y1 = ry + y1 - y0;
                q->S0 = x0 * _itw;
                q->T0 = y0 * _ith;
                q->S1 = x1 * _itw;
                q->T1 = y1 * _ith;
            }
            else
            {
                rx    = (int)(x + xoff);
                ry    = (int)(y - yoff);
                q->X0 = rx;
                q->Y0 = ry;
                q->X1 = rx + x1 - x0;
                q->Y1 = ry - y1 + y0;
                q->S0 = x0 * _itw;
                q->T0 = y0 * _ith;
                q->S1 = x1 * _itw;
                q->T1 = y1 * _ith;
            }

            x += (int)(glyph->XAdvance / 10.0f + 0.5f);
        }
Esempio n. 3
0
        private void GetQuad(Font font, int prevGlyphIndex, FontGlyph glyph, float scale,
                             float spacing, ref float x, ref float y, FontGlyphSquad *q)
        {
            if (prevGlyphIndex != -1)
            {
                float adv = 0;
                if (UseKernings)
                {
                    adv = font.GetKerning(prevGlyphIndex, glyph.Index) * scale;
                }
                x += (int)(adv + spacing + 0.5f);
            }

            float rx = 0;
            float ry = 0;

            if (_params_.IsAlignmentTopLeft)
            {
                rx    = x + glyph.XOffset;
                ry    = y + glyph.YOffset;
                q->X0 = rx;
                q->Y0 = ry;
                q->X1 = rx + (glyph.X1 - glyph.X0);
                q->Y1 = ry + (glyph.Y1 - glyph.Y0);
                q->S0 = glyph.X0 * _itw;
                q->T0 = glyph.Y0 * _ith;
                q->S1 = glyph.X1 * _itw;
                q->T1 = glyph.Y1 * _ith;
            }
            else
            {
                rx    = x + glyph.XOffset;
                ry    = y - glyph.YOffset;
                q->X0 = rx;
                q->Y0 = ry;
                q->X1 = rx + (glyph.X1 - glyph.X0);
                q->Y1 = ry - (glyph.Y1 + glyph.Y0);
                q->S0 = glyph.X0 * _itw;
                q->T0 = glyph.Y0 * _ith;
                q->S1 = glyph.X1 * _itw;
                q->T1 = glyph.Y1 * _ith;
            }

            x += (int)(glyph.XAdvance / 10.0f + 0.5f);
        }
Esempio n. 4
0
        private void GetQuad(Font font, int prevGlyphIndex, FontGlyph glyph, float scale,
                             float spacing, ref float x, ref float y, FontGlyphSquad *q)
        {
            if (prevGlyphIndex != -1)
            {
                var adv = font._font.fons__tt_getGlyphKernAdvance(prevGlyphIndex, glyph.Index) * scale;
                x += (int)(adv + spacing + 0.5f);
            }

            float rx = 0;
            float ry = 0;

            if ((_params_.Flags & FONS_ZERO_TOPLEFT) != 0)
            {
                rx    = x + glyph.XOffset;
                ry    = y + glyph.YOffset;
                q->X0 = rx;
                q->Y0 = ry;
                q->X1 = rx + (glyph.X1 - glyph.X0);
                q->Y1 = ry + (glyph.Y1 - glyph.Y0);
                q->S0 = glyph.X0 * _itw;
                q->T0 = glyph.Y0 * _ith;
                q->S1 = glyph.X1 * _itw;
                q->T1 = glyph.Y1 * _ith;
            }
            else
            {
                rx    = x + glyph.XOffset;
                ry    = y - glyph.YOffset;
                q->X0 = rx;
                q->Y0 = ry;
                q->X1 = rx + (glyph.X1 - glyph.X0);
                q->Y1 = ry - (glyph.Y1 + glyph.Y0);
                q->S0 = glyph.X0 * _itw;
                q->T0 = glyph.Y0 * _ith;
                q->S1 = glyph.X1 * _itw;
                q->T1 = glyph.Y1 * _ith;
            }

            x += (int)(glyph.XAdvance / 10.0f + 0.5f);
        }
Esempio n. 5
0
        void GetQuad(FontGlyph glyph, FontGlyph prevGlyph, GlyphCollection collection, float spacing, ref float x, ref float y, FontGlyphSquad *q)
        {
            if (prevGlyph != null)
            {
                float adv = 0;
                if (UseKernings && glyph.Font == prevGlyph.Font)
                {
                    adv = prevGlyph.Font.GetGlyphKernAdvance(prevGlyph.Index, glyph.Index) * glyph.Font.Scale;
                }

                x += (int)(adv + spacing + 0.5f);
            }

            float rx = 0;
            float ry = 0;

            rx    = x + glyph.XOffset;
            ry    = y + glyph.YOffset;
            q->X0 = rx;
            q->Y0 = ry;
            q->X1 = rx + glyph.Bounds.Width;
            q->Y1 = ry + glyph.Bounds.Height;
            q->S0 = glyph.Bounds.X * _itw;
            q->T0 = glyph.Bounds.Y * _ith;
            q->S1 = glyph.Bounds.Right * _itw;
            q->T1 = glyph.Bounds.Bottom * _ith;

            x += (int)(glyph.XAdvance / 10.0f + 0.5f);
        }