public static void stbtt_GetPackedQuad(stbtt_packedchar *chardata, int pw, int ph, int char_index, float *xpos,
                                               float *ypos, stbtt_aligned_quad *q, int align_to_integer)
        {
            var ipw = 1.0f / pw;
            var iph = 1.0f / ph;
            var b   = chardata + char_index;

            if (align_to_integer != 0)
            {
                float x = (int)CRuntime.floor(*xpos + b->xoff + 0.5f);
                float y = (int)CRuntime.floor(*ypos + b->yoff + 0.5f);
                q->x0 = x;
                q->y0 = y;
                q->x1 = x + b->xoff2 - b->xoff;
                q->y1 = y + b->yoff2 - b->yoff;
            }
            else
            {
                q->x0 = *xpos + b->xoff;
                q->y0 = *ypos + b->yoff;
                q->x1 = *xpos + b->xoff2;
                q->y1 = *ypos + b->yoff2;
            }

            q->s0 = b->x0 * ipw;
            q->t0 = b->y0 * iph;
            q->s1 = b->x1 * ipw;
            q->t1 = b->y1 * iph;
            *xpos += b->xadvance;
        }
        public static void stbtt_GetBakedQuad(stbtt_bakedchar *chardata, int pw, int ph, int char_index, float *xpos,
                                              float *ypos, stbtt_aligned_quad *q, int opengl_fillrule)
        {
            var d3d_bias = opengl_fillrule != 0 ? 0 : -0.5f;
            var ipw      = 1.0f / pw;
            var iph      = 1.0f / ph;
            var b        = chardata + char_index;
            var round_x  = (int)CRuntime.floor(*xpos + b->xoff + 0.5f);
            var round_y  = (int)CRuntime.floor(*ypos + b->yoff + 0.5f);

            q->x0 = round_x + d3d_bias;
            q->y0 = round_y + d3d_bias;
            q->x1 = round_x + b->x1 - b->x0 + d3d_bias;
            q->y1 = round_y + b->y1 - b->y0 + d3d_bias;
            q->s0 = b->x0 * ipw;
            q->t0 = b->y0 * iph;
            q->s1 = b->x1 * ipw;
            q->t1 = b->y1 * iph;
            *xpos += b->xadvance;
        }
Beispiel #3
0
        public static void stbtt_GetBakedQuad(stbtt_bakedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int opengl_fillrule)
        {
            float            d3d_bias = (opengl_fillrule) != 0 ? 0 : -0.5f;
            float            ipw      = 1.0f / pw;
            float            iph      = 1.0f / ph;
            stbtt_bakedchar *b        = chardata + char_index;
            int round_x = ((int)(CRuntime.Floor((*xpos + b->xoff) + 0.5f)));
            int round_y = ((int)(CRuntime.Floor((*ypos + b->yoff) + 0.5f)));

            q->x0 = round_x + d3d_bias;
            q->y0 = round_y + d3d_bias;
            q->x1 = round_x + b->x1 - b->x0 + d3d_bias;
            q->y1 = round_y + b->y1 - b->y0 + d3d_bias;
            q->s0 = b->x0 * ipw;
            q->t0 = b->y0 * iph;
            q->s1 = b->x1 * ipw;
            q->t1 = b->y1 * iph;
            *xpos += b->xadvance;
        }
Beispiel #4
0
        public static void stbtt_GetPackedQuad(stbtt_packedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int align_to_integer)
        {
            float             ipw = (float)(1.0f / pw);
            float             iph = (float)(1.0f / ph);
            stbtt_packedchar *b   = chardata + char_index;

            if ((align_to_integer) != 0)
            {
                float x = (float)((int)(CRuntime.floor((double)((*xpos + b->xoff) + 0.5f))));
                float y = (float)((int)(CRuntime.floor((double)((*ypos + b->yoff) + 0.5f))));
                q->x0 = (float)(x);
                q->y0 = (float)(y);
                q->x1 = (float)(x + b->xoff2 - b->xoff);
                q->y1 = (float)(y + b->yoff2 - b->yoff);
            }
            else
            {
                q->x0 = (float)(*xpos + b->xoff);
                q->y0 = (float)(*ypos + b->yoff);
                q->x1 = (float)(*xpos + b->xoff2);
                q->y1 = (float)(*ypos + b->yoff2);
            }

            q->s0 = (float)(b->x0 * ipw);
            q->t0 = (float)(b->y0 * iph);
            q->s1 = (float)(b->x1 * ipw);
            q->t1 = (float)(b->y1 * iph);
            *xpos += (float)(b->xadvance);
        }