示例#1
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 = 1.0f / pw;
            float             iph = 1.0f / ph;
            stbtt_packedchar *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;
        }
示例#2
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;
        }