"""Test the fonts features.""" from .testing_utils import assert_no_logs, render_pages @assert_no_logs def test_font_face(): page, = render_pages(''' abc''') html, = page.children body, = html.children line, = body.children assert line.width == 3 * 16 @assert_no_logs def test_kerning_default(): # Kerning and ligatures are on by default page, = render_pages(''' kkliga''') html, = page.children body, = html.children line, = body.children span1, span2 = line.children assert span1.width == 1.5 * 16 assert span2.width == 1.5 * 16 @assert_no_logs def test_ligatures_word_space(): # Kerning and ligatures are on for text with increased word spacing # https://github.com/Kozea/WeasyPrint/issues/1469 page, = render_pages(''' aa liga aa''') html, = page.children body, = html.children assert len(body.children) == 1 @assert_no_logs def test_kerning_deactivate(): # Deactivate kerning page, = render_pages(''' kkkk''') html, = page.children body, = html.children line, = body.children span1, span2 = line.children assert span1.width == 1.5 * 16 assert span2.width == 2 * 16 @assert_no_logs def test_kerning_ligature_deactivate(): # Deactivate kerning and ligatures page, = render_pages(''' kk ligakk liga''') html, = page.children body, = html.children line, = body.children span1, span2 = line.children assert span1.width == (1.5 + 1 + 1.5) * 16 assert span2.width == (2 + 1 + 4) * 16 @assert_no_logs def test_font_face_descriptors(): page, = render_pages( ''' ''' 'kk' 'subs' 'dlig' 'onum' 'zero') html, = page.children body, = html.children line, = body.children kern, subs, dlig, onum, zero = line.children assert kern.width == 1.5 * 16 assert subs.width == 1.5 * 16 assert dlig.width == 1.5 * 16 assert onum.width == 1.5 * 16 assert zero.width == 1.5 * 16 @assert_no_logs def test_woff_simple(): page, = render_pages(( ''' ''' 'woff font' 'woff font' 'woff font' 'woff font')) html, = page.children body, = html.children line, = body.children span1, span2, span3, span4 = line.children # otf font matches woff font assert span1.width == span2.width # otf font matches woff font loaded from cache assert span1.width == span3.width # the default font does not match the loaded fonts assert span1.width != span4.width