Python cairo.version_info() Examples

The following are 8 code examples of cairo.version_info(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module cairo , or try the search function .
Example #1
Source File: backend_cairo.py    From Computable with MIT License 5 votes vote down vote up
def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
        # Note: x,y are device/display coords, not user-coords, unlike other
        # draw_* methods
        if _debug: print('%s.%s()' % (self.__class__.__name__, _fn_name()))

        if ismath:
            self._draw_mathtext(gc, x, y, s, prop, angle)

        else:
            ctx = gc.ctx
            ctx.new_path()
            ctx.move_to (x, y)
            ctx.select_font_face (prop.get_name(),
                                  self.fontangles [prop.get_style()],
                                  self.fontweights[prop.get_weight()])

            size = prop.get_size_in_points() * self.dpi / 72.0

            ctx.save()
            if angle:
                ctx.rotate (-angle * np.pi / 180)
            ctx.set_font_size (size)
            if sys.version_info[0] < 3:
                ctx.show_text(s.encode("utf-8"))
            else:
                ctx.show_text(s)
            ctx.restore() 
Example #2
Source File: backend_cairo.py    From Computable with MIT License 5 votes vote down vote up
def _draw_mathtext(self, gc, x, y, s, prop, angle):
        if _debug: print('%s.%s()' % (self.__class__.__name__, _fn_name()))

        ctx = gc.ctx
        width, height, descent, glyphs, rects = self.mathtext_parser.parse(
            s, self.dpi, prop)

        ctx.save()
        ctx.translate(x, y)
        if angle:
            ctx.rotate (-angle * np.pi / 180)

        for font, fontsize, s, ox, oy in glyphs:
            ctx.new_path()
            ctx.move_to(ox, oy)

            fontProp = ttfFontProperty(font)
            ctx.save()
            ctx.select_font_face (fontProp.name,
                                  self.fontangles [fontProp.style],
                                  self.fontweights[fontProp.weight])

            size = fontsize * self.dpi / 72.0
            ctx.set_font_size(size)
            if sys.version_info[0] < 3:
                ctx.show_text(s.encode("utf-8"))
            else:
                ctx.show_text(s)
            ctx.restore()

        for ox, oy, w, h in rects:
            ctx.new_path()
            ctx.rectangle (ox, oy, w, h)
            ctx.set_source_rgb (0, 0, 0)
            ctx.fill_preserve()

        ctx.restore() 
Example #3
Source File: backend_cairo.py    From matplotlib-4-abaqus with MIT License 5 votes vote down vote up
def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
        # Note: x,y are device/display coords, not user-coords, unlike other
        # draw_* methods
        if _debug: print('%s.%s()' % (self.__class__.__name__, _fn_name()))

        if ismath:
            self._draw_mathtext(gc, x, y, s, prop, angle)

        else:
            ctx = gc.ctx
            ctx.new_path()
            ctx.move_to (x, y)
            ctx.select_font_face (prop.get_name(),
                                  self.fontangles [prop.get_style()],
                                  self.fontweights[prop.get_weight()])

            size = prop.get_size_in_points() * self.dpi / 72.0

            ctx.save()
            if angle:
                ctx.rotate (-angle * np.pi / 180)
            ctx.set_font_size (size)
            if sys.version_info[0] < 3:
                ctx.show_text(s.encode("utf-8"))
            else:
                ctx.show_text(s)
            ctx.restore() 
Example #4
Source File: backend_cairo.py    From matplotlib-4-abaqus with MIT License 5 votes vote down vote up
def _draw_mathtext(self, gc, x, y, s, prop, angle):
        if _debug: print('%s.%s()' % (self.__class__.__name__, _fn_name()))

        ctx = gc.ctx
        width, height, descent, glyphs, rects = self.mathtext_parser.parse(
            s, self.dpi, prop)

        ctx.save()
        ctx.translate(x, y)
        if angle:
            ctx.rotate (-angle * np.pi / 180)

        for font, fontsize, s, ox, oy in glyphs:
            ctx.new_path()
            ctx.move_to(ox, oy)

            fontProp = ttfFontProperty(font)
            ctx.save()
            ctx.select_font_face (fontProp.name,
                                  self.fontangles [fontProp.style],
                                  self.fontweights[fontProp.weight])

            size = fontsize * self.dpi / 72.0
            ctx.set_font_size(size)
            if sys.version_info[0] < 3:
                ctx.show_text(s.encode("utf-8"))
            else:
                ctx.show_text(s)
            ctx.restore()

        for ox, oy, w, h in rects:
            ctx.new_path()
            ctx.rectangle (ox, oy, w, h)
            ctx.set_source_rgb (0, 0, 0)
            ctx.fill_preserve()

        ctx.restore() 
Example #5
Source File: PrerequisitesCheckerGramplet.py    From addons-source with GNU General Public License v2.0 5 votes vote down vote up
def check1_python(self):
        '''Check python version Gramps is currently running with against min
        version required

        #TODO - does not handle an older version of Gramps using python 2 on
        that a system that has python 3 installed (same for each of the other
        test)
        '''
        # Start check
        MIN_PYTHON_VERSION = (3, 3, 0)
        min_py_str = verstr(MIN_PYTHON_VERSION)

        # version to check against
        # Gramps running version of python
        py_str = '%d.%d.%d' % sys.version_info[:3]
        check1 = "* Python "

        if not sys.version_info >= MIN_PYTHON_VERSION:
            #print("Failed")
            messagefailed1 = " (Requires version "
            messagefailed3 = " or greater installed.)\n"

            messagefailed = messagefailed1 + min_py_str + messagefailed3

            result = check1 + py_str + messagefailed
        else:
            #print("Success")
            messagesuccess1 = " (Success version "
            messagesuccess3 = " or greater installed.)\n"

            messagesuccess = messagesuccess1 + min_py_str + messagesuccess3

            result = check1 + py_str + messagesuccess
        # End check
        self.append_text(result) 
Example #6
Source File: PrerequisitesCheckerGramplet.py    From addons-source with GNU General Public License v2.0 5 votes vote down vote up
def check31_EditExifMetadata(self):
        '''Edit Image Exif Metadata -

        requires:
        * PIL (Pillow)
        * pyexiv2  ( 0.2.0 )
        * exiv2

        https://github.com/gramps-project/addons-source/tree/master/EditExifMetadata
        '''
        self.append_text("\n")
        self.render_text("""<b>11. <a href="https://gramps-project.org/"""
                         """wiki/index.php?title=Edit_Image_Exif_Metadata">"""
                         """Addon:Edit Image Exif Metadata</a> :</b> """)

        # Start check
        self.check17_pillow()
        '''
        # validate that pyexiv2 is installed and its version...
        import pyexiv2

        # v0.1 has a different API to v0.2 and above
        if hasattr(pyexiv2, 'version_info'):
            OLD_API = False
        else:
        # version_info attribute does not exist prior to v0.2.0
            OLD_API = True

        # validate the exiv2 is installed and its executable
        system_platform = os.sys.platform
        if system_platform == "win32":
            EXIV2_FOUND = "exiv2.exe" if search_for("exiv2.exe") else False
        else:
            EXIV2_FOUND = "exiv2" if search_for("exiv2") else False
        if not EXIV2_FOUND:
            msg = 'You must have exiv2 and its development file installed.'
            raise SystemExit(msg)
        '''
        # End checks
        self.append_text(" ")
        self.check_gexiv2() 
Example #7
Source File: __init__.py    From uniconvertor with GNU Affero General Public License v3.0 5 votes vote down vote up
def get_version():
    v0, v1, v2 = cairo.version_info
    return cairo.cairo_version_string(), '%d.%d.%d' % (v0, v1, v2) 
Example #8
Source File: PrerequisitesCheckerGramplet.py    From addons-source with GNU General Public License v2.0 4 votes vote down vote up
def check4_cairo(self):
        '''Check cairo installed with GObject Introspection bindings
        (the gi package)
        '''
        # Start check
        MIN_CAIRO_VERSION = (1, 13, 1)
        # min version that pycairo supports is 1.13.1
        MIN_PYCAIRO_VERSION = (1, 13, 3)

        try:
            import cairo
            try:
                cairover_str = cairo.cairo_version_string()
                cairover_tpl = vertup(cairover_str)

                pycairo_result = cairo.version_info
                pycairover_str = cairo.version
                #print("pycairo_result : " + str(pycairo_result))

                cairo_result = cairover_tpl
                #print("cairo_result : " + str(cairo_result))
            except Exception:  # any failure to 'get' the version
                pycairover_str = 'unknown version'
                cairover_str = 'unknown version'

        except ImportError:
            pycairover_str = 'not found'
            cairover_str = 'not found'

        # Test Cairo
        if not cairo_result >= MIN_CAIRO_VERSION:
            #print("Failed")
            result = ("* Cairo " + cairover_str + " (Requires version " +
                      verstr(MIN_CAIRO_VERSION) + " or greater.)\n")
        else:
            #print("Success")
            result = ("* Cairo " + cairover_str + " (Success version " +
                      verstr(MIN_CAIRO_VERSION) + " or greater installed.)\n")

        self.append_text(result)
        # Test pycairo
        if not pycairo_result >= MIN_PYCAIRO_VERSION:
            #print("Failed")
            result = ("* Pycairo " + pycairover_str + " (Requires " +
                      verstr(MIN_PYCAIRO_VERSION) + " or greater.)\n")
        else:
            #print("Success")
            result = ("* Pycairo " + pycairover_str + " (Success version " +
                      verstr(MIN_PYCAIRO_VERSION) +
                      " or greater installed.)\n")

        # End check
        self.append_text(result)