Пример #1
0
 def __init__(self, otherPen, steps=10, filterDoubles=True):
     BasePen.__init__(self, {})
     self.otherPen = otherPen
     self.currentPt = None
     self.firstPt = None
     self.steps = steps
     self.filterDoubles = filterDoubles
    def __init__(self, glyphSet, bounds, moveSegment=(0, 0)):
        BasePen.__init__(self, glyphSet)

        self.allSegments = set()
        self.segments = set()
        self.bounds = bounds
        self.moveSegment = moveSegment
Пример #3
0
    def __init__(self, cr, pos, id='EDITOR', scale=1.0):
        BasePen.__init__(self, glyphSet={})
        self.cr = cr

        self.id = id

        # the position the glyph is at while drawing it in a string of glyphs
        self.pos = pos

        self.glyph = globals.GLYPH_BOX[self.id]['glyph']
        self.font = self.glyph.font
        # The advance width of the glyph
        self.w = H = self.glyph.width

        # The difference in the ascender and the descender values
        self.h = self.font.info.ascender - self.font.info.descender

        # the distance between the baseline and the descender
        self.b = 0 - self.font.info.descender

        # the scale of the drawing
        self.scale = scale

        H = globals.GLYPH_BOX[self.id]['height']  # noqa
        W = globals.GLYPH_BOX[self.id]['width']  # noqa
        """
 def __init__(self, glyphSet, optimise=False):
     BasePen.__init__(self, glyphSet)
     self._commands = []
     self._lastCommand = None
     self._lastX = None
     self._lastY = None
     self.optimise = optimise
Пример #5
0
 def __init__(self, glyphSet, ntos: Callable[[float], str] = str):
     BasePen.__init__(self, glyphSet)
     self._commands = []
     self._lastCommand = None
     self._lastX = None
     self._lastY = None
     self._ntos = ntos
Пример #6
0
	def __init__(self, otherPen, selected = [], *splits ):
		BasePen.__init__(self, {})
		self.otherPen = otherPen
		self.currentPt = None
		self.firstPt = None
		self.selected = selected
		self.splits = splits
Пример #7
0
 def __init__(self, glyphSet, yMul):
     BasePen.__init__(self, glyphSet)
     self._commands = []
     self._lastCommand = None
     self._lastX = None
     self._lastY = None
     self._yMul = yMul
Пример #8
0
 def __init__(self, glyphSet, optimise=False):
     BasePen.__init__(self, glyphSet)
     self._commands = []
     self._lastCommand = None
     self._lastX = None
     self._lastY = None
     self.optimise = optimise
Пример #9
0
	def __init__(self, glyphSet, x, y, scale, motherobject):
		BasePen.__init__(self, glyphSet)
		self.scale = scale

		self.motherobject = motherobject
		self.x = x
		self.y = -1 * y
Пример #10
0
	def __init__(self, glyphSet):
		BasePen.__init__(self, glyphSet)

		self.ll = [None, None]
		self.ur = [None, None]
		self.width = None
		self.height = None
Пример #11
0
	def __init__(self, glyphSet, x, y, scale, pathobject):
		BasePen.__init__(self, glyphSet)
		self.scale = scale

		self.pathobject = pathobject
		self.x = x
		self.y = y
Пример #12
0
    def __init__(self, cr, pos, id='EDITOR', scale=1.0):
        BasePen.__init__(self, glyphSet={})
        self.cr = cr

        self.id = id

        # the position the glyph is at while drawing it in a string of glyphs
        self.pos = pos

        self.glyph = globals.GLYPH_BOX[self.id]['glyph']
        self.font = self.glyph.font
        # The advance width of the glyph
        self.w = H = self.glyph.width

        # The difference in the ascender and the descender values
        self.h = self.font.info.ascender - self.font.info.descender

        # the distance between the baseline and the descender
        self.b = 0 - self.font.info.descender

        # the scale of the drawing
        self.scale = scale

        H = globals.GLYPH_BOX[self.id]['height']  # noqa
        W = globals.GLYPH_BOX[self.id]['width']  # noqa

        """
