Exemplo n.º 1
0
    def tr_create_font_in(self, chunk):
        h = get_data('<h', chunk[:2])[0]
        esc = get_data('<h', chunk[4:6])[0]
        weight = get_data('<h', chunk[8:10])[0]
        size = round(abs(self.coef * h), 1) * .7
        size = 12.0 if not size else size
        size = 5.0 if size < 5.0 else size
        fl_b = weight >= 500
        fl_i, fl_u, fl_s, charset = get_data('<BBBB', chunk[10:14])
        fl_i = fl_i == wmfconst.META_TRUE
        fl_u = fl_u == wmfconst.META_TRUE
        fl_s = fl_s == wmfconst.META_TRUE

        if charset in wmfconst.META_CHARSETS:
            charset = wmfconst.META_CHARSETS[charset]
        else:
            charset = wmfconst.META_CHARSETS[wmfconst.ANSI_CHARSET]

        fontface = wmflib.parse_nt_string(chunk[18:]).encode('utf-8')
        font_family = 'Sans'
        if fontface in libpango.get_fonts()[0]:
            font_family = fontface

        font = (font_family, size, fl_b, fl_i, fl_u, fl_s, esc / 10.0, charset)
        self.add_gdiobject(('font', font))
Exemplo n.º 2
0
	def tr_create_font_in(self, chunk):
		h = get_data('<h', chunk[:2])[0]
		esc = get_data('<h', chunk[4:6])[0]
		weight = get_data('<h', chunk[8:10])[0]
		size = round(abs(self.coef * h), 1) * .7
		if not size: size = 12.0
		if size < 5.0: size = 5.0
		fl_b = weight >= 500
		fl_i, fl_u, fl_s, charset = get_data('<BBBB', chunk[10:14])
		fl_i = fl_i == wmfconst.META_TRUE
		fl_u = fl_u == wmfconst.META_TRUE
		fl_s = fl_s == wmfconst.META_TRUE

		if charset in wmfconst.META_CHARSETS:
			charset = wmfconst.META_CHARSETS[charset]
		else:
			charset = wmfconst.META_CHARSETS[wmfconst.ANSI_CHARSET]

		fontface = wmflib.parse_nt_string(chunk[18:]).encode('utf-8')
		font_family = 'Sans'
		if fontface in libpango.get_fonts()[0]: font_family = fontface

		font = (font_family, size, fl_b, fl_i, fl_u, fl_s, esc / 10.0, charset)
		self.add_gdiobject(('font', font))