本文整理汇总了Python中pangocairo.cairo_font_map_get_default函数的典型用法代码示例。如果您正苦于以下问题:Python cairo_font_map_get_default函数的具体用法?Python cairo_font_map_get_default怎么用?Python cairo_font_map_get_default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cairo_font_map_get_default函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __initialize_font_list
def __initialize_font_list(self):
"""
Construct font list
"""
def compare_data(model, iter1, iter2):
"""
Sorting function for the fonts list store
"""
data1 = model.get_value(iter1,0)
data2 = model.get_value(iter2,0)
return cmp(data1, data2)
self.__fontlist=TreeViewFactory('list', ['str','markup'], [],treeview=self.__tview)
# Get all system fonts
self.__font_families=pangocairo.cairo_font_map_get_default().list_families()
for family in self.__font_families:
escaped=gobject.markup_escape_text(family.get_name())
markedup='<span face="%s">%s</span>' % (escaped,escaped)
self.__fontlist.append([family.get_name(),markedup])
self.__tview.set_headers_visible(False)
self.__tview.get_column(0).set_property('visible',False)
self.__scroller.set_policy(gtk.POLICY_NEVER,gtk.POLICY_AUTOMATIC)
self.__fontlist.storagemodel.set_sort_func(0,compare_data)
self.__fontlist.storagemodel.set_sort_column_id(0,gtk.SORT_ASCENDING)
开发者ID:olivergs,项目名称:evogtk,代码行数:26,代码来源:fontcombo.py
示例2: generate_images
def generate_images(opts,args):
# Set up variables for drawing space
width = 2550 # Will resize to match text; default 8.5"x11" @ 300dpi
height = 3300
MARGIN_X = 300
MARGIN_Y = 300
LINE_SPACE = 35 #TODO: Command-line opts
LANG = "ka"
TESS_LANG = "kat"
# Set up decent spacing for box files
attrs = pango.AttrList() #TODO: Command line opts or config
attrs.insert(pango.AttrLanguage(LANG,0,-1))
attrs.insert(pango.AttrLetterSpacing(10000,0,-1))
attrs.insert(pango.AttrSize(48000,0,-1))
attrs.insert(pango.AttrFallback(False,0,-1))
attrs.insert(pango.AttrStyle(pango.STYLE_NORMAL,0,-1))
attrs.insert(pango.AttrWeight(pango.WEIGHT_NORMAL,0,-1))
attrs.insert(pango.AttrUnderline(pango.UNDERLINE_NONE,0,-1))
# Instantiate Cairo surface and context
surf = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
context = pangocairo.CairoContext(cairo.Context(surf))
# Instantiate PangoCairo context
context.set_antialias(cairo.ANTIALIAS_SUBPIXEL)
#get font families:
font_map = pangocairo.cairo_font_map_get_default()
# to see family names:
if opts.list_fonts:
print [f.get_name() for f in font_map.list_families()]
开发者ID:ddohler,项目名称:tess_school,代码行数:32,代码来源:text2img.py
示例3: getTopExents
def getTopExents(self, attr_list, text):
c = pango.FontMap.create_context(pangocairo.cairo_font_map_get_default())
l = pango.Layout(c)
l.set_attributes(attr_list)
l.set_text(text)
line = l.get_line(0)
return (line.get_pixel_extents()[1][3]-line.get_pixel_extents()[0][3]) * (self.input_resolution/self.output_resolution)
开发者ID:jabiertxof,项目名称:Gimp-to-SVG,代码行数:7,代码来源:pango_to_svg.py
示例4: draw_image
def draw_image(self, temp_data):
"""
Draw image file from text file
"""
surf = cairo.ImageSurface(cairo.FORMAT_ARGB32, 1220, 620)
context = cairo.Context(surf)
context.rectangle(0, 0, 1220, 620) # draw a background rectangle:
context.set_source_rgb(1, 1, 1)
context.fill()
font_map = pangocairo.cairo_font_map_get_default()
families = font_map.list_families()
context.translate(150, 55)
pangocairo_context = pangocairo.CairoContext(context)
pangocairo_context.set_antialias(cairo.ANTIALIAS_SUBPIXEL)
layout = pangocairo_context.create_layout()
fontname = sys.argv[1] if len(sys.argv) >= 2 else "Sans"
font = pango.FontDescription(fontname + " 25")
layout.set_font_description(font)
layout.set_text(temp_data)
context.set_source_rgb(0, 0, 0)
pangocairo_context.update_layout(layout)
pangocairo_context.show_layout(layout)
with open("wallnote.png", "wb") as image_file:
surf.write_to_png(image_file)
path = os.path.join(os.getcwd(), "wallnote.png")
fd = os.popen(
"gsettings set org.gnome.desktop.background picture-uri file:///{}".format(path))
fd.close()
开发者ID:tushar-rishav,项目名称:Wallnote,代码行数:30,代码来源:main.py
示例5: use_pango_font
def use_pango_font(font, start, count, will_call_prepost=False):
import pango, cairo, pangocairo
fontDesc = pango.FontDescription(font)
a = array.array('b', itertools.repeat(0, 256*256))
surface = cairo.ImageSurface.create_for_data(a, cairo.FORMAT_A8, 256, 256)
context = pangocairo.CairoContext(cairo.Context(surface))
layout = context.create_layout()
fontmap = pangocairo.cairo_font_map_get_default()
font = fontmap.load_font(fontmap.create_context(), fontDesc)
layout.set_font_description(fontDesc)
metrics = font.get_metrics()
descent = metrics.get_descent()
d = pango.PIXELS(descent)
linespace = metrics.get_ascent() + metrics.get_descent()
width = metrics.get_approximate_char_width()
glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT)
glPixelStorei(GL_UNPACK_SWAP_BYTES, 0)
glPixelStorei(GL_UNPACK_LSB_FIRST, 1)
glPixelStorei(GL_UNPACK_ROW_LENGTH, 256)
glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, 256)
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0)
glPixelStorei(GL_UNPACK_SKIP_ROWS, 0)
glPixelStorei(GL_UNPACK_SKIP_IMAGES, 0)
glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
glPixelZoom(1, -1)
base = glGenLists(count)
for i in range(count):
ch = unichr(start+i)
layout.set_text(ch)
w, h = layout.get_size()
context.save()
context.new_path()
context.rectangle(0, 0, 256, 256)
context.set_source_rgba(0., 0., 0., 0.)
context.set_operator (cairo.OPERATOR_SOURCE);
context.paint()
context.restore()
context.save()
context.set_source_rgba(1., 1., 1., 1.)
context.set_operator (cairo.OPERATOR_SOURCE);
context.move_to(0, 0)
context.update_layout(layout)
context.show_layout(layout)
context.restore()
w, h = pango.PIXELS(w), pango.PIXELS(h)
glNewList(base+i, GL_COMPILE)
glBitmap(0, 0, 0, 0, 0, h-d, '');
if not will_call_prepost: pango_font_pre()
if w and h: glDrawPixels(w, h, GL_LUMINANCE, GL_UNSIGNED_BYTE, a)
glBitmap(0, 0, 0, 0, w, -h+d, '');
if not will_call_prepost: pango_font_post()
glEndList()
glPopClientAttrib()
return base, pango.PIXELS(width), pango.PIXELS(linespace)
开发者ID:13788593535,项目名称:machinekit,代码行数:59,代码来源:glnav.py
示例6: get_font_families
def get_font_families():
'''
Get all font families in system.
@return: Return font families list in current system.
'''
fontmap = pangocairo.cairo_font_map_get_default()
return map (lambda f: f.get_name(), fontmap.list_families())
开发者ID:chenzhiwei,项目名称:deepin-ui,代码行数:8,代码来源:utils.py
示例7: get_font_list
def get_font_list():
"""Returns a sorted list of all system font names"""
font_map = pangocairo.cairo_font_map_get_default()
font_list = [f.get_name() for f in font_map.list_families()]
font_list.sort()
return font_list
开发者ID:daleathan,项目名称:pyspread,代码行数:8,代码来源:sysvars.py
示例8: get_system_fonts
def get_system_fonts():
# Currently this only works with the cairo backend
if settings.IMPOSITIONS_BACKEND != 'cairo':
raise NotImplementedError("Font listing does not work with the selected impositions backend.")
import pangocairo
font_map = pangocairo.cairo_font_map_get_default()
font_list = [f.get_name() for f in font_map.list_families()]
font_list.sort()
return font_list
开发者ID:farstarinc,项目名称:django-impositions,代码行数:9,代码来源:utils.py
示例9: __init__
def __init__(self, image_scale = 1.0, image_width = None, image_height = None):
super(CairoBackend, self).__init__(image_scale, image_width, image_height)
self.set_margin(*(CairoBackend.DEFAULT_MARGIN))
self.set_image_size(0, 0)
self.__surfaces = []
self.__ctx = None
self.__drawn_graph = None
self.__font_map = pangocairo.cairo_font_map_get_default()
self.__available_font_names = [f.get_name() for f in self.__font_map.list_families()]
return
开发者ID:bmustiata,项目名称:shaape,代码行数:10,代码来源:cairobackend.py
示例10: get_font_families
def get_font_families(filter_terminal_font=False):
'''Get all font families in system.'''
fontmap = pangocairo.cairo_font_map_get_default()
font_families = fontmap.list_families()
if filter_terminal_font:
font_families = filter(
lambda f: f.is_monospace() or f.get_name() == "文泉驿等宽微米黑", filter(
lambda f: not f.get_name() in ["Droid Sans Japanese", "MT Extra", "Monospace"],
font_families))
return sorted(map(lambda f: f.get_name(), font_families))
开发者ID:binwen925,项目名称:QMusic,代码行数:10,代码来源:font.py
示例11: _find_font_desc
def _find_font_desc(self, font_name):
font_map = pangocairo.cairo_font_map_get_default()
families = font_map.list_families()
for family in families:
for face in family.list_faces():
_font_name = '{} {}'.format(family.get_name() , face.get_face_name())
if font_name == _font_name or font_name == family.get_name():
return face.describe()
return None
开发者ID:stonewell,项目名称:pymterm,代码行数:11,代码来源:term_pygui_glview_pycairo.py
示例12: create_layout
def create_layout(self, cr):
pcctx = pangocairo.CairoContext(cr)
font_map = pangocairo.cairo_font_map_get_default()
pcr = font_map.create_context()
p_layout = pango.Layout(pcr)
p_layout.set_wrap(pango.WRAP_WORD)
p_layout.set_width(int(self.width*pango.SCALE))
font = pango.FontDescription(self.font_description)
p_layout.set_font_description(font)
p_layout.set_alignment(self.align)
p_layout.set_text(self.string)
return p_layout
开发者ID:bpowers,项目名称:opensim,代码行数:12,代码来源:text.py
示例13: _get_fonts
def _get_fonts(families_list, families_dict):
fm = pangocairo.cairo_font_map_get_default()
context = fm.create_context()
families = context.list_families()
for item in families:
fcs = {}
scalable = True
for face in item.list_faces():
if not face.list_sizes() is None:
scalable = False
fcs[face.get_face_name()] = face
if scalable:
families_dict[item.get_name()] = fcs
families_list.append(item.get_name())
families_list.sort()
开发者ID:kindlychung,项目名称:sk1,代码行数:15,代码来源:__init__.py
示例14: _get_font
def _get_font(self):
font_map = pangocairo.cairo_font_map_get_default()
font_name = self.font_name
if not font_name:
stop_alert("render cairoe unable to find a valid font name, please use --font_name or pymterm.json to set font name")
sys.exit(1)
font = self._find_font_desc(font_name)
if not font:
font = pango.FontDescription(' '.join([font_name, str(self.font_size)]))
else:
font.set_size(int(float(self.font_size) * pango.SCALE * 72 / font_map.get_resolution()) + 1)
return font
开发者ID:stonewell,项目名称:pymterm,代码行数:16,代码来源:term_pygui_glview_pycairo.py
示例15: transformText
def transformText(text, file_path, fontname="Sans"):
# fontname = sys.argv[2] if len(sys.argv) >= 3 else "Sans"
# text = sys.argv[1] if len(sys.argv) >= 2 else u"Some text"
surf = cairo.ImageSurface(cairo.FORMAT_ARGB32, 320, 120)
context = cairo.Context(surf)
#draw a background rectangle:
context.rectangle(0,0,320,120)
context.set_source_rgb(1, 1, 1)
context.fill()
#get font families:
font_map = pangocairo.cairo_font_map_get_default()
families = font_map.list_families()
# to see family names:
print [f.get_name() for f in font_map.list_families()]
开发者ID:LiorKirsch,项目名称:expire-mail,代码行数:21,代码来源:text2Image2.py
示例16: __init__
def __init__(self):
gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
self.set_title(_("Titler"))
self.connect("delete-event", lambda w, e:close_titler())
if editorstate.SCREEN_HEIGHT < 800:
global TEXT_LAYER_LIST_HEIGHT, TEXT_VIEW_HEIGHT, VIEW_EDITOR_HEIGHT
TEXT_LAYER_LIST_HEIGHT = 200
TEXT_VIEW_HEIGHT = 225
VIEW_EDITOR_HEIGHT = 550
self.block_updates = False
self.view_editor = vieweditor.ViewEditor(PLAYER().profile, VIEW_EDITOR_WIDTH, VIEW_EDITOR_HEIGHT)
self.view_editor.active_layer_changed_listener = self.active_layer_changed
self.guides_toggle = vieweditor.GuidesViewToggle(self.view_editor)
add_b = gtk.Button(_("Add"))
del_b = gtk.Button(_("Delete"))
add_b.connect("clicked", lambda w:self._add_layer_pressed())
del_b.connect("clicked", lambda w:self._del_layer_pressed())
add_del_box = gtk.HBox()
add_del_box = gtk.HBox(True,1)
add_del_box.pack_start(add_b)
add_del_box.pack_start(del_b)
center_h_icon = gtk.image_new_from_file(respaths.IMAGE_PATH + "center_horizontal.png")
center_v_icon = gtk.image_new_from_file(respaths.IMAGE_PATH + "center_vertical.png")
center_h = gtk.Button()
center_h.set_image(center_h_icon)
center_h.connect("clicked", lambda w:self._center_h_pressed())
center_v = gtk.Button()
center_v.set_image(center_v_icon)
center_v.connect("clicked", lambda w:self._center_v_pressed())
self.layer_list = TextLayerListView(self._layer_selection_changed, self._layer_visibility_toggled)
self.layer_list.set_size_request(TEXT_LAYER_LIST_WIDTH, TEXT_LAYER_LIST_HEIGHT)
self.text_view = gtk.TextView()
self.text_view.set_pixels_above_lines(2)
self.text_view.set_left_margin(2)
self.text_view.get_buffer().connect("changed", self._text_changed)
self.sw = gtk.ScrolledWindow()
self.sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
self.sw.add(self.text_view)
self.sw.set_size_request(TEXT_VIEW_WIDTH, TEXT_VIEW_HEIGHT)
scroll_frame = gtk.Frame()
scroll_frame.add(self.sw)
self.tc_display = guicomponents.MonitorTCDisplay()
self.tc_display.use_internal_frame = True
self.pos_bar = positionbar.PositionBar()
self.pos_bar.set_listener(self.position_listener)
self.pos_bar.update_display_from_producer(PLAYER().producer)
self.pos_bar.mouse_release_listener = self.pos_bar_mouse_released
pos_bar_frame = gtk.Frame()
pos_bar_frame.add(self.pos_bar.widget)
pos_bar_frame.set_shadow_type(gtk.SHADOW_ETCHED_IN)
font_map = pangocairo.cairo_font_map_get_default()
unsorted_families = font_map.list_families()
if len(unsorted_families) == 0:
print "No font families found in system! Titler will not work."
self.font_families = sorted(unsorted_families, key=lambda family: family.get_name())
self.font_family_indexes_for_name = {}
combo = gtk.combo_box_new_text()
indx = 0
for family in self.font_families:
combo.append_text(family.get_name())
self.font_family_indexes_for_name[family.get_name()] = indx
indx += 1
combo.set_active(0)
self.font_select = combo
self.font_select.connect("changed", self._edit_value_changed)
adj = gtk.Adjustment(float(DEFAULT_FONT_SIZE), float(1), float(300), float(1))
self.size_spin = gtk.SpinButton(adj)
self.size_spin.connect("changed", self._edit_value_changed)
self.size_spin.connect("key-press-event", self._key_pressed_on_widget)
font_main_row = gtk.HBox()
font_main_row.pack_start(self.font_select, True, True, 0)
font_main_row.pack_start(guiutils.pad_label(5, 5), False, False, 0)
font_main_row.pack_start(self.size_spin, False, False, 0)
self.bold_font = gtk.ToggleButton()
self.italic_font = gtk.ToggleButton()
bold_icon = gtk.image_new_from_stock(gtk.STOCK_BOLD,
gtk.ICON_SIZE_BUTTON)
italic_icon = gtk.image_new_from_stock(gtk.STOCK_ITALIC,
gtk.ICON_SIZE_BUTTON)
self.bold_font.set_image(bold_icon)
self.italic_font.set_image(italic_icon)
self.bold_font.connect("clicked", self._edit_value_changed)
self.italic_font.connect("clicked", self._edit_value_changed)
#.........这里部分代码省略.........
开发者ID:Mermouy,项目名称:flowblade,代码行数:101,代码来源:titler.py
示例17: get_all_font_info
def get_all_font_info():
font_map = pangocairo.cairo_font_map_get_default()
families = font_map.list_families()
return sorted([f.get_name() for f in families])
开发者ID:CodeforEvolution,项目名称:miro,代码行数:4,代码来源:fontinfo.py
示例18: bold
text = re.sub( "style=\"font-weight: bold(?:; )?",
"weight=\"bold\" style=\"", text )
text = re.sub( "style=\"font-style: italic(?:; )?",
"style=\"italic\" style=\"", text )
text = re.sub( "style=\"background-color: (#[0-9A-Fa-f]{6})(?:; )?",
"background=\"\\1\" style=\"", text )
text = re.sub( "style=\"\"", "", text )
text = text.strip()
# First pass, find image size to hold the text.
mode = { "grey" : -1,
"bilevel" : cairo.ANTIALIAS_NONE,
"subpixel" : cairo.ANTIALIAS_SUBPIXEL
}[ args.mode ]
pangocairo.cairo_font_map_get_default().set_resolution( 72 )
surface = cairo.ImageSurface( cairo.FORMAT_ARGB32, 0, 0 )
context = pangocairo.CairoContext( cairo.Context( surface ) )
layout = context.create_layout()
options = cairo.FontOptions()
options.set_antialias( mode )
pangocairo.context_set_font_options( layout.get_context(), options )
layout.set_font_description( pango.FontDescription( args.font ) )
layout.set_markup( text )
width = max( layout.get_pixel_size()[ 0 ] + args.pad * 2, args.width )
height = max( layout.get_pixel_size()[ 1 ] + args.pad * 2, args.height )
# Second pass, render actual image and save it.
surface = cairo.ImageSurface( cairo.FORMAT_ARGB32, width, height )
context = pangocairo.CairoContext( cairo.Context( surface ) )
开发者ID:LarryPham,项目名称:codeface,代码行数:31,代码来源:render.py
示例19: new_text
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import pango
import pangocairo
import cairo
import gobject
import logging
logger = logging.getLogger(__name__)
# Shared pango context
pango_context = pangocairo.cairo_font_map_get_default().create_context()
"""
Handles drawing and measuring of text on a screen.
"""
def new_text(screen = None):
"""
Create a new text handler. This should be used rather than directly constructing
the G15PangoText
"""
if screen:
return G15PangoText(screen.driver.get_antialias())
else:
return G15PangoText(True)
开发者ID:FPar,项目名称:gnome15,代码行数:31,代码来源:g15text.py
示例20: __init__
def __init__(self, page_setup, cr):
self.page_setup = page_setup
self.paper_size = page_setup.get_paper_size()
self.pango_fontmap = pangocairo.cairo_font_map_get_default()
self.cr = cr
开发者ID:alexey4petrov,项目名称:reinteract,代码行数:5,代码来源:worksheet_print.py
注:本文中的pangocairo.cairo_font_map_get_default函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论