Upgrading weasyprint 52 to 53
Breaking52.5 → 53.4Breaking2Deprecated2New5Changed6Fixed40Other5
BreakingUpgrade verdict
2 breaking changes.
In plain terms
- weasyprint.tools have been removed.
- Document.resolve_links, Document.make_bookmark_tree and Document.add_hyperlinks have been removed.
- --format and --resolution options have been deprecated, PDF is the only output format supported.
- --optimize-images option has been deprecated and replaced by --optimize-size, allowing images, fonts, all and none values.
Must act 4 items need code or config changes
Adds fonttools >=4.0.0, pydyf >=0.0.3.
Drops cairocffi, cairosvg, setuptools.
Also installs brotli, zopfli.
No longer installs defusedxml.
What you must change
Breaking2
weasyprint.tools have been removed.
weasyprint.toolsDocument.resolve_links, Document.make_bookmark_tree and Document.add_hyperlinks have been removed.
Document.resolve_linksDocument.make_bookmark_treeDocument.add_hyperlinksDeprecations to plan for
Deprecated2
--format and --resolution options have been deprecated, PDF is the only output format supported.
--format--resolution--optimize-images option has been deprecated and replaced by --optimize-size, allowing images, fonts, all and none values.
--optimize-images--optimize-sizeimagesfontsallnoneAPI changes
Generated by DepDelta from published Python source. Not mixed with prose notes.
- removed:
method HTML.write_image_surface(stylesheets=…, resolution=…, presentational_hints=…, optimize_images=…, font_config=…, counter_style=…, image_cache=…) - removed:
method HTML.write_png(target=…, stylesheets=…, resolution=…, presentational_hints=…, optimize_images=…, font_config=…, counter_style=…, image_cache=…) - changed:
method HTML.render(stylesheets=…, enable_hinting=…, presentational_hints=…, optimize_images=…, font_config=…, counter_style=…, image_cache=…) → method HTML.render(stylesheets=…, presentational_hints=…, optimize_size=…, font_config=…, counter_style=…, image_cache=…) - changed:
method HTML.write_pdf(target=…, stylesheets=…, zoom=…, attachments=…, presentational_hints=…, optimize_images=…, font_config=…, counter_style=…, image_cache=…) → method HTML.write_pdf(target=…, stylesheets=…, zoom=…, attachments=…, presentational_hints=…, optimize_size=…, font_config=…, counter_style=…, image_cache=…) - added:
variable __version__
- added:
class AnonymousStyle(Style) - added:
class ComputedStyle(Style) - added:
class Style(dict) - added:
constructor AnonymousStyle(parent_style) - added:
constructor ComputedStyle(parent_style, cascaded, element, pseudo_type, root_style, base_url) - added:
method AnonymousStyle.copy() - added:
method ComputedStyle.copy() - added:
property Style.variables
- removed:
function compute(element, pseudo_type, specified, computed, parent_style, root_style, base_url, target_collector) - changed:
function anchor(computer, name, values) → function anchor(style, name, values) - changed:
function background_image(computer, name, values) → function background_image(style, name, values) - changed:
function background_size(computer, name, values) → function background_size(style, name, values) - changed:
function bleed(computer, name, value) → function bleed(style, name, value) - changed:
function bookmark_label(computer, name, values) → function bookmark_label(style, name, values) - changed:
function border_radius(computer, name, values) → function border_radius(style, name, values) - changed:
function border_width(computer, name, value) → function border_width(style, name, value) - changed:
function break_before_after(computer, name, value) → function break_before_after(style, name, value) - changed:
function column_gap(computer, name, value) → function column_gap(style, name, value) - changed:
function column_width(computer, name, value) → function column_width(style, name, value) - changed:
function compute_attr_function(computer, values) → function compute_attr_function(style, values) - changed:
function compute_float(computer, name, value) → function compute_float(style, name, value) - changed:
function compute_position(computer, name, values) → function compute_position(style, name, values) - changed:
function content(computer, name, values) → function content(style, name, values) - changed:
function display(computer, name, value) → function display(style, name, value) - changed:
function font_size(computer, name, value) → function font_size(style, name, value) - changed:
function font_weight(computer, name, value) → function font_weight(style, name, value) - changed:
function lang(computer, name, values) → function lang(style, name, values) - changed:
function length(computer, name, value, font_size=…, pixels_only=…) → function length(style, name, value, font_size=…, pixels_only=…) - changed:
function length_or_percentage_tuple(computer, name, values) → function length_or_percentage_tuple(style, name, values) - changed:
function length_tuple(computer, name, values) → function length_tuple(style, name, values) - changed:
function line_height(computer, name, value) → function line_height(style, name, value) - changed:
function link(computer, name, values) → function link(style, name, values) - changed:
function pixel_length(computer, name, value) → function pixel_length(style, name, value) - changed:
function string_set(computer, name, values) → function string_set(style, name, values) - changed:
function tab_size(computer, name, value) → function tab_size(style, name, value) - changed:
function transform(computer, name, value) → function transform(style, name, value) - changed:
function vertical_align(computer, name, value) → function vertical_align(style, name, value) - changed:
function word_spacing(computer, name, value) → function word_spacing(style, name, value)
- removed:
method Document.add_hyperlinks(links, anchors, context, scale) - removed:
method Document.resolve_links() - removed:
method Document.write_image_surface(resolution=…) - removed:
method Document.write_png(target=…, resolution=…) - changed:
constructor Document(pages, metadata, url_fetcher, font_config) → constructor Document(pages, metadata, url_fetcher, font_config, optimize_size) - changed:
constructor Page(page_box, enable_hinting=…) → constructor Page(page_box) - changed:
method Page.paint(cairo_context, left_x=…, top_y=…, scale=…, clip=…) → method Page.paint(stream, left_x=…, top_y=…, scale=…, clip=…) - added:
class Font - added:
class Matrix(list) - added:
class Stream(pydyf.Stream) - added:
constructor Font(font_hash, file_content, pango_font, index) - added:
constructor Matrix(a=…, b=…, c=…, d=…, e=…, f=…, matrix=…) - added:
constructor Stream(document, page_rectangle, states, x_objects, patterns, shadings, images, *args, **kwargs) - added:
function add_hyperlinks(links, anchors, matrix, pdf, page, names) - added:
function create_bookmarks(bookmarks, pdf, parent=…) - added:
function resolve_links(pages) - added:
method Matrix.transform_point(x, y) - added:
method Stream.add_font(font_hash, font_content, pango_font, index) - added:
method Stream.add_group(bounding_box) - added:
method Stream.add_image(pillow_image, image_rendering, optimize_size) - added:
method Stream.add_pattern(width, height, repeat_width, repeat_height, matrix) - added:
method Stream.add_shading() - added:
method Stream.begin_text() - added:
method Stream.end_text() - added:
method Stream.get_fonts() - added:
method Stream.pop_state() - added:
method Stream.push_state() - added:
method Stream.set_alpha(alpha, stroke=…, fill=…) - added:
method Stream.set_color_rgb(r, g, b, stroke=…) - added:
method Stream.set_font_size(font, size) - added:
method Stream.set_state(state) - added:
method Stream.transform(a=…, b=…, c=…, d=…, e=…, f=…) - added:
property Font.flags - added:
property Matrix.determinant - added:
property Matrix.invert - added:
property Matrix.values - added:
property Stream.ctm
- removed:
function hsv2rgb(hue, saturation, value) - removed:
function rgb2hsv(red, green, blue) - removed:
variable CROP - removed:
variable CROSS - changed:
function clip_border_segment(context, enable_hinting, style, width, side, border_box, border_widths=…, radii=…) → function clip_border_segment(stream, style, width, side, border_box, border_widths=…, radii=…) - changed:
function draw_background(context, bg, enable_hinting, clip_box=…, bleed=…, marks=…) → function draw_background(stream, bg, clip_box=…, bleed=…, marks=…) - changed:
function draw_background_image(context, layer, image_rendering) → function draw_background_image(stream, layer, image_rendering) - changed:
function draw_border(context, box, enable_hinting) → function draw_border(stream, box) - changed:
function draw_box_background_and_border(context, page, box, enable_hinting) → function draw_box_background_and_border(stream, page, box) - changed:
function draw_collapsed_borders(context, table, enable_hinting) → function draw_collapsed_borders(stream, table) - changed:
function draw_inline_level(context, page, box, enable_hinting, offset_x=…, text_overflow=…, block_ellipsis=…) → function draw_inline_level(stream, page, box, offset_x=…, text_overflow=…, block_ellipsis=…) - changed:
function draw_outlines(context, box, enable_hinting) → function draw_outlines(stream, box) - changed:
function draw_page(page, context, enable_hinting) → function draw_page(page, stream) - changed:
function draw_rect_border(context, box, widths, style, color) → function draw_rect_border(stream, box, widths, style, color) - changed:
function draw_replacedbox(context, box) → function draw_replacedbox(stream, box) - changed:
function draw_rounded_border(context, box, style, color) → function draw_rounded_border(stream, box, style, color) - changed:
function draw_stacking_context(context, stacking_context, enable_hinting) → function draw_stacking_context(stream, stacking_context) - changed:
function draw_table_backgrounds(context, page, table, enable_hinting) → function draw_table_backgrounds(stream, page, table) - changed:
function draw_text(context, textbox, enable_hinting, offset_x=…, text_overflow=…, block_ellipsis=…) → function draw_text(stream, textbox, offset_x, text_overflow, block_ellipsis) - changed:
function draw_text_decoration(context, textbox, offset_x, offset_y, thickness, enable_hinting, color) → function draw_text_decoration(stream, textbox, offset_x, offset_y, thickness, color) - changed:
function draw_wave(context, x, y, width, offset_x, radius) → function draw_wave(stream, x, y, width, offset_x, radius) - changed:
function rounded_box_path(context, radii) → function rounded_box_path(stream, radii) - changed:
function stacked(context) → function stacked(stream) - added:
function draw_first_line(stream, textbox, text_overflow, block_ellipsis, x, y)
- removed:
class FontConfiguration - removed:
class FontConfiguration(FontConfiguration) - removed:
constructor FontConfiguration() - removed:
method FontConfiguration.add_font_face(rule_descriptors, url_fetcher) - removed:
variable FONTCONFIG_STRETCH_CONSTANTS - removed:
variable FONTCONFIG_STYLE_CONSTANTS - removed:
variable FONTCONFIG_WEIGHT_CONSTANTS - removed:
variable ZERO_FONTSIZE_CRASHES_CAIRO - removed:
variable fontconfig - removed:
variable pangoft2
- added:
field Box.download_name - added:
field Box.is_attachment - added:
field Box.is_leader
- removed:
variable level - changed:
function get_html_metadata(wrapper_element, base_url) → function get_html_metadata(html) - added:
function handle_svg(element, box, get_image_from_uri, base_url) - added:
variable HTML5_PH - added:
variable HTML5_UA
- removed:
class FakeSurface - removed:
class ScaledSVGSurface(cairosvg.surface.SVGSurface) - removed:
field FakeSurface.context_height - removed:
field FakeSurface.context_width - removed:
field FakeSurface.dpi - removed:
field FakeSurface.font_size - removed:
field Gradient.intrinsic_ratio - removed:
function normalize_stop_postions(positions) - removed:
property ScaledSVGSurface.device_units_per_user_units - removed:
variable IMAGE_RENDERING_TO_FILTER - removed:
variable PATTERN_TYPES - removed:
variable pixbuf - changed:
constructor RasterImage(image_surface) → constructor RasterImage(pillow_image, optimize_size) - changed:
constructor SVGImage(svg_data, base_url, url_fetcher) → constructor SVGImage(string, base_url, url_fetcher, context) - changed:
function get_image_from_uri(cache, url_fetcher, optimize_images, url, forced_mime_type=…) → function get_image_from_uri(cache, url_fetcher, optimize_size, url, forced_mime_type=…, context=…) - changed:
function process_color_stops(gradient_line_size, positions) → function process_color_stops(vector_length, positions) - changed:
method Gradient.draw(context, concrete_width, concrete_height, _image_rendering) → method Gradient.draw(stream, concrete_width, concrete_height, _image_rendering) - changed:
method Gradient.get_intrinsic_size(_image_resolution, _font_size) → method Gradient.get_intrinsic_size(image_resolution, font_size) - changed:
method Gradient.layout(width, height, user_to_device_distance) → method Gradient.layout(width, height) - changed:
method LinearGradient.layout(width, height, user_to_device_distance) → method LinearGradient.layout(width, height) - changed:
method RadialGradient.layout(width, height, user_to_device_distance) → method RadialGradient.layout(width, height) - changed:
method RasterImage.draw(context, concrete_width, concrete_height, image_rendering) → method RasterImage.draw(stream, concrete_width, concrete_height, image_rendering) - changed:
method RasterImage.get_intrinsic_size(image_resolution, _font_size) → method RasterImage.get_intrinsic_size(image_resolution, font_size) - changed:
method SVGImage.draw(context, concrete_width, concrete_height, _image_rendering) → method SVGImage.draw(stream, concrete_width, concrete_height, image_rendering) - changed:
method SVGImage.get_intrinsic_size(_image_resolution, font_size) → method SVGImage.get_intrinsic_size(image_resolution, font_size) - added:
function normalize_stop_positions(positions)
- changed:
constructor LayoutContext(enable_hinting, style_for, get_image_from_uri, font_config, counter_style, target_collector) → constructor LayoutContext(style_for, get_image_from_uri, font_config, counter_style, target_collector)
- added:
function handle_leaders(context, line, containing_block) - added:
function leader_index(box)
- changed:
function shrink_to_fit(context, box, available_width) → function shrink_to_fit(context, box, available_content_width)
- removed:
class PDFDictionary - removed:
class PDFFile - removed:
class PDFFormatter(string.Formatter) - removed:
constructor PDFDictionary(object_number, byte_string) - removed:
constructor PDFFile(fileobj) - removed:
field PDFFile.trailer_re - removed:
function pdf_escape(value) - removed:
function write_pdf_metadata(fileobj, scale, url_fetcher, attachments, attachment_links, pages, finisher) - removed:
method PDFDictionary.get_indirect_dict(key, pdf_file) - removed:
method PDFDictionary.get_indirect_dict_array(key, pdf_file) - removed:
method PDFDictionary.get_type() - removed:
method PDFDictionary.get_value(key, value_re) - removed:
method PDFFile.extend_dict(dictionary, new_content) - removed:
method PDFFile.finish(finished=…) - removed:
method PDFFile.next_object_number() - removed:
method PDFFile.overwrite_object(object_number, byte_string) - removed:
method PDFFile.read_object(object_number) - removed:
method PDFFile.write_new_object(byte_string) - removed:
method PDFFormatter.convert_field(value, conversion) - removed:
method PDFFormatter.vformat(format_string, args, kwargs) - removed:
variable pdf_format
- added:
class Node - added:
class Pattern(SVG) - added:
class SVG - added:
constructor Node(wrapper, style) - added:
constructor Pattern(tree, svg) - added:
constructor SVG(bytestring_svg, url) - added:
export PointError - added:
export apply_filters - added:
export bounding_box - added:
export circle - added:
export clip_path - added:
export color - added:
export draw_gradient_or_pattern - added:
export ellipse - added:
export image - added:
export is_valid_bounding_box - added:
export line - added:
export normalize - added:
export paint_mask - added:
export parse_declarations - added:
export parse_stylesheets - added:
export parse_url - added:
export path - added:
export polygon - added:
export polyline - added:
export preserve_ratio - added:
export rect - added:
export size - added:
export svg - added:
export text - added:
export transform - added:
export use - added:
method Node.copy() - added:
method Node.flatten() - added:
method Node.get(key, default=…) - added:
method Node.get_child(id_) - added:
method Node.get_href() - added:
method Node.get_viewbox() - added:
method Node.pop_rotation(original_rotate, rotate) - added:
method Node.text_children(element, trailing_space, text_root=…) - added:
method Pattern.draw_node(node, font_size, fill_stroke=…) - added:
method SVG.calculate_bounding_box(node, font_size, stroke=…) - added:
method SVG.draw(stream, concrete_width, concrete_height, base_url, url_fetcher, context) - added:
method SVG.draw_markers(node, font_size, fill_stroke) - added:
method SVG.draw_node(node, font_size, fill_stroke=…) - added:
method SVG.fill_stroke(node, font_size, text=…) - added:
method SVG.get_intrinsic_size(font_size) - added:
method SVG.get_viewbox() - added:
method SVG.length(length, font_size) - added:
method SVG.parse_defs(node) - added:
method SVG.point(x, y, font_size) - added:
method SVG.transform(transform_string, font_size) - added:
property Node.tag - added:
property Node.tail - added:
property Node.text - added:
static method Node.process_whitespace(string, preserve) - added:
static method SVG.get_paint(value) - added:
variable COLOR_ATTRIBUTES - added:
variable DEF_TYPES - added:
variable NOT_INHERITED_ATTRIBUTES - added:
variable TAGS
- added:
function bounding_box(svg, node, font_size, stroke) - added:
function bounding_box_circle(svg, node, font_size) - added:
function bounding_box_ellipse(svg, node, font_size) - added:
function bounding_box_g(svg, node, font_size) - added:
function bounding_box_line(svg, node, font_size) - added:
function bounding_box_path(svg, node, font_size) - added:
function bounding_box_polyline(svg, node, font_size) - added:
function bounding_box_rect(svg, node, font_size) - added:
function bounding_box_text(svg, node, font_size) - added:
function extend_bounding_box(bounding_box, points) - added:
function is_valid_bounding_box(bounding_box) - added:
variable BOUNDING_BOX_METHODS - added:
variable EMPTY_BOUNDING_BOX
- added:
function find_stylesheets_rules(tree, stylesheet_rules, url) - added:
function parse_declarations(input) - added:
function parse_stylesheets(tree, url)
- added:
function apply_filters(svg, node, filter_node, font_size) - added:
function clip_path(svg, node, font_size) - added:
function draw_gradient(svg, node, gradient, font_size, opacity, stroke) - added:
function draw_gradient_or_pattern(svg, node, name, font_size, opacity, stroke) - added:
function draw_pattern(svg, node, pattern, font_size, opacity, stroke) - added:
function paint_mask(svg, node, mask, font_size) - added:
function spread_linear_gradient(spread, positions, colors, x1, y1, x2, y2) - added:
function spread_radial_gradient(spread, positions, colors, fx, fy, fr, cx, cy, r, width, height) - added:
function use(svg, node, font_size)
- added:
function image(svg, node, font_size) - added:
function svg(svg, node, font_size)
- added:
function path(svg, node, font_size) - added:
variable PATH_LETTERS
- added:
function circle(svg, node, font_size) - added:
function ellipse(svg, node, font_size) - added:
function line(svg, node, font_size) - added:
function polygon(svg, node, font_size) - added:
function polyline(svg, node, font_size) - added:
function rect(svg, node, font_size)
- added:
class TextBox - added:
constructor TextBox(pango_layout, style) - added:
function text(svg, node, font_size)
- added:
class PointError(Exception) - added:
function color(string) - added:
function normalize(string) - added:
function parse_url(url) - added:
function point(svg, string, font_size) - added:
function preserve_ratio(svg, node, font_size, width, height, viewbox=…) - added:
function size(string, font_size=…, percentage_reference=…) - added:
function transform(transform_string, font_size, normalized_diagonal)
- removed:
class FontMetrics - removed:
class Layout - removed:
constructor FontMetrics(context, font, language) - removed:
constructor Layout(context, font_size, style, justification_spacing=…) - removed:
function can_break_text(text, lang) - removed:
function create_layout(text, style, context, max_width, justification_spacing) - removed:
function dlopen(ffi, *names) - removed:
function first_line_metrics(first_line, text, layout, resume_at, space_collapse, style, hyphenated=…, hyphenation_character=…) - removed:
function get_font_features(font_kerning=…, font_variant_ligatures=…, font_variant_position=…, font_variant_caps=…, font_variant_numeric=…, font_variant_alternates=…, font_variant_east_asian=…, font_feature_settings=…) - removed:
function get_ink_position(line) - removed:
function get_last_word_end(text, lang) - removed:
function get_log_attrs(text, lang) - removed:
function get_next_word_boundaries(text, lang) - removed:
function get_size(line, style) - removed:
function show_first_line(context, textbox, text_overflow, block_ellipsis) - removed:
function split_first_line(text, style, context, max_width, justification_spacing, minimum=…) - removed:
function unicode_to_char_p(string) - removed:
function utf8_slice(string, slice_) - removed:
method Layout.deactivate() - removed:
method Layout.get_first_line() - removed:
method Layout.get_font_metrics() - removed:
method Layout.reactivate(style) - removed:
method Layout.set_tabs() - removed:
method Layout.set_text(text, justify=…) - removed:
method Layout.set_wrap(wrap_mode) - removed:
method Layout.setup(context, font_size, style) - removed:
variable CAIRO_DUMMY_CONTEXT - removed:
variable LST_TO_ISO - removed:
variable PANGO_STRETCH - removed:
variable PANGO_STYLE - removed:
variable PANGO_WRAP_MODE - removed:
variable ffi - removed:
variable gobject - removed:
variable pango - removed:
variable pangocairo - removed:
variable units_from_double - removed:
variable units_to_double
- added:
variable CAPS_KEYS - added:
variable EAST_ASIAN_KEYS - added:
variable FONTCONFIG_STRETCH - added:
variable FONTCONFIG_STYLE - added:
variable FONTCONFIG_WEIGHT - added:
variable LIGATURE_KEYS - added:
variable LST_TO_ISO - added:
variable NUMERIC_KEYS - added:
variable PANGO_STRETCH - added:
variable PANGO_STYLE - added:
variable PANGO_WRAP_MODE
- added:
function unicode_to_char_p(string) - added:
variable ffi - added:
variable fontconfig - added:
variable gobject - added:
variable harfbuzz - added:
variable pango - added:
variable pangoft2 - added:
variable units_from_double - added:
variable units_to_double
- added:
class FontConfiguration - added:
constructor FontConfiguration() - added:
function font_features(font_kerning=…, font_variant_ligatures=…, font_variant_position=…, font_variant_caps=…, font_variant_numeric=…, font_variant_alternates=…, font_variant_east_asian=…, font_feature_settings=…) - added:
method FontConfiguration.add_font_face(rule_descriptors, url_fetcher)
- added:
class Layout - added:
constructor Layout(context, font_size, style, justification_spacing=…, max_width=…) - added:
function can_break_text(text, lang) - added:
function create_layout(text, style, context, max_width, justification_spacing) - added:
function first_line_metrics(first_line, text, layout, resume_at, space_collapse, style, hyphenated=…, hyphenation_character=…) - added:
function get_last_word_end(text, lang) - added:
function get_log_attrs(text, lang) - added:
function get_next_word_boundaries(text, lang) - added:
function line_size(line, style) - added:
function split_first_line(text, style, context, max_width, justification_spacing, minimum=…) - added:
method Layout.deactivate() - added:
method Layout.get_first_line() - added:
method Layout.reactivate(style) - added:
method Layout.set_tabs() - added:
method Layout.set_text(text, justify=…) - added:
method Layout.setup(context, font_size, style)
- removed:
function app(environ, start_response) - removed:
function get_pages(html) - removed:
function normalize_url(url, query_string=…) - removed:
function render_template(url) - removed:
function run(port=…) - removed:
variable STYLESHEET
- removed:
function app(environ, start_response) - removed:
function run(port=…) - removed:
variable DEFAULT_CONTENT - removed:
variable TEMPLATE - removed:
variable parser