/***************************************************************************** purpose: emit a unicode character. values above 2^15 are negative the default_char should be a simple ascii 0-127 character ******************************************************************************/ static void putUnicodeChar(unsigned char b1, unsigned char b2, char default_char) { if (getTexMode() == MODE_VERTICAL) changeTexMode(MODE_HORIZONTAL); if (b1<128) fprintRTF("\\u%d%c",b1*256+b2,default_char); else fprintRTF("\\u%d%c",b1*256+b2-65536,default_char); }
void CmdLogo(int code) /****************************************************************************** purpose : converts the LaTeX, TeX, SLiTex, etc logos to RTF ******************************************************************************/ { int dnsize; changeTexMode(MODE_HORIZONTAL); fprintRTF("{\\plain "); switch (code) { case CMD_TEX: TeXlogo(); break; case CMD_LATEX: LaTeXlogo(); break; case CMD_SLITEX: fprintRTF("{\\scaps Sli}"); TeXlogo(); break; case CMD_BIBTEX: fprintRTF("{\\scaps Bib}"); TeXlogo(); break; case CMD_LATEXE: LaTeXlogo(); dnsize = (int) (0.3 * CurrentFontSize() + 0.45); fprintRTF("2{\\dn%d", dnsize); putUnicodeChar(0x03,0xF5,'e'); fprintRTF("}"); break; case CMD_AMSTEX: fprintRTF("{\\i AmS}-"); /* should be calligraphic */ TeXlogo(); break; case CMD_AMSLATEX: fprintRTF("{\\i AmS}-"); /* should be calligraphic */ LaTeXlogo(); break; case CMD_LYX: dnsize = (int) (0.3 * CurrentFontSize() + 0.45); fprintRTF("L{\\dn%d Y}X", dnsize); break; } fprintRTF("}"); }
void CmdTextNormal(int code) /**************************************************************************** purpose: handle \textnormal{text} {\normalfont ...} commands F_TEXT_NORMAL for \normalfont ... F_TEXT_NORMAL_1 F_TEXT_NORMAL_2 for \textnormal{...} F_TEXT_NORMAL_3 for \begin{normalfont} ... \end{normalfont} ******************************************************************************/ { int true_code = code & ~ON; diagnostics(5, "CmdTextNormal (before) depth=%d, family=%d, size=%d, shape=%d, series=%d", FontInfoDepth, RtfFontInfo[FontInfoDepth].family, RtfFontInfo[FontInfoDepth].size, RtfFontInfo[FontInfoDepth].shape, RtfFontInfo[FontInfoDepth].series); if (true_code == F_TEXT_NORMAL_3 && !(code & ON)) return; if (getTexMode() == MODE_VERTICAL) changeTexMode(MODE_HORIZONTAL); if (code == F_TEXT_NORMAL_2) fprintRTF("{"); if (CurrentFontShape() != DefaultFontShape()) CmdFontShape(DefaultFontShape()); if (CurrentFontSeries() != DefaultFontSeries()) CmdFontSeries(DefaultFontSeries()); if (CurrentFontSize() != DefaultFontSize()) CmdFontSize(DefaultFontSize()); if (CurrentFontFamily() != DefaultFontFamily()) CmdFontFamily(DefaultFontFamily()); if (code == F_TEXT_NORMAL_2) { char *s; s = getBraceParam(); ConvertString(s); free(s); fprintRTF("}"); } diagnostics(5, "CmdTextNormal (after) depth=%d, family=%d, size=%d, shape=%d, series=%d", FontInfoDepth, RtfFontInfo[FontInfoDepth].family, RtfFontInfo[FontInfoDepth].size, RtfFontInfo[FontInfoDepth].shape, RtfFontInfo[FontInfoDepth].series); }
/****************************************************************************** * purpose : inserts a Unicode character *******************************************************************************/ void CmdUnicodeChar(int code) { unsigned char a,b; uint16_t thechar; if (getTexMode() == MODE_VERTICAL) changeTexMode(MODE_HORIZONTAL); thechar = code; a = thechar >> 8; b = thechar - a * 256; putUnicodeChar(a,b,'?'); }
void CmdUnderline(int code) /**************************************************************************** purpose: handle \underline{text} ******************************************************************************/ { char *s; diagnostics(5, "Entering CmdUnderline"); s = getBraceParam(); if (strlen(s) != 0 && getTexMode() == MODE_VERTICAL) /* add check text */ changeTexMode(MODE_HORIZONTAL); fprintRTF("{\\ul "); ConvertString(s); free(s); fprintRTF("}"); diagnostics(5, "Exiting CmdUnderline"); }
void CmdFontSeries(int code) /**************************************************************************** purpose : sets the font weight to medium or bold F_SERIES_BOLD for \bfseries ... F_SERIES_BOLD_1 for \bf ... F_SERIES_BOLD_2 for \textbf{...} F_SERIES_BOLD_3 for \begin{bfseries} ... \end{bfseries} ****************************************************************************/ { int true_code = code & ~ON; char *s; diagnostics(5, "CmdFontSeries (before) depth=%d, family=%d, size=%d, shape=%d, series=%d", FontInfoDepth, RtfFontInfo[FontInfoDepth].family, RtfFontInfo[FontInfoDepth].size, RtfFontInfo[FontInfoDepth].shape, RtfFontInfo[FontInfoDepth].series); /* either \end{bfseries} or \end{mdseries} */ if ((true_code == F_SERIES_MEDIUM_3 || true_code == F_SERIES_BOLD_3 || true_code == F_SERIES_BOLD_4) && !(code & ON)) return; if (true_code == F_SERIES_BOLD_2 || true_code == F_SERIES_MEDIUM_2) { s = getBraceParam(); if (strlen(s) != 0 && getTexMode() == MODE_VERTICAL) changeTexMode(MODE_HORIZONTAL); } switch (code) { case F_SERIES_MEDIUM_3: case F_SERIES_MEDIUM: fprintRTF("\\b0 "); break; case F_SERIES_MEDIUM_1: fprintRTF("\\i0\\scaps0\\b0 "); break; case F_SERIES_MEDIUM_2: fprintRTF("{\\b0 "); break; case F_SERIES_BOLD: case F_SERIES_BOLD_3: fprintRTF("\\b "); break; case F_SERIES_BOLD_1: case F_SERIES_BOLD_4: fprintRTF("\\i0\\scaps0\\b "); break; case F_SERIES_BOLD_2: if (getTexMode() == MODE_VERTICAL) changeTexMode(MODE_HORIZONTAL); fprintRTF("{\\b "); break; } if (true_code == F_SERIES_BOLD_2 || true_code == F_SERIES_MEDIUM_2) { ConvertString(s); fprintRTF("}"); free(s); } diagnostics(5, "CmdFontShape (after) depth=%d, family=%d, size=%d, shape=%d, series=%d", FontInfoDepth, RtfFontInfo[FontInfoDepth].family, RtfFontInfo[FontInfoDepth].size, RtfFontInfo[FontInfoDepth].shape, RtfFontInfo[FontInfoDepth].series); }
void CmdFontShape(int code) /**************************************************************************** purpose : sets the font to upright, italic, or small caps F_SHAPE_ITALIC for \itshape F_SHAPE_ITALIC_1 for \it F_SHAPE_ITALIC_2 for \textit{...} F_SHAPE_ITALIC_3 for \begin{itshape} F_SHAPE_ITALIC_4 for \begin{it} ****************************************************************************/ { int true_code = code & ~ON; char *s; diagnostics(5, "CmdFontShape (before) depth=%d, family=%d, size=%d, shape=%d, series=%d", FontInfoDepth, RtfFontInfo[FontInfoDepth].family, RtfFontInfo[FontInfoDepth].size, RtfFontInfo[FontInfoDepth].shape, RtfFontInfo[FontInfoDepth].series); /* \end{itshape}, \end{sc} ... */ if (!(code & ON) && (true_code == F_SHAPE_UPRIGHT_3 || true_code == F_SHAPE_ITALIC_3 || true_code == F_SHAPE_SLANTED_3 || true_code == F_SHAPE_CAPS_3 || true_code == F_SHAPE_ITALIC_4 || true_code == F_SHAPE_SLANTED_4 || true_code == F_SHAPE_CAPS_4)) return; if (true_code == F_SHAPE_UPRIGHT_2 || true_code == F_SHAPE_ITALIC_2 || true_code == F_SHAPE_SLANTED_2 || true_code == F_SHAPE_CAPS_2) { s = getBraceParam(); if (strlen(s) != 0 && getTexMode() == MODE_VERTICAL) changeTexMode(MODE_HORIZONTAL); } switch (true_code) { case F_SHAPE_UPRIGHT: case F_SHAPE_UPRIGHT_3: fprintRTF("\\i0\\scaps0 "); break; case F_SHAPE_UPRIGHT_1: fprintRTF("\\i0\\scaps0\\b0 "); break; case F_SHAPE_UPRIGHT_2: fprintRTF("{\\i0\\b0\\scaps0 "); break; case F_SHAPE_SLANTED: case F_SHAPE_ITALIC: fprintRTF("\\scaps0\\i "); break; case F_SHAPE_SLANTED_1: case F_SHAPE_ITALIC_1: fprintRTF("\\scaps0\\b0\\i "); break; case F_SHAPE_SLANTED_2: case F_SHAPE_ITALIC_2: fprintRTF("{\\i "); break; case F_SHAPE_SLANTED_3: case F_SHAPE_ITALIC_3: fprintRTF("\\scaps0\\i "); break; case F_SHAPE_SLANTED_4: case F_SHAPE_ITALIC_4: fprintRTF("\\scaps0\\b0\\i "); break; case F_SHAPE_CAPS: case F_SHAPE_CAPS_3: fprintRTF("\\scaps "); break; case F_SHAPE_CAPS_1: case F_SHAPE_CAPS_4: fprintRTF("\\i0\\b0\\scaps "); break; case F_SHAPE_CAPS_2: fprintRTF("{\\scaps "); break; } if (true_code == F_SHAPE_UPRIGHT_2 || true_code == F_SHAPE_ITALIC_2 || true_code == F_SHAPE_SLANTED_2 || true_code == F_SHAPE_CAPS_2) { ConvertString(s); fprintRTF("}"); free(s); } diagnostics(5, "CmdFontShape (after) depth=%d, family=%d, size=%d, shape=%d, series=%d", FontInfoDepth, RtfFontInfo[FontInfoDepth].family, RtfFontInfo[FontInfoDepth].size, RtfFontInfo[FontInfoDepth].shape, RtfFontInfo[FontInfoDepth].series); }
void CmdFontFamily(int code) /****************************************************************************** purpose: selects the appropriate font family F_FAMILY_ROMAN for \rmfamily F_FAMILY_ROMAN_1 for \rm F_FAMILY_ROMAN_2 for \textrm{...} F_FAMILY_ROMAN_3 for \begin{rmfamily} or \end{rmfamily} ******************************************************************************/ { char *s; int num, true_code; true_code = code & ~ON; diagnostics(6, "CmdFontFamily (before) depth=%d, family=%d, size=%d, shape=%d, series=%d", FontInfoDepth, RtfFontInfo[FontInfoDepth].family, RtfFontInfo[FontInfoDepth].size, RtfFontInfo[FontInfoDepth].shape, RtfFontInfo[FontInfoDepth].series); if (!(code & ON) && (true_code == F_FAMILY_CALLIGRAPHIC_3 || true_code == F_FAMILY_TYPEWRITER_3 || true_code == F_FAMILY_SANSSERIF_3 || true_code == F_FAMILY_ROMAN_3 || true_code == F_FAMILY_TYPEWRITER_4 || true_code == F_FAMILY_SANSSERIF_4 || true_code == F_FAMILY_ROMAN_4)) return; switch (true_code) { case F_FAMILY_SANSSERIF: case F_FAMILY_SANSSERIF_1: case F_FAMILY_SANSSERIF_2: case F_FAMILY_SANSSERIF_3: case F_FAMILY_SANSSERIF_4: num = TexFontNumber("Sans Serif"); break; case F_FAMILY_TYPEWRITER: case F_FAMILY_TYPEWRITER_1: case F_FAMILY_TYPEWRITER_2: case F_FAMILY_TYPEWRITER_3: case F_FAMILY_TYPEWRITER_4: num = TexFontNumber("Typewriter"); break; case F_FAMILY_CALLIGRAPHIC: case F_FAMILY_CALLIGRAPHIC_1: case F_FAMILY_CALLIGRAPHIC_2: case F_FAMILY_CALLIGRAPHIC_3: num = TexFontNumber("Calligraphic"); break; case F_FAMILY_ROMAN: case F_FAMILY_ROMAN_1: case F_FAMILY_ROMAN_2: case F_FAMILY_ROMAN_3: case F_FAMILY_ROMAN_4: default: num = TexFontNumber("Roman"); break; } switch (true_code) { case F_FAMILY_ROMAN: case F_FAMILY_SANSSERIF: case F_FAMILY_TYPEWRITER: case F_FAMILY_CALLIGRAPHIC: case F_FAMILY_ROMAN_3: case F_FAMILY_SANSSERIF_3: case F_FAMILY_TYPEWRITER_3: case F_FAMILY_CALLIGRAPHIC_3: fprintRTF("\\f%d ", num); break; case F_FAMILY_ROMAN_1: case F_FAMILY_SANSSERIF_1: case F_FAMILY_TYPEWRITER_1: case F_FAMILY_ROMAN_4: case F_FAMILY_SANSSERIF_4: case F_FAMILY_TYPEWRITER_4: fprintRTF("\\i0\\scaps0\\b0\\f%d ", num); break; case F_FAMILY_ROMAN_2: case F_FAMILY_SANSSERIF_2: case F_FAMILY_TYPEWRITER_2: case F_FAMILY_CALLIGRAPHIC_2: s = getBraceParam(); if (strlen(s) != 0 && getTexMode() == MODE_VERTICAL) changeTexMode(MODE_HORIZONTAL); fprintRTF("{\\f%d ", num); ConvertString(s); fprintRTF("}"); free(s); break; } diagnostics(6, "CmdFontFamily (after) depth=%d, family=%d, size=%d, shape=%d, series=%d", FontInfoDepth, RtfFontInfo[FontInfoDepth].family, RtfFontInfo[FontInfoDepth].size, RtfFontInfo[FontInfoDepth].shape, RtfFontInfo[FontInfoDepth].series); }