9
9
10
10
class Fonts
11
11
{
12
+ int def_rows;
13
+ int def_cols;
12
14
int char_rows;
13
15
int char_cols;
14
16
int curr_col;
15
- std::vector<std::vector<char > > letters;
17
+ std::vector<std::vector<char >> letters;
16
18
17
19
protected:
18
- char **getCharGrid ()
20
+ char **getCharGrid (int rows = 0 , int cols = 0 )
19
21
{
22
+ this ->char_rows = rows ? rows : def_rows;
23
+ this ->char_cols = cols ? cols : def_cols;
24
+
20
25
char **char_grid = new char *[char_rows];
21
26
for (int i = 0 ; i < char_rows; i++)
22
27
{
@@ -28,13 +33,13 @@ class Fonts
28
33
}
29
34
30
35
public:
31
- Fonts (int char_rows , int char_cols )
36
+ Fonts (int def_rows , int def_cols )
32
37
{
33
- this ->char_rows = char_rows ;
34
- this ->char_cols = char_cols ;
38
+ this ->def_rows = def_rows ;
39
+ this ->def_cols = def_cols ;
35
40
36
- letters.reserve (char_rows );
37
- for (int i = 0 ; i < char_rows ; i++)
41
+ letters.reserve (def_rows );
42
+ for (int i = 0 ; i < def_rows ; i++)
38
43
{
39
44
letters.emplace_back (100 , ' ' ); // Create rows with 100 spaces each
40
45
}
@@ -45,6 +50,12 @@ class Fonts
45
50
{
46
51
if (!character)
47
52
return ;
53
+
54
+ while (letters.size () < char_rows)
55
+ {
56
+ letters.emplace_back (100 , ' ' );
57
+ }
58
+
48
59
for (int i = 0 ; i < char_rows; i++)
49
60
{
50
61
for (int j = 0 ; j < char_cols; j++)
@@ -55,7 +66,7 @@ class Fonts
55
66
curr_col += (char_cols + 2 );
56
67
}
57
68
58
- std::vector<std::vector<char > > getletters ()
69
+ std::vector<std::vector<char >> getletters ()
59
70
{
60
71
return letters;
61
72
}
0 commit comments