STBTTFontEssence( BitmapGlyphRenderingBase& parent, TextureUnitSelector bitmap_tex_unit, TextureUnitSelector metric_tex_unit, TextureUnitSelector pg_map_tex_unit, const std::string& font_name, GLsizei frames, GLint default_page, GLuint pixel_height ): _parent(parent) , _tt_font(std::ifstream(_page_font_path(font_name), std::ios::binary)) , _font_resolution(pixel_height) , _tex_side(BitmapGlyphDefaultPageTexSide(parent, _font_resolution)) , _pager( parent, pg_map_tex_unit, frames ), _initial_frame(_pager.FindFrame()) , _page_storage( parent, bitmap_tex_unit, metric_tex_unit, _initial_frame, frames, _make_page_bitmap(default_page), _make_page_metric(default_page) ) { _pager.SwapPageIn(_initial_frame, default_page); }
BitmapGlyphFontEssence( BitmapGlyphRenderingBase& parent, TextureUnitSelector bitmap_tex_unit, TextureUnitSelector metric_tex_unit, TextureUnitSelector pg_map_tex_unit, const std::string& font_name, SizeType frames, GLuint default_page, GLuint /* pixel_height*/ ): _parent(parent) , _font_name(font_name) , _pager( parent, pg_map_tex_unit, frames ), _initial_frame(_pager.FindFrame()) , _page_storage( parent, bitmap_tex_unit, metric_tex_unit, _initial_frame, frames, _load_page_bitmap(default_page), _load_page_metric(default_page) ) { _pager.SwapPageIn(_initial_frame, default_page); }
void _do_load_pages( PageGetter get_page, const Element* elem, GLsizei size ) { _page_storage.Bind(); // go through the list of code-points for(GLsizei i=0; i!=size; ++i) { // get the page number for the glyph GLuint page = get_page(elem[i]); // check if the page is active if(!_pager.UsePage(page)) { // if not let the pager find // a frame for the new page auto frame = _pager.FindFrame(); // load the bitmap image _page_storage.LoadPage( frame, _load_page_bitmap(page), _load_page_metric(page) ); // tell the pages that the page // is successfully loaded in the frame _pager.SwapPageIn(frame, page); } } }
void _do_load_pages( const Element* elem, GLsizei size ) { _page_storage.Bind(); // go through the list of code-points for(GLsizei i=0; i!=size; ++i) { // get the page number for the glyph GLint page = elem[i]; // check if the page is active if(!_pager.UsePage(page)) { // if not let the pager find // a frame for the new page auto frame = _pager.FindFrame(); // load the bitmap image unsigned glyphs_per_page = BitmapGlyphGlyphsPerPage(_parent); std::vector<unsigned char> bmp(_tex_side*_tex_side); std::vector<GLfloat> metrics(glyphs_per_page*12); _do_make_page_bitmap_and_metric( page, bmp.data(), metrics.data() ); _page_storage.LoadPage( frame, images::Image( _tex_side, _tex_side, 1, 1, bmp.data(), PixelDataFormat::Red, PixelDataInternalFormat::R8 ), metrics ); // tell the pager that the page // is successfully loaded in the frame _pager.SwapPageIn(frame, page); } } }