本文整理汇总了Python中surface.Surface.empty方法的典型用法代码示例。如果您正苦于以下问题:Python Surface.empty方法的具体用法?Python Surface.empty怎么用?Python Surface.empty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类surface.Surface
的用法示例。
在下文中一共展示了Surface.empty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __call__
# 需要导入模块: from surface import Surface [as 别名]
# 或者: from surface.Surface import empty [as 别名]
def __call__(self, text):
font_width, font_height = self.surface.size
offsets = [0]
baseline = 0
overline = 0
x = 0
for character in text:
metrics = self.metadata.get(character)
if metrics is None:
continue
if metrics["display"]:
baseline = max(baseline, metrics["vbearing"])
overline = max(overline, metrics["height"] - metrics["vbearing"])
x += metrics['advance']
offsets.append(x)
surface = Surface.empty(offsets[-1], baseline + overline)
x = 0
for character in text:
metrics = self.metadata.get(character)
if metrics is None:
continue
if metrics["display"]:
width = metrics["width"]
height = metrics["height"]
uv = metrics["uv"]
glyph = self.surface.subsurface((
(uv["s"] * font_width,
uv["t"] * font_height),
(width,
height)
))
surface(glyph, (
(x + metrics["hbearing"],
baseline - metrics["vbearing"]),
(width,
height)
))
x += metrics['advance']
mathline = self.calculate_mathline(baseline)
return Label(surface.pys, offsets, baseline, mathline)