libgeda: Enable use from C++ programs.
[geda-gaf/whiteaudio.git] / utils / src / char_width.c
blob23cb95681dfbb67e3397b1473d1341179ea1bd7f
2 #include "config.h"
3 #ifdef HAVE_STRING_H
4 #include <string.h>
5 #endif
7 #ifdef HAVE_LIBDMALLOC
8 #include <dmalloc.h>
9 #endif
11 #define CHAR_POINTS 2
13 const int char_width[]={
14 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
15 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
16 11,14,14,22,28,28,24,10,12,12,16,20,14,20,12,18,
17 26,16,26,20,26,20,24,20,22,26,12,12,20,20,20,20,
18 36,29,29,28,26,29,21,30,29,9,21,27,22,32,28,32,
19 25,32,26,25,23,27,27,37,27,25,27,12,14,12,20,25,
20 10,24,22,22,20,20,12,24,20,8,10,19,9,32,20,20,
21 20,24,14,18,12,19,20,28,19,20,21,12,10,12,22,0,
22 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
23 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
24 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
25 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
26 0,0,0,0,29,29,0,0,0,0,0,0,0,0,0,0,
27 0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,
28 0,0,0,0,24,24,0,0,0,0,0,0,0,0,0,0,
29 0,0,0,0,0,0,20,0,0,0,0,0,0,0,0,0
32 /***************************************************************/
33 /* GetStringDisplayLength: */
34 /* inputs: string to be sized */
35 /* string's font size to use */
36 /* returns: length of string in gEDA points */
37 /***************************************************************/
38 int GetStringDisplayLength(char *str,int font_size)
39 { int width=0;
40 int i, len;
41 len = strlen(str);
42 for (i=0;i<len;i++)
43 width += char_width[(int)str[i]];
44 width = (font_size*width)/CHAR_POINTS;
45 return width;