def handle_letter(letter, mode): letter_paper = draw_letter( letter, mode, fixed_width=30.0, show_template=True, fuse=False, ) letter_paper.translate((5, 0), bounds=False) p = Pen() p.move_to((-8, 3)) p.text( letter.case, 6.0, font, gray, centered=True, ) p.move_to((-8, -3)) p.text( ', '.join(lookup(letter.case)), 6.0, font, gray, centered=True, ) letter_paper.merge(p.paper) return letter_paper
def test_text(): p = Pen() p.move_to((0, 0)) p.text('abcd', 1, 'sans-serif') svg_data = p.paper.format_svg(0) assert ('<text x="0" y="0" font-family="sans-serif" font-size="1" ' 'fill="#000000">abcd</text>') in svg_data
def test_text_centered(): p = Pen() p.move_to((0, 0)) p.text('abcd', 1, 'sans-serif', centered=True) svg_data = p.paper.format_svg(0) assert ('<text x="0" y="0" font-family="sans-serif" font-size="1" ' 'fill="#000000" text-anchor="middle">abcd</text>') in svg_data
def test_text(): p = Pen() p.move_to((0, 0)) p.text('abcd', 1, 'sans-serif') svg_data = p.paper.format_svg(0) assert ( '<text x="0" y="0" font-family="sans-serif" font-size="1" ' 'fill="#000000">abcd</text>' ) in svg_data
def test_text_centered(): p = Pen() p.move_to((0, 0)) p.text('abcd', 1, 'sans-serif', centered=True) svg_data = p.paper.format_svg(0) assert ( '<text x="0" y="0" font-family="sans-serif" font-size="1" ' 'fill="#000000" text-anchor="middle">abcd</text>' ) in svg_data
def test_text_translate(): p = Pen() p.move_to((0, 0)) p.text('abcd', 1) paper = p.paper paper.translate((2, 3)) svg_data = paper.format_svg(0) assert ('<text x="2" y="-3" font-family="sans-serif" font-size="1" ' 'fill="#000000">abcd</text>') in svg_data
def test_text_translate(): p = Pen() p.move_to((0, 0)) p.text('abcd', 1) paper = p.paper paper.translate((2, 3)) svg_data = paper.format_svg(0) assert ( '<text x="2" y="-3" font-family="sans-serif" font-size="1" ' 'fill="#000000">abcd</text>' ) in svg_data
def test_text_merge(): p = Pen() p.move_to((0, 0)) p.text('abcd', 1) paper1 = p.paper assert '<text' in paper1.format_svg(0) paper2 = Paper() paper2.merge(paper1) assert '<text' in paper2.format_svg(0) paper3 = Paper() paper3.merge_under(paper1) assert '<text' in paper3.format_svg(0)
for consonant_class in consonants: letter = consonant_class(se.Normal, be.Normal) letter_paper = draw_letter( letter, mode, fixed_width=27.0, show_template=True, ) letter_paper.translate((5, 0), bounds=False) p = Pen() p.move_to((-5, 0)) p.text( convert_ascii_to_html(consonant_class.pronunciation), 8.0, 'Caudex', '#233042', centered=True, ) letter_paper.merge(p.paper) papers.append(letter_paper) page = typeset( papers, letter_spacing=1.0, letters_per_line=6, line_spacing=3.5, page_margin=5.0, ) print(page.format_svg(4, resolution=1000 / page.bounds().width))
from canoepaddle import Pen, StrokeOutlineMode from ithkuil.writing.consonant import consonants from ithkuil.writing.typeset import draw_letter, typeset from ithkuil.phonology import convert_ascii_to_html import ithkuil.writing.side_ending as se import ithkuil.writing.bottom_ending as be font = "Caudex" font_size = 8 red = "#d6041a" black = "#260003" gray = "#233042" mode = StrokeOutlineMode(1.0, 0.2, red, black) papers = [] for consonant_class in consonants: letter = consonant_class(se.Normal, be.Normal) letter_paper = draw_letter(letter, mode, fixed_width=27.0, show_template=True) letter_paper.translate((5, 0), bounds=False) p = Pen() p.move_to((-5, 0)) p.text(convert_ascii_to_html(consonant_class.pronunciation), 8.0, "Caudex", "#233042", centered=True) letter_paper.merge(p.paper) papers.append(letter_paper) page = typeset(papers, letter_spacing=1.0, letters_per_line=6, line_spacing=3.5, page_margin=5.0) print(page.format_svg(4, resolution=1000 / page.bounds().width))
paper.override_bounds(bounds) paper.translate((-0.5, 0)) # Generate text indicating pattern and stem. pen = Pen() pen.paper = paper if letter.side_ending_class.relation == 'UNFRAMED': pen.move_to((2, 9.5)) else: pen.move_to((2, 11.5)) text = '{} {}'.format( letter.side_ending_class.pattern, letter.side_ending_class.stem, ) pen.text(text, font_size, font, gray, centered=True) papers.append(paper) page = typeset( papers, letter_spacing=4.0, letters_per_line=9, line_spacing=5.0, page_margin=5.0, ) # Add row text. page_bounds = page.bounds() pen = Pen() pen.paper = page
paper.override_bounds(bounds) paper.translate((-0.5, 0)) # Generate text indicating pattern and stem. pen = Pen() pen.paper = paper if letter.side_ending_class.relation == 'UNFRAMED': pen.move_to((2, 9.5)) else: pen.move_to((2, 11.5)) text = '{} {}'.format( letter.side_ending_class.pattern, letter.side_ending_class.stem, ) pen.text(text, font_size, font, gray, centered=True) papers.append(paper) page = typeset( papers, letter_spacing=4.0, letters_per_line=9, line_spacing=5.0, page_margin=5.0, ) # Add row text. page_bounds = page.bounds() pen = Pen()