int size = outline.get_n_points();
float points[] = LinuxNativeFont.getPointsFromFTVector(pPointsPtr, size);
Int16Pointer pContours = outline.get_contours(); // array of contour end points
Int8Pointer pTags = outline.get_tags(); // an array of point tags
int index = 0; // current point's index
int tag; // current tag
float x_start;
float y_start;
float x_finish;
float y_finish;
for (int i=0; i < n_contours; i++){
short end = pContours.get(i);// index of the last point
// get start position
x_start = points[index*2];
y_start = points[index*2 + 1];
// get finish position
x_finish = points[end*2];
y_finish = points[end*2 + 1];
tag = pTags.get(index);// tag of the current point
if (tag == LinuxNativeFontWrapper.FT_CURVE_TAG_CONIC){
tag = pTags.get(end);// tag of the last point
if ((tag & LinuxNativeFontWrapper.FT_CURVE_TAG_ON)==0){
x_start = x_finish;
y_start = y_finish;
end--;
} else {
x_start = (x_start + x_finish)/2;
y_start = (y_start + y_finish)/2;
x_finish = x_start;
y_finish = y_start;
index --;
}
}
gp.moveTo(x_start, y_start);
while(index < end){
index++;
tag = pTags.get(index);// tag of the current point
switch((tag & 3)){
case(LinuxNativeFontWrapper.FT_CURVE_TAG_ON):
float x = points[index*2];
float y = points[index*2 + 1];
gp.lineTo(x, y);
// System.out.println("AddPoint [" + x + "," + y + "]");
break;
case(LinuxNativeFontWrapper.FT_CURVE_TAG_CONIC):
float x1 = points[index*2];
float y1 = points[index*2 + 1];
float x2;
float y2;
while (index < end){
index++;
tag = pTags.get(index);// tag of the current point
x2 = points[index*2];
y2 = points[index*2 + 1];
if ((tag & LinuxNativeFontWrapper.FT_CURVE_TAG_ON) != 0){
gp.quadTo(x1, y1, x2, y2);
// System.out.println("AddQSpline 1[" + x1 + "," + y1 + "][" + x2 + "," + y2 + "]");