Example #1
0
def test_linespacing_from_string():
    assert LineSpacing.from_string('default') == DEFAULT
    assert LineSpacing.from_string('StandarD') == STANDARD
    assert LineSpacing.from_string('SINGLE') == SINGLE
    assert LineSpacing.from_string('Double') == DOUBLE
    assert LineSpacing.from_string('proportional(2)') == ProportionalSpacing(2)
    assert LineSpacing.from_string('fixed(2pt)') == FixedSpacing(2*PT)
    assert LineSpacing.from_string('fixed(1.4 cm)') == FixedSpacing(1.4*CM)
    assert LineSpacing.from_string('fixed(1pT,single)') == FixedSpacing(1*PT)
    assert LineSpacing.from_string('fixed(1pT ,DOUBLE)') \
               == FixedSpacing(1*PT, DOUBLE)
    assert LineSpacing.from_string('leading(3    PT)') == Leading(3*PT)
    with pytest.raises(ParseError):
        assert LineSpacing.from_string('5 pt')
    with pytest.raises(ParseError):
        assert LineSpacing.from_string('proportional')
    with pytest.raises(ParseError):
        assert LineSpacing.from_string('proportional(1 cm)')
    with pytest.raises(ParseError):
        assert LineSpacing.from_string('fixed')
    with pytest.raises(ParseError):
        assert LineSpacing.from_string('fixed(2)')
    with pytest.raises(ParseError):
        assert LineSpacing.from_string('fixed(2pt, badvalue)')
    with pytest.raises(ParseError):
        assert LineSpacing.from_string('leading')
Example #2
0
                          standard_symbols, cmex9)
else:
    from rinoh.fonts.adobe14 import pdf_family as ieeeFamily
    #from rinoh.fonts.adobe35 import palatino, helvetica, courier
    #from rinoh.fonts.adobe35 import newcenturyschlbk, bookman
    #ieeeFamily = TypeFamily(serif=palatino, sans=helvetica, mono=courier)
    from rinoh.fonts.adobe35 import postscript_mathfonts as mathfonts

# styles
# ----------------------------------------------------------------------------
styles = StyleStore()

styles['body'] = ParagraphStyle(typeface=ieeeFamily.serif,
                                font_weight=REGULAR,
                                font_size=10 * PT,
                                line_spacing=FixedSpacing(12 * PT),
                                indent_first=0.125 * INCH,
                                space_above=0 * PT,
                                space_below=0 * PT,
                                justify=BOTH)

# set style defaults

#TextStyle.attributes['kerning'] = False
#TextStyle.attributes['ligatures'] = False
ParagraphStyle.attributes['typeface'] = styles['body'].typeface
ParagraphStyle.attributes['hyphen_lang'] = 'en_US'
ParagraphStyle.attributes['hyphen_chars'] = 4

styles['math'] = MathStyle(fonts=mathfonts)
Example #3
0

class IndexTerms(Paragraph):
    def __init__(self, terms):
        label = SingleStyledText("Index Terms \N{EM DASH} ", BOLD_ITALIC_STYLE)
        text = ", ".join(sorted(terms)) + "."
        text = text.capitalize()
        return super().__init__(label + text)


styles('abstract',
       ClassSelector(Abstract),
       base='body',
       font_weight=BOLD,
       font_size=9 * PT,
       line_spacing=FixedSpacing(10 * PT),
       indent_first=0.125 * INCH,
       space_above=0 * PT,
       space_below=0 * PT,
       justify=BOTH)

styles('index terms', ClassSelector(IndexTerms), base='abstract')

# input parsing
# ----------------------------------------------------------------------------

CustomElement, NestedElement = element_factory(xml_frontend)


class Section(CustomElement):
    def parse(self):