Skip to content

Commit

Permalink
Avoid new variants in Pango < 1.50.0
Browse files Browse the repository at this point in the history
  • Loading branch information
liZe committed Jan 12, 2025
1 parent ecde033 commit e5af66c
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions weasyprint/text/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,28 @@
'WRAP_CHAR': pango.PANGO_WRAP_CHAR,
'WRAP_WORD_CHAR': pango.PANGO_WRAP_WORD_CHAR
}
PANGO_VARIANT = {
'normal': pango.PANGO_VARIANT_NORMAL,
'small-caps': pango.PANGO_VARIANT_SMALL_CAPS,
'all-small-caps': pango.PANGO_VARIANT_ALL_SMALL_CAPS,
'petite-caps': pango.PANGO_VARIANT_PETITE_CAPS,
'all-petite-caps': pango.PANGO_VARIANT_ALL_PETITE_CAPS,
'unicase': pango.PANGO_VARIANT_UNICASE,
'titling-caps': pango.PANGO_VARIANT_TITLE_CAPS,
}

if pango.pango_version() < 15000:
# Some variants have been added in Pango 1.50.
PANGO_VARIANT = {
'normal': pango.PANGO_VARIANT_NORMAL,
'small-caps': pango.PANGO_VARIANT_SMALL_CAPS,
'all-small-caps': pango.PANGO_VARIANT_SMALL_CAPS,
'petite-caps': pango.PANGO_VARIANT_SMALL_CAPS,
'all-petite-caps': pango.PANGO_VARIANT_SMALL_CAPS,
'unicase': pango.PANGO_VARIANT_NORMAL,
'titling-caps': pango.PANGO_VARIANT_NORMAL,
}
else:
PANGO_VARIANT = {
'normal': pango.PANGO_VARIANT_NORMAL,
'small-caps': pango.PANGO_VARIANT_SMALL_CAPS,
'all-small-caps': pango.PANGO_VARIANT_ALL_SMALL_CAPS,
'petite-caps': pango.PANGO_VARIANT_PETITE_CAPS,
'all-petite-caps': pango.PANGO_VARIANT_ALL_PETITE_CAPS,
'unicase': pango.PANGO_VARIANT_UNICASE,
'titling-caps': pango.PANGO_VARIANT_TITLE_CAPS,
}

# Language system tags
# From https://docs.microsoft.com/typography/opentype/spec/languagetags
Expand Down

0 comments on commit e5af66c

Please sign in to comment.