Пример #13
0
    def __init__(self, glyphSet, bounds, moveSegment=(0, 0)):
        BasePen.__init__(self, glyphSet)

        self.allSegments = set()
        self.segments = set()
        self.bounds = bounds
        self.moveSegment = moveSegment
Пример #14
0
 def __init__(self, glyphSet, otherPen, resolution=25):
     BasePen.__init__(self,glyphSet)
     self.resolution = resolution
     self.otherPen = otherPen
     self.subsegments = []
     self.startContour = (0,0)
     self.contourIndex = -1
Пример #15
0
    def __init__(self, glyphSet, path=None):
        BasePen.__init__(self, glyphSet)
        if path is None:
            from AppKit import NSBezierPath

            path = NSBezierPath.bezierPath()
        self.path = path
Пример #16
0
    def __init__(self, glyphSet, path=None):
        BasePen.__init__(self, glyphSet)
        if path is None:
            from PyQt5.QtGui import QPainterPath

            path = QPainterPath()
        self.path = path
Пример #17
0
 def __init__(self, otherPen, steps=10, filterDoubles=True):
     BasePen.__init__(self, {})
     self.otherPen = otherPen
     self.currentPt = None
     self.firstPt = None
     self.steps = steps
     self.filterDoubles = filterDoubles
Пример #18
0
    def __init__(self, glyph):
        BasePen.__init__(self, glyph)

        self.glyph = RGlyph()
        self.pen = self.glyph.getPen()
        self.firstPt = None
        self.prevPt = None
Пример #19
0
	def __init__(self, otherPen, approximateSegmentLength=5, segmentLines=False, filterDoubles=True):
		self.approximateSegmentLength = approximateSegmentLength
		BasePen.__init__(self, {})
		self.otherPen = otherPen
		self.currentPt = None
		self.firstPt = None
		self.segmentLines = segmentLines
		self.filterDoubles = filterDoubles
Пример #20
0
 def __init__(self, otherPen, approximateSegmentLength=5, segmentLines=False, filterDoubles=True):
     self.approximateSegmentLength = approximateSegmentLength
     BasePen.__init__(self, {})
     self.otherPen = otherPen
     self.currentPt = None
     self.firstPt = None
     self.segmentLines = segmentLines
     self.filterDoubles = filterDoubles
Пример #21
0
	def __init__(self, glyphSet, value, isHorizontal=True):
		BasePen.__init__(self, glyphSet)
		self.value = value
		self.hits = {}
		self.filterDoubles = True
		self.contourIndex = None
		self.startPt = None
		self.isHorizontal = isHorizontal
Пример #22
0
 def __init__(self, glyphSet, step, width, height, angle, shape):
     BasePen.__init__(self, glyphSet)
     self.step = step
     self.width = width
     self.height = height
     self.angle = angle
     self.shape = shape
     self.firstPoint = None
Пример #23
0
 def __init__(self, glyphSet, value, isHorizontal=True):
     BasePen.__init__(self, glyphSet)
     self.value = value
     self.hits = {}
     self.filterDoubles = True
     self.contourIndex = None
     self.startPt = None
     self.isHorizontal = isHorizontal
Пример #24
0
 def __init__(self, point, font):
     BasePen.__init__(self, glyphSet=font)
     self.currentPt = None
     self.firstPt = None
     self.orthoPt = None
     self.approximateSegmentLength = 1
     self.point = point
     self.bestDistance = 100000
Пример #25
0
 def __init__(self, glyphSet, scale=1):
     BasePen.__init__(self, glyphSet)
     self._scale = scale
     self._init_seq = self._get_init_sequence()
     self._hpgl = ""
     self._end_seq = self._get_end_sequence()
     self._pen_down = False
     self._prev_segment = None
 def __init__(self, glyphSet, step, width, height, angle, shape):
     BasePen.__init__(self, glyphSet)
     self.step = step
     self.width = width
     self.height = height
     self.angle = angle
     self.shape = shape
     self.firstPoint = None
