本文整理汇总了Python中gi.repository.Pango.font_description_from_string方法的典型用法代码示例。如果您正苦于以下问题:Python Pango.font_description_from_string方法的具体用法?Python Pango.font_description_from_string怎么用?Python Pango.font_description_from_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.Pango
的用法示例。
在下文中一共展示了Pango.font_description_from_string方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_render
# 需要导入模块: from gi.repository import Pango [as 别名]
# 或者: from gi.repository.Pango import font_description_from_string [as 别名]
def do_render(self, context, widget, background_area, cell_area, flags):
if not self.data:
return
text, widthfrac, goodness = self.data
if widthfrac:
paintGraph(context, widthfrac, stoplightColor(goodness), cell_area)
if text:
layout = PangoCairo.create_layout(context)
layout.set_text(text, -1)
fd = Pango.font_description_from_string("Sans 10")
layout.set_font_description(fd)
w, h = layout.get_pixel_size()
context.move_to(cell_area.x, cell_area.y)
context.rel_move_to(70 - w, (height - h) / 2)
PangoCairo.show_layout(context, layout)
示例2: _parse_font
# 需要导入模块: from gi.repository import Pango [as 别名]
# 或者: from gi.repository.Pango import font_description_from_string [as 别名]
def _parse_font(font, cr=None):
if not cr:
ims = cairo.ImageSurface(cairo.FORMAT_RGB24, 300, 300)
cr = cairo.Context(ims)
fd = Pango.font_description_from_string(font)
layout = PangoCairo.create_layout(cr)
layout.set_font_description(fd)
layout.set_alignment(Pango.Alignment.LEFT)
layout.set_markup('<span font_weight="bold">A</span>')
bold_width, _ = layout.get_size()
layout.set_markup('<span>A</span>')
pixels = layout.get_pixel_size()
normal_width, _ = layout.get_size()
return fd, pixels, normal_width, bold_width
示例3: fetch_chess_conf
# 需要导入模块: from gi.repository import Pango [as 别名]
# 或者: from gi.repository.Pango import font_description_from_string [as 别名]
def fetch_chess_conf(self):
"""
The method retrieves few parameters from the configuration.
"""
self.fan = conf.get("figuresInNotation")
movetext_font = conf.get("movetextFont")
self.font = Pango.font_description_from_string(movetext_font)
self.showEmt = conf.get("showEmt")
self.showBlunder = conf.get("showBlunder") and not self.gamemodel.isPlayingICSGame()
self.showEval = conf.get("showEval") and not self.gamemodel.isPlayingICSGame()
示例4: __init__
# 需要导入模块: from gi.repository import Pango [as 别名]
# 或者: from gi.repository.Pango import font_description_from_string [as 别名]
def __init__(self, parentWindow):
self.parentWindow = parentWindow
builder = get_ui("scriptpage.xml")
self.ui = builder.get_object("scriptpage")
builder.connect_signals(self)
self.buffer = GtkSource.Buffer()
self.buffer.connect("changed", self.on_modified)
self.editor = GtkSource.View.new_with_buffer(self.buffer)
scrolledWindow = builder.get_object("scrolledWindow")
scrolledWindow.add(self.editor)
# Editor font
settings = Gio.Settings.new("org.gnome.desktop.interface")
fontDesc = Pango.font_description_from_string(settings.get_string("monospace-font-name"))
self.editor.modify_font(fontDesc)
self.promptCheckbox = builder.get_object("promptCheckbox")
self.showInTrayCheckbox = builder.get_object("showInTrayCheckbox")
self.linkButton = builder.get_object("linkButton")
label = self.linkButton.get_child()
label.set_ellipsize(Pango.EllipsizeMode.MIDDLE)
vbox = builder.get_object("settingsVbox")
self.settingsWidget = SettingsWidget(parentWindow)
vbox.pack_start(self.settingsWidget.ui, False, False, 0)
# Configure script editor
self.__m = GtkSource.LanguageManager()
self.__sm = GtkSource.StyleSchemeManager()
self.buffer.set_language(self.__m.get_language("python"))
self.buffer.set_style_scheme(self.__sm.get_scheme("classic"))
self.editor.set_auto_indent(True)
self.editor.set_smart_home_end(True)
self.editor.set_insert_spaces_instead_of_tabs(True)
self.editor.set_tab_width(4)
self.ui.show_all()
示例5: do_draw_cb
# 需要导入模块: from gi.repository import Pango [as 别名]
# 或者: from gi.repository.Pango import font_description_from_string [as 别名]
def do_draw_cb(self, widget, cr):
# The do_draw_cb is called when the widget is asked to draw itself
# with the 'draw' as opposed to old function 'expose event'
# Remember that this will be called a lot of times, so it's usually
# a good idea to write this code as optimized as it can be, don't
# Create any resources in here.
cr.translate ( RADIUS, RADIUS)
layout = PangoCairo.create_layout (cr)
layout.set_text("శ్రీమదాంధ్రమహాభారతము", -1)
desc = Pango.font_description_from_string (FONT)
layout.set_font_description( desc)
rangec = range(0, N_WORDS)
for i in rangec:
width, height = 0,0
angle = (360. * i) / N_WORDS;
cr.save ()
red = (1 + math.cos ((angle - 60) * math.pi / 180.)) / 2
cr.set_source_rgb ( red, 0, 1.0 - red)
cr.rotate ( angle * math.pi / 180.)
#/* Inform Pango to re-layout the text with the new transformation */
PangoCairo.update_layout (cr, layout)
width, height = layout.get_size()
cr.move_to ( - (float(width) / 1024.) / 2, - RADIUS)
PangoCairo.show_layout (cr, layout)
cr.restore()
示例6: __init__
# 需要导入模块: from gi.repository import Pango [as 别名]
# 或者: from gi.repository.Pango import font_description_from_string [as 别名]
def __init__(
self, transient_for,
headline=_("Export Theme"),
width=150,
height=80
):
Gtk.Dialog.__init__(self, headline, transient_for, 0)
self.set_default_size(width, height)
self.label = CenterLabel()
self.spinner = Gtk.Spinner()
# Scrollable log window:
self.log = Gtk.TextView()
self.log.set_editable(False)
# self.log.set_cursor_visible(False)
self.log.override_font(
# @TODO: make log size configurable?
Pango.font_description_from_string("monospace 8")
)
self.log.set_wrap_mode(Gtk.WrapMode.CHAR)
#
self.scrolled_window = Gtk.ScrolledWindow(expand=True)
self.scrolled_window.set_margin_bottom(5)
self.scrolled_window.add(self.log)
#
adj = self.scrolled_window.get_vadjustment()
adj.connect(
'changed',
lambda adj: adj.set_value(adj.get_upper() - adj.get_page_size())
)
self.options_box = Gtk.Box(
orientation=Gtk.Orientation.VERTICAL, spacing=5
)
self.options_box.set_margin_top(5)
self.options_box.set_margin_bottom(15)
self.apply_button = Gtk.Button(label=_("_Apply Options and Export"), use_underline=True)
self.apply_button.connect("clicked", lambda x: self.do_export())
self.error_box = Gtk.Box(
orientation=Gtk.Orientation.VERTICAL, spacing=5
)
self.error_box.set_margin_bottom(10)
self.box = self.get_content_area()
self.box.set_margin_left(5)
self.box.set_margin_right(5)
self.box.set_spacing(5)
self.top_area = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
self.box.add(self.top_area)
self.top_area.add(self.label)
self.show_all()
self.box.add(self.spinner)
self.box.add(self.scrolled_window)