本文整理汇总了C++中FontInfo::GetAscent方法的典型用法代码示例。如果您正苦于以下问题:C++ FontInfo::GetAscent方法的具体用法?C++ FontInfo::GetAscent怎么用?C++ FontInfo::GetAscent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FontInfo
的用法示例。
在下文中一共展示了FontInfo::GetAscent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TextOnPath
void TextOnPath(Painter& sw)
{
Font fnt = Roman(100);
FontInfo fi = fnt.Info();
double pos = 0;
const char *s = "Hello world, this is text on path!";
int l = GetTextSize(s, fnt).cx;
double r = l / (2 * M_PI);
sw.Circle(300, 300, r).Stroke(1, Red());
while(*s) {
double w = fi[*s];
sw.BeginOnPath(pos + w / 2, true);
sw.Character(-w / 2, -fi.GetAscent(), *s++, fnt)
.Fill(0, -fi.GetAscent(), Yellow(), 0, fi.GetDescent(), Blue())
.Stroke(1, Black());
sw.End();
pos += w;
}
}
示例2: DrawMnemonicText
void DrawMnemonicText(Draw& w, int x, int y, const String& s, Font font, Color color,
int mnemonic, bool menumark)
{
int apos = HIWORD(mnemonic);
int q;
if(apos && apos < s.GetLength())
q = apos - 1;
else {
q = s.Find(ToUpper(mnemonic));
if(q < 0)
q = s.Find(ToLower(mnemonic));
}
w.DrawText(x, y, s, font, color);
if(q < 0) return;
FontInfo f = font.Info();
w.DrawRect(x + GetTextSize(~s, font, q).cx, y + f.GetAscent() + 1, f[s[q]], 1,
menumark ? SColorMenuMark() : SColorMark());
}
示例3: DrawFileName
void DrawFileName(Draw& ww, int x0, int y, int wcx0, int cy, const WString& mname, bool isdir, Font font,
Color ink, Color extink, const WString& desc, Font descfont, bool justname, Color uln)
{
for(int pass = IsNull(uln); pass < 2; pass++) {
NilDraw nd;
Draw *w = pass ? &ww : &nd;
FontInfo fi = font.Info();
int extpos = (isdir ? -1 : mname.ReverseFind('.'));
int slash = isdir ? -1 : max(mname.ReverseFind('\\'), mname.ReverseFind('/'));
if(extpos < slash)
extpos = -1;
const wchar *ext = extpos >= slash && extpos >= 0 ? mname.Begin() + extpos + 1
: mname.End();
const wchar *name = mname;
if(justname && slash >= 0)
name += slash + 1;
int txtcx = GetTextSize(fi, name);
int x = x0;
int wcx = wcx0;
if(txtcx <= wcx) {
if(pass == 0)
ww.DrawRect(x0, y + fi.GetAscent() + 1, txtcx, 1, uln);
ww.DrawText(x, y, name, font, ink, (int)(ext - name));
ww.DrawText(x + GetTextSize(fi, name, ext), y, ext, font, extink, (int)(mname.End() - ext));
if(!IsEmpty(desc) && pass)
DrawTextEllipsis(ww, x + fi.GetHeight(), y, wcx - txtcx,
desc, "...", descfont, extink);
x += txtcx;
return;
}
else {
int dot3 = 3 * fi['.'];
if(2 * dot3 > wcx) {
int n = GetTextFitCount(fi, name, wcx);
w->DrawText(x, y, name, font, ink, n);
x += GetTextSize(fi, name, name + n);
}
else {
const wchar *end = mname.End();
int dircx = 2 * fi['.'] + fi[DIR_SEP];
const wchar *bk = strdirsep(name);
if(bk) {
wcx -= dircx;
w->DrawText(x, y, ".." DIR_SEPS, font, SColorDisabled, 3);
x += dircx;
do {
txtcx -= GetTextSize(fi, name, bk + 1);
name = bk + 1;
if(txtcx < wcx) {
w->DrawText(x, y, name, font, ink, (int)(ext - name));
x += GetTextSize(fi, name, ext);
w->DrawText(x, y, ext, font, extink, (int)(end - ext));
x += GetTextSize(fi, ext, end);
goto end;
}
bk = strdirsep(name);
}
while(bk);
}
wcx -= dot3;
int extcx = GetTextSize(fi, ext, end);
if(2 * extcx > wcx || ext == end) {
int n = GetTextFitCount(fi, name, wcx);
w->DrawText(x, y, name, font, ink, n);
x += GetTextSize(fi, name, name + n);
w->DrawText(x, y, "...", font, SColorDisabled, 3);
x += dot3;
}
else {
wcx -= extcx;
int n = (int)(GetTextFitLim(fi, name, end, wcx) - name);
w->DrawText(x, y, name, font, ink, n);
x += GetTextSize(fi, name, name + n);
w->DrawText(x, y, "...", font, SColorDisabled, 3);
w->DrawText(x + dot3, y, ext, font, extink, (int)(end - ext));
x += dot3 + extcx;
}
}
}
end:
if(pass == 0)
ww.DrawRect(x0, y + fi.GetAscent() + 1, x - x0, 1, uln);
}
}
示例4: Format
bool Paragraph::Format(ParaTypo& pfmt, int cx, int zoom) const {
int len = length + !!style.indent;
Buffer<char> chr(len);
Buffer<int> width(len);
Buffer<ParaTypo::Part *> info(len);
Buffer<ParaTypo::Part> pinfo(part.GetCount() + !!style.indent);
const Part *pptr = part.Begin();
const Part *plim = part.End();
ParaTypo::Part *pp = pinfo;
char *cp = chr;
int *wp = width;
ParaTypo::Part **ip = info;
if(!IsNull(parafont)) {
Font pf = parafont;
// pf.Height(max(1, DocZoom(zoom, parafont.GetHeight())));
int n = DocZoom(zoom, parafont.GetHeight());
pf.Height(n ? n : 1);
FontInfo f = pf.Info();
pfmt.SetMin(f.GetAscent(), f.GetDescent(), f.GetExternal());
}
/* if(!IsNull(parafont)) {
FontInfo f = w.GetFontInfo(parafont);
pfmt.SetMin(DocZoom(zoom, f.GetAscent()),
DocZoom(zoom, f.GetDescent()),
DocZoom(zoom, f.GetExternal()));
}
*/ if(style.indent) {
static Part dummy;
*cp++ = ' ';
*wp++ = DocZoom(zoom, style.indent);
pp->Set(Arial(0), Black);
pp->voidptr = &dummy;
*ip++ = pp;
pp++;
}
while(pptr != plim) {
if(pptr->pr) {
*cp++ = '@';
Size sz = pptr->pr.GetStdSize();
*wp++ = pp->width = pptr->pr && !pptr->sz.cx ? sz.cx : DocZoom(zoom, pptr->sz.cx);
*ip++ = pp;
pp->ascent = minmax(pptr->pr && !pptr->sz.cy ? sz.cy : DocZoom(zoom, pptr->sz.cy), 0, 1000);
pp->descent = 0;
pp->external = pp->overhang = 0;
pp->color = pptr->color;
}
else {
Font font = pptr->font;
font.Height(DocZoom(zoom, pptr->font.GetHeight()));
FontInfo pf = pp->Set(font, pptr->color);
const char *s = pptr->text;
int n = pptr->text.GetLength();
while(n--) {
*cp++ = *s;
*wp++ = pf[*s == 31 ? 32 : ToUnicode((byte) *s, CHARSET_DEFAULT)];
*ip++ = pp;
s++;
}
}
pp->voidptr = (void *)pptr;
pp++;
pptr++;
}
return pfmt.Format(style.align, len, chr, width, info, cx);
}