Пример #27
0
    def __init__(self,
                 glyphSet,
                 offset=10,
                 contrast=0,
                 contrastAngle=0,
                 connection="square",
                 cap="round",
                 miterLimit=None,
                 closeOpenPaths=True,
                 optimizeCurve=False,
                 preserveComponents=False,
                 filterDoubles=True,
                 alwaysConnect=False):
        BasePen.__init__(self, glyphSet)

        self.offset = abs(offset)
        self.contrast = abs(contrast)
        self.contrastAngle = contrastAngle
        self._inputmiterLimit = miterLimit
        if miterLimit is None:
            miterLimit = self.offset * 2
        self.miterLimit = abs(miterLimit)

        self.closeOpenPaths = closeOpenPaths
        self.optimizeCurve = optimizeCurve

        self.connectionCallback = getattr(
            self, "connection%s" % (connection.title()))
        self.capCallback = getattr(self, "cap%s" % (cap.title()))

        self.originalGlyph = Glyph()
        self.originalPen = self.originalGlyph.getPen()

        self.outerGlyph = Glyph()
        self.outerPen = self.outerGlyph.getPen()
        self.outerCurrentPoint = None
        self.outerFirstPoint = None
        self.outerPrevPoint = None

        self.innerGlyph = Glyph()
        self.innerPen = self.innerGlyph.getPen()
        self.innerCurrentPoint = None
        self.innerFirstPoint = None
        self.innerPrevPoint = None

        self.prevPoint = None
        self.firstPoint = None
        self.firstAngle = None
        self.prevAngle = None

        self.shouldHandleMove = True

        self.preserveComponents = preserveComponents
        self.components = []

        self.filterDoubles = filterDoubles
        self.alwaysConnect = alwaysConnect
        self.drawSettings()
Пример #28
0
	def __init__(self, glyphset=None):
		BasePen.__init__(self, glyphset)

		self.area = 0
		self.momentX = 0
		self.momentY = 0
		self.momentXX = 0
		self.momentXY = 0
		self.momentYY = 0
Пример #29
0
    def __init__(self, glyphset=None):
        BasePen.__init__(self, glyphset)

        self.area = 0
        self.momentX = 0
        self.momentY = 0
        self.momentXX = 0
        self.momentXY = 0
        self.momentYY = 0
Пример #30
0
    def __init__(self, path=None, glyphSet=None):
        """

        >>> path = BaseBezierPath()
        >>> path
        <BaseBezierPath>
        """
        self._contours = []
        #super().__init__(glyphSet)
        BasePen.__init__(self, glyphSet)
Пример #31
0
 def __init__(self, glyphSet, otherPen, subsegmentGlyph, subsegments):
     BasePen.__init__(self, None)
     self.otherPen = otherPen
     self.ssglyph = subsegmentGlyph
     self.subsegments = subsegments
     self.contourIndex = -1
     self.segmentIndex = -1
     self.lastPoint = (0,0)
     self.lastSmooth = False
     self.nextSmooth = False
Пример #32
0
    def __init__(self, glyphset=None, tolerance=0.005):
        BasePen.__init__(self, glyphset)
        self.value = 0
        self.tolerance = tolerance

        # Choose which algorithm to use for quadratic and for cubic.
        # Quadrature is faster but has fixed error characteristic with no strong
        # error bound.  The cutoff points are derived empirically.
        self._addCubic = self._addCubicQuadrature if tolerance >= 0.0015 else self._addCubicRecursive
        self._addQuadratic = self._addQuadraticQuadrature if tolerance >= 0.00075 else self._addQuadraticExact
Пример #33
0
 def __init__(self, glyphSet, width, italicAngle):
     BasePen.__init__(self, glyphSet)
     self.width = width
     self._angle = math.radians(90 + italicAngle)
     self.maxSteps = 100
     self.margin = None
     self._left = None
     self._right = None
     self._start = None
     self.currentPoint = None
 def __init__(self, glyphSet, width, italicAngle):
     BasePen.__init__(self, glyphSet)
     self.width = width
     self._angle = math.radians(90 + italicAngle)
     self.maxSteps = 100
     self.margin = None
     self._left = None
     self._right = None
     self._start = None
     self.currentPt = None
