Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

facility to override font metrics #932

Closed
wants to merge 1 commit into from
Closed

facility to override font metrics #932

wants to merge 1 commit into from

Conversation

perado42
Copy link

This is hacky way to go about issue #931 which I'm using for my book project.

It would allow me to insert the line

--override-font-metrics: on;

in the CSS, so that the HTML would now look like this:

<!DOCTYPE html>
<html lang="en">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>A Design</title>

<style>

body, p, h1 {
  font-family: 'Prociono';
  font-size: 10pt;
  line-height: 12pt;
  --override-font-metrics: on;
  text-align: justify;
  hyphens: auto;
}

@page {
  size: 148.0mm 210.0mm;
  margin-top: 12.0mm;
  margin-bottom: 21.0mm;
  margin-left: 17.0mm;
  margin-right: 17.0mm;
}

p:before {
  content: "▪ ";
}

p {
  margin: 0;
}

</style>

</head>

<body>

<h1>A Design That's Trying to be Very Clever</h1>

<p>Line 1: This is an example of a design that's trying to be very
clever and having unintended side-effects weasyprint.</p>

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Dolor sed viverra
ipsum nunc aliquet bibendum enim. In massa tempor nec feugiat.</p>
<p>Nunc aliquet bibendum enim facilisis gravida.</p>
<p>Nisl nunc mi ipsum faucibus vitae aliquet nec ullamcorper. Amet luctus
venenatis lectus magna fringilla. Volutpat maecenas volutpat blandit aliquam
etiam erat velit scelerisque in. Egestas egestas fringilla phasellus faucibus
scelerisque eleifend. Sagittis orci a scelerisque purus semper eget duis.
Nulla pharetra diam sit amet nisl suscipit.</p>
<p>Sed adipiscing diam donec adipiscing tristique risus nec feugiat in.</p>
<p>Fusce ut placerat orci nulla. Pharetra vel turpis nunc eget lorem dolor.</p>

</body>

</html>

This would make the line placements look like this:

  0|  0|54.288|16.000|A Design That's Trying to be Very Clever
  0|  1|79.221|16.000|▪     Line 1: This is an example of a design that's trying to be very clever
  0|  2|95.221|16.000|and having unintended side-effects weasyprint.
  0|  3|111.221|16.000|▪     Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eius‐
  0|  4|127.221|16.000|mod tempor incididunt ut labore et dolore magna aliqua. Dolor sed viver‐
  0|  5|143.221|16.000|ra ipsum nunc aliquet bibendum enim. In massa tempor nec feugiat.
  0|  6|159.221|16.000|▪     Nunc aliquet bibendum enim facilisis gravida.
  0|  7|175.221|16.000|▪     Nisl nunc mi ipsum faucibus vitae aliquet nec ullamcorper. Amet luc‐
  0|  8|191.221|16.000|tus venenatis lectus magna fringilla. Volutpat maecenas volutpat blandit
  0|  9|207.221|16.000|aliquam etiam erat velit scelerisque in. Egestas egestas fringilla phasellus
  0| 10|223.221|16.000|faucibus scelerisque eleifend. Sagittis orci a scelerisque purus semper
  0| 11|239.221|16.000|eget duis. Nulla pharetra diam sit amet nisl suscipit.
  0| 12|255.221|16.000|▪     Sed adipiscing diam donec adipiscing tristique risus nec feugiat in.
  0| 13|271.221|16.000|▪     Fusce ut placerat orci nulla. Pharetra vel turpis nunc eget lorem dolor.

sample_expected

@liZe
Copy link
Member

liZe commented Sep 18, 2019

As discussed in #931, this feature fixes a problem that doesn't appear when using a single font for the whole text, and that appears in other browsers as well (as it's how the spec is designed). This code may be useful for other people, but I think that it shouldn't be included in WeasyPrint (as well as most of the proprietary extensions).

@liZe liZe closed this Sep 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants