本文整理汇总了C++中Font::GetAscent方法的典型用法代码示例。如果您正苦于以下问题:C++ Font::GetAscent方法的具体用法?C++ Font::GetAscent怎么用?C++ Font::GetAscent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Font
的用法示例。
在下文中一共展示了Font::GetAscent方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawTextOp
void SystemDraw::DrawTextOp(int x, int y, int angle, const wchar *text, Font font, Color ink, int n, const int *dx)
{
GuiLock __;
int ascent = font.GetAscent();
double sina = 0;
double cosa = 1;
if(angle)
Draw::SinCos(angle, sina, cosa);
int xpos = 0;
Buffer<cairo_glyph_t> gs(n);
for(int i = 0; i < n; i++) {
cairo_glyph_t& g = gs[i];
g.index = GetGlyphInfo(font, text[i]).glyphi;
g.x = fround(x + cosa * xpos + sina * ascent);
g.y = fround(y + cosa * ascent - sina * xpos);
xpos += dx ? dx[i] : font[text[i]];
}
static LRUCache<FontSysData, Tuple2<Font, int> > cache;
FontDataSysMaker m;
m.font = font;
m.angle = angle;
FontSysData& sf = cache.Get(m);
cairo_set_scaled_font(cr, sf.scaled_font);
SetColor(ink);
cairo_show_glyphs(cr, gs, n);
cache.Shrink(64);
}
示例2: WriteCenteredLine
Rect Widget::WriteCenteredLine(Graphics* g, int anOffset, const SexyString& theLine)
{
Font* aFont = g->GetFont();
int aWidth = aFont->StringWidth(theLine);
int aX = (mWidth - aWidth) / 2;
g->DrawString(theLine, aX, anOffset);
return Rect(aX, anOffset - aFont->GetAscent(), aWidth, aFont->GetHeight());
}
示例3: PaintCharacterSys
void PaintCharacterSys(Painter& sw, double x, double y, int ch, Font fnt)
{
DrawLock __;
PAINTER_TIMING("CharacterOp");
FT_Face face = FTFace(fnt, NULL);
int glyph_index = FT_Get_Char_Index(face, ch);
if(glyph_index && FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT) == 0)
RenderOutline(face->glyph->outline, sw, x, y + fnt.GetAscent());
sw.EvenOdd(true);
}
示例4: Replace
bool Replace(Font fnt, int chr, Font& rfnt)
{
static Vector<int> rface;
static Vector<dword> l, h;
ONCELOCK {
for(int i = 0; i < __countof(sFontReplacements) && rface.GetCount() < 20; i++) {
int q = Font::FindFaceNameIndex(sFontReplacements[i].name);
if(q > 0) {
rface.Add(q);
l.Add(sFontReplacements[i].l);
h.Add(sFontReplacements[i].h);
}
}
}
Font f = fnt;
// dword tl = chr < 4096 ? 0x80000000 >> (chr >> 7) : 0;
// dword th = 0x80000000 >> ((dword)chr >> 11);
for(int i = 0; i < rface.GetCount(); i++) {
if(/*((l[i] & tl) || (h[i] & th)) && */IsNormal(f.Face(rface[i]), chr)) {
int a = fnt.GetAscent();
int d = fnt.GetDescent();
if(f.GetAscent() > a || f.GetDescent() > d) {
static sFontMetricsReplacement cache[256];
int q = CombineHash(fnt, f) & 255;
if(cache[q].src != fnt || cache[q].dst != f) {
cache[q].src = fnt;
cache[q].dst = f;
while((f.GetAscent() > a || f.GetDescent() > d) && f.GetHeight() > 1) {
f.Height(max(1, min(f.GetHeight() - 1, f.GetHeight() * 9 / 10)));
}
cache[q].mdst = f;
}
else
f = cache[q].mdst;
}
rfnt = f;
return true;
}
}
return false;
}
示例5: PaintCharacter
void PaintCharacter(Painter& sw, const Pointf& p, int chr, Font font)
{
GlyphInfo gi = GetGlyphInfo(font, chr);
PaintCharPath pw;
pw.sw = &sw;
if(gi.IsNormal())
font.Render(pw, p.x, p.y, chr);
else
if(gi.IsReplaced()) {
Font fnt = font;
fnt.Face(gi.lspc);
fnt.Height(gi.rspc);
fnt.Render(pw, p.x, p.y + font.GetAscent() - fnt.GetAscent(), chr);
}
else
if(gi.IsComposed()) {
ComposedGlyph cg;
Compose(font, chr, cg);
font.Render(pw, p.x, p.y, cg.basic_char);
sw.Div();
cg.mark_font.Render(pw, p.x + cg.mark_pos.x, p.y + cg.mark_pos.y, cg.mark_char);
}
sw.EvenOdd(true);
}
示例6: RenderCharacterSys
void RenderCharacterSys(FontGlyphConsumer& sw, double x, double y, int ch, Font fnt)
{
HFONT hfont = GetWin32Font(fnt, 0);
if(hfont) {
HDC hdc = Win32_IC();
HFONT ohfont = (HFONT) ::SelectObject(hdc, hfont);
GLYPHMETRICS gm;
MAT2 m_matrix;
memset(&m_matrix, 0, sizeof(m_matrix));
m_matrix.eM11.value = 1;
m_matrix.eM22.value = 1;
int gsz = GetGlyphOutlineW(hdc, ch, GGO_NATIVE, &gm, 0, NULL, &m_matrix);
if(gsz < 0)
return;
StringBuffer gb(gsz);
gsz = GetGlyphOutlineW(hdc, ch, GGO_NATIVE, &gm, gsz, ~gb, &m_matrix);
if(gsz < 0)
return;
RenderCharPath(~gb, gsz, sw, x, y + fnt.GetAscent());
::SelectObject(hdc, ohfont);
}
}
示例7: DrawText
void Draw::DrawText(int x, int y, int angle, const wchar *text, Font font,
Color ink, int n, const int *dx)
{
#if defined(flagWINGL) || defined(flagLINUXGL)
if(IsNull(ink))
return;
DrawTextOp(x, y, angle, text, font, ink, n, dx);
#else
if(IsNull(ink)) return;
if(n < 0)
n = wstrlen(text);
Std(font);
double sina = 0;
double cosa = 1;
int posx = 0;
if(angle)
Draw::SinCos(angle, sina, cosa);
Font font0 = font;
if(GetInfo() & DRAWTEXTLINES)
font.Underline(false).Strikeout(false);
for(int i = 0; i < n; i++) {
wchar chr = text[i];
GlyphInfo gi = GetGlyphInfo(font, chr);
if(gi.IsNormal())
if(angle)
DrawTextOp(int(x + cosa * posx), int(y - sina * posx), angle, &chr, font, ink, 1, NULL);
else {
int c = 1;
int dd = 0;
while(i + c < n && c < 1000) {
GlyphInfo gi2 = GetGlyphInfo(font, text[i + c]);
if(!gi2.IsNormal())
break;
dd += dx ? dx[c - 1] : gi.width;
c++;
gi = gi2;
}
DrawTextOp(x + posx, y, 0, text + i, font, ink, c, dx);
posx += dd;
i += c - 1;
if(dx)
dx += c - 1;
}
else
if(gi.IsReplaced()) {
Font fnt = font;
fnt.Face(gi.lspc);
fnt.Height(gi.rspc);
if(angle)
DrawTextOp(int(x + cosa * posx), int(y - sina * (font.GetAscent() - fnt.GetAscent() + posx)),
angle, &chr, fnt, ink, 1, NULL);
else
DrawTextOp(x + posx, y + font.GetAscent() - fnt.GetAscent(), 0, &chr, fnt, ink, 1, NULL);
GlyphMetrics(gi, font, chr);
}
else
if(gi.IsComposed()) {
ComposedGlyph cg;
Compose(font, chr, cg);
if(angle) {
DrawTextOp(int(x + cosa * posx), int(y - sina * posx), angle, &cg.basic_char, font, ink, 1, NULL);
DrawTextOp(int(x + cosa * (posx + cg.mark_pos.x)), int(y - sina * (cg.mark_pos.y + posx)), angle, &cg.mark_char, cg.mark_font, ink, 1, NULL);
}
else {
DrawTextOp(x + posx, y, 0, &cg.basic_char, font, ink, 1, NULL);
DrawTextOp(x + cg.mark_pos.x + posx, y + cg.mark_pos.y, 0, &cg.mark_char, cg.mark_font, ink, 1, NULL);
}
GlyphMetrics(gi, font, chr);
}
else {
Font fnt = Arial(font.GetHeight());
wchar chr = 0x25a1;
gi = GetGlyphInfo(fnt, chr);
if(!gi.IsNormal()) {
chr = ' ';
gi = GetGlyphInfo(fnt, chr);
}
if(angle)
DrawTextOp(int(x + cosa * posx), int(y - sina * posx), angle, &chr, fnt, ink, 1, NULL);
else
DrawTextOp(x + posx, y, 0, &chr, fnt, ink, 1, NULL);
}
posx += dx ? *dx++ : gi.width;
}
if((GetInfo() & DRAWTEXTLINES) && (font0.IsUnderline() || font0.IsStrikeout())) {
int hg = abs(font0.GetCy());
if(hg == 0) hg = 10;
int thickness = max(hg / 20, 1);
int ascent = font0.GetAscent();
Size offset = Point(0, ascent);
if(angle) {
offset.cx = fround(ascent * sina);
offset.cy = fround(ascent * cosa);
}
x += offset.cx;
y += offset.cy;
if(font0.IsUnderline()) {
//.........这里部分代码省略.........
示例8: DrawText
void Draw::DrawText(int x, int y, int angle, const wchar *text, Font font,
Color ink, int n, const int *dx)
{
#ifdef flagWINGL
if(IsNull(ink))
return;
DrawTextOp(x, y, angle, text, font, ink, n, dx);
#else
if(IsNull(ink)) return;
if(n < 0)
n = wstrlen(text);
Std(font);
double sina;
double cosa;
int d = 0;
if(angle)
Draw::SinCos(angle, sina, cosa);
for(int i = 0; i < n; i++) {
wchar chr = text[i];
GlyphInfo gi = GetGlyphInfo(font, chr);
if(gi.IsNormal())
if(angle)
DrawTextOp(int(x + cosa * d), int(y - sina * d), angle, &chr, font, ink, 1, NULL);
else {
int c = 1;
int dd = 0;
while(i + c < n) {
GlyphInfo gi2 = GetGlyphInfo(font, text[i + c]);
if(!gi2.IsNormal())
break;
dd += dx ? dx[c] : gi.width;
c++;
gi = gi2;
}
DrawTextOp(x + d, y, 0, text + i, font, ink, c, dx);
d += dd;
i += c - 1;
if(dx)
dx += c - 1;
}
else
if(gi.IsReplaced()) {
Font fnt = font;
fnt.Face(gi.lspc);
fnt.Height(gi.rspc);
if(angle)
DrawTextOp(int(x + cosa * d), int(y - sina * (font.GetAscent() - fnt.GetAscent() + d)),
angle, &chr, fnt, ink, 1, NULL);
else
DrawTextOp(x + d, y + font.GetAscent() - fnt.GetAscent(), 0, &chr, fnt, ink, 1, NULL);
GlyphMetrics(gi, font, chr);
}
else
if(gi.IsComposed()) {
ComposedGlyph cg;
Compose(font, chr, cg);
if(angle) {
DrawTextOp(int(x + cosa * d), int(y - sina * d), angle, &cg.basic_char, font, ink, 1, NULL);
DrawTextOp(int(x + cosa * (d + cg.mark_pos.x)), int(y - sina * (cg.mark_pos.y + d)), angle, &cg.mark_char, cg.mark_font, ink, 1, NULL);
}
else {
DrawTextOp(x + d, y, 0, &cg.basic_char, font, ink, 1, NULL);
DrawTextOp(x + cg.mark_pos.x + d, y + cg.mark_pos.y, 0, &cg.mark_char, cg.mark_font, ink, 1, NULL);
}
GlyphMetrics(gi, font, chr);
}
else {
Font fnt = Arial(font.GetHeight());
wchar chr = 0x25a1;
gi = GetGlyphInfo(fnt, chr);
if(!gi.IsNormal()) {
chr = ' ';
gi = GetGlyphInfo(fnt, chr);
}
if(angle)
DrawTextOp(int(x + cosa * d), int(y - sina * d), angle, &chr, fnt, ink, 1, NULL);
else
DrawTextOp(x + d, y, 0, &chr, fnt, ink, 1, NULL);
}
d += dx ? *dx++ : gi.width;
}
#endif
}