Пример #35
0
	def __init__(self, glyphset=None, tolerance=0.005):
		BasePen.__init__(self, glyphset)
		self.value = 0
		self._mult = 1.+1.5*tolerance # The 1.5 is a empirical hack; no math

		# Choose which algorithm to use for quadratic and for cubic.
		# Quadrature is faster but has fixed error characteristic with no strong
		# error bound.  The cutoff points are derived empirically.
		self._addCubic = self._addCubicQuadrature if tolerance >= 0.0015 else self._addCubicRecursive
		self._addQuadratic = self._addQuadraticQuadrature if tolerance >= 0.00075 else self._addQuadraticExact
    def __init__(self, glyphSet, radius, draw):
        BasePen.__init__(self, glyphSet)

        self.radius = radius
        self.draw = draw
        self.glyph = CurrentGlyph()
        self.glyphcopy = self.glyph.copy()

        if self.draw:
            self.glyphcopy.clear()
    def __init__(
        self,
        glyphSet,
        offset=10,
        contrast=0,
        contrastAngle=0,
        connection="square",
        cap="round",
        miterLimit=None,
        closeOpenPaths=True,
        optimizeCurve=False,
        preserveComponents=False,
    ):
        BasePen.__init__(self, glyphSet)

        self.offset = abs(offset)
        self.contrast = abs(contrast)
        self.contrastAngle = contrastAngle
        self._inputmiterLimit = miterLimit
        if miterLimit is None:
            miterLimit = self.offset * 2
        self.miterLimit = abs(miterLimit)

        self.closeOpenPaths = closeOpenPaths
        self.optimizeCurve = optimizeCurve

        self.connectionCallback = getattr(self, "connection%s" % (connection.title()))
        self.capCallback = getattr(self, "cap%s" % (cap.title()))

        self.originalGlyph = Glyph()
        self.originalPen = self.originalGlyph.getPen()

        self.outerGlyph = Glyph()
        self.outerPen = self.outerGlyph.getPen()
        self.outerCurrentPoint = None
        self.outerFirstPoint = None
        self.outerPrevPoint = None

        self.innerGlyph = Glyph()
        self.innerPen = self.innerGlyph.getPen()
        self.innerCurrentPoint = None
        self.innerFirstPoint = None
        self.innerPrevPoint = None

        self.prevPoint = None
        self.firstPoint = None
        self.firstAngle = None
        self.prevAngle = None

        self.shouldHandleMove = True

        self.preserveComponents = preserveComponents
        self.components = []

        self.drawSettings()
Пример #38
0
 def __init__(self, state=None, rounding=False, scale=1, min_segment_units=20, max_curve_steps=50):
     BasePen.__init__(self, glyphSet=None)
     self._state = state
     self._rounding = rounding
     self._scale = scale
     self._hpgl = []
     self._prev_segment = None
     self._select_pen()
     self.min_segment_units = min_segment_units
     self.max_curve_steps = max_curve_steps
     self.currentPt = None
Пример #39
0
 def __init__(self, dat, rect):
     BasePen.__init__(self, None)
     self.pStr = f""
     self.lastMove = None
     self.dat = dat
     self.serialAttrs = {"tag":dat.tag()}
     self.rect = rect
     if self.rect:
         tp = TransformPen(self, (1, 0, 0, -1, 0, self.rect.h))
         dat.replay(tp)
     else:
         dat.replay(self)
Пример #40
0
    def __init__(self, glyphSet,
                 freeMoveFeed, drawingFeed):

        BasePen.__init__(self, glyphSet)

        self.freeMoveFeed = freeMoveFeed
        self.drawingFeed  = drawingFeed

        self._commands = [
            'G21',         # set units to mm
            'M03 S0',      # lift the pen
            # 'G92 X0 Y0'    # set the relative zero
        ]
        self.lastPt = None
Пример #41
0
    def __init__(self, glyphSet, round_coordinates=False, relative_coordinates=False, optimize_output=False):
        """
A pen that converts a glyph outline to an SVG path. After drawing, SVGPen.d contains the path as string. This corresponds to the SVG path element attribute "d".

   glyphSet (RFont or GSFont)      The font object
   round_coordinates (Boolean)     Round all coordinates to integer. Default is False.
   relative_coordinates (Boolean)  Store all coordinates as relative. Default is False, i.e. choose whichever notation (absolute or relative) produces shorter output for each individual segment.
   optimize_output (Boolean)       Make the output path string as short as possible. Default is True. Setting this to False also overrides the relative_coordinates option.
        """
        self._rnd = round_coordinates
        self._rel = relative_coordinates
        self._opt = optimize_output
        self.prev_x = 0
        self.prev_y = 0
        BasePen.__init__(self, glyphSet)
        self.d = ''
