def generate_fontsamples(fonts): bitmaps = [] w = config.font_preview_width fontsize = config.font_preview_size color = cms.val_255(config.font_preview_color) text = config.font_preview_text for item in fonts: h = libpango.get_sample_size(text, item, fontsize)[1] surface = cairo.ImageSurface(cairo.FORMAT_RGB24, w, h) ctx = cairo.Context(surface) ctx.set_source_rgb(0.0, 0.0, 0.0) ctx.paint() matrix = cairo.Matrix(1.0, 0.0, 0.0, 1.0, 0.0, 0.0) ctx.set_matrix(matrix) ctx.set_source_rgb(1.0, 1.0, 1.0) ctx.set_antialias(cairo.ANTIALIAS_DEFAULT) libpango.render_sample(ctx, text, item, fontsize) ctx.fill() bmp = wal.copy_surface_to_bitmap(surface) bitmaps.append(wal.invert_text_bitmap(bmp, color)) return bitmaps
def generate_fontsample_cache(fonts): w = config.font_preview_width fontsize = config.font_preview_size color = cms.val_255(config.font_preview_color) text = config.font_preview_text.decode('utf-8') for item in fonts: h = libpango.get_sample_size(text, item, fontsize)[1] if not h: h = 10 LOG.warn('Incorrect font <%s>: zero font height', item) surface = cairo.ImageSurface(cairo.FORMAT_RGB24, w, h) ctx = cairo.Context(surface) ctx.set_source_rgb(0.0, 0.0, 0.0) ctx.paint() matrix = cairo.Matrix(1.0, 0.0, 0.0, 1.0, 0.0, 0.0) ctx.set_matrix(matrix) ctx.set_source_rgb(1.0, 1.0, 1.0) ctx.set_antialias(cairo.ANTIALIAS_DEFAULT) libpango.render_sample(ctx, text, item, fontsize) ctx.fill() bmp = wal.copy_surface_to_bitmap(surface) FONTSAMPLE_CACHE.append(wal.invert_text_bitmap(bmp, color))
def generate_fontsample_cache(fonts): w = config.font_preview_width fontsize = config.font_preview_size color = cms.val_255(config.font_preview_color) text = config.font_preview_text for item in fonts: h = libpango.get_sample_size(text, item, fontsize)[1] if not h: h = 10 warn(_('incorrect font') + ' - %s' % item) surface = cairo.ImageSurface(cairo.FORMAT_RGB24, w, h) ctx = cairo.Context(surface) ctx.set_source_rgb(0.0, 0.0, 0.0) ctx.paint() matrix = cairo.Matrix(1.0, 0.0, 0.0, 1.0, 0.0, 0.0) ctx.set_matrix(matrix) ctx.set_source_rgb(1.0, 1.0, 1.0) ctx.set_antialias(cairo.ANTIALIAS_DEFAULT) libpango.render_sample(ctx, text, item, fontsize) ctx.fill() bmp = wal.copy_surface_to_bitmap(surface) FONTSAMPLE_CACHE.append(wal.invert_text_bitmap(bmp, color))