Beispiel #1
0
void text_renderer<T>::render(pixel_position pos)
{
    FT_Error  error;
    FT_Vector start;
    unsigned height = pixmap_.height();

    start.x =  static_cast<FT_Pos>(pos.x * (1 << 6));
    start.y =  static_cast<FT_Pos>((height - pos.y) * (1 << 6));

    // now render transformed glyphs
    typename glyphs_t::iterator itr;
    for (itr = glyphs_.begin(); itr != glyphs_.end(); ++itr)
    {
        double halo_radius = itr->properties->halo_radius;
        //make sure we've got reasonable values.
        if (halo_radius <= 0.0 || halo_radius > 1024.0) continue;
        stroker_.init(halo_radius);
        FT_Glyph g;
        error = FT_Glyph_Copy(itr->image, &g);
        if (!error)
        {
            FT_Glyph_Transform(g,0,&start);
            FT_Glyph_Stroke(&g,stroker_.get(),1);
            error = FT_Glyph_To_Bitmap( &g,FT_RENDER_MODE_NORMAL,0,1);
            if ( ! error )
            {

                FT_BitmapGlyph bit = (FT_BitmapGlyph)g;
                render_bitmap(&bit->bitmap, itr->properties->halo_fill.rgba(),
                              bit->left,
                              height - bit->top, itr->properties->text_opacity);
            }
        }
        FT_Done_Glyph(g);
    }
    //render actual text
    for (itr = glyphs_.begin(); itr != glyphs_.end(); ++itr)
    {

        FT_Glyph_Transform(itr->image,0,&start);

        error = FT_Glyph_To_Bitmap( &(itr->image),FT_RENDER_MODE_NORMAL,0,1);
        if ( ! error )
        {

            FT_BitmapGlyph bit = (FT_BitmapGlyph)itr->image;
            render_bitmap(&bit->bitmap, itr->properties->fill.rgba(),
                          bit->left,
                          height - bit->top, itr->properties->text_opacity);
        }
    }
}
Beispiel #2
0
int seed_drop(BYTE *ColorNybbles,int x,int y)
{
	if(get_center_distance(x,y)<100){
		render_bitmap(BitmapScreen,BullseyeChar,x,y,0,2,1,8);
		return FALSE;
	}
	else{
		render_bitmap(BitmapScreen,VortexChar,x-8,y-8,0,2,2,16);
		if(!seed_dropped){
			seed_dropped=TRUE;
			ship_smear[0].seed_x=x+12;
			ship_smear[0].seed_y=y+11;
		}
		return TRUE;
	}
}
Beispiel #3
0
     void TextRasterizer<PixBuffer>::render(const char* text)
 {
     FT_Library library;
     FT_Face face;
     FT_Error  error;
     error = FT_Init_FreeType( &library );
     if (error)
     {
         cout<<"an error occurred during library initialization\n";
         return;
     }
     error = FT_New_Face( library, fontName_.c_str(), 0, &face );
     if (error == FT_Err_Unknown_File_Format )
     {
         cout<<"the font file could be opened and read, but it appears\n";
         cout<<"that its font format is unsupported"<<endl;
         return;
     }
     else if ( error )
     {
         cout<<"font file could not be opened or read, or simply that it is broken\n";
         return;
     }
     error = FT_Set_Pixel_Sizes(face,24,0);
     FT_GlyphSlot slot = face->glyph;
     int x=40,y=200;
     int len=strlen(text);
     for (int i=0;i<len;++i)
     {
         FT_UInt glyph_index;
         glyph_index = FT_Get_Char_Index(face,text[i]);
         error=FT_Load_Glyph(face,glyph_index,FT_LOAD_DEFAULT);
         if (error) continue;
         error=FT_Render_Glyph( face->glyph,FT_RENDER_MODE_NORMAL);
         if (error) continue;
         render_bitmap(&slot->bitmap,x+slot->bitmap_left,y-slot->bitmap_top);
         x+=slot->advance.x>>6;
         y+=slot->advance.y>>6;
     }
     FT_Done_Face(face);
     FT_Done_FreeType(library);
 }
Beispiel #4
0
bool SkDrawSpriteCommand::render(SkCanvas* canvas) const {
    render_bitmap(canvas, fBitmap);
    return true;
}
Beispiel #5
0
bool SkDrawBitmapRectCommand::render(SkCanvas* canvas) const {
    render_bitmap(canvas, fBitmap, this->srcRect());
    return true;
}