void InsetVSpace::draw(PainterInfo & pi, int x, int y) const { Dimension const dim = dimension(*pi.base.bv); x += ADD_TO_VSPACE_WIDTH; int const start = y - dim.asc; int const end = y + dim.des; // y-values for top arrow int ty1, ty2; // y-values for bottom arrow int by1, by2; if (space_.kind() == VSpace::VFILL) { ty1 = ty2 = start; by1 = by2 = end; } else { // adding or removing space bool const added = space_.kind() != VSpace::LENGTH || space_.length().len().value() >= 0.0; ty1 = added ? (start + vspace_arrow_size) : start; ty2 = added ? start : (start + vspace_arrow_size); by1 = added ? (end - vspace_arrow_size) : end; by2 = added ? end : (end - vspace_arrow_size); } int const midx = x + vspace_arrow_size; int const rightx = midx + vspace_arrow_size; // first the string int w = 0; int a = 0; int d = 0; FontInfo font; font.setColor(Color_added_space); font.decSize(); font.decSize(); docstring const lab = label(); theFontMetrics(font).rectText(lab, w, a, d); pi.pain.rectText(x + 2 * vspace_arrow_size + 5, start + (end - start) / 2 + (a - d) / 2, lab, font, Color_none, Color_none); // top arrow pi.pain.line(x, ty1, midx, ty2, Color_added_space); pi.pain.line(midx, ty2, rightx, ty1, Color_added_space); // bottom arrow pi.pain.line(x, by1, midx, by2, Color_added_space); pi.pain.line(midx, by2, rightx, by1, Color_added_space); // joining line pi.pain.line(midx, ty2, midx, by2, Color_added_space); }
void RenderButton::draw(PainterInfo & pi, int x, int y) const { // Draw it as a box with the LaTeX text FontInfo font = sane_font; font.setColor(Color_command); font.decSize(); if (editable_) { pi.pain.buttonText(x + 1, y, text_, font, renderState()); } else { pi.pain.rectText(x + 1, y, text_, font, Color_commandbg, Color_commandframe); } }
void RenderButton::metrics(MetricsInfo &, Dimension & dim) const { FontInfo font = sane_font; font.decSize(); frontend::FontMetrics const & fm = theFontMetrics(font); if (editable_) fm.buttonText(text_, dim.wid, dim.asc, dim.des); else fm.rectText(text_, dim.wid, dim.asc, dim.des); dim.wid += 2; dim_ = dim; }
void InsetVSpace::metrics(MetricsInfo & mi, Dimension & dim) const { int height = 3 * vspace_arrow_size; if (space_.length().len().value() >= 0.0) height = max(height, space_.inPixels(*mi.base.bv)); FontInfo font; font.decSize(); font.decSize(); int w = 0; int a = 0; int d = 0; theFontMetrics(font).rectText(label(), w, a, d); height = max(height, a + d); dim.asc = height / 2 + (a - d) / 2; // align cursor with the dim.des = height - dim.asc; // label text dim.wid = ADD_TO_VSPACE_WIDTH + 2 * vspace_arrow_size + 5 + w; // Cache the inset dimension. setDimCache(mi, dim); }
GuiFontInfo::GuiFontInfo(FontInfo const & f) : metrics(QFont()) { font.setKerning(false); QString const pat = symbolFamily(f.family()); if (!pat.isEmpty()) { bool ok; font = symbolFont(pat, &ok); } else { switch (f.family()) { case ROMAN_FAMILY: { QString family = makeFontName(toqstr(lyxrc.roman_font_name), toqstr(lyxrc.roman_font_foundry)); font.setFamily(family); #ifdef Q_WS_MACX #if QT_VERSION >= 0x040300 //&& QT_VERSION < 0x040800 // Workaround for a Qt bug, see http://www.lyx.org/trac/ticket/3684 // and http://bugreports.qt.nokia.com/browse/QTBUG-11145. // FIXME: Check whether this is really fixed in Qt 4.8 if (family == "Times" && !font.exactMatch()) font.setFamily("Times New Roman"); #endif #endif break; } case SANS_FAMILY: font.setFamily(makeFontName(toqstr(lyxrc.sans_font_name), toqstr(lyxrc.sans_font_foundry))); break; case TYPEWRITER_FAMILY: font.setFamily(makeFontName(toqstr(lyxrc.typewriter_font_name), toqstr(lyxrc.typewriter_font_foundry))); break; default: break; } } switch (f.series()) { case MEDIUM_SERIES: font.setWeight(QFont::Normal); break; case BOLD_SERIES: font.setWeight(QFont::Bold); break; default: break; } switch (f.realShape()) { case ITALIC_SHAPE: case SLANTED_SHAPE: font.setItalic(true); break; default: break; } LYXERR(Debug::FONT, "Font '" << stateText(f) << "' matched by\n" << font.family()); // Is this an exact match? if (font.exactMatch()) LYXERR(Debug::FONT, "This font is an exact match"); else LYXERR(Debug::FONT, "This font is NOT an exact match"); LYXERR(Debug::FONT, "XFLD: " << font.rawName()); font.setPointSizeF(convert<double>(lyxrc.font_sizes[f.size()]) * lyxrc.zoom / 100.0); LYXERR(Debug::FONT, "The font has size: " << font.pointSizeF()); if (f.realShape() != SMALLCAPS_SHAPE) { metrics = GuiFontMetrics(font); } else { // handle small caps ourselves ... FontInfo smallfont = f; smallfont.decSize().decSize().setShape(UP_SHAPE); QFont font2(font); font2.setKerning(false); font2.setPointSizeF(convert<double>(lyxrc.font_sizes[smallfont.size()]) * lyxrc.zoom / 100.0); metrics = GuiFontMetrics(font, font2); } }