This program generates proportional spacing fonts. for use with the SDD1963 driver

Dependencies:   mbed

Committer:
andrewcrussell
Date:
Thu Nov 21 04:13:59 2013 +0000
Revision:
0:f207e3c3b773
Font Generator Program for SDD1963 graphics driver.  Written/modified by Tedd Okano

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andrewcrussell 0:f207e3c3b773 1 #ifndef FONT_H
andrewcrussell 0:f207e3c3b773 2
andrewcrussell 0:f207e3c3b773 3 #define TEST
andrewcrussell 0:f207e3c3b773 4 #define SMALL_TEST
andrewcrussell 0:f207e3c3b773 5
andrewcrussell 0:f207e3c3b773 6
andrewcrussell 0:f207e3c3b773 7 extern const unsigned char c14_data_table[];
andrewcrussell 0:f207e3c3b773 8 extern const unsigned int c14_offset_table[];
andrewcrussell 0:f207e3c3b773 9 extern const unsigned char c14_index_table[];
andrewcrussell 0:f207e3c3b773 10 extern const unsigned char c14_width_table[];
andrewcrussell 0:f207e3c3b773 11
andrewcrussell 0:f207e3c3b773 12 extern const unsigned char c28_data_table[];
andrewcrussell 0:f207e3c3b773 13 extern const unsigned int c28_offset_table[];
andrewcrussell 0:f207e3c3b773 14 extern const unsigned char c28_index_table[];
andrewcrussell 0:f207e3c3b773 15 extern const unsigned char c28_width_table[];
andrewcrussell 0:f207e3c3b773 16
andrewcrussell 0:f207e3c3b773 17 extern const unsigned char c72_data_table[];
andrewcrussell 0:f207e3c3b773 18 extern const unsigned int c72_offset_table[];
andrewcrussell 0:f207e3c3b773 19 extern const unsigned char c72_index_table[];
andrewcrussell 0:f207e3c3b773 20 extern const unsigned char c72_width_table[];
andrewcrussell 0:f207e3c3b773 21
andrewcrussell 0:f207e3c3b773 22 extern const unsigned char c78_1_data_table[];
andrewcrussell 0:f207e3c3b773 23 extern const unsigned int c78_1_offset_table[];
andrewcrussell 0:f207e3c3b773 24 extern const unsigned char c78_1_index_table[];
andrewcrussell 0:f207e3c3b773 25 extern const unsigned char c78_1_width_table[];
andrewcrussell 0:f207e3c3b773 26
andrewcrussell 0:f207e3c3b773 27 typedef struct _font {
andrewcrussell 0:f207e3c3b773 28 int dummy0;
andrewcrussell 0:f207e3c3b773 29 int dummy1;
andrewcrussell 0:f207e3c3b773 30 int dummy2;
andrewcrussell 0:f207e3c3b773 31 int height;
andrewcrussell 0:f207e3c3b773 32 int max_width;
andrewcrussell 0:f207e3c3b773 33 int space_width;
andrewcrussell 0:f207e3c3b773 34 const unsigned char *data_table;
andrewcrussell 0:f207e3c3b773 35 const unsigned int *offset_table;
andrewcrussell 0:f207e3c3b773 36 const unsigned char *index_table;
andrewcrussell 0:f207e3c3b773 37 const unsigned char *width_table;
andrewcrussell 0:f207e3c3b773 38 }
andrewcrussell 0:f207e3c3b773 39 font;
andrewcrussell 0:f207e3c3b773 40
andrewcrussell 0:f207e3c3b773 41
andrewcrussell 0:f207e3c3b773 42 extern font Calibri14;
andrewcrussell 0:f207e3c3b773 43 extern font Calibri28;
andrewcrussell 0:f207e3c3b773 44 extern font Calibri72;
andrewcrussell 0:f207e3c3b773 45 extern font Calibri78_1;
andrewcrussell 0:f207e3c3b773 46
andrewcrussell 0:f207e3c3b773 47
andrewcrussell 0:f207e3c3b773 48 #ifdef TEST
andrewcrussell 0:f207e3c3b773 49 #ifdef SMALL_TEST
andrewcrussell 0:f207e3c3b773 50 #define SC_WIDTH 128
andrewcrussell 0:f207e3c3b773 51 #define SC_HEIGHT 128
andrewcrussell 0:f207e3c3b773 52 #else
andrewcrussell 0:f207e3c3b773 53 #define SC_WIDTH 640
andrewcrussell 0:f207e3c3b773 54 #define SC_HEIGHT 480
andrewcrussell 0:f207e3c3b773 55 #endif
andrewcrussell 0:f207e3c3b773 56 #endif
andrewcrussell 0:f207e3c3b773 57
andrewcrussell 0:f207e3c3b773 58 void FontDrawInit( void );
andrewcrussell 0:f207e3c3b773 59
andrewcrussell 0:f207e3c3b773 60
andrewcrussell 0:f207e3c3b773 61
andrewcrussell 0:f207e3c3b773 62
andrewcrussell 0:f207e3c3b773 63
andrewcrussell 0:f207e3c3b773 64
andrewcrussell 0:f207e3c3b773 65
andrewcrussell 0:f207e3c3b773 66
andrewcrussell 0:f207e3c3b773 67
andrewcrussell 0:f207e3c3b773 68 /** FontDraw_printf
andrewcrussell 0:f207e3c3b773 69 *
andrewcrussell 0:f207e3c3b773 70 * A "printf" function that takes coodinate values as starting point of the string.
andrewcrussell 0:f207e3c3b773 71 * The coodinate is a point if the left-bottom point of string output area.
andrewcrussell 0:f207e3c3b773 72 *
andrewcrussell 0:f207e3c3b773 73 * Drawing parameters should be set by FontDraw_Set... functions before this function call.
andrewcrussell 0:f207e3c3b773 74 *
andrewcrussell 0:f207e3c3b773 75 * param: x left position of the string
andrewcrussell 0:f207e3c3b773 76 * param: y bottom position of the string
andrewcrussell 0:f207e3c3b773 77 * param: format... followings are normal printf arguments
andrewcrussell 0:f207e3c3b773 78 */
andrewcrussell 0:f207e3c3b773 79 void FontDraw_printf( int x, int y, char *format, ... );
andrewcrussell 0:f207e3c3b773 80
andrewcrussell 0:f207e3c3b773 81
andrewcrussell 0:f207e3c3b773 82 /** FontDraw_puts
andrewcrussell 0:f207e3c3b773 83 *
andrewcrussell 0:f207e3c3b773 84 * Similar to "printf" but no format support. It just put a strin on to the screen.
andrewcrussell 0:f207e3c3b773 85 * This may be bit faster than "FontDraw_printf".
andrewcrussell 0:f207e3c3b773 86 *
andrewcrussell 0:f207e3c3b773 87 * Drawing parameters should be set by FontDraw_Set... functions before this function call.
andrewcrussell 0:f207e3c3b773 88 *
andrewcrussell 0:f207e3c3b773 89 * param: x left position of the string
andrewcrussell 0:f207e3c3b773 90 * param: y bottom position of the string
andrewcrussell 0:f207e3c3b773 91 * param: s string
andrewcrussell 0:f207e3c3b773 92 */
andrewcrussell 0:f207e3c3b773 93 void FontDraw_puts( int x, int y, char *s );
andrewcrussell 0:f207e3c3b773 94
andrewcrussell 0:f207e3c3b773 95
andrewcrussell 0:f207e3c3b773 96 /** FontDrawString
andrewcrussell 0:f207e3c3b773 97 *
andrewcrussell 0:f207e3c3b773 98 * Similar to "FontDraw_puts" but this function takes several parameters to define its propaty.
andrewcrussell 0:f207e3c3b773 99 * This function will be useful if user want to use other parameter setting temporary.
andrewcrussell 0:f207e3c3b773 100 *
andrewcrussell 0:f207e3c3b773 101 * param: s string
andrewcrussell 0:f207e3c3b773 102 * param: x left position of the string
andrewcrussell 0:f207e3c3b773 103 * param: y bottom position of the string
andrewcrussell 0:f207e3c3b773 104 * param: f_color color value for string itself
andrewcrussell 0:f207e3c3b773 105 * param: b_color color value for rectangle around the string
andrewcrussell 0:f207e3c3b773 106 * param: font_ptr pointer to the font
andrewcrussell 0:f207e3c3b773 107 */
andrewcrussell 0:f207e3c3b773 108 void FontDrawString( char *s, int xpos, int ypos, int f_color, int b_color, font *font_ptr );
andrewcrussell 0:f207e3c3b773 109
andrewcrussell 0:f207e3c3b773 110
andrewcrussell 0:f207e3c3b773 111 /** FontDrawChar
andrewcrussell 0:f207e3c3b773 112 *
andrewcrussell 0:f207e3c3b773 113 * Similar to "FontDraw_puts" but this function takes several parameters to define its propaty.
andrewcrussell 0:f207e3c3b773 114 * This function will be useful if user want to use other parameter setting temporary.
andrewcrussell 0:f207e3c3b773 115 *
andrewcrussell 0:f207e3c3b773 116 * param: c character
andrewcrussell 0:f207e3c3b773 117 * param: x left position of the string
andrewcrussell 0:f207e3c3b773 118 * param: y bottom position of the string
andrewcrussell 0:f207e3c3b773 119 * param: f_color color value for character itself
andrewcrussell 0:f207e3c3b773 120 * param: b_color color value for rectangle around the character
andrewcrussell 0:f207e3c3b773 121 * param: font_ptr pointer to the font
andrewcrussell 0:f207e3c3b773 122 * return: the width of the character (including inter-caracter space if user set)
andrewcrussell 0:f207e3c3b773 123 */
andrewcrussell 0:f207e3c3b773 124 int FontDrawChar( char c, int xpos, int ypos, int f_color, int b_color, font *font_ptr );
andrewcrussell 0:f207e3c3b773 125
andrewcrussell 0:f207e3c3b773 126 /** FontDrawStringWidth
andrewcrussell 0:f207e3c3b773 127 *
andrewcrussell 0:f207e3c3b773 128 * Returns the string width (span) which will be drawn on the screen.
andrewcrussell 0:f207e3c3b773 129 * This will be useful like case of aligning the string at center or right.
andrewcrussell 0:f207e3c3b773 130 * for instance, if the string needed to be aligned to right and of the screen (ex. pixel=480), the code will be...
andrewcrussell 0:f207e3c3b773 131 *
andrewcrussell 0:f207e3c3b773 132 * code:
andrewcrussell 0:f207e3c3b773 133 * x = 480 - FontDrawStringWidth( "sample string", &Calibri14 );
andrewcrussell 0:f207e3c3b773 134 * FontDrawString( "sample string", x, y, 0x000000, 0xFFFFFF, &Calibri14 );
andrewcrussell 0:f207e3c3b773 135 *
andrewcrussell 0:f207e3c3b773 136 * param: s string
andrewcrussell 0:f207e3c3b773 137 * param: font_ptr pointer to the font
andrewcrussell 0:f207e3c3b773 138 * return: string width (including inter-caracter space if user set)
andrewcrussell 0:f207e3c3b773 139 */
andrewcrussell 0:f207e3c3b773 140 int FontDrawStringWidth( char *s, font *font_ptr );
andrewcrussell 0:f207e3c3b773 141
andrewcrussell 0:f207e3c3b773 142
andrewcrussell 0:f207e3c3b773 143 /** FontDraw_SetFont
andrewcrussell 0:f207e3c3b773 144 *
andrewcrussell 0:f207e3c3b773 145 * Setting the font to draw
andrewcrussell 0:f207e3c3b773 146 * This will affect to following "FontDraw_printf" and "FontDraw_puts" calls
andrewcrussell 0:f207e3c3b773 147 *
andrewcrussell 0:f207e3c3b773 148 * param: f font (default: Carlibri14)
andrewcrussell 0:f207e3c3b773 149 */
andrewcrussell 0:f207e3c3b773 150 void FontDraw_SetFont( font f );
andrewcrussell 0:f207e3c3b773 151
andrewcrussell 0:f207e3c3b773 152
andrewcrussell 0:f207e3c3b773 153 /** FontDraw_SetInterCharSpace
andrewcrussell 0:f207e3c3b773 154 *
andrewcrussell 0:f207e3c3b773 155 * Setting the inter-character space
andrewcrussell 0:f207e3c3b773 156 * When drawing the string, each caracters can have additional space between those (this will not applied to space caracters)
andrewcrussell 0:f207e3c3b773 157 *
andrewcrussell 0:f207e3c3b773 158 * param: space pixels. no ngative number can be specified (default: 0)
andrewcrussell 0:f207e3c3b773 159 */
andrewcrussell 0:f207e3c3b773 160 void FontDraw_SetInterCharSpace( int space );
andrewcrussell 0:f207e3c3b773 161
andrewcrussell 0:f207e3c3b773 162
andrewcrussell 0:f207e3c3b773 163 /** FontDraw_SetAlphaMode
andrewcrussell 0:f207e3c3b773 164 *
andrewcrussell 0:f207e3c3b773 165 * If the alphamode is enabled,no background will be written. No rectangle around the charators are drawn.
andrewcrussell 0:f207e3c3b773 166 *
andrewcrussell 0:f207e3c3b773 167 * param: mode zero for disable, non-zero for enable (default: disable)
andrewcrussell 0:f207e3c3b773 168 */
andrewcrussell 0:f207e3c3b773 169 void FontDraw_SetAlphaMode( int mode );
andrewcrussell 0:f207e3c3b773 170
andrewcrussell 0:f207e3c3b773 171
andrewcrussell 0:f207e3c3b773 172 /** FontDraw_SetForegroundColor
andrewcrussell 0:f207e3c3b773 173 *
andrewcrussell 0:f207e3c3b773 174 * Settng of the color for character itself.
andrewcrussell 0:f207e3c3b773 175 *
andrewcrussell 0:f207e3c3b773 176 * param: v color (24 bit value) (default: 0x0000FF)
andrewcrussell 0:f207e3c3b773 177 */
andrewcrussell 0:f207e3c3b773 178 void FontDraw_SetForegroundColor( int v );
andrewcrussell 0:f207e3c3b773 179
andrewcrussell 0:f207e3c3b773 180
andrewcrussell 0:f207e3c3b773 181 /** FontDraw_SetBackgroundColor
andrewcrussell 0:f207e3c3b773 182 *
andrewcrussell 0:f207e3c3b773 183 * Settng of the color for rectangle around the charators.
andrewcrussell 0:f207e3c3b773 184 *
andrewcrussell 0:f207e3c3b773 185 * param: v color (24 bit value) (default: 0xFFFFFF)
andrewcrussell 0:f207e3c3b773 186 */
andrewcrussell 0:f207e3c3b773 187 void FontDraw_SetBackgroundColor( int v );
andrewcrussell 0:f207e3c3b773 188
andrewcrussell 0:f207e3c3b773 189
andrewcrussell 0:f207e3c3b773 190 #endif