utils
|
00001 00002 #include "config.h" 00003 #ifdef HAVE_STRING_H 00004 #include <string.h> 00005 #endif 00006 00007 #ifdef HAVE_LIBDMALLOC 00008 #include <dmalloc.h> 00009 #endif 00010 00011 #define CHAR_POINTS 2 00012 00013 const int char_width[]={ 00014 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 00015 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 00016 11,14,14,22,28,28,24,10,12,12,16,20,14,20,12,18, 00017 26,16,26,20,26,20,24,20,22,26,12,12,20,20,20,20, 00018 36,29,29,28,26,29,21,30,29,9,21,27,22,32,28,32, 00019 25,32,26,25,23,27,27,37,27,25,27,12,14,12,20,25, 00020 10,24,22,22,20,20,12,24,20,8,10,19,9,32,20,20, 00021 20,24,14,18,12,19,20,28,19,20,21,12,10,12,22,0, 00022 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 00023 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 00024 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 00025 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 00026 0,0,0,0,29,29,0,0,0,0,0,0,0,0,0,0, 00027 0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0, 00028 0,0,0,0,24,24,0,0,0,0,0,0,0,0,0,0, 00029 0,0,0,0,0,0,20,0,0,0,0,0,0,0,0,0 00030 }; 00031 00032 /***************************************************************/ 00033 /* GetStringDisplayLength: */ 00034 /* inputs: string to be sized */ 00035 /* string's font size to use */ 00036 /* returns: length of string in gEDA points */ 00037 /***************************************************************/ 00038 int GetStringDisplayLength(char *str,int font_size) 00039 { int width=0; 00040 int i, len; 00041 len = strlen(str); 00042 for (i=0;i<len;i++) 00043 width += char_width[(int)str[i]]; 00044 width = (font_size*width)/CHAR_POINTS; 00045 return width; 00046 } 00047