Exemplo n.º 1
0
 def invoke(self, canvas: "Canvas", operands: List[AnyPDFType] = []):  # type: ignore [name-defined]
     """
     Invoke the BT operator
     """
     canvas.graphics_state.text_matrix = Matrix.identity_matrix()
     canvas.graphics_state.text_line_matrix = Matrix.identity_matrix()
     canvas._event_occurred(BeginTextEvent())
Exemplo n.º 2
0
 def __init__(self):
     self.ctm = Matrix.identity_matrix()
     self.text_matrix = Matrix.identity_matrix()
     self.text_line_matrix = Matrix.identity_matrix()
     self.text_rise = Decimal(0)
     self.character_spacing = Decimal(0)
     self.word_spacing = Decimal(0)
     self.horizontal_scaling = Decimal(100)
     self.leading = Decimal(0)
     self.font = None
     self.font_size = None
     self.path: typing.List["LineSegment"] = []
     self.clipping_path: typing.List["LineSegment"] = []
     self.non_stroke_color_space = None
     self.non_stroke_color = RGBColor(Decimal(0), Decimal(0), Decimal(0))
     self.stroke_color_space = None
     self.stroke_color = RGBColor(Decimal(0), Decimal(0), Decimal(0))
     self.line_width = Decimal(1)
     self.line_cap = None
     self.line_join = None
     self.miter_limit = Decimal(10)
     self.dash_pattern = None
     self.rendering_intent = None
     self.stroke_adjustment = None
     self.blend_mode = None
     self.soft_mask = None
     self.alpha_constant = None
     self.alpha_source = None
Exemplo n.º 3
0
    def test_matrix_determinant_002(self):

        # 0.453486      0.286607    0.803428
        # 0.69059       0.877364    0.555546
        # 0.00726739    0.0278032   0.421974
        m0 = Matrix.identity_matrix()

        m0[0][0] = Decimal(0.453486)
        m0[0][1] = Decimal(0.286607)
        m0[0][2] = Decimal(0.803428)

        m0[1][0] = Decimal(0.69059)
        m0[1][1] = Decimal(0.877364)
        m0[1][2] = Decimal(0.555546)

        m0[2][0] = Decimal(0.00726739)
        m0[2][1] = Decimal(0.0278032)
        m0[2][2] = Decimal(0.421974)

        # print matrix
        print(m0)

        # calculate determinant
        det = m0.determinant()
        print(det)

        # test
        assert round(det,
                     10) == round(Decimal(0.08882747052120038238163180078), 10)
Exemplo n.º 4
0
    def test_matrix_determinant_001(self):
        m0 = Matrix.identity_matrix()

        # print matrix
        print(m0)

        # test
        assert m0.determinant() == Decimal(1)
Exemplo n.º 5
0
 def get_font_matrix(self) -> Matrix:
     """
     Character glyphs in a font shall be defined in glyph space (see 9.2.4, "Glyph Positioning and Metrics").
     The transformation from glyph space to text space shall be defined by the font matrix. For most types of fonts,
     this matrix shall be predefined to map 1000 units of glyph space to 1 unit of text space; for Type 3 fonts, the
     font matrix shall be given explicitly in the font dictionary (see 9.6.5, "Type 3 Fonts").
     """
     return Matrix.identity_matrix()
Exemplo n.º 6
0
    def invoke(self,
               canvas: "Canvas",
               operands: List[AnyPDFType] = []):  # type: ignore [name-defined]

        assert isinstance(operands[0], Decimal)
        assert isinstance(operands[1], Decimal)

        tx = operands[0]
        ty = operands[1]

        m = Matrix.identity_matrix()
        m[2][0] = tx
        m[2][1] = ty

        canvas.graphics_state.text_matrix = m.mul(
            canvas.graphics_state.text_line_matrix)
        canvas.graphics_state.text_line_matrix = copy.deepcopy(
            canvas.graphics_state.text_matrix)
Exemplo n.º 7
0
    def invoke(self, canvas: "Canvas", operands: List[AnyPDFType] = []):

        if not isinstance(operands[0], Decimal):
            raise PDFTypeError(
                expected_type=Decimal, received_type=operands[0].__class__
            )
        if not isinstance(operands[1], Decimal):
            raise PDFTypeError(
                expected_type=Decimal, received_type=operands[1].__class__
            )

        tx = operands[0]
        ty = operands[1]

        m = Matrix.identity_matrix()
        m[2][0] = tx
        m[2][1] = ty

        canvas.graphics_state.text_matrix = m.mul(
            canvas.graphics_state.text_line_matrix
        )
        canvas.graphics_state.text_line_matrix = copy.deepcopy(
            canvas.graphics_state.text_matrix
        )
Exemplo n.º 8
0
 def get_font_matrix(self) -> Matrix:
     return Matrix.identity_matrix()
 def invoke(self, canvas: "Canvas", operands: List[AnyPDFType] = []):
     canvas.graphics_state.text_matrix = Matrix.identity_matrix()
     canvas.graphics_state.text_line_matrix = Matrix.identity_matrix()
     canvas.event_occurred(BeginTextEvent())