!********************* modtsize ***************************** ! ! +++ ! Calculates new text height for a text if space not is enough ! ! --- !************************************************************* !sdesce Calculates new text height for a text if space not is enough BASIC GEOMETRY MODULE modtsize( STRING intext*132; ! Input text FLOAT a_length; ! Available space (mm) FLOAT t_height_in; ! Input text height (mm) FLOAT t_width_in; ! Input text width (%) VAR FLOAT t_height_out; ! Output text height (mm) VAR FLOAT t_width_out); ! Output text width (%) ! Internal variables: FLOAT t_height; ! Text height (mm) FLOAT t_width; ! Text width (mm) FLOAT input_length; ! String length (mm) INT n_char; ! Number of characters in string BEGINMODULE ! Number of characters in input string n_char := LENGTH(intext); ! Text height t_height := t_height_in; ! Text width converted from % to length unit (mm) t_width := t_height_in * t_width_in / 100.0; ! Input string length input_length := n_char*t_width + (n_char - 1) * t_width * 0.67; ! Return if there is enough space IF input_length < a_length THEN t_height_out := t_height; t_width_out := t_width_in; EXIT(); ENDIF; ! Calculate text size t_width := 3 * a_length / (5 * n_char - 2); t_height := 100 * t_width / t_width_in; ! Ouput values t_height_out := t_height; t_width_out := t_width_in; ENDMODULE