Exemplo n.º 1
0
void MonitorFontChanges(const unsigned char *text)
{
    int n;

    diagnostics(6, "\nMonitorFont %10s\n", text);
    diagnostics(6, "MonitorFont 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 (strstart(text, "\\b0"))
        RtfFontInfo[FontInfoDepth].series = F_SERIES_MEDIUM;

    else if (strstart(text, "\\b ") || strstart(text, "\\b\\"))
        RtfFontInfo[FontInfoDepth].series = F_SERIES_BOLD;

    else if (strstart(text, "\\i0")) {
        int mode=getTexMode();
        if (mode==MODE_MATH || mode==MODE_DISPLAYMATH)
            RtfFontInfo[FontInfoDepth].shape = F_SHAPE_MATH_UPRIGHT;
        else
            RtfFontInfo[FontInfoDepth].shape = F_SHAPE_UPRIGHT;
    }
    else if (strstart(text, "\\i ") || strstart(text, "\\i\\"))
        RtfFontInfo[FontInfoDepth].shape = F_SHAPE_ITALIC;

    else if (strstart(text, "\\scaps0")){
        int mode=getTexMode();
        if (mode==MODE_MATH || mode==MODE_DISPLAYMATH)
            RtfFontInfo[FontInfoDepth].shape = F_SHAPE_MATH_UPRIGHT;
        else
            RtfFontInfo[FontInfoDepth].shape = F_SHAPE_UPRIGHT;
    }

    else if (strstart(text, "\\scaps ") || strstart(text, "\\scaps\\"))
        RtfFontInfo[FontInfoDepth].shape = F_SHAPE_CAPS;

    else if (strstartnum(text, "\\fs", &n))
        RtfFontInfo[FontInfoDepth].size = n;

    else if (strstartnum(text, "\\f", &n))
        RtfFontInfo[FontInfoDepth].family = n;

    else if (strstart(text, "\\plain")) {
        RtfFontInfo[FontInfoDepth].size = RtfFontInfo[0].size;
        RtfFontInfo[FontInfoDepth].family = RtfFontInfo[0].family;
        RtfFontInfo[FontInfoDepth].shape = RtfFontInfo[0].shape;
        RtfFontInfo[FontInfoDepth].series = RtfFontInfo[0].series;
    }

    diagnostics(6, "MonitorFont after depth=%d, family=%d, size=%d, shape=%d, series=%d",
      FontInfoDepth, RtfFontInfo[FontInfoDepth].family,
      RtfFontInfo[FontInfoDepth].size, RtfFontInfo[FontInfoDepth].shape, RtfFontInfo[FontInfoDepth].series);
}
Exemplo n.º 2
0
/*****************************************************************************
 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);
}
Exemplo n.º 3
0
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);
}
Exemplo n.º 4
0
/******************************************************************************
 * 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,'?');
}
Exemplo n.º 5
0
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");
}
Exemplo n.º 6
0
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);
}
Exemplo n.º 7
0
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);
}
Exemplo n.º 8
0
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);
}