File: fonts.c

package info (click to toggle)
latex2rtf 1.8aa-2
  • links: PTS
  • area: main
  • in suites: potato
  • size: 1,300 kB
  • ctags: 535
  • sloc: ansic: 5,434; makefile: 231; sh: 4
file content (130 lines) | stat: -rw-r--r-- 4,373 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
 * $Id: fonts.c,v 1.6 1998/10/28 06:27:56 glehner Exp $
 * History:
 * $Log: fonts.c,v $
 * Revision 1.6  1998/10/28 06:27:56  glehner
 * Removed <malloc.h>
 *
 * Revision 1.5  1997/02/15 20:55:50  ralf
 * Some reformatting and changes suggested by lclint
 * Removed direct access to data structures in cfg.c
 *
 * Revision 1.4  1995/05/24 15:32:22  ralf
 * Changes by Vladimir Menkov for DOS port
 *
 * Revision 1.3  1995/03/23  15:58:08  ralf
 * Reworked version by Friedrich Polzer and Gerhard Trisko
 *
 * Revision 1.2  1994/06/17  14:19:41  ralf
 * Corrected various bugs, for example interactive read of arguments
 *
 * Revision 1.1  1994/06/17  11:26:29  ralf
 * Initial revision
 *
 */
/***************************************************************************
     name : fonts.c
   author : DORNER Fernando, GRANZER Andreas
            POLZER Friedrich,TRISKO Gerhard
 * uses now sorted array instead of fonts.cfg and chained list
 *
 purpose : The LaTeX font will be converted to the RTF font
 ******************************************************************************/

/****************************************** includes ************************/
#include <stdio.h>
#include <stdlib.h>
#include "main.h"
#include "fonts.h"
#include "cfg.h" 
/******************************************************************************/
void error(char *);

/************************************* extern variables *********************/
extern int fontsize;
extern size_t DefFont;

/******************************************************************************/


/********************* defines and structures ********************************/
#define MAXLEN 80
/****************************************************************************/


/***/
void WriteFontHeader(FILE* fRtf)
/****************************************************************************
 *   purpose: writes fontnumbers and styles for headers into Rtf-File 
 * parameter: fRtf: File-Pointer to Rtf-File
 *   globals: fontsize
 *            DefFont (default font number)
 ****************************************************************************/
{
    size_t num = 0;
    const ConfigEntryT **config_handle;

    fprintf(fRtf,"{\\fonttbl");

    config_handle = CfgStartIterate (FONT_A);
    while ((config_handle = CfgNext (FONT_A, config_handle)) != NULL)
    {
	fprintf( fRtf
	       , "{\\f%u\\fnil %s;}"
	       , (unsigned int)num
	       , (*config_handle)->RtfCommand
	       );
	++num;
    }

    fprintf(fRtf,"}\\f%u\n", (unsigned int)(DefFont = GetFontNumber("Roman")));
    fprintf(fRtf,"{\\stylesheet{\\fs%d\\lang1031\\snext0 Normal;}",fontsize);
    fprintf( fRtf,"{%s%u%s \\sbasedon0\\snext0 heading 1;}\n"
	   , HEADER11,(unsigned int)DefFont,HEADER12);
    fprintf( fRtf,"{%s%u%s \\sbasedon0\\snext0 heading 2;}\n"
           , HEADER21,(unsigned int)DefFont,HEADER22);
    fprintf( fRtf,"{%s%u%s \\sbasedon0\\snext0 heading 3;}\n"
           , HEADER31,(unsigned int)DefFont,HEADER32);
    fprintf( fRtf,"{%s%u%s \\sbasedon0\\snext0 heading 4;}\n"
           , HEADER41,(unsigned int)DefFont,HEADER42);

    fprintf(fRtf,"%s\n", HEADER03);
    fprintf(fRtf,"%s\n", HEADER13);
    fprintf(fRtf,"%s\n", HEADER23);
    fprintf(fRtf,"%s\n", HEADER33);
    fprintf(fRtf,"%s\n", HEADER43);
}


/***/
size_t GetFontNumber(char * Fname)
/****************************************************************************
 *   purpose: gets the font number from an Rtf font name
 * parameter: Fname: fontname in Rtf
 *    return: font number
 ****************************************************************************/
{
    size_t num = 0;
    const ConfigEntryT **config_handle = CfgStartIterate (FONT_A);

    while ((config_handle = CfgNext (FONT_A, config_handle)) != NULL)
    {
	if (strcmp ((*config_handle)->RtfCommand, Fname) == 0)
	{
	    return num;  
	}
      num++; /* found by gerard P´┐Żnillault, added by W.Hennings March08,1999 */
    }
    return GetTexFontNumber ("Roman");  /* default font */
}

/***/
size_t GetTexFontNumber(char * Fname)
/****************************************************************************
  purpose: gets the RTF font number from given LaTex font
parameter: Fname: fontname in LaTex
   return: RTF font number
 ****************************************************************************/
{
    return SearchRtfIndex (Fname, FONT_A);
}