Python gi.repository.Pango.font_description_from_string() Examples
The following are 6
code examples of gi.repository.Pango.font_description_from_string().
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
gi.repository.Pango
, or try the search function
.
Example #1
Source File: bookPanel.py From pychess with GNU General Public License v3.0 | 6 votes |
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)
Example #2
Source File: gtk_ui.py From python-gui with Apache License 2.0 | 5 votes |
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
Example #3
Source File: annotationPanel.py From pychess with GNU General Public License v3.0 | 5 votes |
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()
Example #4
Source File: configwindow.py From autokey with GNU General Public License v3.0 | 5 votes |
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()
Example #5
Source File: draw_text.py From chamanti_ocr with Apache License 2.0 | 5 votes |
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()
Example #6
Source File: export_common.py From oomox with GNU General Public License v3.0 | 4 votes |
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)