weasyprint 64.1__py3-none-any.whl → 65.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
weasyprint/text/fonts.py CHANGED
@@ -208,14 +208,23 @@ class FontConfiguration:
208
208
  match = SubElement(root, 'match', target='font')
209
209
  test = SubElement(match, 'test', name='file', compare='eq')
210
210
  SubElement(test, 'string').text = str(font_path)
211
- edit = SubElement(match, 'edit', name='fontfeatures', mode=mode)
212
211
  descriptors = {
213
212
  rules[0][0].replace('-', '_'): rules[0][1] for rules in
214
213
  rule_descriptors.get('font_variant', [])}
215
214
  settings = rule_descriptors.get('font_feature_settings', 'normal')
216
215
  features = font_features(font_feature_settings=settings, **descriptors)
217
- for key, value in features.items():
218
- SubElement(edit, 'string').text = f'{key} {value}'
216
+ if features:
217
+ edit = SubElement(match, 'edit', name='fontfeatures', mode=mode)
218
+ for key, value in features.items():
219
+ SubElement(edit, 'string').text = f'{key} {value}'
220
+ if unicode_ranges := rule_descriptors.get('unicode_range'):
221
+ edit = SubElement(match, 'edit', name='charset', mode=mode)
222
+ plus = SubElement(edit, 'plus')
223
+ for unicode_range in unicode_ranges:
224
+ charset = SubElement(plus, 'charset')
225
+ range_ = SubElement(charset, 'range')
226
+ for value in (unicode_range.start, unicode_range.end):
227
+ SubElement(range_, 'int').text = f'0x{value:x}'
219
228
  header = (
220
229
  b'<?xml version="1.0"?>',
221
230
  b'<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">')
@@ -5,7 +5,7 @@ from math import inf
5
5
 
6
6
  import pyphen
7
7
 
8
- from .constants import LST_TO_ISO, PANGO_WRAP_MODE
8
+ from .constants import LST_TO_ISO, PANGO_DIRECTION, PANGO_WRAP_MODE
9
9
  from .ffi import FROM_UNITS, TO_UNITS, ffi, gobject, pango, pangoft2, unicode_to_char_p
10
10
  from .fonts import font_features, get_font_description
11
11
 
@@ -76,6 +76,8 @@ class Layout:
76
76
  pango.pango_font_map_create_context(font_map),
77
77
  gobject.g_object_unref)
78
78
  pango.pango_context_set_round_glyph_positions(pango_context, False)
79
+ pango.pango_context_set_base_dir(
80
+ pango_context, PANGO_DIRECTION[style['direction']])
79
81
 
80
82
  if style['font_language_override'] != 'normal':
