void GetGlyphBBox_AAT(ATSUStyle style, UInt16 gid, GlyphBBox* bbox) /* returns glyph bounding box in TeX points */ { ATSCurveType curveType; OSStatus status; bbox->xMin = 65536.0; bbox->yMin = 65536.0; bbox->xMax = -65536.0; bbox->yMax = -65536.0; status = ATSUGetNativeCurveType(style, &curveType); if (status == noErr) { OSStatus cbStatus; if (curveType == kATSCubicCurveType) { static ATSCubicMoveToUPP cubicMoveToProc; static ATSCubicLineToUPP cubicLineToProc; static ATSCubicCurveToUPP cubicCurveToProc; static ATSCubicClosePathUPP cubicClosePathProc; if (cubicMoveToProc == NULL) { cubicMoveToProc = NewATSCubicMoveToUPP(&CubicMoveTo); cubicLineToProc = NewATSCubicLineToUPP(&CubicLineTo); cubicCurveToProc = NewATSCubicCurveToUPP(&CubicCurveTo); cubicClosePathProc = NewATSCubicClosePathUPP(&CubicClosePath); } status = ATSUGlyphGetCubicPaths(style, gid, cubicMoveToProc, cubicLineToProc, cubicCurveToProc, cubicClosePathProc, bbox, &cbStatus); } else { static ATSQuadraticNewPathUPP quadraticNewPathProc; static ATSQuadraticLineUPP quadraticLineProc; static ATSQuadraticCurveUPP quadraticCurveProc; static ATSQuadraticClosePathUPP quadraticClosePathProc; if (quadraticNewPathProc == NULL) { quadraticNewPathProc = NewATSQuadraticNewPathUPP(&QuadraticNewPath); quadraticLineProc = NewATSQuadraticLineUPP(&QuadraticLine); quadraticCurveProc = NewATSQuadraticCurveUPP(&QuadraticCurve); quadraticClosePathProc = NewATSQuadraticClosePathUPP(&QuadraticClosePath); } status = ATSUGlyphGetQuadraticPaths(style, gid, quadraticNewPathProc, quadraticLineProc, quadraticCurveProc, quadraticClosePathProc, bbox, &cbStatus); } } if (status != noErr || bbox->xMin == 65536.0) bbox->xMin = bbox->yMin = bbox->xMax = bbox->yMax = 0; else { // convert PS to TeX points and flip y-axis float tmp = bbox->yMin; bbox->yMin = -bbox->yMax * 72.27 / 72.0; bbox->yMax = -tmp * 72.27 / 72.0; bbox->xMin *= 72.27 / 72.0; bbox->xMax *= 72.27 / 72.0; } }
MacOpSVGFont::MacOpSVGFont(OpFont* font) : SVGSystemFont(font) , mMoveToUPP(NULL) , mLineToUPP(NULL) , mCurveToUPP(NULL) , mClosePathUPP(NULL) , mQuadNewPathUPP(NULL) , mQuadLineUPP(NULL) , mQuadCurveUPP(NULL) , mQuadClosePathUPP(NULL) , mCurveType(0) #ifndef USE_CG_SHOW_GLYPHS , mGlyphInfoArray(NULL) #endif { mTransform.LoadIdentity(); if(noErr == ATSUGetNativeCurveType(((MacOpFont*)m_font)->GetATSUStyle(1.0), &mCurveType)) { if(kATSQuadCurveType != mCurveType) { mMoveToUPP = NewATSCubicMoveToUPP(MoveToProc); mLineToUPP = NewATSCubicLineToUPP(LineToProc); mCurveToUPP = NewATSCubicCurveToUPP(CurveToProc); mClosePathUPP = NewATSCubicClosePathUPP(ClosePathProc); } else { mQuadNewPathUPP = NewATSQuadraticNewPathUPP(QuadNewPathProc); mQuadLineUPP = NewATSQuadraticLineUPP(QuadLineProc); mQuadCurveUPP = NewATSQuadraticCurveUPP(QuadCurveProc); mQuadClosePathUPP = NewATSQuadraticClosePathUPP(QuadClosePathProc); } } else { mMoveToUPP = NewATSCubicMoveToUPP(MoveToProc); mLineToUPP = NewATSCubicLineToUPP(LineToProc); mCurveToUPP = NewATSCubicCurveToUPP(CurveToProc); mClosePathUPP = NewATSCubicClosePathUPP(ClosePathProc); } }