Esempio n. 1
0
FTGlyph::FTGlyph (FT_GlyphSlot glyph)
	:   err(0) {
	if (glyph) {
		bBox = FTBBox (glyph);
		advance = FTPoint (glyph->advance.x / 64.0f, glyph->advance.y / 64.0f, 0.0f);
	}
}
Esempio n. 2
0
FTGlyphImpl::FTGlyphImpl(FT_GlyphSlot glyph, bool /*useList*/) : err(0)
{
    if(glyph)
    {
        bBox = FTBBox(glyph);
        advance = FTPoint(glyph->advance.x / 64.0f,
                          glyph->advance.y / 64.0f);
    }
}
Esempio n. 3
0
FTGlyph::FTGlyph( FT_GlyphSlot glyph, bool useList)
:   useDisplayList(useList),
    err(0)  
{
    if( glyph)
    {
        bBox = FTBBox( glyph);
        advance = FTPoint( glyph->advance.x / 64.0f, glyph->advance.y / 64.0f, 0.0f);
    }
}
Esempio n. 4
0
FTGlyph::FTGlyph(FileStream & stream, char * data,
                 int x_offset, int y_offset,
                 int tex_width, int tex_height)
: tex(0)
{
    charcode = stream.read_uint32();
    float x1, y1, x2, y2;
    x1 = stream.read_float();
    y1 = stream.read_float();
    x2 = stream.read_float();
    y2 = stream.read_float();
    bBox = FTBBox(x1, y1, x2, y2);
    float advance_x, advance_y;
    advance_x = stream.read_float();
    advance_y = stream.read_float();
    advance = FTPoint(advance_x, advance_y);
    float corner_x, corner_y;
    corner_x = stream.read_float();
    corner_y = stream.read_float();
    corner = FTPoint(corner_x, corner_y);
    width = stream.read_int32();
    height = stream.read_int32();

    char * glyph = new char[width*height];
    stream.read(glyph, width * height);

    if (width && height) {
        if (y_offset + height > tex_height) {
            // copy subimage
            height = tex_height - y_offset;
        }
        if (height >= 0) {
            for (int y = 0; y < height; ++y) {
                for (int x = 0; x < width; ++x) {
                    char c = glyph[y * width + x];
                    data[(y + y_offset) * tex_width + x + x_offset] = c;
                }
            }
        }
    }

#ifdef USE_OUTLINE
    uv[0].X(float(x_offset - 1) / float(tex_width));
    uv[0].Y(float(y_offset - 1) / float(tex_height));
    uv[1].X(float(x_offset + width + 1) / float(tex_width));
    uv[1].Y(float(y_offset + height + 1) / float(tex_height));
#else
    uv[0].X(float(x_offset) / float(tex_width));
    uv[0].Y(float(y_offset) / float(tex_height));
    uv[1].X(float(x_offset + width) / float(tex_width));
    uv[1].Y(float(y_offset + height) / float(tex_height));
#endif

    delete[] glyph;
}
Esempio n. 5
0
inline void FTSimpleLayoutImpl::OutputWrappedI(const T *buf, const int len,
                                               FTPoint position, int renderMode,
                                               const float remaining,
                                               FTBBox *bounds)
{
    float distributeWidth = 0.0;
    // Align the text according as specified by Alignment
    switch (alignment)
    {
        case FTGL::ALIGN_LEFT:
            pen.X(0);
            break;
        case FTGL::ALIGN_CENTER:
            pen.X(remaining / 2);
            break;
        case FTGL::ALIGN_RIGHT:
            pen.X(remaining);
            break;
        case FTGL::ALIGN_JUSTIFY:
            pen.X(0);
            distributeWidth = remaining;
            break;
    }

    // If we have bounds expand them by the line's bounds, otherwise render
    // the line.
    if(bounds)
    {
        FTBBox temp = currentFont->BBox(buf, len);

        // Add the extra space to the upper x dimension
        temp = FTBBox(temp.Lower() + pen,
                      temp.Upper() + pen + FTPoint(distributeWidth, 0));

        // See if this is the first area to be added to the bounds
        if(bounds->IsValid())
        {
            *bounds |= temp;
        }
        else
        {
            *bounds = temp;
        }
    }
    else
    {
        RenderSpace(buf, len, position, renderMode, distributeWidth);
    }
}