Пример #42
0
    def __init__(self,
                 glyphSet,
                 offset=10,
                 connection="square",
                 cap="round",
                 miterLimit=None,
                 closeOpenPaths=True):
        BasePen.__init__(self, glyphSet)

        self.offset = abs(offset)
        self._inputmiterLimit = miterLimit
        if miterLimit is None:
            miterLimit = self.offset
        self.miterLimit = abs(miterLimit)

        self.closeOpenPaths = closeOpenPaths

        self.connectionCallback = getattr(
            self,
            "connection%s" % (connection[0].capitalize() + connection[1:]))
        self.capCallback = getattr(self,
                                   "cap%s" % (cap[0].capitalize() + cap[1:]))

        self.originalGlyph = Glyph()
        self.originalPen = self.originalGlyph.getPen()

        self.outerGlyph = Glyph()
        self.outerPen = self.outerGlyph.getPen()
        self.outerCurrentPoint = None
        self.outerFirstPoint = None
        self.outerPrevPoint = None

        self.innerGlyph = Glyph()
        self.innerPen = self.innerGlyph.getPen()
        self.innerCurrentPoint = None
        self.innerFirstPoint = None
        self.innerPrevPoint = None

        self.prevPoint = None
        self.firstPoint = None
        self.firstAngle = None
        self.prevAngle = None

        self.shouldHandleMove = True

        self.drawSettings()
Пример #43
0
 def __init__(self, glyphSet, boundingBox, creator="AICBPen"):
     BasePen.__init__(self, glyphSet)
     boundingBox = ' '.join([str(i) for i in boundingBox])
     self._epsData = [
             "%!PS-Adobe-3.0",
             "%%%%Creator: %s" % creator,
             "%%%%Title: %s Data" % creator,
             "%%%%CreationDate: %s" % _timeStamp(),
             "%%%%BoundingBox: %s" % boundingBox,
             "%%EndComments",
             "%%BeginProlog",
             _epsDict,
             "%%EndProlog",
             _epsSetup,
             "0 A  *u 0 O 0 g",
             ]
     self._firstPoint = None 
     self._currentPoint = None
	def __init__(self, cr, pos, scale = 1.0):
		BasePen.__init__(self, glyphSet={})
		self.cr = cr
		
		#the position the glyph is at while drawing it in a string of glyphs
		self.pos = pos
		
		#The advance width of the glyph
		self.w = GLYPH.width

		#The difference in the ascender and the descender values
		self.h = FONT.info.ascender - FONT.info.descender

		#the distance between the baseline and the descender
		self.b = 0 - FONT.info.descender

		#the scale of the drawing
		self.scale = scale
Пример #45
0
 def __init__(self, glyphSet, boundingBox, creator="AICBPen"):
     BasePen.__init__(self, glyphSet)
     boundingBox = ' '.join([str(i) for i in boundingBox])
     self._epsData = [
         "%!PS-Adobe-3.0",
         "%%%%Creator: %s" % creator,
         "%%%%Title: %s Data" % creator,
         "%%%%CreationDate: %s" % _timeStamp(),
         "%%%%BoundingBox: %s" % boundingBox,
         "%%EndComments",
         "%%BeginProlog",
         _epsDict,
         "%%EndProlog",
         _epsSetup,
         "0 A  *u 0 O 0 g",
     ]
     self._firstPoint = None
     self._currentPoint = None
Пример #46
0
    def __init__(self,
                 glyphSet,
                 round_coordinates=False,
                 relative_coordinates=False,
                 optimize_output=False):
        """
A pen that converts a glyph outline to an SVG path. After drawing, SVGPen.d contains the path as string. This corresponds to the SVG path element attribute "d".

   glyphSet (RFont or GSFont)      The font object
   round_coordinates (Boolean)     Round all coordinates to integer. Default is False.
   relative_coordinates (Boolean)  Store all coordinates as relative. Default is False, i.e. choose whichever notation (absolute or relative) produces shorter output for each individual segment.
   optimize_output (Boolean)       Make the output path string as short as possible. Default is True. Setting this to False also overrides the relative_coordinates option.
        """
        self._rnd = round_coordinates
        self._rel = relative_coordinates
        self._opt = optimize_output
        self.prev_x = 0
        self.prev_y = 0
        BasePen.__init__(self, glyphSet)
        self.d = ''
