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 "OutputParams.h"
31 #include "output_xhtml.h"
32 #include "Paragraph.h"
33 #include "ParIterator.h"
34 #include "texstream.h"
36 #include "frontends/FontMetrics.h"
37 #include "frontends/Painter.h"
39 #include "support/debug.h"
40 #include "support/docstring.h"
41 #include "support/docstream.h"
42 #include "support/gettext.h"
43 #include "support/lstrings.h"
44 #include "support/textutils.h"
49 using namespace lyx::support;
55 /* codes used to read/write quotes to LyX files
57 * e ``english'' (`inner quotation')
58 * s ''swedish'' ('inner quotation')
59 * g ,,german`` (,inner quotation`)
60 * p ,,polish'' (,inner quotation')
61 * c <<swiss>> (<inner quotation>)
62 * a >>danish<< (>inner quotation<)
63 * q "plain" ('inner quotation')
64 * b `british' (``inner quotation'')
65 * w >>swedishg>> ('inner quotation') ["g" = Guillemets]
66 * f <<french>> (``inner quotation'')
67 * i <<frenchin>> (<<inner quotation>>) ["in" = Imprimerie Nationale]
68 * r <<russian>> (,,inner quotation``)
69 * j [U+300C]cjk[U+300D] ([U+300E]inner quotation[U+300F]) [CORNER BRACKETS]
70 * k [U+300A]cjkangle[U+300B] ([U+3008]inner quotation[U+3009]) [ANGLE BRACKETS]
71 * x dynamic style (inherits document settings)
74 char const * const style_char = "esgpcaqbwfirjkx";
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[style];
102 InsetQuotesParams::QuoteStyle InsetQuotesParams::getQuoteStyle(string const & s,
103 bool const allow_wildcards, QuoteStyle fb)
108 if (str.length() != 3) {
109 LYXERR0("ERROR (InsetQuotes::InsetQuotes):"
110 " bad string length.");
116 // '.' wildcard means: keep current style
117 if (!allow_wildcards || str[0] != '.') {
118 for (i = 0; i < stylescount(); ++i) {
119 if (str[0] == style_char[i]) {
124 if (i >= stylescount()) {
125 LYXERR0("ERROR (InsetQuotes::InsetQuotes):"
126 " bad style specification.");
135 InsetQuotesParams::QuoteSide InsetQuotesParams::getQuoteSide(string const & s,
136 bool const allow_wildcards, QuoteSide fb)
141 if (str.length() != 3) {
142 LYXERR0("ERROR (InsetQuotes::InsetQuotes):"
143 " bad string length.");
149 // '.' wildcard means: keep current side
150 if (!allow_wildcards || str[1] != '.') {
151 for (i = 0; i < 2; ++i) {
152 if (str[1] == side_char[i]) {
153 res = InsetQuotesParams::QuoteSide(i);
158 LYXERR0("ERROR (InsetQuotes::InsetQuotes):"
159 " bad side specification.");
168 InsetQuotesParams::QuoteLevel InsetQuotesParams::getQuoteLevel(string const & s,
169 bool const allow_wildcards, QuoteLevel fb)
174 if (str.length() != 3) {
175 LYXERR0("ERROR (InsetQuotes::InsetQuotes):"
176 " bad string length.");
182 // '.' wildcard means: keep current level
183 if (!allow_wildcards || str[2] != '.') {
184 for (i = 0; i < 2; ++i) {
185 if (str[2] == level_char[i]) {
186 res = InsetQuotesParams::QuoteLevel(i);
191 LYXERR0("ERROR (InsetQuotes::InsetQuotes):"
192 " bad level specification.");
193 res = InsetQuotesParams::PrimaryQuotes;
201 char_type InsetQuotesParams::getQuoteChar(QuoteStyle const & style, QuoteLevel const & level,
202 QuoteSide const & side) const
204 // main opening quotation mark
205 char_type left_primary;
206 // main closing quotation mark
207 char_type right_primary;
208 // secondary (inner, 'single') opening quotation mark
209 char_type left_secondary;
210 // secondary (inner, 'single') closing quotation mark
211 char_type right_secondary;
214 case EnglishQuotes: {
215 left_primary = 0x201c; // ``
216 right_primary = 0x201d; // ''
217 left_secondary = 0x2018; // `
218 right_secondary = 0x2019; // '
221 case SwedishQuotes: {
222 left_primary = 0x201d; // ''
223 right_primary = 0x201d; // ''
224 left_secondary = 0x2019; // '
225 right_secondary = 0x2019; // '
229 left_primary = 0x201e; // ,,
230 right_primary = 0x201c; // ``
231 left_secondary = 0x201a; // ,
232 right_secondary = 0x2018; // `
236 left_primary = 0x201e; // ,,
237 right_primary = 0x201d; // ''
238 left_secondary = 0x201a; // ,
239 right_secondary = 0x2019; // '
243 left_primary = 0x00ab; // <<
244 right_primary = 0x00bb; // >>
245 left_secondary = 0x2039; // <
246 right_secondary = 0x203a; // >
250 left_primary = 0x00bb; // >>
251 right_primary = 0x00ab; // <<
252 left_secondary = 0x203a; // >
253 right_secondary = 0x2039; // <
257 left_primary = 0x0022; // "
258 right_primary = 0x0022; // "
259 left_secondary = 0x0027; // '
260 right_secondary = 0x0027; // '
263 case BritishQuotes: {
264 left_primary = 0x2018; // `
265 right_primary = 0x2019; // '
266 left_secondary = 0x201c; // ``
267 right_secondary = 0x201d; // ''
270 case SwedishGQuotes: {
271 left_primary = 0x00bb; // >>
272 right_primary = 0x00bb; // >>
273 left_secondary = 0x2019; // '
274 right_secondary = 0x2019; // '
278 left_primary = 0x00ab; // <<
279 right_primary = 0x00bb; // >>
280 left_secondary = 0x201c; // ``
281 right_secondary = 0x201d; // ''
284 case FrenchINQuotes:{
285 left_primary = 0x00ab; // <<
286 right_primary = 0x00bb; // >>
287 left_secondary = 0x00ab; // <<
288 right_secondary = 0x00bb; // >>
292 left_primary = 0x00ab; // <<
293 right_primary = 0x00bb; // >>
294 left_secondary = 0x201e; // ,,
295 right_secondary = 0x201c; // ``
299 left_primary = 0x300c; // LEFT CORNER BRACKET
300 right_primary = 0x300d; // RIGHT CORNER BRACKET
301 left_secondary = 0x300e; // LEFT WHITE CORNER BRACKET
302 right_secondary = 0x300f; // RIGHT WHITE CORNER BRACKET
305 case CJKAngleQuotes:{
306 left_primary = 0x300a; // LEFT DOUBLE ANGLE BRACKET
307 right_primary = 0x300b; // RIGHT DOUBLE ANGLE BRACKET
308 left_secondary = 0x3008; // LEFT ANGLE BRACKET
309 right_secondary = 0x3009; // RIGHT ANGLE BRACKET
315 left_primary = 0x003f; // ?
316 right_primary = 0x003f; // ?
317 left_secondary = 0x003f; // ?
318 right_secondary = 0x003f; // ?
323 case SecondaryQuotes:
324 return (side == OpeningQuote) ? left_secondary : right_secondary;
326 return (side == OpeningQuote) ? left_primary : right_primary;
336 docstring InsetQuotesParams::getLaTeXQuote(char_type c, string const & op) const
345 res = "\\quotesinglbase";
350 res = "\\textquoteleft";
357 res = "\\textquoteright";
366 res = "\\guilsinglleft";
373 res = "\\guilsinglright";
376 case 0x0027: {// ' (plain)
377 res = "\\textquotesingle";
383 else if (op == "babel")
386 res = "\\quotedblbase";
391 res = "\\textquotedblleft";
398 res = "\\textquotedblright";
406 else if (op == "babel")
409 res = "\\guillemotleft";
415 else if (op == "babel")
418 res = "\\guillemotright";
422 res = "\\textquotedbl";
425 // The following are fakes
426 // This is just to get something symbolic
427 // in encodings where this chars would not be used ayway
428 case 0x300c: // LEFT CORNER BRACKET
429 res = "\\ensuremath{\\lceil}";
431 case 0x300d: // RIGHT CORNER BRACKET
432 res = "\\ensuremath{\\rfloor}";
434 case 0x300e: // LEFT WHITE CORNER BRACKET
435 res = "\\ensuremath{\\llceil}";
437 case 0x300f: // RIGHT WHITE CORNER BRACKET
438 res = "\\ensuremath{\\rrfloor}";
440 case 0x300a: // LEFT DOUBLE ANGLE BRACKET
441 res = "\\ensuremath{\\langle\\kern-2.5pt\\langle}";
443 case 0x300b: // RIGHT DOUBLE ANGLE BRACKET
444 res = "\\ensuremath{\\rangle\\kern-2.5pt\\rangle}";
446 case 0x3008: // LEFT ANGLE BRACKET
447 res = "\\ensuremath{\\langle}";
449 case 0x3009: // RIGHT ANGLE BRACKET
450 res = "\\ensuremath{\\rangle}";
456 return from_ascii(res);
460 docstring InsetQuotesParams::getHTMLQuote(char_type c) const
480 case 0x0027: // ' (plain)
501 case 0x300c: // LEFT CORNER BRACKET
504 case 0x300d: // RIGHT CORNER BRACKET
507 case 0x300e: // LEFT WHITE CORNER BRACKET
510 case 0x300f: // RIGHT WHITE CORNER BRACKET
513 case 0x300a: // LEFT DOUBLE ANGLE BRACKET
516 case 0x300b: // RIGHT DOUBLE ANGLE BRACKET
519 case 0x3008: // LEFT ANGLE BRACKET
522 case 0x3009: // RIGHT ANGLE BRACKET
529 return from_ascii(res);
533 map<string, docstring> InsetQuotesParams::getTypes() const
535 map<string, docstring> res;
543 // get all quote types
544 for (sty = 0; sty < stylescount(); ++sty) {
545 style = QuoteStyle(sty);
546 if (style == DynamicQuotes)
548 for (sid = 0; sid < 2; ++sid) {
549 side = QuoteSide(sid);
550 for (lev = 0; lev < 2; ++lev) {
551 type += style_char[style];
552 type += side_char[sid];
553 level = QuoteLevel(lev);
554 type += level_char[lev];
555 res[type] = docstring(1, getQuoteChar(style, level, side));
564 docstring const InsetQuotesParams::getGuiLabel(QuoteStyle const & qs, bool langdef)
566 docstring const styledesc =
567 bformat(_("%1$souter%2$s and %3$sinner%4$s[[quotation marks]]"),
568 docstring(1, getQuoteChar(qs, PrimaryQuotes, OpeningQuote)),
569 docstring(1, getQuoteChar(qs, PrimaryQuotes, ClosingQuote)),
570 docstring(1, getQuoteChar(qs, SecondaryQuotes, OpeningQuote)),
571 docstring(1, getQuoteChar(qs, SecondaryQuotes, ClosingQuote))
577 return bformat(_("%1$s[[quot. mark description]] (language default)"),
582 docstring const InsetQuotesParams::getShortGuiLabel(docstring const string)
584 std::string const s = to_ascii(string);
585 QuoteStyle const style = getQuoteStyle(s);
586 QuoteSide const side = getQuoteSide(s);
587 QuoteLevel const level = getQuoteLevel(s);
589 return (side == OpeningQuote) ?
590 bformat(_("%1$stext"),
591 docstring(1, getQuoteChar(style, level, side))) :
592 bformat(_("text%1$s"),
593 docstring(1, getQuoteChar(style, level, side)));
597 /////////////////////////////////////////////////////////////////////
601 ///////////////////////////////////////////////////////////////////////
603 InsetQuotes::InsetQuotes(Buffer * buf, string const & str)
605 style_(InsetQuotesParams::EnglishQuotes), side_(InsetQuotesParams::OpeningQuote),
606 pass_thru_(false), internal_fontenc_(false)
609 global_style_ = buf->masterBuffer()->params().quotes_style;
610 fontspec_ = buf->masterBuffer()->params().useNonTeXFonts;
613 global_style_ = InsetQuotesParams::EnglishQuotes;
621 InsetQuotes::InsetQuotes(Buffer * buf, char_type c, InsetQuotesParams::QuoteLevel level,
622 string const & side, string const & style)
623 : Inset(buf), level_(level), pass_thru_(false), fontspec_(false), internal_fontenc_(false)
625 bool dynamic = false;
627 global_style_ = buf->masterBuffer()->params().quotes_style;
628 fontenc_ = buf->masterBuffer()->params().main_font_encoding();
629 dynamic = buf->masterBuffer()->params().dynamic_quotes;
630 fontspec_ = buf->masterBuffer()->params().useNonTeXFonts;
632 global_style_ = InsetQuotesParams::EnglishQuotes;
637 style_ = dynamic ? InsetQuotesParams::DynamicQuotes : global_style_;
639 style_ = getStyle(style);
641 if (side == "left" || side == "opening")
642 side_ = InsetQuotesParams::OpeningQuote;
643 else if (side == "right" || side == "closing")
644 side_ = InsetQuotesParams::ClosingQuote;
650 docstring InsetQuotes::layoutName() const
652 return from_ascii("Quotes");
656 void InsetQuotes::setSide(char_type c)
658 // Decide whether opening or closing quote
659 if (lyx::isSpace(c) || isOpenPunctuation(c))
660 side_ = InsetQuotesParams::OpeningQuote;// opening quote
662 side_ = InsetQuotesParams::ClosingQuote;// closing quote
666 void InsetQuotes::parseString(string const & s, bool const allow_wildcards)
668 style_ = quoteparams.getQuoteStyle(s, allow_wildcards, style_);
669 side_ = quoteparams.getQuoteSide(s, allow_wildcards, side_);
670 level_ = quoteparams.getQuoteLevel(s, allow_wildcards, level_);
674 InsetQuotesParams::QuoteStyle InsetQuotes::getStyle(string const & s)
676 InsetQuotesParams::QuoteStyle qs = InsetQuotesParams::EnglishQuotes;
679 qs = InsetQuotesParams::EnglishQuotes;
680 else if (s == "swedish")
681 qs = InsetQuotesParams::SwedishQuotes;
682 else if (s == "german")
683 qs = InsetQuotesParams::GermanQuotes;
684 else if (s == "polish")
685 qs = InsetQuotesParams::PolishQuotes;
686 else if (s == "swiss")
687 qs = InsetQuotesParams::SwissQuotes;
688 else if (s == "danish")
689 qs = InsetQuotesParams::DanishQuotes;
690 else if (s == "plain")
691 qs = InsetQuotesParams::PlainQuotes;
692 else if (s == "british")
693 qs = InsetQuotesParams::BritishQuotes;
694 else if (s == "swedishg")
695 qs = InsetQuotesParams::SwedishGQuotes;
696 else if (s == "french")
697 qs = InsetQuotesParams::FrenchQuotes;
698 else if (s == "frenchin")
699 qs = InsetQuotesParams::FrenchINQuotes;
700 else if (s == "russian")
701 qs = InsetQuotesParams::RussianQuotes;
703 qs = InsetQuotesParams::CJKQuotes;
704 else if (s == "cjkangle")
705 qs = InsetQuotesParams::CJKAngleQuotes;
706 else if (s == "dynamic")
707 qs = InsetQuotesParams::DynamicQuotes;
713 docstring InsetQuotes::displayString() const
715 // In PassThru, we use straight quotes
717 return (level_ == InsetQuotesParams::PrimaryQuotes) ?
718 from_ascii("\"") : from_ascii("'");
720 InsetQuotesParams::QuoteStyle style =
721 (style_ == InsetQuotesParams::DynamicQuotes) ? global_style_ : style_;
723 docstring retdisp = docstring(1, quoteparams.getQuoteChar(style, level_, side_));
725 // in French, thin spaces are added inside double guillemets
726 if (prefixIs(context_lang_, "fr")
727 && level_ == InsetQuotesParams::PrimaryQuotes
728 && (style == InsetQuotesParams::SwissQuotes
729 || style == InsetQuotesParams::FrenchQuotes
730 || style == InsetQuotesParams::FrenchINQuotes)) {
731 // THIN SPACE (U+2009)
732 char_type const thin_space = 0x2009;
733 if (side_ == InsetQuotesParams::OpeningQuote)
734 retdisp += thin_space;
736 retdisp = thin_space + retdisp;
743 void InsetQuotes::metrics(MetricsInfo & mi, Dimension & dim) const
745 FontInfo & font = mi.base.font;
746 frontend::FontMetrics const & fm = theFontMetrics(font);
747 dim.asc = fm.maxAscent();
748 dim.des = fm.maxDescent();
749 dim.wid = fm.width(displayString());
753 void InsetQuotes::draw(PainterInfo & pi, int x, int y) const
755 FontInfo font = pi.base.font;
756 if (style_ == InsetQuotesParams::DynamicQuotes)
757 font.setPaintColor(Color_special);
759 font.setPaintColor(pi.textColor(font.realColor()));
760 pi.pain.text(x, y, displayString(), font);
764 string InsetQuotes::getType() const
767 text += style_char[style_];
768 text += side_char[side_];
769 text += level_char[level_];
774 void InsetQuotes::write(ostream & os) const
776 os << "Quotes " << getType();
780 void InsetQuotes::read(Lexer & lex)
782 lex.setContext("InsetQuotes::read");
784 parseString(lex.getString());
785 lex >> "\\end_inset";
789 void InsetQuotes::doDispatch(Cursor & cur, FuncRequest & cmd)
791 switch (cmd.action()) {
792 case LFUN_INSET_MODIFY: {
793 string const first_arg = cmd.getArg(0);
794 bool const change_type = first_arg == "changetype";
797 // this will not be handled higher up
801 cur.recordUndoInset(this);
802 parseString(cmd.getArg(1), true);
803 cur.buffer()->updateBuffer();
807 Inset::doDispatch(cur, cmd);
813 bool InsetQuotes::getStatus(Cursor & cur, FuncRequest const & cmd,
814 FuncStatus & flag) const
816 switch (cmd.action()) {
818 case LFUN_INSET_MODIFY: {
819 string const first_arg = cmd.getArg(0);
820 if (first_arg == "changetype") {
821 string const type = cmd.getArg(1);
822 flag.setOnOff(type == getType());
823 flag.setEnabled(!pass_thru_);
826 return Inset::getStatus(cur, cmd, flag);
830 return Inset::getStatus(cur, cmd, flag);
835 void InsetQuotes::latex(otexstream & os, OutputParams const & runparams) const
837 InsetQuotesParams::QuoteStyle style =
838 (style_ == InsetQuotesParams::DynamicQuotes) ? global_style_ : style_;
839 char_type quotechar = quoteparams.getQuoteChar(style, level_, side_);
842 // In pass-thru context, we output plain quotes
843 if (runparams.pass_thru)
844 qstr = (level_ == InsetQuotesParams::PrimaryQuotes) ? from_ascii("\"") : from_ascii("'");
845 else if (style == InsetQuotesParams::PlainQuotes && fontspec_) {
846 // For XeTeX and LuaTeX,we need to disable mapping to get straight
847 // quotes. We define our own commands that do this
848 qstr = (level_ == InsetQuotesParams::PrimaryQuotes) ?
849 from_ascii("\\textquotedblplain") : from_ascii("\\textquotesingleplain");
851 else if (runparams.use_polyglossia) {
852 // For polyglossia, we directly output the respective unicode chars
853 // (spacing and kerning is then handled respectively)
854 qstr = docstring(1, quotechar);
856 else if (style == InsetQuotesParams::CJKQuotes || style == InsetQuotesParams::CJKAngleQuotes) {
857 if (runparams.encoding && runparams.encoding->encodable(quotechar))
858 qstr = docstring(1, quotechar);
860 qstr = quoteparams.getLaTeXQuote(quotechar, "int");
862 else if ((style == InsetQuotesParams::SwissQuotes
863 || style == InsetQuotesParams::FrenchQuotes
864 || style == InsetQuotesParams::FrenchINQuotes)
865 && level_ == InsetQuotesParams::PrimaryQuotes
866 && prefixIs(runparams.local_font->language()->code(), "fr")) {
867 // Specific guillemets of French babel
868 // including correct French spacing
869 if (side_ == InsetQuotesParams::OpeningQuote)
870 qstr = from_ascii("\\og");
872 qstr = from_ascii("\\fg");
873 } else if (fontenc_ == "T1"
874 && !runparams.local_font->language()->internalFontEncoding()) {
875 // Quotation marks for T1 font encoding
877 qstr = quoteparams.getLaTeXQuote(quotechar, "t1");
878 } else if (runparams.local_font->language()->internalFontEncoding()) {
879 // Quotation marks for internal font encodings
880 // (ligatures not featured)
881 qstr = quoteparams.getLaTeXQuote(quotechar, "int");
882 #ifdef DO_USE_DEFAULT_LANGUAGE
883 } else if ((doclang == "default"
885 } else if ((!runparams.use_babel
887 || (fontenc_ != "T1" && fontenc_ != "OT1"))
888 || runparams.isFullUnicode()) {
889 // Standard quotation mark macros
890 // These are also used by babel
891 // without fontenc (XeTeX/LuaTeX)
892 qstr = quoteparams.getLaTeXQuote(quotechar, "ot1");
894 // Babel shorthand quotation marks (for T1/OT1)
895 qstr = quoteparams.getLaTeXQuote(quotechar, "babel");
898 if (!runparams.pass_thru) {
899 // Guard against unwanted ligatures with preceding text
900 char_type const lastchar = os.lastChar();
901 // LuaTeX does not respect {} as ligature breaker by design,
902 // see https://tex.stackexchange.com/q/349725/19291
903 docstring const nolig =
904 (runparams.flavor == OutputParams::LUATEX
905 || runparams.flavor == OutputParams::DVILUATEX) ?
906 from_ascii("\\/") : from_ascii("{}");
907 // !` ?` => !{}` ?{}`
908 if (prefixIs(qstr, from_ascii("`"))
909 && (lastchar == '!' || lastchar == '?'))
911 // ``` ''' ,,, <<< >>>
912 // => `{}`` '{}'' ,{},, <{}<< >{}>>
913 if (contains(from_ascii(",'`<>"), lastchar)
914 && prefixIs(qstr, lastchar))
920 if (prefixIs(qstr, from_ascii("\\")) && !suffixIs(qstr, '}'))
921 // properly terminate the command depending on the context
926 int InsetQuotes::plaintext(odocstringstream & os,
927 OutputParams const &, size_t) const
929 docstring const str = displayString();
935 docstring InsetQuotes::getQuoteEntity() const {
936 InsetQuotesParams::QuoteStyle style =
937 (style_ == InsetQuotesParams::DynamicQuotes) ? global_style_ : style_;
938 docstring res = quoteparams.getHTMLQuote(quoteparams.getQuoteChar(style, level_, side_));
939 // in French, thin spaces are added inside double guillemets
940 if (prefixIs(context_lang_, "fr")
941 && level_ == InsetQuotesParams::PrimaryQuotes
942 && (style == InsetQuotesParams::FrenchQuotes
943 || style == InsetQuotesParams::FrenchINQuotes
944 || style == InsetQuotesParams::SwissQuotes)) {
945 // THIN SPACE (U+2009)
946 docstring const thin_space = from_ascii(" ");
947 if (side_ == InsetQuotesParams::OpeningQuote)
950 res = thin_space + res;
956 int InsetQuotes::docbook(odocstream & os, OutputParams const &) const
958 os << getQuoteEntity();
963 docstring InsetQuotes::xhtml(XHTMLStream & xs, OutputParams const &) const
965 xs << XHTMLStream::ESCAPE_NONE << getQuoteEntity();
970 void InsetQuotes::toString(odocstream & os) const
972 os << displayString();
976 void InsetQuotes::forOutliner(docstring & os, size_t const, bool const) const
978 os += displayString();
982 void InsetQuotes::updateBuffer(ParIterator const & it, UpdateType /* utype*/)
984 BufferParams const & bp = buffer().masterBuffer()->params();
985 pass_thru_ = it.paragraph().isPassThru();
986 context_lang_ = it.paragraph().getFontSettings(bp, it.pos()).language()->code();
987 internal_fontenc_ = it.paragraph().getFontSettings(bp, it.pos()).language()->internalFontEncoding();
988 fontenc_ = bp.main_font_encoding();
989 global_style_ = bp.quotes_style;
990 fontspec_ = bp.useNonTeXFonts;
994 void InsetQuotes::validate(LaTeXFeatures & features) const
996 InsetQuotesParams::QuoteStyle style =
997 (style_ == InsetQuotesParams::DynamicQuotes) ? global_style_ : style_;
998 char_type type = quoteparams.getQuoteChar(style, level_, side_);
1000 // Handle characters that are not natively supported by
1001 // specific font encodings (we roll our own definitions)
1002 #ifdef DO_USE_DEFAULT_LANGUAGE
1003 if (features.bufferParams().language->lang() == "default"
1005 if (!features.useBabel()
1007 && !features.runparams().isFullUnicode() && fontenc_ != "T1") {
1010 features.require("quotesinglbase");
1013 features.require("guilsinglleft");
1016 features.require("guilsinglright");
1019 features.require("quotedblbase");
1022 features.require("guillemotleft");
1025 features.require("guillemotright");
1031 // Handle straight quotation marks. These need special care
1032 // in most output formats
1035 if (features.runparams().isFullUnicode() && fontspec_)
1036 features.require("textquotesinglep");
1038 features.require("textcomp");
1042 if (features.runparams().isFullUnicode() && fontspec_)
1043 features.require("textquotedblp");
1044 else if (fontenc_ != "T1" || internal_fontenc_)
1045 features.require("textquotedbl");
1048 // we fake these from math
1049 case 0x300e: // LEFT WHITE CORNER BRACKET
1050 case 0x300f: // RIGHT WHITE CORNER BRACKET
1051 if (!features.runparams().encoding
1052 || !features.runparams().encoding->encodable(type))
1053 features.require("stmaryrd");
1061 string InsetQuotes::contextMenuName() const
1063 return "context-quote";