81
83
  lang_p, lang = unicode_to_char_p(LST_TO_ISO.get(
@@ -96,6 +98,7 @@ class Layout:
96
98
  self.layout = ffi.gc(
97
99
  pango.pango_layout_new(pango_context),
98
100
  gobject.g_object_unref)
101
+ pango.pango_layout_set_auto_dir(self.layout, False)
99
102
  pango.pango_layout_set_font_description(self.layout, font_description)
100
103
 
101
104
  text_decoration = style['text_decoration_line']
@@ -187,13 +190,11 @@ class Layout:
187
190
  pango.pango_layout_set_text(self.layout, text, -1)
188
191
 
189
192
  space_spacing = int(word_spacing * TO_UNITS + letter_spacing)
190
- position = bytestring.find(b' ')
191
193
  # Pango gives only half of word-spacing on boundaries
192
194
  boundary_positions = (0, len(bytestring) - 1)
193
- while position != -1:
194
- factor = 1 + (position in boundary_positions)
195
- add_attr(position, position + 1, factor * space_spacing)
196
- position = bytestring.find(b' ', position + 1)
195
+ for match in re.finditer(' |\u00a0'.encode(), bytestring):
196
+ factor = 1 + (match.start() in boundary_positions)
197
+ add_attr(match.start(), match.end(), factor * space_spacing)
197
198
 
198
199
  if word_breaking:
199
200
  attr = pango.pango_attr_insert_hyphens_new(False)
@@ -213,7 +214,7 @@ class Layout:
213
214
  layout.set_text(' ' * self.style['tab_size'])
214
215
  line, _ = layout.get_first_line()
215
216
  width, _ = line_size(line, self.style)
216
- width = int(round(width))
217
+ width = round(width)
217
218
  else:
218
219
  width = int(self.style['tab_size'].value)
219
220
  # 0 is not handled correctly by Pango
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: weasyprint
3
- Version: 64.1
3
+ Version: 65.1
4
4
  Summary: The Awesome Document Factory
5
5
  Keywords: html,css,pdf,converter
6
6
  Author-email: Simon Sapin <simon.sapin@exyr.org>
@@ -30,7 +30,7 @@ Requires-Dist: pydyf >=0.11.0
30
30
  Requires-Dist: cffi >=0.6
31
31
  Requires-Dist: tinyhtml5 >=2.0.0b1
32
32
  Requires-Dist: tinycss2 >=1.4.0
33
- Requires-Dist: cssselect2 >=0.1
33
+ Requires-Dist: cssselect2 >=0.8.0
34
34
  Requires-Dist: Pyphen >=0.9.1
35
35
  Requires-Dist: Pillow >=9.1.0
36
36
  Requires-Dist: fonttools[woff] >=4.0.0
@@ -1,60 +1,60 @@
1
- weasyprint/__init__.py,sha256=elGPspiq8Urexan8_lM1IBSjRcptb6ILZhMxOnZYhic,17338
1
+ weasyprint/__init__.py,sha256=MrV26630NkuBXozSOqGdsFZWOFI6arULa1nSj-7EYM8,17409
2
2
  weasyprint/__main__.py,sha256=WaRdNsuuTBCJlny8AgqF9I_0Mnx5GseQEFA5lXimErw,7114
3
3
  weasyprint/anchors.py,sha256=yXEZD0uFsCAdDjC07cHgWqRuGOSsOsmmmk4omZZecAo,6428
4
4
  weasyprint/document.py,sha256=pUwJKcUp3tmgxh155RsQpS3kVUMuXWZfXCOziqQwaNc,17131
5
5
  weasyprint/html.py,sha256=om7dvhx12ecunTaVclmWejkr5nPQF1BZmeH7jqQ_4GM,11590
6
- weasyprint/images.py,sha256=NupVZkwBFqZa_kp4UXgaFK-NZtX8SZyB81j1lQMp58g,35565
6
+ weasyprint/images.py,sha256=PI6xXN8z7vB79wK4RB9x3bLDwpPw7dQHZlzV4mLzqjM,35555
7
7
  weasyprint/logger.py,sha256=z1q548fX5shfAyLoMLeM9ozWGKgoBTKQsdlTtfRE_9U,1824
8
8
  weasyprint/matrix.py,sha256=v1BPtyn_-S_4TrAUgzOOR-viUXgdqsABKRndCEprkPc,1909
9
- weasyprint/stacking.py,sha256=TN4Bg6pRIUFdT7B9FKwRwNPTM6Tqj0u-miuNamxpCI4,5601
9
+ weasyprint/stacking.py,sha256=oFB1-UHHeY8jO9nnS-IU5KK55azQ7V5QjEHYWGSqGW0,5628
10
10
  weasyprint/urls.py,sha256=yf6pXTic73l_nZiYkX03bfgFl2HdQlH0rCs4bSY5tjQ,9960
11
11
  weasyprint/css/__init__.py,sha256=6w2UoHQSoZ76eCuferHS3R0M8nAzFgab1NwR1vpy9LA,51599
12
- weasyprint/css/computed_values.py,sha256=dMznkSRT1bczjGdCF0bqiUURI5KK5YadMYeftmdcFeo,27306
12
+ weasyprint/css/computed_values.py,sha256=O3USpx2ZH7Ff_FN5oIjn40lNMHj3zdThR0r51HRniIQ,27301
13
13
  weasyprint/css/counters.py,sha256=DHSrGJr2ktpZLCc-JYIiE67ak0TORsKSBKkjju-qwdE,11373
14
- weasyprint/css/html5_ph.css,sha256=u2VD0dJ5nAL3ubnQVd7q9Ii649T8vDKQ539I8h1Fh5o,7407
15
- weasyprint/css/html5_ua.css,sha256=1QuLfrHzSjksbLYKwlOBXK2QqEB-eRNrKF6YXcbebqU,31358
16
- weasyprint/css/html5_ua_form.css,sha256=WvUjNE1JUmikG7cLs0UOAo3aNW89nan5oo_FRwTZ2z0,241
14
+ weasyprint/css/html5_ph.css,sha256=l8t4ZN3KoevKx0UEfNw3_vgVjArcII6y5DZXZolWaw0,4629
15
+ weasyprint/css/html5_ua.css,sha256=qGUxl1eIu3tQRVu2fVMnC_oo_CbMYoukAC8dSvH1ErM,19111
16
+ weasyprint/css/html5_ua_form.css,sha256=0JLdrpmhokuy9IFhK2L1ZwbTa2G3ibXTXcGuCkAw80Y,288
17
17
  weasyprint/css/media_queries.py,sha256=wHPteZ9Gs2ttuA5kZpMDgRtFHnhYZVwrFXrhKgmR-4g,1072
18
18
  weasyprint/css/properties.py,sha256=5nywzyQjLOSKKGxsvJsVgoyQfMsLSQarMeso-WRgYlU,11593
19
19
  weasyprint/css/targets.py,sha256=5Ofw1RrmPsfQjDuZ1FCgktspGUai3wJmNa03MbT2sOI,8853
20
20
  weasyprint/css/utils.py,sha256=bRZYaMDRGtlHqyQouzZRAA-SfMep6_xGe-nnIbUUG_Y,25105
21
21
  weasyprint/css/validation/__init__.py,sha256=tuyJXGP6TbUdVi_KtxLj0nFa49vGF5KNZkXI8HxR_cw,8468
22
- weasyprint/css/validation/descriptors.py,sha256=3Eu8TgxNnH_OhE4ibQYgviecA9A1QimkSskXqyse410,10961
22
+ weasyprint/css/validation/descriptors.py,sha256=VOLmaKZP76mTVwMCqMzVgfzP1JaI4zYWdEIFLNXCfYQ,11160
23
23
  weasyprint/css/validation/expanders.py,sha256=9SJiVhoK8HESwwmN2IqXj-bmaC9p4SSD15tqmfMITnE,39263
24
24
  weasyprint/css/validation/properties.py,sha256=1xoYf0rEs4dKZDeZT7Qh-Z3_GmrBJ1pQ8ZozEIJOgyE,66811
25
25
  weasyprint/draw/__init__.py,sha256=JGk_UCt045atrZPkLlUDNNlqeV7ngze487-v_wqwG0w,22914
26
- weasyprint/draw/border.py,sha256=e66tKNdvYH8g29n57hPKr59GXa3rH6Dzj1CEmlC1520,27930
26
+ weasyprint/draw/border.py,sha256=MRG9E7Bi_QLGkSVEgEJ7D1QlFbs3atkATAAA2s9a6wY,27910
27
27
  weasyprint/draw/color.py,sha256=ZjqiMDSNIFOLsIz2qP30HrFMbVqeEmYAKxcU6tl4GBs,1449
28
28
  weasyprint/draw/stack.py,sha256=o9VB8GtAdLfbrzQpZ1SWiV_hneHAz64egURawBLYbMo,281
29
- weasyprint/draw/text.py,sha256=OBnOvC6NCHg-DZBYSA2OQ1vWwFrkWUzyoMfxd-RPmhA,11231
29
+ weasyprint/draw/text.py,sha256=L_5VqeAzz2PpPCdBhl7Dfza08NteNU0SfbAwITEaroE,11419
30
30
  weasyprint/formatting_structure/boxes.py,sha256=U3HPSaM9mbzQSbZCo_ZQp8VAS48KVOsQaH0g08iBGpc,26279
31
- weasyprint/formatting_structure/build.py,sha256=JwDU1ndfeBfnrYcaydM0HiVVFXzfVt5gLf-1VOsABFo,56607
32
- weasyprint/layout/__init__.py,sha256=hRt1LlxYuCdRG8pOcQXkePI4iHtqkoQfSiFnhk9Fjzk,15761
33
- weasyprint/layout/absolute.py,sha256=f9d9AZ7kAqXnMHxfRHHwu_L2nhee3ZtiZZm00A7BXDI,13966
31
+ weasyprint/formatting_structure/build.py,sha256=c86cB4K8JL2oVMogFOWQn4V_GIhN1yEQL0z_wMqgPjo,56697
32
+ weasyprint/layout/__init__.py,sha256=TNzbltiiuLVLLOlFDTLbwVlOoS7OnOzNPmHtWeaLk3M,16292
33
+ weasyprint/layout/absolute.py,sha256=Caek_aFJDz5NLYFxTfEYO1-l7ITUMcx6TNDjNpE15-Y,13981
34
34
  weasyprint/layout/background.py,sha256=0ZRFZGAJnvF9eULIMyt8oy6lDqE-hKSbcyomQPx8HsQ,10008
35
- weasyprint/layout/block.py,sha256=TCzvUUNNqit-QYBdPr1IrKWWWBRFl7NBGNNBotiq9dU,45237
36
- weasyprint/layout/column.py,sha256=Oi-GzsZMpWZnR1SDAIBsc1o6Jz67gUVdk0m_t3i8O8Y,17322
37
- weasyprint/layout/flex.py,sha256=vwyISpZvDu67yQakAaE03Kcwcgeuig5ZDpDu6oWCrg8,53771
38
- weasyprint/layout/float.py,sha256=_ObCohsvfRvp9P_t_4WIkqdwfMPdIbHWPIrlT7uNGeM,9146
35
+ weasyprint/layout/block.py,sha256=jwQS2jGCoQ0hSvCsWRPFK7Y3wad-Ucgzv0fzf-4DKm0,45388
36
+ weasyprint/layout/column.py,sha256=P_863u0_vFYzig9tfBUMI8ZCpXlbx9SLoYekbZ5vg5Y,17299
37
+ weasyprint/layout/flex.py,sha256=uAm4DAOvomSg0aX1oEse8-vT3M_fVI-IGFO1yatBH6E,42630
38
+ weasyprint/layout/float.py,sha256=xo9CuXfvrC5jE8rnCVT2ShNRAXl7vAISq41oqkvvbK8,9266
39
39
  weasyprint/layout/grid.py,sha256=hzmsWXWQYw5rdy2XA_O_4Hz7CWCVle0RnnWTkugPEvY,54729
40
- weasyprint/layout/inline.py,sha256=4OK3eoj_77ja7oBkgDh81t3JSCB-CETSwzCDA8ivEvc,48167
40
+ weasyprint/layout/inline.py,sha256=aFxHM0b-fQCSIWyXgf3dLHM90sQq8AOcS1ELx7sDpbc,48217
41
41
  weasyprint/layout/leader.py,sha256=wklI0aLyTx0VJhqU7D_FxtJpfe7dXswcN-VApAusM-Q,2825
42
42
  weasyprint/layout/min_max.py,sha256=JdXJG9ISO_RsfeHua_-3g477a16I-NrnYuwH_tQwq4o,1527
43
- weasyprint/layout/page.py,sha256=W3TLuK1Haa35WbA-ljQxsH2xffPrVLfJcEla96P8ez8,39690
44
- weasyprint/layout/percent.py,sha256=_UdU9eMTvRTRZYRiqGvOXCtB9alxbCU0huf6HKPhabo,6173
45
- weasyprint/layout/preferred.py,sha256=LGXBVZG5eKLEU2TxbeVBtt1yvPUWs5CaKUKPmzKCFP8,31011
43
+ weasyprint/layout/page.py,sha256=JLKoYzGmrULONv11KLLrQuRFaTRK7XJZocuUsB0EGKs,39908
44
+ weasyprint/layout/percent.py,sha256=2XzT_Y-fu7OVt2Ut1f9T1Tt9S4ftRr4x7wL3agvEJus,5626
45
+ weasyprint/layout/preferred.py,sha256=cSOraU8g7i_8dDUifJhvKk0gxHBdPXqGZjjIgs8LVIs,31040
46
46
  weasyprint/layout/replaced.py,sha256=ucAd6VMKIEryjnwK8ciKbUoE2yK29-ggdYlGW3KPDXk,11178
47
47
  weasyprint/layout/table.py,sha256=qomzhxW0m4WaZ4Vis4GW7bfNQ6JP7yRSt7aze-dNcbU,47431
48
48
  weasyprint/pdf/__init__.py,sha256=pEehJ-JDH0ZepUFtj3Fz75BvVGBf7psduIbnph08PRo,12022
49
49
  weasyprint/pdf/anchors.py,sha256=Slgq3_IBiIBg3J7zzHMajISBb7ph2AVezIs-lW_tB9I,17386
50
50
  weasyprint/pdf/debug.py,sha256=reLw6U6hK94FOVNYW8psdt_SFN11iIe1rhYkr6sURF4,1407
51
- weasyprint/pdf/fonts.py,sha256=gheeTH3tTj5Vu77VQMtQ6px9E6iNu9vxQzcD1BstePE,24692
51
+ weasyprint/pdf/fonts.py,sha256=D_T0JWFnofSDqdU29noTg8IbyenN9SlaULxSTPlg1JQ,24777
52
52
  weasyprint/pdf/metadata.py,sha256=r5ATj8Lv_6Ib-RbA2zgazyo6yJwF-LoqoNAWUchV4qE,4168
53
53
  weasyprint/pdf/pdfa.py,sha256=97J7nlKHmP5vdSBz0X0cDnGnqAPZ5qqoQ7ArZsdWRT8,3626
54
54
  weasyprint/pdf/pdfua.py,sha256=mCgXdr1RUe6hffg6Jsu4LzmDtBNyJTtj32wTouBeJy4,5236
55
55
  weasyprint/pdf/sRGB2014.icc,sha256=OEuDLeNBIGZ0O1KnXukGtvufuNngnpNvwsQyI4Fcbgo,3024
56
56
  weasyprint/pdf/stream.py,sha256=-s_ZT2xDsKzhjj9cgMnf4OkvVp88EnKBwzAvxKwOwWs,11301
57
- weasyprint/svg/__init__.py,sha256=0ADPt-G4mWMKcLY58xj3qMN0220g-YqvSEr3YLdJYmY,29802
57
+ weasyprint/svg/__init__.py,sha256=smY5L9f68vf3BTZL1KTB0fz5JcwFM0kxFgywgRAOxdE,30012
58
58
  weasyprint/svg/bounding_box.py,sha256=ti9BZ8Pxr4K_RZr41vrcDeBu1Mz9CReh8ECbUzzh_0s,12999
59
59
  weasyprint/svg/css.py,sha256=AUsIim2rOmRGLgFuiWm4EzXwnrRlThczfM17Uq2MRUg,3832
60
60
  weasyprint/svg/defs.py,sha256=u_VQ-b6045qCBuLNEe9lwJWHcOsYYO4wBwsSWiXEZm0,20978
@@ -63,12 +63,12 @@ weasyprint/svg/path.py,sha256=Z-T6kbUU3pyHhzVV0JSBgO--XaCGXLsH-cS9iAsITMM,10064
63
63
  weasyprint/svg/shapes.py,sha256=NDo0KMnwrm0hj3BOmfrKjRZo4iJF9o-MeUhZ5avANco,3845
64
64
  weasyprint/svg/text.py,sha256=JVrLSpDtU3P9IgkG50g_lQVi0L5uNbXoEDh6tk3o2z4,6404
65
65
  weasyprint/svg/utils.py,sha256=RkmPhTAqBfn85YACP3u9m4Rs8hyqZyQLBLME1q8psyw,6969
66
- weasyprint/text/constants.py,sha256=5C1LzxrP2kVe4TsrjrpW_MQxSyEV_ONXjPCB3FJgC-M,14092
67
- weasyprint/text/ffi.py,sha256=3_t4Esj16_LiMoHwHyXNMG0fHVvleCy2MbQHAs87cxw,17852
68
- weasyprint/text/fonts.py,sha256=chphT780TvE3JuZcWhZRsMsgUbfS708tdFyH5K8OLUA,16911
69
- weasyprint/text/line_break.py,sha256=g_8cSpkZjO5mADU0jvApcn-EFcT96RCI1G2tiJtuy88,24627
70
- weasyprint-64.1.dist-info/entry_points.txt,sha256=wgDp3XXzFywdYgI5vUWMp1zAwx1sZXXH0FTUQbFOq6A,55
71
- weasyprint-64.1.dist-info/licenses/LICENSE,sha256=v9FOzPphAFdUYOaFVWsYM5nUvTNZBOPJUhsBFtIcVNo,1534
72
- weasyprint-64.1.dist-info/WHEEL,sha256=_2ozNFCLWc93bK4WKHCO-eDUENDlo-dgc9cU3qokYO4,82
73
- weasyprint-64.1.dist-info/METADATA,sha256=zhSoS-a58cPe3oAmdYnQ3822Q_SC_dVd1W8-RqGYWt8,3705
74
- weasyprint-64.1.dist-info/RECORD,,
66
+ weasyprint/text/constants.py,sha256=ifPeTG_us_sSgWuM-WTQgDrrAgwwnohYR63HhS_1dIM,14191
67
+ weasyprint/text/ffi.py,sha256=0FWxNeYn0Nub-fKHWElFcQc9GmlgiLAKvS82hpDxsAs,18282
68
+ weasyprint/text/fonts.py,sha256=Qa7HxrQeJN84XXBKgJitcRdVMRA9vz1QY8Kl3StRCE4,17460
69
+ weasyprint/text/line_break.py,sha256=FXlHDk8A4lBB-i3wqgl7RO66P3TPpFzkkFbmu-FHGKg,24735
70
+ weasyprint-65.1.dist-info/entry_points.txt,sha256=wgDp3XXzFywdYgI5vUWMp1zAwx1sZXXH0FTUQbFOq6A,55
71
+ weasyprint-65.1.dist-info/licenses/LICENSE,sha256=v9FOzPphAFdUYOaFVWsYM5nUvTNZBOPJUhsBFtIcVNo,1534
72
+ weasyprint-65.1.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
73
+ weasyprint-65.1.dist-info/METADATA,sha256=v9-RDucK9Kk_K1t1UO7i1KRMr7GRF-bbdCdt9XGn-qg,3707
74
+ weasyprint-65.1.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: flit 3.11.0
2
+ Generator: flit 3.12.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any