简体   繁体   English

如何更改 Kivy 字符串中某些字符的偏移量?

[英]How can I change offset for some characters in Kivy string?

How can I set offset for a some characters or words in Kivy?如何为 Kivy 中的某些字符或单词设置偏移量? I'd like to obtain something like我想获得类似的东西符号和文字的混合

It consists of 24pt Windings symbol which has offset -18% (to have bigger sign vertically centered relatively smaller font) and 12 pt common font label.它由偏移 -18% 的 24pt Windings 符号(具有较大的符号垂直居中相对较小的字体)和 12 pt 常用字体 label 组成。 It's important to have symbol with the text inline, 'cause really it's the part of a text paragraph.内嵌文本的符号很重要,因为它实际上是文本段落的一部分。 I've tried to do something like我试图做类似的事情

string = "[sub][size=45]t[/size][/sub]est"

But to no avail - Kivy just ignores all previous [] markup commands, ie if I use [sub] and [size=...] it always use the last instruction to the basic text, so I cannot have BOTH [sub] and [size=...] rendered.但无济于事 - Kivy 只是忽略所有以前的 [] 标记命令,即如果我使用 [sub] 和 [size=...] 它总是使用基本文本的最后一条指令,所以我不能同时拥有 [sub] 和[size=...] 渲染。 I know that I can install pango library, fully reinstall Kivy and then I can achieve what I need with [font_features].我知道我可以安装 pango 库,完全重新安装 Kivy 然后我可以用 [font_features] 实现我需要的。 The problem is that I will build Android app from this code so I need to keep app as light as possible (it is 30M right now already and starts relatively slowly even at middle-level smartphones).问题是我将从这段代码构建 Android 应用程序,所以我需要保持应用程序尽可能轻(现在已经是 30M,即使在中级智能手机上也启动相对缓慢)。 Moreover, it's quite unobviously how can I add pango library to buildozer and build APK with pango support (and how to turn ON pango text render under Android).此外,我如何将 pango 库添加到 buildozer 并构建具有 pango 支持的 APK(以及如何在 Android 下打开 pango 文本渲染),这很不明显。

If you are using this string in a Label , you can also use the font_size attribute of the Label .如果您在Label中使用此字符串,您还可以使用Labelfont_size属性。 Perhaps you could use that attribute to set the size for the entire Label to the size that you want inside the [sub] and [/sub] , and use markup to adjust the rest of the string.也许您可以使用该属性将整个Labelsize设置为您想要在[sub][/sub]内的size ,并使用标记来调整字符串的 rest。 Like this:像这样:

    t = "[sub]t[/sub][size=12]est[/size]"
    l = Label(text=t, font_size=45, markup=True)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM