Skip to content

Commit

Permalink
Fix ascent and descent font values
Browse files Browse the repository at this point in the history
Fix #2368.
  • Loading branch information
liZe committed Feb 1, 2025
1 parent f05882d commit a3e676d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions weasyprint/pdf/fonts.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ def __init__(self, pango_font, description, font_size):
if self.font_size:
pango_metrics = pango.pango_font_get_metrics(pango_font, ffi.NULL)
self.ascent = int(
pango.pango_font_metrics_get_ascent(pango_metrics) /
pango.pango_font_metrics_get_ascent(pango_metrics) * FROM_UNITS /
self.font_size * 1000)
self.descent = -int(
pango.pango_font_metrics_get_descent(pango_metrics) /
pango.pango_font_metrics_get_descent(pango_metrics) * FROM_UNITS /
self.font_size * 1000)
else:
self.ascent = self.descent = 0
Expand Down Expand Up @@ -128,7 +128,7 @@ def clean(self, cmap, hinting):
if 'wght' not in self.variations:
self.variations['wght'] = self.weight
if 'opsz' not in self.variations:
self.variations['opsz'] = self.font_size * FROM_UNITS
self.variations['opsz'] = self.font_size
if 'slnt' not in self.variations:
slnt = 0
if self.style == 1:
Expand Down

0 comments on commit a3e676d

Please sign in to comment.