本文整理汇总了C++中font类的典型用法代码示例。如果您正苦于以下问题:C++ font类的具体用法?C++ font怎么用?C++ font使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了font类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: REPORT_GENERATOR
REPORT_GENERATOR(income, rc)
{
std::ostringstream str;
int viewing_side = rc.screen().viewing_side();
const team &viewing_team = rc.teams()[viewing_side - 1];
team_data td = rc.dc().calculate_team_data(viewing_team, viewing_side);
char const *end = naps;
if (viewing_side != rc.screen().playing_side()) {
if (td.net_income < 0) {
td.net_income = - td.net_income;
str << span_color(font::GRAY_COLOR);
str << utils::unicode_minus;
}
else {
str << span_color(font::GRAY_COLOR);
}
}
else if (td.net_income < 0) {
td.net_income = - td.net_income;
str << span_color(font::BAD_COLOR);
str << utils::unicode_minus;
}
else {
end = "";
}
str << td.net_income << end;
return text_report(str.str());
}
开发者ID:CliffsDover,项目名称:wesnoth,代码行数:28,代码来源:reports.cpp
示例2: get_wide
static string
get_wide (string s, font fn, SI width) {
ASSERT (N(s) >= 2 && s[0] == '<' && s[N(s)-1] == '>',
"invalid rubber character");
string radical= s (0, N(s)-1) * "-";
string first = radical * "0>";
metric ex;
fn->get_extents (first, ex);
if ((ex->x2- ex->x1) >= width) return first;
string second = radical * "1>";
metric ey;
fn->get_extents (second, ey);
SI w1= ex->x2- ex->x1;
SI w2= ey->x2- ey->x1;
if ((w2 <= w1) || (w2 > width)) return first;
SI d= w2- w1;
int n= (width-w1) / (d+1);
int credit= 20;
while (true) {
string test= radical * as_string (n+1) * ">";
fn->get_extents (test, ey);
if (ey->x2- ey->x1 > width || credit <= 0)
return radical * as_string (n) * ">";
n++;
credit--;
}
}
开发者ID:mgubi,项目名称:texmacs,代码行数:29,代码来源:text_boxes.cpp
示例3: hash
std::size_t font_hasher::hash(const font& v) {
std::size_t seed(0);
combine(seed, v.family());
combine(seed, v.style());
combine(seed, v.name());
return seed;
}
开发者ID:memsharded,项目名称:dogen,代码行数:9,代码来源:font_hash.cpp
示例4: make_bbb
glyph
poor_bbb_font_rep::get_glyph (string s) {
glyph gl= base->get_glyph (s);
if (is_nil (gl)) return gl;
font_metric fnm;
font_glyphs fng;
int c= base->index_glyph (s, fnm, fng);
if (c < 0) return glyph ();
return make_bbb (gl, c, wpen, hpen, fat);
}
开发者ID:mgubi,项目名称:texmacs,代码行数:10,代码来源:poor_bbb.cpp
示例5: gray_inactive
static config gray_inactive(reports::context & rc, const std::string &str)
{
if ( rc.screen().viewing_side() == rc.screen().playing_side() )
return text_report(str);
return text_report(span_color(font::GRAY_COLOR) + str + naps);
}
开发者ID:rasata,项目名称:wesnoth,代码行数:7,代码来源:reports.cpp
示例6: unit_abilities
static config unit_abilities(const unit* u)
{
if (!u) return report();
config res;
std::vector<bool> active;
const std::vector<boost::tuple<t_string,t_string,t_string> > &abilities = u->ability_tooltips(&active);
const size_t abilities_size = abilities.size();
for ( size_t i = 0; i != abilities_size; ++i )
{
// Aliases for readability:
const std::string &base_name = abilities[i].get<0>().base_str();
const t_string &display_name = abilities[i].get<1>();
const t_string &description = abilities[i].get<2>();
std::ostringstream str, tooltip;
if ( active[i] )
str << display_name;
else
str << span_color(font::inactive_ability_color) << display_name << naps;
if ( i + 1 != abilities_size )
str << ", ";
tooltip << _("Ability: ") << "<b>" << display_name << "</b>";
if ( !active[i] )
tooltip << "<i>" << _(" (inactive)") << "</i>";
tooltip << '\n' << description;
add_text(res, str.str(), tooltip.str(), "ability_" + base_name);
}
return res;
}
开发者ID:jayantj,项目名称:wesnoth-old,代码行数:33,代码来源:reports.cpp
示例7: str
renderer_i::texture sfml2_renderer::make_text_label(const std::u32string& text,
const color& fill,
const font& font,
float point_size,
text_style style)
{
const sfml2_font& tmp = dynamic_cast<const sfml2_font&>(*font);
const sf::Font& sffont = tmp.sf_font();
sf::String str(reinterpret_cast<const sf::Uint32*>(text.c_str()));
sf::Text label(str, sffont, (int)point_size);
sf::RenderTexture rt;
auto size = label.getLocalBounds();
if (!rt.create(size.width + 1, font->height(point_size) + 1))
throw std::runtime_error("cannot create sf::RenderTexture");
rt.clear(sf::Color::Transparent);
label.move(0, -label.getLocalBounds().top);
label.setColor(col(fill));
label.setStyle(static_cast<sf::Uint32>(style));
rt.draw(label);
rt.display();
return texture{new sfml2_texture{rt.getTexture()}};
}
开发者ID:Nocte-,项目名称:hexahedra,代码行数:25,代码来源:sfml2.cpp
示例8: unit_race
static config unit_race(const unit* u)
{
if (!u) return report();
std::ostringstream str, tooltip;
str << span_color(font::race_color) << u->race()->name(u->gender()) << naps;
tooltip << _("Race: ") << "<b>" << u->race()->name(u->gender()) << "</b>";
return text_report(str.str(), tooltip.str(), "..race_" + u->race()->id());
}
开发者ID:jayantj,项目名称:wesnoth-old,代码行数:8,代码来源:reports.cpp
示例9: floor
void
poor_stretched_font_rep::get_extents (string s, metric& ex) {
base->get_extents (s, ex);
ex->y1= (SI) floor (factor * ex->y1 + 0.5);
ex->y2= (SI) floor (factor * ex->y2 + 0.5);
ex->y3= (SI) floor (factor * ex->y3);
ex->y4= (SI) ceil (factor * ex->y4);
}
开发者ID:mgubi,项目名称:texmacs,代码行数:8,代码来源:poor_stretched.cpp
示例10: stretched
int
poor_stretched_font_rep::index_glyph (string s, font_metric& fnm,
font_glyphs& fng) {
int c= base->index_glyph (s, fnm, fng);
if (c < 0) return c;
fnm= stretched (fnm, 1.0, factor);
fng= stretched (fng, 1.0, factor);
return c;
}
开发者ID:mgubi,项目名称:texmacs,代码行数:9,代码来源:poor_stretched.cpp
示例11:
int
poor_bbb_font_rep::index_glyph (string s, font_metric& fnm,
font_glyphs& fng) {
int c= base->index_glyph (s, fnm, fng);
if (c < 0) return c;
fnm= bolden (fnm, fat, 0);
fng= make_bbb (fng, wpen, hpen, fat);
return c;
}
开发者ID:mgubi,项目名称:texmacs,代码行数:9,代码来源:poor_bbb.cpp
示例12: gray_inactive
static config gray_inactive(const std::string &str)
{
if ( (resources::screen &&
(resources::screen->viewing_side() == resources::screen->playing_side()) )
|| !resources::screen )
return text_report(str);
return text_report(span_color(font::GRAY_COLOR) + str + naps);
}
开发者ID:jayantj,项目名称:wesnoth-old,代码行数:9,代码来源:reports.cpp
示例13: distorted
int
poor_distorted_font_rep::index_glyph (string s, font_metric& fnm,
font_glyphs& fng) {
int c= base->index_glyph (s, fnm, fng);
if (c < 0) return c;
//fnm= distorted (fnm, kind);
fng= distorted (fng, kind, wfn);
return c;
}
开发者ID:mgubi,项目名称:texmacs,代码行数:9,代码来源:poor_distorted.cpp
示例14: unit_type
static config unit_type(const unit* u)
{
if (!u) return report();
std::ostringstream str, tooltip;
str << span_color(font::unit_type_color) << u->type_name() << naps;
tooltip << _("Type: ") << "<b>" << u->type_name() << "</b>\n"
<< u->unit_description();
return text_report(str.str(), tooltip.str(), "unit_" + u->type_id());
}
开发者ID:jayantj,项目名称:wesnoth-old,代码行数:9,代码来源:reports.cpp
示例15: get_min_size
rectangle BtStyle::get_min_size( const ustring& name, const font& mfont ) const
{
unsigned long width;
unsigned long height;
mfont.compute_size( name, width, height );
name_width = width;
return rectangle( width + 2*padding, height + 2*padding );
}
开发者ID:alcemirfernandes,项目名称:GD,代码行数:9,代码来源:nStyle.cpp
示例16: N
void
poor_bbb_font_rep::get_extents (string s, metric& ex) {
base->get_extents (s, ex);
if (N(s) == 0) return;
STACK_NEW_ARRAY (xpos, SI, N(s)+1);
get_xpositions (s, xpos);
ex->x4 += xpos[N(s)] - ex->x2;
ex->x2= xpos[N(s)];
STACK_DELETE_ARRAY (xpos);
}
开发者ID:mgubi,项目名称:texmacs,代码行数:10,代码来源:poor_bbb.cpp
示例17: extents
static neogfx::size extents(const font& aFont, const_iterator aBegin, const_iterator aEnd)
{
neogfx::size result;
bool usingNormal = false;
bool usingFallback = false;
for (glyph_text::const_iterator i = aBegin; i != aEnd; ++i)
{
result.cx += i->advance().cx;
if (!i->use_fallback())
usingNormal = true;
else
usingFallback = true;
}
if (usingNormal || !usingFallback)
result.cy = aFont.height();
if (usingFallback)
result.cy = std::max(result.cy, aFont.fallback().height());
return neogfx::size(std::ceil(result.cx), std::ceil(result.cy));
}
开发者ID:,项目名称:,代码行数:19,代码来源:
示例18: count_trace
string
count_trace (font fn, array<int> cs) {
array<int> a;
for (int i= 0; i < N(cs); i++) {
string s; s << ((char) cs[i]);
glyph g= fn->get_glyph (s);
if (is_nil (g)) return "";
a << pixel_count (g);
}
return array_trace (a);
}
开发者ID:svn2github,项目名称:texmacs,代码行数:11,代码来源:tt_analyze.cpp
示例19: virtual_font
void
math_font_rep::init_font (int fn_nr, font& fn) {
tree t= font_name [fn_nr];
if (is_tuple (t, "virtual", 3))
fn= virtual_font (this, as_string (t[1]), as_int (t[2]),
(int) tm_round (as_int (t[3]) * zf));
else
fn= find_magnified_font (t, zf);
ASSERT (!is_nil (fn), "font not found");
fn->copy_math_pars (base_fn);
font_table [fn_nr]= fn;
}
开发者ID:svn2github,项目名称:texmacs,代码行数:12,代码来源:math_font.cpp
示例20: fallback_font
font fallback_font(font aFont) const
{
if (!use_fallback())
return aFont;
else
{
font fallbackFont = aFont.fallback();
for (uint8_t i = 0; i < iFallbackIndex; ++i)
fallbackFont = fallbackFont.fallback();
return fallbackFont;
}
}
开发者ID:,项目名称:,代码行数:12,代码来源:
注:本文中的font类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论