📄 t1outline.c
字号:
} /* if necessary load font into memory */ if (i==0) if (T1_LoadFont(FontID)) return(NULL); /* Check for valid size */ if (size<=0.0){ T1_errno=T1ERR_INVALID_PARAMETER; return(NULL); } FontP=pFontBase->pFontArray[i].pType1Data; /* font is now loaded into memory => Check for size: */ if ((font_ptr=QueryFontSize( FontID, size, NO_ANTIALIAS))==NULL){ font_ptr=CreateNewFontSize( FontID, size, NO_ANTIALIAS); if (font_ptr==NULL){ T1_errno=T1ERR_ALLOC_MEM; return(NULL); } } /* Setup an appropriate charspace matrix. Note that the rasterizer assumes vertical values with inverted sign! Transformation should create a copy of the local charspace matrix which then still has to be made permanent. */ if (transform!=NULL){ Current_S=(struct XYspace *) Permanent(Scale(Transform (font_ptr->pCharSpaceLocal, transform->cxx, - transform->cxy, transform->cyx, - transform->cyy), DeviceSpecifics.scale_x, DeviceSpecifics.scale_y)); } else{ Current_S=(struct XYspace *) Permanent(Scale(Transform(font_ptr->pCharSpaceLocal, 1.0, 0.0, 0.0, -1.0), DeviceSpecifics.scale_x, DeviceSpecifics.scale_y)); } path=(struct segment *)ILoc( Current_S, deltax, deltay); /* Take care for underlining and such */ length=(float) deltax; if (modflag & T1_UNDERLINE){ tmppath=(struct segment *)Type1Line(FontP,Current_S, pFontBase->pFontArray[FontID].UndrLnPos, pFontBase->pFontArray[FontID].UndrLnThick, length); path=(struct segment *)Join(path,tmppath); } if (modflag & T1_OVERLINE){ tmppath=(struct segment *)Type1Line(FontP,Current_S, pFontBase->pFontArray[FontID].OvrLnPos, pFontBase->pFontArray[FontID].OvrLnThick, length); path=(struct segment *)Join(path,tmppath); } if (modflag & T1_OVERSTRIKE){ tmppath=(struct segment *)Type1Line(FontP,Current_S, pFontBase->pFontArray[FontID].OvrStrkPos, pFontBase->pFontArray[FontID].OvrStrkThick, length); path=(struct segment *)Join(path,tmppath); } KillSpace( Current_S); return( (T1_OUTLINE *)path); }/* T1_ConcatOutlines(): Concatenate two outline to one path */T1_OUTLINE *T1_ConcatOutlines( T1_OUTLINE *path1, T1_OUTLINE *path2){ return( (T1_OUTLINE *) t1_Join( (struct segment *) path1, (struct segment *) path2)); }/* T1_ScaleOutline(): Scale an outline */T1_OUTLINE *T1_ScaleOutline( T1_OUTLINE *path, float scale){ struct segment *ipath; /* Step through the path list */ ipath=(struct segment *)path; do { if (ipath->type==LINETYPE){ ipath->dest.x = (fractpel) (ipath->dest.x * scale); ipath->dest.y = (fractpel) (ipath->dest.y * scale); } if (ipath->type==CONICTYPE){ ((struct conicsegment *)ipath)->dest.x = (fractpel) ((struct conicsegment *)ipath)->dest.x * scale; ((struct conicsegment *)ipath)->dest.y = (fractpel) ((struct conicsegment *)ipath)->dest.y * scale; ((struct conicsegment *)ipath)->M.x = (fractpel) ((struct conicsegment *)ipath)->M.x * scale; ((struct conicsegment *)ipath)->M.y = (fractpel) ((struct conicsegment *)ipath)->M.y * scale; } if (ipath->type==MOVETYPE){ ipath->dest.x = (fractpel) (ipath->dest.x * scale); ipath->dest.y = (fractpel) (ipath->dest.y * scale); } if (ipath->type==BEZIERTYPE){ ((struct beziersegment *)ipath)->B.x = (fractpel) (((struct beziersegment *)ipath)->B.x * scale); ((struct beziersegment *)ipath)->B.y = (fractpel) (((struct beziersegment *)ipath)->B.y * scale); ((struct beziersegment *)ipath)->C.x = (fractpel) (((struct beziersegment *)ipath)->C.x * scale); ((struct beziersegment *)ipath)->C.y = (fractpel) (((struct beziersegment *)ipath)->C.y * scale); ((struct beziersegment *)ipath)->dest.x = (fractpel) (((struct beziersegment *)ipath)->dest.x * scale); ((struct beziersegment *)ipath)->dest.y = (fractpel) (((struct beziersegment *)ipath)->dest.y * scale); } if (ipath->type==HINTTYPE){ ((struct hintsegment *)ipath)->dest.x = (fractpel) (((struct hintsegment *)ipath)->dest.x * scale); ((struct hintsegment *)ipath)->dest.y = (fractpel) (((struct hintsegment *)ipath)->dest.y * scale); ((struct hintsegment *)ipath)->ref.x = (fractpel) (((struct hintsegment *)ipath)->ref.x * scale); ((struct hintsegment *)ipath)->ref.y = (fractpel) (((struct hintsegment *)ipath)->ref.y * scale); ((struct hintsegment *)ipath)->width.x = (fractpel) (((struct hintsegment *)ipath)->width.x * scale); ((struct hintsegment *)ipath)->width.y = (fractpel) (((struct hintsegment *)ipath)->width.y * scale); } if (ipath->type==TEXTTYPE) ; ipath=ipath->link; } while (ipath!=NULL); return( path); }/* dump a description of path elements to stdout */void T1_DumpPath( T1_OUTLINE *path){ struct segment *ipath; /* Step through the path list */ ipath=(struct segment *)path; do { if (ipath->type==LINETYPE){ printf("Line-Segment: -> (%f,%f)\n", (ipath->dest.x)/(double)(0xFFFF), -(ipath->dest.y)/(double)(0xFFFF)); } if (ipath->type==MOVETYPE){ printf("Move-Segment: -> (%f,%f)\n", (ipath->dest.x)/(double)(0xFFFF), -(ipath->dest.y)/(double)(0xFFFF)); } if (ipath->type==BEZIERTYPE){ printf("Bezier-Segment: ... (%f,%f) ... (%f,%f) -> (%f,%f)\n", (((struct beziersegment *)ipath)->B.x)/(double)(0xFFFF), -(((struct beziersegment *)ipath)->B.y)/(double)(0xFFFF), (((struct beziersegment *)ipath)->C.x)/(double)(0xFFFF), -(((struct beziersegment *)ipath)->C.y)/(double)(0xFFFF), (((struct beziersegment *)ipath)->dest.x)/(double)(0xFFFF), -(((struct beziersegment *)ipath)->dest.y)/(double)(0xFFFF)); } ipath=ipath->link; } while (ipath!=NULL); }/* convert a relative path to an absolute path */void T1_AbsolutePath( T1_OUTLINE *rpath){ struct segment *ipath; fractpel xcurr=0, ycurr=0; /* Step through the path list */ ipath=(struct segment *)rpath; do { if (ipath->type==LINETYPE){ ipath->dest.x +=xcurr; ipath->dest.y +=ycurr;#ifdef PRINT_PATHS_TO_STDOUT printf("Line-Segment: -> (%f,%f)\n", (ipath->dest.x)/(double)(0xFFFF), -(ipath->dest.y)/(double)(0xFFFF));#endif xcurr=ipath->dest.x; ycurr=ipath->dest.y; } if (ipath->type==MOVETYPE){ ipath->dest.x +=xcurr; ipath->dest.y +=ycurr;#ifdef PRINT_PATHS_TO_STDOUT printf("Move-Segment: -> (%f,%f)\n", (ipath->dest.x)/(double)(0xFFFF), -(ipath->dest.y)/(double)(0xFFFF));#endif xcurr=ipath->dest.x; ycurr=ipath->dest.y; } if (ipath->type==BEZIERTYPE){ ((struct beziersegment *)ipath)->B.x +=xcurr; ((struct beziersegment *)ipath)->B.y +=ycurr; ((struct beziersegment *)ipath)->C.x +=xcurr; ((struct beziersegment *)ipath)->C.y +=ycurr; ipath->dest.x +=xcurr; ipath->dest.y +=ycurr;#ifdef PRINT_PATHS_TO_STDOUT printf("Bezier-Segment: ... (%f,%f) ... (%f,%f) -> (%f,%f)\n", (((struct beziersegment *)ipath)->B.x)/(double)(0xFFFF), -(((struct beziersegment *)ipath)->B.y)/(double)(0xFFFF), (((struct beziersegment *)ipath)->C.x)/(double)(0xFFFF), -(((struct beziersegment *)ipath)->C.y)/(double)(0xFFFF), (((struct beziersegment *)ipath)->dest.x)/(double)(0xFFFF), -(((struct beziersegment *)ipath)->dest.y)/(double)(0xFFFF));#endif xcurr=ipath->dest.x; ycurr=ipath->dest.y; } ipath=ipath->link; } while (ipath!=NULL); }/* convert path into a relative path as needed by the rasterizer */void T1_RelativePath( T1_OUTLINE *apath){ struct segment *ipath; fractpel xcurr=0, ycurr=0; /* Step through the path list */ ipath=(struct segment *)apath; do { if (ipath->type==LINETYPE){ ipath->dest.x -=xcurr; ipath->dest.y -=ycurr; xcurr +=ipath->dest.x; ycurr +=ipath->dest.y;#ifdef PRINT_PATHS_TO_STDOUT printf("Line-Segment: -> (%f,%f), curr=(%f,%f)\n", (ipath->dest.x)/(double)(0xFFFF), -(ipath->dest.y)/(double)(0xFFFF), xcurr/(double)(0xFFFF), -ycurr/(double)(0xFFFF));#endif } if (ipath->type==MOVETYPE){ ipath->dest.x -=xcurr; ipath->dest.y -=ycurr; xcurr +=ipath->dest.x; ycurr +=ipath->dest.y;#ifdef PRINT_PATHS_TO_STDOUT printf("Move-Segment: -> (%f,%f), curr=(%f,%f)\n", (ipath->dest.x)/(double)(0xFFFF), -(ipath->dest.y)/(double)(0xFFFF), xcurr/(double)(0xFFFF), -ycurr/(double)(0xFFFF));#endif } if (ipath->type==BEZIERTYPE){ ipath->dest.x -=xcurr; ipath->dest.y -=ycurr; ((struct beziersegment *)ipath)->C.x -=xcurr; ((struct beziersegment *)ipath)->C.y -=ycurr; ((struct beziersegment *)ipath)->B.x -=xcurr; ((struct beziersegment *)ipath)->B.y -=ycurr; xcurr +=ipath->dest.x; ycurr +=ipath->dest.y;#ifdef PRINT_PATHS_TO_STDOUT printf("Bezier-Segment: ... (%f,%f) ... (%f,%f) -> (%f,%f)\n", (((struct beziersegment *)ipath)->B.x)/(double)(0xFFFF), -(((struct beziersegment *)ipath)->B.y)/(double)(0xFFFF), (((struct beziersegment *)ipath)->C.x)/(double)(0xFFFF), -(((struct beziersegment *)ipath)->C.y)/(double)(0xFFFF), (((struct beziersegment *)ipath)->dest.x)/(double)(0xFFFF), -(((struct beziersegment *)ipath)->dest.y)/(double)(0xFFFF));#endif } ipath=ipath->link; } while (ipath!=NULL); }/* maniuplate the coordinata points of a path */void T1_ManipulatePath( T1_OUTLINE *path, void (*manipulate)(fractpel *x,fractpel *y,int type)){ struct segment *ipath; /* Step through the path list */ ipath=(struct segment *)path; do { if (ipath->type==LINETYPE){ manipulate( &(ipath->dest.x), &ipath->dest.y, LINETYPE);#ifdef PRINT_PATHS_TO_STDOUT printf("Line-Segment: -> (%f,%f)\n", (ipath->dest.x)/(double)(0xFFFF), -(ipath->dest.y)/(double)(0xFFFF));#endif } if (ipath->type==MOVETYPE){ manipulate( &(ipath->dest.x), &ipath->dest.y, MOVETYPE);#ifdef PRINT_PATHS_TO_STDOUT printf("Move-Segment: -> (%f,%f)\n", (ipath->dest.x)/(double)(0xFFFF), -(ipath->dest.y)/(double)(0xFFFF));#endif } if (ipath->type==BEZIERTYPE){ manipulate( &((struct beziersegment *)ipath)->B.x, &((struct beziersegment *)ipath)->B.y, BEZIERTYPE); manipulate( &((struct beziersegment *)ipath)->C.x, &((struct beziersegment *)ipath)->C.y, BEZIERTYPE); manipulate( &((struct beziersegment *)ipath)->dest.x, &((struct beziersegment *)ipath)->dest.y, BEZIERTYPE);#ifdef PRINT_PATHS_TO_STDOUT printf("Bezier-Segment: ... (%f,%f) ... (%f,%f) -> (%f,%f)\n", (((struct beziersegment *)ipath)->B.x)/(double)(0xFFFF), -(((struct beziersegment *)ipath)->B.y)/(double)(0xFFFF), (((struct beziersegment *)ipath)->C.x)/(double)(0xFFFF), -(((struct beziersegment *)ipath)->C.y)/(double)(0xFFFF), (((struct beziersegment *)ipath)->dest.x)/(double)(0xFFFF), -(((struct beziersegment *)ipath)->dest.y)/(double)(0xFFFF));#endif } ipath=ipath->link; } while (ipath!=NULL); }/* T1_CopyOutline(): Copy an outline physically. Returns a pointer to the path or NULL */T1_OUTLINE *T1_CopyOutline( T1_OUTLINE *path){ return( (T1_OUTLINE *) CopyPath( (struct segment *)path)); }/* T1_FreeOutline(): Free an outline. */void T1_FreeOutline( T1_OUTLINE *path){ KillPath( (struct segment *)path); return; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -