本文整理汇总了C++中BitmapFont::add_character方法的典型用法代码示例。如果您正苦于以下问题:C++ BitmapFont::add_character方法的具体用法?C++ BitmapFont::add_character怎么用?C++ BitmapFont::add_character使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitmapFont
的用法示例。
在下文中一共展示了BitmapFont::add_character方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load
//.........这里部分代码省略.........
read_string(file);
}
break;
case BmfCommonBlock::TYPE:
common_block.line_height = read_uint16(file);
common_block.base = read_uint16(file);
common_block.scale_w = read_uint16(file);
common_block.scale_h = read_uint16(file);
common_block.pages = read_uint16(file);
common_block.bit_field = read_uint8(file);
common_block.alpha_channel = read_uint8(file);
common_block.red_channel = read_uint8(file);
common_block.green_channel = read_uint8(file);
common_block.blue_channel = read_uint8(file);
break;
case BmfPageBlock::TYPE:
read_string(file);
break;
case BmfCharBlock::TYPE:
{
int number_of_characters = block_size / 20;
log::debug("BitmapFontLoader: number of characters in font file: %", number_of_characters);
for (int i=0; i<number_of_characters; i++)
{
BmfCharBlock block;
block.id = read_uint32(file);
block.x = read_uint16(file);
block.y = read_uint16(file);
block.width = read_uint16(file);
block.height = read_uint16(file);
block.offset_x = read_int16(file);
block.offset_y = read_int16(file);
block.advance_x = read_uint16(file);
block.page = read_uint8(file);
block.channel = read_uint8(file);
//log::debug("BitmapFontLoader: char id: % (%)", block.id, (char)block.id);
character_blocks.push_back(block);
if (block.id > largest_id)
largest_id = block.id;
}
}
break;
case BmfKerningPairBlock::TYPE:
{
int number_of_kerning_pairs = block_size / 10;
for (int i=0; i<number_of_kerning_pairs; i++)
{
BmfKerningPairBlock block;
block.first = read_uint32(file);
block.second = read_uint32(file);
block.amount = read_int16(file);
}
}
break;
default:
throw ParseError("Invalid block type " + to_string(static_cast<unsigned int>(block_type)));
}
}
}
catch (EndOfFile &eof)
{
log::error("BitmapFontLoader: Encountered end of file unexpectedly.");
log::debug("File position: %", file.tellg());
file.close();
return false;
}
catch (ParseError &err)
{
log::error("BitmapFontLoader: Failed to parse font definition. Position: %\n Reason: %", file.tellg(), err.what());
file.close();
return false;
}
file.close();
font.m_base = common_block.base;
font.m_line_height = common_block.line_height;
font.reserve(largest_id+1);
for (BmfCharBlock &cblock : character_blocks)
{
BitmapFontCharacter c;
c.id = cblock.id;
c.x = cblock.x;
c.y = cblock.y;
c.width = cblock.width;
c.height = cblock.height;
c.offset_x = cblock.offset_x;
c.offset_y = cblock.offset_y;
c.advance_x = cblock.advance_x;
font.add_character(c);
}
return true;
}