Jump to content

  • Log In with Google      Sign In   
  • Create Account


Designing a vectored font engine


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 AhmedCoeia   Members   -  Reputation: 304

Like
0Likes
Like

Posted 12 December 2012 - 04:45 AM

0 down vote favorite
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);
    }
}


Sponsor:

#2 uglybdavis   Members   -  Reputation: 894

Like
0Likes
Like

Posted 12 December 2012 - 12:05 PM

Nothing wrong with a list of points :) Your character class looks like it will work just fine.
If you enter the data by hand like that it's going to be a pain no matter what your structure is.

#3 AhmedCoeia   Members   -  Reputation: 304

Like
0Likes
Like

Posted 12 December 2012 - 12:08 PM

I wonder how in 1979 they did that in Atari... Is there any other better way ?!

#4 Yrjö P.   Crossbones+   -  Reputation: 1412

Like
1Likes
Like

Posted 13 December 2012 - 07:34 AM

You are assuming there's just one continuous stroke, so if you wanted to use that structure to represent something like big "E", you'd have two lines on top of each other in the middle part, one going right and one going left. That doesn't seem very elegant. You also can't represent non-continuous characters like "=" at all.

The usual way to represent a bunch of primitives like that is to define the points and lines separately; think "std::vector<ci::Vec2i> points; std::vector<unsigned[2]> lines" where every item describes a line via giving the indices of the points of that line. However, since in this special case you have 2D points, it may be equally convenient to skip separate point definition and just describe every line segment with four coordinates ("std::vector<ci::Vec4i> lines").

Entering this stuff by hand sucks but is doable if your characters are simple enough (e.g. do not have round shapes). Otherwise you have the choice of writing yourself a simple graphical editor for drawing the line segments, or using an existing editor for that purpose. Basically any vector drawing program where you can get the points/lines exported sufficiently cleanly is fine.

Edited by Stroppy Katamari, 13 December 2012 - 07:39 AM.


#5 AhmedCoeia   Members   -  Reputation: 304

Like
0Likes
Like

Posted 13 December 2012 - 09:22 AM

The usual way to represent a bunch of primitives like that is to define the points and lines separately; think "std::vector<ci::Vec2i> points; std::vector<unsigned[2]> lines" where every item describes a line via giving the indices of the points of that line


Would you please explain this in details by a pseudo code ? I'm interested.

#6 Yrjö P.   Crossbones+   -  Reputation: 1412

Like
1Likes
Like

Posted 13 December 2012 - 12:19 PM

// points (9,9), (3,4) and (5,5) in a vector like you had before

std::vector<ci::Vec2i> points{{9,9}, {3,4}, {5,5}};

// there's a line between points[0] and points[1], and another line between points[1] and points[2]

std::vector<unsigned[2]> lines{{0,1}, {1,2}};

// drawing all lines

for(unsigned i=0; i<lines.size(); ++i) { /* draw a line between points[lines[i][0]] and points[lines[i][1]] */ }





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS