예제 #1
0
void View::DrawPgHeader(DeviceContext *dc, RunningElement *pgHeader)
{
    assert(dc);
    assert(pgHeader);

    dc->StartGraphic(pgHeader, "", pgHeader->GetUuid());

    FontInfo pgHeadTxt;

    TextDrawingParams params;

    // If we have not timestamp
    params.m_x = pgHeader->GetDrawingX();
    params.m_y = pgHeader->GetDrawingY();
    params.m_width = pgHeader->GetWidth();
    params.m_alignment = HORIZONTALALIGNMENT_NONE;
    params.m_laidOut = true;
    params.m_pointSize = m_doc->GetDrawingLyricFont(100)->GetPointSize();

    pgHeadTxt.SetPointSize(params.m_pointSize);

    dc->SetBrush(m_currentColour, AxSOLID);
    dc->SetFont(&pgHeadTxt);

    DrawRunningChildren(dc, pgHeader, params);

    dc->ResetFont();
    dc->ResetBrush();

    dc->EndGraphic(pgHeader, this);
}
예제 #2
0
void View::DrawLyricString ( DeviceContext *dc, int x, int y, std::wstring s, int staffSize)
{
    assert( dc );
    
    dc->StartText( ToDeviceContextX( x ), ToDeviceContextY( y ) );
    
    std::wistringstream iss( s  );
    std::wstring token;
    while( std::getline( iss, token, L'_' ))
    {
        dc->DrawText( UTF16to8( token.c_str() ), token );
        // no _
        if (iss.eof())
            break;
        
        FontInfo vrvTxt;
        vrvTxt.SetFaceName("VerovioText");
        vrvTxt.SetPointSize( m_doc->GetDrawingLyricFont(staffSize)->GetPointSize() );
        
        dc->SetFont( &vrvTxt );
        dc->VrvTextFont();
        std::wstring str;
        str.push_back(VRV_TEXT_E551);
        dc->DrawText( UTF16to8( str.c_str() ), str );
        dc->ResetFont();
    }
    //std::wcout << std::endl;
    
    dc->EndText( );
}
예제 #3
0
ColorChanger::ColorChanger(FontInfo & font, ColorCode color,
			   bool really_change_color)
	: Changer<FontInfo, ColorCode>(font, font.color()), change_(really_change_color)
{
	if (change_) {
		font.setColor(color);
	}
}
예제 #4
0
Size FileList::GetStdSize(const Value& q) const
{
	const File& m = ValueTo<File>(q);
	FontInfo fi = m.font.Info();
	int cx = GetTextSize(fi, WString(m.name)) + 2 + iconwidth + 2 + 3;
	if(!IsNull(m.desc))
		cx += GetTextSize(m.descfont.Info(), WString(m.desc)) + fi.GetHeight();
	return Size(cx, GetItemHeight());
}
예제 #5
0
static FontState getBar(FontInfo const & fi)
{
	if (fi.emph() == FONT_TOGGLE)
		return EMPH_TOGGLE;

	if (fi.underbar() == FONT_TOGGLE)
		return UNDERBAR_TOGGLE;

	if (fi.strikeout() == FONT_TOGGLE)
		return STRIKEOUT_TOGGLE;

	if (fi.uuline() == FONT_TOGGLE)
		return UULINE_TOGGLE;

	if (fi.uwave() == FONT_TOGGLE)
		return UWAVE_TOGGLE;

	if (fi.noun() == FONT_TOGGLE)
		return NOUN_TOGGLE;

	if (fi.emph() == FONT_IGNORE
	    && fi.underbar() == FONT_IGNORE
	    && fi.noun() == FONT_IGNORE)
		return IGNORE;

	return INHERIT;
}
예제 #6
0
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);
}
예제 #7
0
파일: InsetNote.cpp 프로젝트: djmitche/lyx
FontInfo InsetNote::getFont() const
{
	FontInfo font = getLayout().font();
	// FIXME: This hardcoded color is a hack!
	if (params_.type == InsetNoteParams::Greyedout
	    && buffer().params().notefontcolor != lyx::rgbFromHexName("#cccccc")) {
		ColorCode c = lcolor.getFromLyXName("notefontcolor");
		if (c != Color_none)
			font.setColor(c);
	}
	return font;
}
예제 #8
0
GuiDelimiter::GuiDelimiter(GuiView & lv)
	: GuiDialog(lv, "mathdelimiter", qt_("Math Delimiter"))
{
	setupUi(this);

	connect(closePB, SIGNAL(clicked()), this, SLOT(accept()));

	setFocusProxy(leftLW);

	leftLW->setViewMode(QListView::IconMode);
	rightLW->setViewMode(QListView::IconMode);

	leftLW->setDragDropMode(QAbstractItemView::NoDragDrop);
	rightLW->setDragDropMode(QAbstractItemView::NoDragDrop);

	initMathSymbols();

	typedef map<char_type, QListWidgetItem *> ListItems;
	ListItems list_items;
	// The last element is the empty one.
	int const end = nr_latex_delimiters - 1;
	for (int i = 0; i < end; ++i) {
		string const delim = latex_delimiters[i];
		MathSymbol const & ms =	mathSymbol(delim);
		QString symbol(ms.fontcode?
			QChar(ms.fontcode) : toqstr(docstring(1, ms.unicode)));
		QListWidgetItem * lwi = new QListWidgetItem(symbol);
		lwi->setToolTip(toqstr(delim));
		FontInfo lyxfont;
		lyxfont.setFamily(ms.fontfamily);
		lwi->setFont(frontend::getFont(lyxfont));
		list_items[ms.unicode] = lwi;
		leftLW->addItem(lwi);
	}

	for (int i = 0; i != leftLW->count(); ++i) {
		MathSymbol const & ms =	mathSymbol(
			fromqstr(leftLW->item(i)->toolTip()));
		rightLW->addItem(list_items[doMatch(ms.unicode)]->clone());
	}

	// The last element is the empty one.
	leftLW->addItem(qt_("(None)"));
	rightLW->addItem(qt_("(None)"));

	sizeCO->addItem(qt_("Variable"));

	for (int i = 0; *biggui[i]; ++i)
		sizeCO->addItem(qt_(biggui[i]));

	on_leftLW_currentRowChanged(0);
	bc().setPolicy(ButtonPolicy::IgnorantPolicy);
}
예제 #9
0
void InsetMathBrace::draw(PainterInfo & pi, int x, int y) const
{
	FontInfo font = pi.base.font;
	augmentFont(font, from_ascii("mathnormal"));
	font.setShape(UP_SHAPE);
	font.setColor(Color_latex);
	Dimension t = theFontMetrics(font).dimension('{');
	pi.pain.text(x, y, '{', font);
	cell(0).draw(pi, x + t.wid, y);
	Dimension const & dim0 = cell(0).dimension(*pi.base.bv);
	pi.pain.text(x + t.wid + dim0.width(), y, '}', font);
	drawMarkers(pi, x, y);
}
예제 #10
0
/**
*  @brief
*    Constructor
*/
Font::Font(Gui &cGui, const FontInfo &cFontInfo) :
	m_pGui(&cGui),
	m_pFontImpl(nullptr),
	m_sFamily(cFontInfo.GetFamily()),
	m_nHeight(cFontInfo.GetHeight()),
	m_nWeight(cFontInfo.GetWeight()),
	m_nStyle(cFontInfo.GetStyle()),
	m_sFilename(cFontInfo.GetFilename())
{
	// Load font
	if (m_sFilename.GetLength() > 0) LoadFromFile(m_sFilename, m_nHeight);
	else							 Load(m_sFamily, m_nHeight, m_nWeight, m_nStyle);
}
예제 #11
0
void RowPainter::paintTextDecoration(Row::Element const & e) const
{
	// element selected?
	bool const sel = (e.pos >= row_.sel_beg && e.endpos <= row_.sel_end)
		|| pi_.selected;
	FontInfo copy = e.font.fontInfo();
	if (sel || e.change.changed()) {
		Color const col = e.change.changed() ? e.change.color()
		                                     : Color_selectiontext;
		copy.setPaintColor(col);
	}
	pi_.pain.textDecoration(copy, int(x_), yo_, int(e.full_width()));
}
예제 #12
0
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);
	}
}
예제 #13
0
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;
}
예제 #14
0
파일: Template.cpp 프로젝트: kolyden/mirror
void AppPreview::Paint(Draw& w)
{
	Size sz = GetSize();
	FontInfo fi = CourierZ(12).Info();
	int y = 0;
	int i = sb;
	while(y < sz.cy) {
		bool hdr = i < line.GetCount() && line[i].header;
		w.DrawRect(0, y, sz.cx, fi.GetHeight(), hdr ? LtCyan : SColorPaper);
		if(i < line.GetCount())
			w.DrawText(0, y, line[i].text, hdr ? ArialZ(12).Bold().Italic() : CourierZ(12), SColorText);
		y += fi.GetHeight();
		i++;
	}
}
예제 #15
0
void FileList::Paint(Draw& w, const Rect& r, const Value& q,
		             Color ink, Color paper, dword style) const
{
	const File& m = ValueTo<File>(q);
	bool dark = Grayscale(paper) < 150;
	w.DrawRect(r, paper);
	int x = r.left + 2;
	w.DrawImage(x, r.top + (r.Height() - m.icon.GetSize().cy) / 2, m.icon);
	x += iconwidth;
	x += 2;
	FontInfo fi = m.font.Info();
	DrawFileName(w, x, r.top + (r.Height() - fi.GetHeight()) / 2,
	             r.right - x - 2, r.Height(), WString(m.name), m.isdir, m.font,
	             dark ? SColorHighlightText : m.ink,
	             dark ? SColorHighlightText : m.extink,
	             WString(m.desc), m.descfont, justname, m.underline);
}
예제 #16
0
파일: view_text.cpp 프로젝트: DDMAL/verovio
void View::DrawHarmString(DeviceContext *dc, int x, int y, std::wstring s)
{
    assert(dc);

    std::size_t prev_pos = 0, pos;
    while ((pos = s.find_first_of(L"\u266D\u266E\u266F", prev_pos)) != std::wstring::npos) {
        // If pos is > than the previous, it is the substring to extract
        if (pos > prev_pos) {
            std::wstring substr = s.substr(prev_pos, pos - prev_pos);
            dc->DrawText(UTF16to8(substr), substr);
        }

        // if it is the same or we still have space, it is the accidental
        if (pos == prev_pos || pos < s.length()) {
            // Then the accidental
            std::wstring accid = s.substr(pos, 1);
            std::wstring smufl_accid;
            if (accid == L"\u266D") { // MUSIC FLAT SIGN
                smufl_accid.push_back(SMUFL_E260_accidentalFlat);
            }
            else if (accid == L"\u266E") { // MUSIC NATURAL SIGN
                smufl_accid.push_back(SMUFL_E261_accidentalNatural);
            }
            else if (accid == L"\u266F") { // MUSIC SHARP SIGN
                smufl_accid.push_back(SMUFL_E262_accidentalSharp);
            }
            else {
                smufl_accid.push_back(0xE26D);
            }

            FontInfo vrvTxt;
            vrvTxt.SetFaceName("VerovioText");
            dc->SetFont(&vrvTxt);
            dc->DrawText(UTF16to8(smufl_accid), smufl_accid);
            dc->ResetFont();
        }
        // Skip the accidental and continue
        prev_pos = pos + 1;
    }
    // Print the remainder of the string, or the full string if no accid
    if (prev_pos < s.length()) {
        std::wstring substr = s.substr(prev_pos, std::wstring::npos);
        dc->DrawText(UTF16to8(substr), substr);
    }
}
예제 #17
0
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());
}
예제 #18
0
void RowPainter::paintLast() const
{
	int const endlabel = text_.getEndLabel(row_.pit());
	switch (endlabel) {
	case END_LABEL_BOX:
	case END_LABEL_FILLED_BOX: {
		FontInfo font = labelFont(true);
		if (font.realColor() != Color_selectiontext)
			font.setPaintColor(Color_eolmarker);
		FontMetrics const & fm = theFontMetrics(font);
		int const size = int(0.75 * fm.maxAscent());
		int const y = yo_ - size;

		// If needed, move the box a bit to avoid overlapping with text.
		int x = 0;
		if (row_.isRTL()) {
			int const normal_x = nestMargin() + changebarMargin();
			x = min(normal_x, row_.left_margin - size - Inset::TEXT_TO_INSET_OFFSET);
		} else {
			int const normal_x = tm_.width() - row_.right_margin
				- size - Inset::TEXT_TO_INSET_OFFSET;
			x = max(normal_x, row_.width());
		}

		if (endlabel == END_LABEL_BOX)
			pi_.pain.rectangle(int(xo_) + x, y, size, size, font.realColor());
		else
			pi_.pain.fillRectangle(int(xo_) + x, y, size, size, font.realColor());
		break;
	}

	case END_LABEL_STATIC: {
		FontInfo const font = labelFont(true);
		FontMetrics const & fm = theFontMetrics(font);
		docstring const & str = par_.layout().endlabelstring();
		double const x = row_.isRTL() ? x_ - fm.width(str) : x_;
		pi_.pain.text(int(x), yo_, str, font);
		break;
	}

	case END_LABEL_NO_LABEL:
		break;
	}
}
예제 #19
0
파일: DrawText.cpp 프로젝트: koz4k/soccer
Size GetTextSize(const wchar *text, Font font, int n)
{
#if defined(flagWINGL) || defined(flagLINUXGL)
	return GetTextSize(text, resources.GetFont(font), n);
#else
	FontInfo fi = font.Info();
	if(n < 0)
		n = wstrlen(text);
	Size sz;
	sz.cx = 0;
	const wchar *wtext = (const wchar *)text;
	while(n > 0) {
		sz.cx += fi[*wtext++];
		n--;
	}
	sz.cy = fi.GetHeight();
	return sz;
#endif
}
예제 #20
0
파일: Text2.cpp 프로젝트: mandeepsimak/Lyx
// Note that this is supposed to return a fully realized font.
FontInfo Text::labelFont(Paragraph const & par) const
{
	Buffer const & buffer = owner_->buffer();
	Layout const & layout = par.layout();

	if (!par.getDepth()) {
		FontInfo lf = layout.reslabelfont;
		// In case the default family has been customized
		if (layout.labelfont.family() == INHERIT_FAMILY)
			lf.setFamily(buffer.params().getFont().fontInfo().family());
		return lf;
	}

	FontInfo font = layout.labelfont;
	// Realize with the fonts of lesser depth.
	font.realize(buffer.params().getFont().fontInfo());

	return font;
}
예제 #21
0
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;
	}
}
예제 #22
0
int FontInfo::initRuby(FontInfo &body_info, int body_count, int ruby_count)
{
    if ((tateyoko_mode == YOKO_MODE &&
         body_count + body_info.xy[0]/2 >= body_info.num_xy[0]-1) ||
        (tateyoko_mode == TATE_MODE &&
         body_count + body_info.xy[1]/2 > body_info.num_xy[1]))
        body_info.newLine();

    top_xy[0] = body_info.x();
    top_xy[1] = body_info.y();
    pitch_xy[0] = font_size_xy[0];
    pitch_xy[1] = font_size_xy[1];

    int margin=0;
    
    if (tateyoko_mode == YOKO_MODE){
        top_xy[1] -= font_size_xy[1];
        num_xy[0] = ruby_count;
        num_xy[1] = 1;
    }
    else{
        top_xy[0] += body_info.font_size_xy[0];
        num_xy[0] = 1;
        num_xy[1] = ruby_count;
    }
    
    if (ruby_count*font_size_xy[tateyoko_mode] >= body_count*body_info.pitch_xy[tateyoko_mode]){
        margin = (ruby_count*font_size_xy[tateyoko_mode] - body_count*body_info.pitch_xy[tateyoko_mode] + 1)/2;
    }
    else{
        int offset = 0;
        if (ruby_count > 0) 
            offset = (body_count*body_info.pitch_xy[tateyoko_mode] - ruby_count*font_size_xy[tateyoko_mode] + ruby_count) / (ruby_count*2);
        top_xy[tateyoko_mode] += offset;
        pitch_xy[tateyoko_mode] += offset*2;
    }
    body_info.line_offset_xy[tateyoko_mode] += margin;
    
    clear();

    return margin;
}
예제 #23
0
파일: view_text.cpp 프로젝트: DDMAL/verovio
void View::DrawRend(DeviceContext *dc, Rend *rend, int x, int y, bool &setX, bool &setY)
{
    assert(dc);
    assert(rend);

    dc->StartTextGraphic(rend, "", rend->GetUuid());

    FontInfo rendFont;
    bool customFont = false;
    if (rend->HasFontsize()) {
        customFont = true;
        rendFont.SetPointSize(rend->GetFontsize());
    }
    if (customFont) dc->SetFont(&rendFont);

    DrawTextChildren(dc, rend, x, y, setX, setY);

    if (customFont) dc->ResetFont();

    dc->EndTextGraphic(rend, this);
}
예제 #24
0
파일: Text2.cpp 프로젝트: mandeepsimak/Lyx
void Text::setCharFont(pit_type pit,
		pos_type pos, Font const & fnt, Font const & display_font)
{
	Buffer const & buffer = owner_->buffer();
	Font font = fnt;
	Layout const & layout = pars_[pit].layout();

	// Get concrete layout font to reduce against
	FontInfo layoutfont;

	if (pos < pars_[pit].beginOfBody())
		layoutfont = layout.labelfont;
	else
		layoutfont = layout.font;

	// Realize against environment font information
	if (pars_[pit].getDepth()) {
		pit_type tp = pit;
		while (!layoutfont.resolved() &&
		       tp != pit_type(paragraphs().size()) &&
		       pars_[tp].getDepth()) {
			tp = outerHook(tp);
			if (tp != pit_type(paragraphs().size()))
				layoutfont.realize(pars_[tp].layout().font);
		}
	}

	// Inside inset, apply the inset's font attributes if any
	// (charstyle!)
	if (!isMainText())
		layoutfont.realize(display_font.fontInfo());

	layoutfont.realize(buffer.params().getFont().fontInfo());

	// Now, reduce font against full layout font
	font.fontInfo().reduce(layoutfont);

	pars_[pit].setFont(pos, font);
}
예제 #25
0
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);
}
예제 #26
0
bool FontLoader::available(FontInfo const & f)
{
	static vector<int> cache_set(NUM_FAMILIES, false);
	static vector<int> cache(NUM_FAMILIES, false);

	FontFamily family = f.family();
	if (cache_set[family])
		return cache[family];
	cache_set[family] = true;

	QString const pat = symbolFamily(family);
	if (pat.isEmpty())
		// We don't care about non-symbol fonts
		return false;

	bool ok;
	symbolFont(pat, &ok);
	if (!ok)
		return false;

	cache[family] = true;
	return true;
}
예제 #27
0
/// Writes ending block of LaTeX needed to close use of this font
// Returns number of chars written
// This one corresponds to latexWriteStartChanges(). (Asger)
int Font::latexWriteEndChanges(otexstream & os, BufferParams const & bparams,
				  OutputParams const & runparams,
				  Font const & base,
				  Font const & next,
				  bool const & closeLanguage) const
{
	int count = 0;
	bool env = false;

	// reduce the current font to changes against the base
	// font (of the layout). We use a temporary for this to
	// avoid changing this font instance, as that would break
	FontInfo f = bits_;
	f.reduce(base.bits_);

	if (f.family() != INHERIT_FAMILY) {
		os << '}';
		++count;
		env = true; // Size change need not bother about closing env.
	}
	if (f.series() != INHERIT_SERIES) {
		os << '}';
		++count;
		env = true; // Size change need not bother about closing env.
	}
	if (f.shape() != INHERIT_SHAPE) {
		os << '}';
		++count;
		env = true; // Size change need not bother about closing env.
	}
	if (f.color() != Color_inherit && f.color() != Color_ignore) {
		os << '}';
		++count;
		env = true; // Size change need not bother about closing env.
	}
	if (f.emph() == FONT_ON) {
		os << '}';
		++count;
		env = true; // Size change need not bother about closing env.
	}
	if (f.noun() == FONT_ON) {
		os << '}';
		++count;
		env = true; // Size change need not bother about closing env.
	}
	if (f.size() != FONT_SIZE_INHERIT) {
		// We only have to close if only size changed
		if (!env) {
			os << '}';
			++count;
		}
	}
	if (f.underbar() == FONT_ON) {
		os << '}';
		++count;
		runparams.inulemcmd = false;
	}
	if (f.strikeout() == FONT_ON) {
		os << '}';
		++count;
		runparams.inulemcmd = false;
	}
	if (f.uuline() == FONT_ON) {
		os << '}';
		++count;
		runparams.inulemcmd = false;
	}
	if (f.uwave() == FONT_ON) {
		os << '}';
		++count;
		runparams.inulemcmd = false;
	}

	// If the current language is Hebrew, Arabic, or Farsi
	// the numbers are written Left-to-Right. ArabTeX package
	// reorders the number automatically but the packages used
	// for Hebrew and Farsi (Arabi) do not.
	if (bits_.number() == FONT_ON && next.fontInfo().number() != FONT_ON
		&& (language()->lang() == "hebrew"
			|| language()->lang() == "farsi"
			|| language()->lang() == "arabic_arabi")) {
		os << "\\endL}";
		count += 6;
	}

	if (open_encoding_) {
		// We need to close the encoding even if it does not change
		// to do correct environment nesting
		Encoding const * const ascii = encodings.fromLyXName("ascii");
		pair<bool, int> const c = switchEncoding(os.os(), bparams,
				runparams, *ascii);
		LATTEST(c.first);
		count += c.second;
		runparams.encoding = ascii;
		open_encoding_ = false;
	}

	if (closeLanguage
	    && language() != base.language() && language() != next.language()
	    && language()->encoding()->package() != Encoding::CJK) {
		os << '}';
		++count;
	}

	return count;
}
예제 #28
0
/// Writes the head of the LaTeX needed to impose this font
// Returns number of chars written.
int Font::latexWriteStartChanges(odocstream & os, BufferParams const & bparams,
				    OutputParams const & runparams,
				    Font const & base,
				    Font const & prev) const
{
	bool env = false;

	int count = 0;

	// polyglossia or babel?
	if (runparams.use_polyglossia
	    && language()->lang() != base.language()->lang()
	    && language() != prev.language()) {
		if (!language()->polyglossia().empty()) {
			string tmp = "\\text" + language()->polyglossia();
			if (!language()->polyglossiaOpts().empty())
				tmp += "[" + language()->polyglossiaOpts() + "]";
			tmp += "{";
			os << from_ascii(tmp);
			count += tmp.length();
		} else {
			os << '{';
			count += 1;
		}
	} else if (language()->babel() != base.language()->babel() &&
	    language() != prev.language()) {
		if (language()->lang() == "farsi") {
			os << "\\textFR{";
			count += 8;
		} else if (!isRightToLeft() &&
			    base.language()->lang() == "farsi") {
			os << "\\textLR{";
			count += 8;
		} else if (language()->lang() == "arabic_arabi") {
			os << "\\textAR{";
			count += 8;
 		} else if (!isRightToLeft() &&
				base.language()->lang() == "arabic_arabi") {
			os << "\\textLR{";
			count += 8;
		// currently the remaining RTL languages are arabic_arabtex and hebrew
		} else if (isRightToLeft() != prev.isRightToLeft()) {
			if (isRightToLeft()) {
				os << "\\R{";
				count += 3;
			} else {
				os << "\\L{";
				count += 3;
			}
		} else if (!language()->babel().empty()) {
			string const tmp =
				subst(lyxrc.language_command_local,
				      "$$lang", language()->babel());
			os << from_ascii(tmp);
			count += tmp.length();
		} else {
			os << '{';
			count += 1;
		}
	}

	if (language()->encoding()->package() == Encoding::CJK) {
		pair<bool, int> const c = switchEncoding(os, bparams,
				runparams, *(language()->encoding()));
		if (c.first) {
			open_encoding_ = true;
			count += c.second;
			runparams.encoding = language()->encoding();
		}
	}

	// If the current language is Hebrew, Arabic, or Farsi
	// the numbers are written Left-to-Right. ArabTeX package
	// reorders the number automatically but the packages used
	// for Hebrew and Farsi (Arabi) do not.
	if (bits_.number() == FONT_ON && prev.fontInfo().number() != FONT_ON
		&& (language()->lang() == "hebrew"
			|| language()->lang() == "farsi" 
			|| language()->lang() == "arabic_arabi")) {
		os << "{\\beginL ";
		count += 9;
	}

	FontInfo f = bits_;
	f.reduce(base.bits_);

	if (f.family() != INHERIT_FAMILY) {
		os << '\\'
		   << LaTeXFamilyNames[f.family()]
		   << '{';
		count += strlen(LaTeXFamilyNames[f.family()]) + 2;
		env = true; //We have opened a new environment
	}
	if (f.series() != INHERIT_SERIES) {
		os << '\\'
		   << LaTeXSeriesNames[f.series()]
		   << '{';
		count += strlen(LaTeXSeriesNames[f.series()]) + 2;
		env = true; //We have opened a new environment
	}
	if (f.shape() != INHERIT_SHAPE) {
		os << '\\'
		   << LaTeXShapeNames[f.shape()]
		   << '{';
		count += strlen(LaTeXShapeNames[f.shape()]) + 2;
		env = true; //We have opened a new environment
	}
	if (f.color() != Color_inherit && f.color() != Color_ignore) {
		os << "\\textcolor{"
		   << from_ascii(lcolor.getLaTeXName(f.color()))
		   << "}{";
		count += lcolor.getLaTeXName(f.color()).length() + 13;
		env = true; //We have opened a new environment
	}
	// FIXME: uncomment this when we support background.
	/*
	if (f.background() != Color_inherit && f.background() != Color_ignore) {
		os << "\\textcolor{"
		   << from_ascii(lcolor.getLaTeXName(f.background()))
		   << "}{";
		count += lcolor.getLaTeXName(f.background()).length() + 13;
		env = true; //We have opened a new environment
	}
	*/
	if (f.emph() == FONT_ON) {
		os << "\\emph{";
		count += 6;
		env = true; //We have opened a new environment
	}
	// \noun{} is a LyX special macro
	if (f.noun() == FONT_ON) {
		os << "\\noun{";
		count += 6;
		env = true; //We have opened a new environment
	}
	if (f.size() != FONT_SIZE_INHERIT) {
		// If we didn't open an environment above, we open one here
		if (!env) {
			os << '{';
			++count;
		}
		os << '\\'
		   << LaTeXSizeNames[f.size()]
		   << "{}";
		count += strlen(LaTeXSizeNames[f.size()]) + 3;
	}
	// The ulem commands need to be on the deepest nesting level
	// because ulem puts every nested group or macro in a box,
	// which prevents linebreaks (#8424, #8733)
	if (f.underbar() == FONT_ON) {
		os << "\\uline{";
		count += 10;
		runparams.inulemcmd = true;
	}
	if (f.strikeout() == FONT_ON) {
		os << "\\sout{";
		count += 9;
		runparams.inulemcmd = true;
	}
	if (f.uuline() == FONT_ON) {
		os << "\\uuline{";
		count += 11;
		runparams.inulemcmd = true;
	}
	if (f.uwave() == FONT_ON) {
		os << "\\uwave{";
		count += 10;
		runparams.inulemcmd = true;
	}
	return count;
}
예제 #29
0
docstring const stateText(FontInfo const & f)
{
	odocstringstream os;
	if (f.family() != INHERIT_FAMILY)
		os << _(GUIFamilyNames[f.family()]) << ", ";
	if (f.series() != INHERIT_SERIES)
		os << _(GUISeriesNames[f.series()]) << ", ";
	if (f.shape() != INHERIT_SHAPE)
		os << _(GUIShapeNames[f.shape()]) << ", ";
	if (f.size() != FONT_SIZE_INHERIT)
		os << _(GUISizeNames[f.size()]) << ", ";
	if (f.color() != Color_inherit)
		os << lcolor.getGUIName(f.color()) << ", ";
	// FIXME: uncomment this when we support background.
	//if (f.background() != Color_inherit)
	//	os << lcolor.getGUIName(f.background()) << ", ";
	if (f.emph() != FONT_INHERIT)
		os << bformat(_("Emphasis %1$s, "),
			      _(GUIMiscNames[f.emph()]));
	if (f.underbar() != FONT_INHERIT)
		os << bformat(_("Underline %1$s, "),
			      _(GUIMiscNames[f.underbar()]));
	if (f.strikeout() != FONT_INHERIT)
		os << bformat(_("Strikeout %1$s, "),
			      _(GUIMiscNames[f.strikeout()]));
	if (f.uuline() != FONT_INHERIT)
		os << bformat(_("Double underline %1$s, "),
			      _(GUIMiscNames[f.uuline()]));
	if (f.uwave() != FONT_INHERIT)
		os << bformat(_("Wavy underline %1$s, "),
			      _(GUIMiscNames[f.uwave()]));
	if (f.noun() != FONT_INHERIT)
		os << bformat(_("Noun %1$s, "),
			      _(GUIMiscNames[f.noun()]));
	if (f == inherit_font)
		os << _("Default") << ", ";

	return os.str();
}
예제 #30
0
ShapeChanger::ShapeChanger(FontInfo & font, FontShape shape)
	: Changer<FontInfo, FontShape>(font, font.shape())
{
	orig_.setShape(shape);
}