本文整理汇总了C++中FontBoundingBox::font_ascent方法的典型用法代码示例。如果您正苦于以下问题:C++ FontBoundingBox::font_ascent方法的具体用法?C++ FontBoundingBox::font_ascent怎么用?C++ FontBoundingBox::font_ascent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FontBoundingBox
的用法示例。
在下文中一共展示了FontBoundingBox::font_ascent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Glyph
Character::Character(long ch, const Font* f, const Color* c) : Glyph() {
c_ = ch;
font_ = f;
Resource::ref(font_);
color_ = c;
Resource::ref(color_);
if (font_ != nil) {
FontBoundingBox b;
font_->char_bbox(c_, b);
left_bearing_ = b.left_bearing();
right_bearing_ = b.right_bearing();
width_ = b.width();
ascent_ = b.font_ascent();
descent_ = b.font_descent();
height_ = ascent_ + descent_;
alignment_ = (height_ == 0) ? 0 : descent_ / height_;
} else {
left_bearing_ = 0;
right_bearing_ = 0;
ascent_ = 0;
descent_ = 0;
width_ = 0;
height_ = 0;
alignment_ = 0;
}
}
示例2: read_idraw_graphic
Glyph* read_idraw_graphic (
FILE* file, const Brush* pb, const Color* pfg, const Color* pbg,
const Font* pf, Stipple* ps
) {
skip(file);
Transformer tx;
Glyph* glyph = nil;
const LayoutKit& layout = *LayoutKit::instance();
if (fscanf(file, "%s", buffer) != EOF) {
figure& fig = figures[which(figures, buffer)];
if (strcmp(fig.name, "Idraw") == 0) {
fscanf(file, "%d", &drawing_version);
figures = versions[drawing_version];
}
const Brush* b = (fig.brush) ? read_brush(file) : nil;
const Color* fg = (fig.foreground) ? read_color(file) : nil;
const Color* bg = (fig.background) ? read_color(file) : nil;
const Font* f = (fig.font) ? read_font(file) : nil;
Stipple* s = (fig.pattern) ? read_stipple(file) : nil;
if (fig.transformer) {
read_transformer(file, tx);
}
if (pb) b = pb;
if (pfg) fg = pfg;
if (pbg) bg = pbg;
if (pf) f = pf;
if (ps) s = ps;
if (fig.name == nil) {
; // error
} else if (
strcmp(fig.name, "Idraw") == 0 || strcmp(fig.name, "Pict") == 0
) {
Glyph* pic = layout.overlay();
Glyph* g;
do {
g = read_idraw_graphic(file, b, fg, bg, f, s);
if (g != nil) {
pic->append(g);
}
} while (g != nil);
glyph = pic;
} else if (strcmp(fig.name, "eop") == 0) {
glyph = nil;
} else if (strcmp(fig.name, "Text") == 0) {
skip(file);
fscanf(file, "%s", buffer);
getc(file);
PolyGlyph* col = layout.vbox_first_aligned();
PolyGlyph* line = layout.hbox_first_aligned();
FontBoundingBox bbox;
f->font_bbox(bbox);
Coord lineheight = bbox.font_ascent() + bbox.font_descent();
if (_idraw_font_metrics) {
lineheight /= fixtextscale;
}
int c;
while ((c = getc(file)) != ']') {
if (c == '\n') {
line->append(layout.strut(f));
col->append(
layout.v_fixed_span(line, lineheight)
);
line = layout.hbox();
} else if (c == ' ') {
if (_idraw_font_metrics) {
line->append(
layout.shape_of(new Character(' ', f, fg))
);
} else {
line->append(new Character(' ', f, fg));
}
} else if (c != ')' && c != '(') {
if (c == '\\') {
c = getc(file);
if (isdigit(c)) {
c -= '0';
c = (c * 8) + getc(file) - '0';
c = (c * 8) + getc(file) - '0';
}
}
line->append(new Character(c, f, fg));
}
}
Transformer fixtext;
if (_idraw_font_metrics) {
fixtext.scale(fixtextscale, fixtextscale);
}
fixtext.translate(0, bbox.font_descent() - lineheight);
glyph = new TransformSetter(col, fixtext);
} else {
skip(file);
int c = fig.coords;
if (c == -1) {
fscanf(file, "%d", &c);
}
Coord xx, yy;
Coord* x = new Coord[c];
//.........这里部分代码省略.........