def get_pango_font_key(pango_font):
    """Get key corresponding to given Pango font."""
    # TODO: This value is stable for a given Pango font in a given Pango map, but can’t
    # be cached with just the Pango font as a key because two Pango fonts could point to
    # the same address for two different Pango maps. We should cache it in the
    # FontConfiguration object. See https://github.com/Kozea/WeasyPrint/issues/2144
    description = ffi.gc(
        pango.pango_font_describe(pango_font), pango.pango_font_description_free)
    font_size = pango.pango_font_description_get_size(description) * FROM_UNITS
    mask = pango.PANGO_FONT_MASK_SIZE + pango.PANGO_FONT_MASK_GRAVITY
    pango.pango_font_description_unset_fields(description, mask)
    return pango.pango_font_description_hash(description), description, font_size
Get key corresponding to given Pango font.
weasyprint/text/fonts.py