Пример #1
0
static void addGlyphsToPath(ATSUStyle style, glyph_t *glyphs, QFixedPoint *positions, int numGlyphs, QPainterPath *path)
{
    if (!numGlyphs)
        return;

    OSStatus e;

    QMacFontPath fontpath(0, 0, path);
    ATSCubicMoveToUPP moveTo = NewATSCubicMoveToUPP(QMacFontPath::moveTo);
    ATSCubicLineToUPP lineTo = NewATSCubicLineToUPP(QMacFontPath::lineTo);
    ATSCubicCurveToUPP cubicTo = NewATSCubicCurveToUPP(QMacFontPath::cubicTo);
    ATSCubicClosePathUPP closePath = NewATSCubicClosePathUPP(QMacFontPath::closePath);

    for (int i = 0; i < numGlyphs; ++i) {
        GlyphID glyph = glyphs[i];

        fontpath.setPosition(positions[i].x.toReal(), positions[i].y.toReal());
        ATSUGlyphGetCubicPaths(style, glyph, moveTo, lineTo,
                               cubicTo, closePath, &fontpath, &e);
    }

    DisposeATSCubicMoveToUPP(moveTo);
    DisposeATSCubicLineToUPP(lineTo);
    DisposeATSCubicCurveToUPP(cubicTo);
    DisposeATSCubicClosePathUPP(closePath);
}
Пример #2
0
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;
	}
}
Пример #3
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);
	}

}
Пример #4
0
static cairo_status_t
_cairo_atsui_font_glyph_path(void *abstract_font,
                             cairo_glyph_t *glyphs, int num_glyphs,
			     cairo_path_fixed_t *path)
{
    int i;
    cairo_atsui_font_t *font = abstract_font;
    OSStatus err;
    cairo_ATSUI_glyph_path_callback_info_t info;


    static ATSCubicMoveToUPP moveProc = NULL;
    static ATSCubicLineToUPP lineProc = NULL;
    static ATSCubicCurveToUPP curveProc = NULL;
    static ATSCubicClosePathUPP closePathProc = NULL;


    if (moveProc == NULL) {
        moveProc = NewATSCubicMoveToUPP(MyATSCubicMoveToCallback);
        lineProc = NewATSCubicLineToUPP(MyATSCubicLineToCallback);
        curveProc = NewATSCubicCurveToUPP(MyATSCubicCurveToCallback);
        closePathProc = NewATSCubicClosePathUPP(MyCubicClosePathProc);
    }


    info.path = path;


    for (i = 0; i < num_glyphs; i++) {
        GlyphID theGlyph = glyphs[i].index;

	info.scale = font->scale;
	info.scale.x0 = glyphs[i].x;
	info.scale.y0 = glyphs[i].y;

        err = ATSUGlyphGetCubicPaths(font->unscaled_style,
                                     theGlyph,
                                     moveProc,
                                     lineProc,
                                     curveProc,
                                     closePathProc, (void *) &info, &err);
    }

    return CAIRO_STATUS_SUCCESS;
}