I’m trying to design a vectored font engine like the one in Atari 1979. I have problem of saving the predefined character set and their co-ordinates, I don’t know what is the best data-structure to save those polygons or what is the best way for to design a class for that. Here is my trial which I’m not comfortable about it at all.
class Character
{
public:
Character();
public:
int ascii;
int strokes;
std::vector<ci::Vec2i> points;
};
void VectorFont::Init_Chars()
{
for (int i=0; i<1;i++)
{
Character char_A;
char_A.ascii = 65;
char_A.strokes = 6;
ci::Vec2i point_1 = ci::Vec2i(-6,-4);
ci::Vec2i point_2 = ci::Vec2i(0,8);
ci::Vec2i point_3 = ci::Vec2i(0,8);
ci::Vec2i point_4 = ci::Vec2i(6,-4);
ci::Vec2i point_5 = ci::Vec2i(4,0);
ci::Vec2i point_6 = ci::Vec2i(-4,0);
char_A.points.push_back(point_1);
char_A.points.push_back(point_2);
char_A.points.push_back(point_3);
char_A.points.push_back(point_4);
char_A.points.push_back(point_5);
char_A.points.push_back(point_6);
chars.push_back(char_A);
}
}
Since these characters have holes, you will need to define a
Pathclass:A
Pathis a collection of points and an orientation. Your paths should be closed, that is, first and last point are the same. If orientation is 1, then it means fill with black. If it’s a 0, cut a hole.Then your
Characterclass would have a collection of Paths, which would be fills or holes.The above just describes the data structure for points on fills and holes. An engine would have to be written to translate that data structure into pixels. That’s another topic.