当前位置: 首页>>代码示例>>Python>>正文


Python Context.select_font_face方法代码示例

本文整理汇总了Python中cairo.Context.select_font_face方法的典型用法代码示例。如果您正苦于以下问题:Python Context.select_font_face方法的具体用法?Python Context.select_font_face怎么用?Python Context.select_font_face使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cairo.Context的用法示例。


在下文中一共展示了Context.select_font_face方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: on_draw

# 需要导入模块: from cairo import Context [as 别名]
# 或者: from cairo.Context import select_font_face [as 别名]
    def on_draw(self, widget: Widget, context: cairo.Context):


        for b in self._buttons:
            b.set_shape_from_context(context)

        shapes = [b.shape for b in self._buttons]

        context.save()
        context.select_font_face("", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_BOLD)
        xb, yb, w, h, xa, ya = context.text_extents(self.title)

        width = max(shape.width for shape in shapes)
        width = max(width, xa)
        container_width = self.container_size[0]
        translation = Point(0, self.distance)
        if container_width > width:
            translation += Point((container_width)/2, 0)
        else:
            translation += Point(width/2, 0)

        context.move_to(translation.x - xa/2, h + 2 * self.distance)
        context.show_text(self.title)
        context.restore()

        height = h + self.distance * 3
        for b in self._buttons:
            height += b.shape.height + self.distance

        self.min_size = width + 2 * self.distance, height + self.distance

        start_point = context.get_current_point()
        translation += Point(0, h + self.distance * 3)
        context.translate(translation.x, translation.y)

        distance_offset = Point(0, self.distance)


        for b in self._buttons:
            context.move_to(*start_point)
            b.set_translate(translation.x, translation.y)
            context.save()
            b.on_draw(widget, context)
            context.restore()

            to_translate = Point(distance_offset.x,
                                 distance_offset.y + b.shape.height)
            context.translate(to_translate.x, to_translate.y)
            translation += to_translate
开发者ID:gcali,项目名称:crucipixel,代码行数:51,代码来源:main_menu.py

示例2: _set_font

# 需要导入模块: from cairo import Context [as 别名]
# 或者: from cairo.Context import select_font_face [as 别名]
 def _set_font(self, context: cairo.Context):
     context.set_font_size(self.font_size)
     slant = cairo.FONT_SLANT_NORMAL if not self.italic else cairo.FONT_SLANT_ITALIC
     weight = cairo.FONT_WEIGHT_NORMAL if not self.bold else cairo.FONT_WEIGHT_BOLD
     context.select_font_face("", slant, weight)
开发者ID:gcali,项目名称:crucipixel,代码行数:7,代码来源:text.py


注:本文中的cairo.Context.select_font_face方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。