2 * \file InsetQuotes.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Jean-Marc Lasgouttes
7 * \author Jürgen Spitzmüller
9 * Full author contact details are available in file CREDITS.
14 #include "InsetQuotes.h"
17 #include "BufferParams.h"
18 #include "BufferView.h"
20 #include "Dimension.h"
23 #include "FuncStatus.h"
24 #include "FuncRequest.h"
26 #include "LaTeXFeatures.h"
29 #include "MetricsInfo.h"
30 #include "Paragraph.h"
31 #include "ParIterator.h"
32 #include "texstream.h"
35 #include "frontends/FontMetrics.h"
36 #include "frontends/Painter.h"
38 #include "support/debug.h"
39 #include "support/docstring.h"
40 #include "support/docstream.h"
41 #include "support/gettext.h"
42 #include "support/lstrings.h"
43 #include "support/textutils.h"
48 using namespace lyx::support;
54 /* codes used to read/write quotes to LyX files
56 * e ``english'' (`inner quotation')
57 * s ''swedish'' ('inner quotation')
58 * g ,,german`` (,inner quotation`)
59 * p ,,polish'' (,inner quotation')
60 * c <<swiss>> (<inner quotation>)
61 * a >>danish<< (>inner quotation<)
62 * q "plain" ('inner quotation')
63 * b `british' (``inner quotation'')
64 * w >>swedishg>> ('inner quotation') ["g" = Guillemets]
65 * f <<french>> (``inner quotation'')
66 * i <<frenchin>> (<<inner quotation>>) ["in" = Imprimerie Nationale]
67 * r <<russian>> (,,inner quotation``)
68 * j [U+300C]cjk[U+300D] ([U+300E]inner quotation[U+300F]) [CORNER BRACKETS]
69 * k [U+300A]cjkangle[U+300B] ([U+3008]inner quotation[U+3009]) [ANGLE BRACKETS]
70 * h ,,hungarian'' (>>inner quotation<<)
71 * x dynamic style (inherits document settings)
74 char const * const style_char = "esgpcaqbwfirjkhx";
75 char const * const side_char = "lr" ;
76 char const * const level_char = "sd";
81 /////////////////////////////////////////////////////////////////////
85 ///////////////////////////////////////////////////////////////////////
87 InsetQuotesParams quoteparams;
90 int InsetQuotesParams::stylescount() const
92 return strlen(style_char);
96 char InsetQuotesParams::getStyleChar(QuoteStyle const & style) const
98 return style_char[static_cast<int>(style)];
102 QuoteStyle InsetQuotesParams::getQuoteStyle(string const & s,
103 bool const allow_wildcards, QuoteStyle fb) const
108 if (str.length() != 3) {
109 LYXERR0("ERROR (InsetQuotes::InsetQuotes):"
110 " bad string length.");
114 // '.' wildcard means: keep current style
115 if (!allow_wildcards || str[0] != '.') {
117 for (i = 0; i < stylescount(); ++i) {
118 if (str[0] == style_char[i]) {
123 if (i >= stylescount()) {
124 LYXERR0("ERROR (InsetQuotes::InsetQuotes):"
125 " bad style specification.");
126 res = QuoteStyle::English;
134 QuoteSide InsetQuotesParams::getQuoteSide(string const & s,
135 bool const allow_wildcards, QuoteSide fb) const
140 if (str.length() != 3) {
141 LYXERR0("ERROR (InsetQuotes::InsetQuotes):"
142 " bad string length.");
146 // '.' wildcard means: keep current side
147 if (!allow_wildcards || str[1] != '.') {
149 for (i = 0; i < 2; ++i) {
150 if (str[1] == side_char[i]) {
156 LYXERR0("ERROR (InsetQuotes::InsetQuotes):"
157 " bad side specification.");
158 res = QuoteSide::Opening;
166 QuoteLevel InsetQuotesParams::getQuoteLevel(string const & s,
167 bool const allow_wildcards, QuoteLevel fb) const
172 if (str.length() != 3) {
173 LYXERR0("ERROR (InsetQuotes::InsetQuotes):"
174 " bad string length.");
178 // '.' wildcard means: keep current level
179 if (!allow_wildcards || str[2] != '.') {
181 for (i = 0; i < 2; ++i) {
182 if (str[2] == level_char[i]) {
188 LYXERR0("ERROR (InsetQuotes::InsetQuotes):"
189 " bad level specification.");
190 res = QuoteLevel::Primary;
198 char_type InsetQuotesParams::getQuoteChar(QuoteStyle const & style, QuoteLevel const & level,
199 QuoteSide const & side, bool const rtl) const
201 // main opening quotation mark
202 char_type left_primary;
203 // main closing quotation mark
204 char_type right_primary;
205 // secondary (inner, 'single') opening quotation mark
206 char_type left_secondary;
207 // secondary (inner, 'single') closing quotation mark
208 char_type right_secondary;
211 case QuoteStyle::English: {
212 left_primary = 0x201c; // ``
213 right_primary = 0x201d; // ''
214 left_secondary = 0x2018; // `
215 right_secondary = 0x2019; // '
218 case QuoteStyle::Swedish: {
219 left_primary = 0x201d; // ''
220 right_primary = 0x201d; // ''
221 left_secondary = 0x2019; // '
222 right_secondary = 0x2019; // '
225 case QuoteStyle::German: {
226 left_primary = 0x201e; // ,,
227 right_primary = 0x201c; // ``
228 left_secondary = 0x201a; // ,
229 right_secondary = 0x2018; // `
232 case QuoteStyle::Polish: {
233 left_primary = 0x201e; // ,,
234 right_primary = 0x201d; // ''
235 left_secondary = 0x201a; // ,
236 right_secondary = 0x2019; // '
239 case QuoteStyle::Swiss: {
240 left_primary = 0x00ab; // <<
241 right_primary = 0x00bb; // >>
242 left_secondary = 0x2039; // <
243 right_secondary = 0x203a; // >
246 case QuoteStyle::Danish: {
247 left_primary = 0x00bb; // >>
248 right_primary = 0x00ab; // <<
249 left_secondary = 0x203a; // >
250 right_secondary = 0x2039; // <
253 case QuoteStyle::Plain: {
254 left_primary = 0x0022; // "
255 right_primary = 0x0022; // "
256 left_secondary = 0x0027; // '
257 right_secondary = 0x0027; // '
260 case QuoteStyle::British: {
261 left_primary = 0x2018; // `
262 right_primary = 0x2019; // '
263 left_secondary = 0x201c; // ``
264 right_secondary = 0x201d; // ''
267 case QuoteStyle::SwedishG: {
268 left_primary = 0x00bb; // >>
269 right_primary = 0x00bb; // >>
270 left_secondary = 0x2019; // '
271 right_secondary = 0x2019; // '
274 case QuoteStyle::French: {
275 left_primary = 0x00ab; // <<
276 right_primary = 0x00bb; // >>
277 left_secondary = 0x201c; // ``
278 right_secondary = 0x201d; // ''
281 case QuoteStyle::FrenchIN:{
282 left_primary = 0x00ab; // <<
283 right_primary = 0x00bb; // >>
284 left_secondary = 0x00ab; // <<
285 right_secondary = 0x00bb; // >>
288 case QuoteStyle::Russian:{
289 left_primary = 0x00ab; // <<
290 right_primary = 0x00bb; // >>
291 left_secondary = 0x201e; // ,,
292 right_secondary = 0x201c; // ``
295 case QuoteStyle::CJK:{
296 left_primary = 0x300c; // LEFT CORNER BRACKET
297 right_primary = 0x300d; // RIGHT CORNER BRACKET
298 left_secondary = 0x300e; // LEFT WHITE CORNER BRACKET
299 right_secondary = 0x300f; // RIGHT WHITE CORNER BRACKET
302 case QuoteStyle::CJKAngle:{
303 left_primary = 0x300a; // LEFT DOUBLE ANGLE BRACKET
304 right_primary = 0x300b; // RIGHT DOUBLE ANGLE BRACKET
305 left_secondary = 0x3008; // LEFT ANGLE BRACKET
306 right_secondary = 0x3009; // RIGHT ANGLE BRACKET
309 case QuoteStyle::Hungarian: {
310 left_primary = 0x201e; // ,,
311 right_primary = 0x201d; // ''
312 left_secondary = 0x00bb; // >>
313 right_secondary = 0x00ab; // <<
316 case QuoteStyle::Dynamic:
319 left_primary = 0x003f; // ?
320 right_primary = 0x003f; // ?
321 left_secondary = 0x003f; // ?
322 right_secondary = 0x003f; // ?
327 case QuoteLevel::Secondary:
329 return (side == QuoteSide::Closing) ? left_secondary : right_secondary;
330 return (side == QuoteSide::Opening) ? left_secondary : right_secondary;
331 case QuoteLevel::Primary:
333 return (side == QuoteSide::Closing) ? left_primary : right_primary;
334 return (side == QuoteSide::Opening) ? left_primary : right_primary;
344 docstring InsetQuotesParams::getLaTeXQuote(char_type c, string const & op,
345 bool const rtl) const
354 res = "\\quotesinglbase";
359 // This macro is redefined in rtl mode
360 res = rtl ? "\\textquoteleft" : "\\textquoteright";
367 // This macro is redefined in rtl mode
368 res = rtl ? "\\textquoteright" : "\\textquoteleft";
377 res = "\\guilsinglleft";
384 res = "\\guilsinglright";
387 case 0x0027: {// ' (plain)
388 res = "\\textquotesingle";
394 else if (op == "babel")
397 res = "\\quotedblbase";
402 // This macro is redefined in rtl mode
403 res = rtl ? "\\textquotedblleft" : "\\textquotedblright";
410 // This macro is redefined in rtl mode
411 res = rtl ? "\\textquotedblright" : "\\textquotedblleft";
419 else if (op == "babel")
422 res = "\\guillemotleft";
428 else if (op == "babel")
431 res = "\\guillemotright";
435 res = "\\textquotedbl";
438 // The following are fakes
439 // This is just to get something symbolic
440 // in encodings where this chars would not be used anyway
441 case 0x300c: // LEFT CORNER BRACKET
442 res = "\\ensuremath{\\lceil}";
444 case 0x300d: // RIGHT CORNER BRACKET
445 res = "\\ensuremath{\\rfloor}";
447 case 0x300e: // LEFT WHITE CORNER BRACKET
448 res = "\\ensuremath{\\llceil}";
450 case 0x300f: // RIGHT WHITE CORNER BRACKET
451 res = "\\ensuremath{\\rrfloor}";
453 case 0x300a: // LEFT DOUBLE ANGLE BRACKET
454 res = "\\ensuremath{\\langle\\kern-2.5pt\\langle}";
456 case 0x300b: // RIGHT DOUBLE ANGLE BRACKET
457 res = "\\ensuremath{\\rangle\\kern-2.5pt\\rangle}";
459 case 0x3008: // LEFT ANGLE BRACKET
460 res = "\\ensuremath{\\langle}";
462 case 0x3009: // RIGHT ANGLE BRACKET
463 res = "\\ensuremath{\\rangle}";
469 return from_ascii(res);
473 docstring InsetQuotesParams::getXMLQuote(char_type c) const
475 // Directly output the character Unicode form.
476 return from_ascii("&#" + to_string(c) + ";");
480 map<string, docstring> InsetQuotesParams::getTypes() const
482 map<string, docstring> res;
490 // get all quote types
491 for (sty = 0; sty < stylescount(); ++sty) {
492 style = QuoteStyle(sty);
493 if (style == QuoteStyle::Dynamic)
495 for (sid = 0; sid < 2; ++sid) {
496 side = QuoteSide(sid);
497 for (lev = 0; lev < 2; ++lev) {
498 type += style_char[static_cast<int>(style)];
499 type += side_char[sid];
500 level = QuoteLevel(lev);
501 type += level_char[lev];
502 res[type] = docstring(1, getQuoteChar(style, level, side));
511 docstring const InsetQuotesParams::getGuiLabel(QuoteStyle const & qs, bool langdef) const
513 docstring const styledesc =
514 bformat(_("%1$souter%2$s and %3$sinner%4$s[[quotation marks]]"),
515 docstring(1, getQuoteChar(qs, QuoteLevel::Primary, QuoteSide::Opening)),
516 docstring(1, getQuoteChar(qs, QuoteLevel::Primary, QuoteSide::Closing)),
517 docstring(1, getQuoteChar(qs, QuoteLevel::Secondary, QuoteSide::Opening)),
518 docstring(1, getQuoteChar(qs, QuoteLevel::Secondary, QuoteSide::Closing))
524 return bformat(_("%1$s[[quot. mark description]] (language default)"),
529 docstring const InsetQuotesParams::getShortGuiLabel(docstring const & str) const
531 string const s = to_ascii(str);
532 QuoteStyle const style = getQuoteStyle(s);
533 QuoteSide const side = getQuoteSide(s);
534 QuoteLevel const level = getQuoteLevel(s);
536 return (side == QuoteSide::Opening) ?
537 bformat(_("%1$stext"),
538 docstring(1, getQuoteChar(style, level, side))) :
539 bformat(_("text%1$s"),
540 docstring(1, getQuoteChar(style, level, side)));
544 /////////////////////////////////////////////////////////////////////
548 ///////////////////////////////////////////////////////////////////////
550 InsetQuotes::InsetQuotes(Buffer * buf, string const & str)
554 global_style_ = buf->masterBuffer()->params().quotes_style;
555 fontspec_ = buf->masterBuffer()->params().useNonTeXFonts;
562 InsetQuotes::InsetQuotes(Buffer * buf, char_type c, QuoteLevel level,
563 string const & side, string const & style)
564 : Inset(buf), level_(level)
566 bool dynamic = false;
568 global_style_ = buf->masterBuffer()->params().quotes_style;
569 dynamic = buf->masterBuffer()->params().dynamic_quotes;
570 fontspec_ = buf->masterBuffer()->params().useNonTeXFonts;
573 style_ = dynamic ? QuoteStyle::Dynamic : global_style_;
575 style_ = getStyle(style);
577 if (side == "left" || side == "opening")
578 side_ = QuoteSide::Opening;
579 else if (side == "right" || side == "closing")
580 side_ = QuoteSide::Closing;
586 docstring InsetQuotes::layoutName() const
588 return from_ascii("Quotes");
592 void InsetQuotes::setSide(char_type c)
594 // Decide whether opening or closing quote
595 if (lyx::isSpace(c) || isOpenPunctuation(c))
596 side_ = QuoteSide::Opening;// opening quote
598 side_ = QuoteSide::Closing;// closing quote
602 void InsetQuotes::parseString(string const & s, bool const allow_wildcards)
604 style_ = quoteparams.getQuoteStyle(s, allow_wildcards, style_);
605 side_ = quoteparams.getQuoteSide(s, allow_wildcards, side_);
606 level_ = quoteparams.getQuoteLevel(s, allow_wildcards, level_);
610 QuoteStyle InsetQuotes::getStyle(string const & s)
612 QuoteStyle qs = QuoteStyle::English;
615 qs = QuoteStyle::English;
616 else if (s == "swedish")
617 qs = QuoteStyle::Swedish;
618 else if (s == "german")
619 qs = QuoteStyle::German;
620 else if (s == "polish")
621 qs = QuoteStyle::Polish;
622 else if (s == "swiss")
623 qs = QuoteStyle::Swiss;
624 else if (s == "danish")
625 qs = QuoteStyle::Danish;
626 else if (s == "plain")
627 qs = QuoteStyle::Plain;
628 else if (s == "british")
629 qs = QuoteStyle::British;
630 else if (s == "swedishg")
631 qs = QuoteStyle::SwedishG;
632 else if (s == "french")
633 qs = QuoteStyle::French;
634 else if (s == "frenchin")
635 qs = QuoteStyle::FrenchIN;
636 else if (s == "russian")
637 qs = QuoteStyle::Russian;
639 qs = QuoteStyle::CJK;
640 else if (s == "cjkangle")
641 qs = QuoteStyle::CJKAngle;
642 else if (s == "hungarian")
643 qs = QuoteStyle::Hungarian;
644 else if (s == "dynamic")
645 qs = QuoteStyle::Dynamic;
651 docstring InsetQuotes::displayString() const
653 // In PassThru, we use straight quotes
655 return (level_ == QuoteLevel::Primary) ?
656 from_ascii("\"") : from_ascii("'");
659 (style_ == QuoteStyle::Dynamic) ? global_style_ : style_;
661 docstring retdisp = docstring(1, quoteparams.getQuoteChar(style, level_, side_, rtl_));
663 // in French, thin spaces are added inside double guillemets
664 if (prefixIs(context_lang_, "fr")
665 && level_ == QuoteLevel::Primary
666 && (style == QuoteStyle::Swiss
667 || style == QuoteStyle::French
668 || style == QuoteStyle::FrenchIN)) {
669 // THIN SPACE (U+2009)
670 char_type const thin_space = 0x2009;
671 if (side_ == QuoteSide::Opening)
672 retdisp += thin_space;
674 retdisp = thin_space + retdisp;
681 void InsetQuotes::metrics(MetricsInfo & mi, Dimension & dim) const
683 FontInfo & font = mi.base.font;
684 frontend::FontMetrics const & fm = theFontMetrics(font);
685 dim.asc = fm.maxAscent();
686 dim.des = fm.maxDescent();
687 dim.wid = fm.width(displayString());
691 void InsetQuotes::draw(PainterInfo & pi, int x, int y) const
693 FontInfo font = pi.base.font;
694 if (style_ == QuoteStyle::Dynamic)
695 font.setPaintColor(Color_special);
697 font.setPaintColor(pi.textColor(font.realColor()));
698 pi.pain.text(x, y, displayString(), font);
702 string InsetQuotes::getType() const
705 text += style_char[static_cast<int>(style_)];
706 text += side_char[static_cast<int>(side_)];
707 text += level_char[static_cast<int>(level_)];
712 void InsetQuotes::write(ostream & os) const
714 os << "Quotes " << getType();
718 void InsetQuotes::read(Lexer & lex)
720 lex.setContext("InsetQuotes::read");
722 parseString(lex.getString());
723 lex >> "\\end_inset";
727 void InsetQuotes::doDispatch(Cursor & cur, FuncRequest & cmd)
729 switch (cmd.action()) {
730 case LFUN_INSET_MODIFY: {
731 string const first_arg = cmd.getArg(0);
732 bool const change_type = first_arg == "changetype";
735 // this will not be handled higher up
739 cur.recordUndoInset(this);
740 parseString(cmd.getArg(1), true);
741 cur.forceBufferUpdate();
745 Inset::doDispatch(cur, cmd);
751 bool InsetQuotes::getStatus(Cursor & cur, FuncRequest const & cmd,
752 FuncStatus & flag) const
754 switch (cmd.action()) {
756 case LFUN_INSET_MODIFY: {
757 string const first_arg = cmd.getArg(0);
758 if (first_arg == "changetype") {
759 string const type = cmd.getArg(1);
760 flag.setOnOff(type == getType());
761 flag.setEnabled(!pass_thru_);
764 return Inset::getStatus(cur, cmd, flag);
768 return Inset::getStatus(cur, cmd, flag);
773 void InsetQuotes::latex(otexstream & os, OutputParams const & runparams) const
776 (style_ == QuoteStyle::Dynamic) ? global_style_ : style_;
777 char_type quotechar = quoteparams.getQuoteChar(style, level_, side_, rtl_);
780 // In pass-thru context, we output plain quotes
781 if (runparams.pass_thru || runparams.find_effective())
782 qstr = (level_ == QuoteLevel::Primary) ? from_ascii("\"") : from_ascii("'");
783 else if (style == QuoteStyle::Plain && fontspec_) {
784 // For XeTeX and LuaTeX,we need to disable mapping to get straight
785 // quotes. We define our own commands that do this
786 qstr = (level_ == QuoteLevel::Primary) ?
787 from_ascii("\\textquotedblplain") : from_ascii("\\textquotesingleplain");
789 else if (runparams.use_polyglossia) {
790 // For polyglossia, we directly output the respective unicode chars
791 // (spacing and kerning is then handled respectively)
792 qstr = docstring(1, quotechar);
794 // The CJK marks are not yet covered by utf8 inputenc (we don't have the entry in
795 // unicodesymbols, since we don't want to add fake synbols there).
796 else if (style == QuoteStyle::CJK || style == QuoteStyle::CJKAngle) {
797 if (runparams.encoding && runparams.encoding->name() != "utf8"
798 && runparams.encoding->encodable(quotechar))
799 qstr = docstring(1, quotechar);
801 qstr = quoteparams.getLaTeXQuote(quotechar, "int");
803 else if ((style == QuoteStyle::Swiss
804 || style == QuoteStyle::French
805 || style == QuoteStyle::FrenchIN)
806 && level_ == QuoteLevel::Primary
807 && prefixIs(runparams.local_font->language()->code(), "fr")) {
808 // Specific guillemets of French babel
809 // including correct French spacing
810 if (side_ == QuoteSide::Opening)
811 qstr = from_ascii("\\og");
813 qstr = from_ascii("\\fg");
814 } else if (runparams.use_hyperref && runparams.moving_arg) {
815 // Use internal commands in headings with hyperref
816 // (ligatures not featured in PDF strings)
817 qstr = quoteparams.getLaTeXQuote(quotechar, "int", rtl_);
818 } else if (runparams.main_fontenc == "T1"
819 && !runparams.local_font->language()->internalFontEncoding()) {
820 // Quotation marks for T1 font encoding
822 qstr = quoteparams.getLaTeXQuote(quotechar, "t1");
823 } else if (runparams.local_font->language()->internalFontEncoding()) {
824 // Quotation marks for internal font encodings
825 // (ligatures not featured)
826 qstr = quoteparams.getLaTeXQuote(quotechar, "int", rtl_);
827 #ifdef DO_USE_DEFAULT_LANGUAGE
828 } else if ((doclang == "default"
830 } else if ((!runparams.use_babel
832 || (runparams.main_fontenc != "T1" && runparams.main_fontenc != "OT1"))
833 || runparams.isFullUnicode()) {
834 // Standard quotation mark macros
835 // These are also used by babel
836 // without fontenc (XeTeX/LuaTeX)
837 qstr = quoteparams.getLaTeXQuote(quotechar, "ot1");
839 // Babel shorthand quotation marks (for T1/OT1)
840 qstr = quoteparams.getLaTeXQuote(quotechar, "babel");
843 if (!runparams.pass_thru) {
844 // Guard against unwanted ligatures with preceding text
845 char_type const lastchar = os.lastChar();
846 // LuaTeX does not respect {} as ligature breaker by design,
847 // see https://tex.stackexchange.com/q/349725/19291
848 docstring const nolig =
849 (runparams.flavor == Flavor::LuaTeX
850 || runparams.flavor == Flavor::DviLuaTeX) ?
851 from_ascii("\\/") : from_ascii("{}");
852 // !` ?` => !{}` ?{}`
853 if (prefixIs(qstr, from_ascii("`"))
854 && (lastchar == '!' || lastchar == '?'))
856 // ``` ''' ,,, <<< >>>
857 // => `{}`` '{}'' ,{},, <{}<< >{}>>
858 if (contains(from_ascii(",'`<>"), lastchar)
859 && prefixIs(qstr, lastchar))
865 if (prefixIs(qstr, from_ascii("\\")) && !suffixIs(qstr, '}'))
866 // properly terminate the command depending on the context
871 int InsetQuotes::plaintext(odocstringstream & os,
872 OutputParams const & op, size_t) const
874 if (!op.find_effective()) {
875 docstring const str = displayString();
880 if (level_ == QuoteLevel::Primary)
881 os << from_ascii("\"");
883 os << from_ascii("'");
889 docstring InsetQuotes::getQuoteXMLEntity() const {
891 (style_ == QuoteStyle::Dynamic) ? global_style_ : style_;
892 docstring res = quoteparams.getXMLQuote(quoteparams.getQuoteChar(style, level_, side_));
894 // in French, thin spaces are added inside double guillemets
895 if (prefixIs(context_lang_, "fr")
896 && level_ == QuoteLevel::Primary
897 && (style == QuoteStyle::French
898 || style == QuoteStyle::FrenchIN
899 || style == QuoteStyle::Swiss)) {
900 // THIN SPACE (U+2009)
901 docstring const thin_space = from_ascii(" ");
902 if (side_ == QuoteSide::Opening) // Open quote: space after
904 else // Close quote: space before
905 res = thin_space + res;
911 void InsetQuotes::docbook(XMLStream & xs, OutputParams const &) const
913 xs << XMLStream::ESCAPE_NONE << getQuoteXMLEntity();
917 docstring InsetQuotes::xhtml(XMLStream & xs, OutputParams const &) const
919 xs << XMLStream::ESCAPE_NONE << getQuoteXMLEntity();
924 void InsetQuotes::toString(odocstream & os) const
926 os << displayString();
930 void InsetQuotes::forOutliner(docstring & os, size_t const, bool const) const
932 os += displayString();
936 void InsetQuotes::updateBuffer(ParIterator const & it, UpdateType /* utype*/, bool const /*deleted*/)
938 BufferParams const & bp = buffer().masterBuffer()->params();
939 Font const & font = it.paragraph().getFontSettings(bp, it.pos());
940 pass_thru_ = it.paragraph().isPassThru();
941 context_lang_ = font.language()->code();
942 internal_fontenc_ = font.language()->internalFontEncoding();
943 global_style_ = bp.quotes_style;
944 fontspec_ = bp.useNonTeXFonts;
945 rtl_ = font.isRightToLeft();
949 void InsetQuotes::validate(LaTeXFeatures & features) const
952 (style_ == QuoteStyle::Dynamic) ? global_style_ : style_;
953 char_type type = quoteparams.getQuoteChar(style, level_, side_);
955 // Handle characters that are not natively supported by
956 // specific font encodings (we roll our own definitions)
957 #ifdef DO_USE_DEFAULT_LANGUAGE
958 if (features.bufferParams().language->lang() == "default"
960 if (!features.useBabel()
962 && !features.runparams().isFullUnicode()
963 && features.runparams().main_fontenc != "T1") {
966 features.require("quotesinglbase");
969 features.require("guilsinglleft");
972 features.require("guilsinglright");
975 features.require("quotedblbase");
978 features.require("guillemotleft");
981 features.require("guillemotright");
987 // Handle straight quotation marks. These need special care
988 // in most output formats
991 if (features.runparams().isFullUnicode() && fontspec_)
992 features.require("textquotesinglep");
994 features.require("textcomp");
998 if (features.runparams().isFullUnicode() && fontspec_)
999 features.require("textquotedblp");
1000 else if (features.runparams().main_fontenc != "T1" || internal_fontenc_)
1001 features.require("textquotedbl");
1004 // we fake these from math (also for utf8 inputenc
1005 // currently; see above)
1006 case 0x300e: // LEFT WHITE CORNER BRACKET
1007 case 0x300f: // RIGHT WHITE CORNER BRACKET
1008 if (!features.runparams().encoding
1009 || features.runparams().encoding->name() == "utf8"
1010 || !features.runparams().encoding->encodable(type))
1011 features.require("stmaryrd");
1019 string InsetQuotes::contextMenuName() const
1021 return "context-quote";