Пример #47
0
    def __init__(self,
                 glyphSet,
                 angle,
                 width,
                 height,
                 show_nib_faces=False,
                 alpha=0.2,
                 nib_superness=2.5,
                 trace=False,
                 round_coords=False):
        BasePen.__init__(self, glyphSet)
        self.angle = angle
        if self.angle > pi:
            self.angle -= pi
        elif self.angle < -pi:
            self.angle += pi
        # Store a transform, used for calculating extrema in some nib models
        self.transform = Transform().rotate(-self.angle)
        self.transform_reverse = Transform().rotate(self.angle)
        self.width = width
        self.height = height
        self.a = 0.5 * width
        self.b = 0.5 * height
        self.color = show_nib_faces
        self.highlight_nib_faces = False
        self.alpha = alpha
        self.nib_superness = nib_superness
        self.trace = trace
        self.round_coords = round_coords

        # Initialize the nib face path
        # This is only needed for more complex shapes
        self.setup_nib()

        self.path = []

        self.__currentPoint = None
        if self.color:
            stroke(0, 0, 0, 0.5)
            strokeWidth(0.1)
Пример #48
0
    def __init__(self, glyphSet, offset=10, connection="square", cap="round", miterLimit=None, closeOpenPaths=True):
        BasePen.__init__(self, glyphSet)

        self.offset = abs(offset)
        self._inputmiterLimit = miterLimit
        if miterLimit is None:
            miterLimit = self.offset
        self.miterLimit = abs(miterLimit)

        self.closeOpenPaths = closeOpenPaths

        self.connectionCallback = getattr(self, "connection%s" %(connection[0].capitalize() + connection[1:]))
        self.capCallback = getattr(self, "cap%s" %(cap[0].capitalize() + cap[1:]))

        self.originalGlyph = Glyph()
        self.originalPen = self.originalGlyph.getPen()

        self.outerGlyph = Glyph()
        self.outerPen = self.outerGlyph.getPen()
        self.outerCurrentPoint = None
        self.outerFirstPoint = None
        self.outerPrevPoint = None

        self.innerGlyph = Glyph()
        self.innerPen = self.innerGlyph.getPen()
        self.innerCurrentPoint = None
        self.innerFirstPoint = None
        self.innerPrevPoint = None

        self.prevPoint = None
        self.firstPoint = None
        self.firstAngle = None
        self.prevAngle = None

        self.shouldHandleMove = True

        self.drawSettings()
 def addComponent(self, glyphName, transform):
     if self.preserveComponents:
         self.components.append((glyphName, transform))
     else:
         BasePen.addComponent(self, glyphName, transform)
Пример #50
0
 def __init__(self, glyphSet, path):
     BasePen.__init__(self, glyphSet)
     self.path = path
Пример #51
0
 def __init__(self, pen, glyphSet):
     BasePen.__init__(self, glyphSet)
     self.pen = pen
Пример #52
0
 def __init__(self, glyphSet):
     BasePen.__init__(self, glyphSet)
     self.pen = CocoaPen(glyphSet)
     self.path = self.pen.path
Пример #53
0
	def __init__(self, glyphSet, testPoint, evenOdd=0):
		BasePen.__init__(self, glyphSet)
		self.setTestPoint(testPoint, evenOdd)
 def addComponent(self, glyphName, transform):
     if self.preserveComponents:
         self.components.append((glyphName, transform))
     else:
         BasePen.addComponent(self, glyphName, transform)
Пример #55
0
 def __init__(self, glyphSet, path):
     BasePen.__init__(self, glyphSet)
     self.path = path
Пример #56
0
 def __init__(self, glyphSet):
     BasePen.__init__(self, glyphSet)
     self.d = u''
     self._lastX = self._lastY = None