xref: /aosp_15_r20/external/fonttools/Lib/fontTools/pens/cairoPen.py (revision e1fe3e4ad2793916b15cccdc4a7da52a7e1dd0e9)
1*e1fe3e4aSElliott Hughes"""Pen to draw to a Cairo graphics library context."""
2*e1fe3e4aSElliott Hughes
3*e1fe3e4aSElliott Hughesfrom fontTools.pens.basePen import BasePen
4*e1fe3e4aSElliott Hughes
5*e1fe3e4aSElliott Hughes
6*e1fe3e4aSElliott Hughes__all__ = ["CairoPen"]
7*e1fe3e4aSElliott Hughes
8*e1fe3e4aSElliott Hughes
9*e1fe3e4aSElliott Hughesclass CairoPen(BasePen):
10*e1fe3e4aSElliott Hughes    """Pen to draw to a Cairo graphics library context."""
11*e1fe3e4aSElliott Hughes
12*e1fe3e4aSElliott Hughes    def __init__(self, glyphSet, context):
13*e1fe3e4aSElliott Hughes        BasePen.__init__(self, glyphSet)
14*e1fe3e4aSElliott Hughes        self.context = context
15*e1fe3e4aSElliott Hughes
16*e1fe3e4aSElliott Hughes    def _moveTo(self, p):
17*e1fe3e4aSElliott Hughes        self.context.move_to(*p)
18*e1fe3e4aSElliott Hughes
19*e1fe3e4aSElliott Hughes    def _lineTo(self, p):
20*e1fe3e4aSElliott Hughes        self.context.line_to(*p)
21*e1fe3e4aSElliott Hughes
22*e1fe3e4aSElliott Hughes    def _curveToOne(self, p1, p2, p3):
23*e1fe3e4aSElliott Hughes        self.context.curve_to(*p1, *p2, *p3)
24*e1fe3e4aSElliott Hughes
25*e1fe3e4aSElliott Hughes    def _closePath(self):
26*e1fe3e4aSElliott Hughes        self.context.close_path()
27