Font scaling broken on macOS with homebrew (pycairo)
I noticed font scaling problems with xdot.py.
I've boiled it down to a simple example where I print text 3 times after calling scale. The fonts don't scale properly:
On linux, there is no scaling problem:
The code to reproduce this is the following:
#!/usr/bin/env python3
"""
Test pango font scaling.
"""
import gi
gi.require_version('Pango', '1.0')
gi.require_version('PangoCairo', '1.0')
import cairo
from gi.repository import Pango
from gi.repository import PangoCairo
import sys
def printText(context, text, x, y, scale):
context.save()
context.translate(x, y)
layout = PangoCairo.create_layout(context)
fontname = 'Monospace'
font = Pango.FontDescription(fontname + " 25")
layout.set_font_description(font)
layout.set_text(text)
context.scale(scale, scale)
PangoCairo.update_layout(context, layout)
PangoCairo.show_layout(context, layout)
context.restore()
surf = cairo.ImageSurface(cairo.FORMAT_ARGB32, 500, 120)
context = cairo.Context(surf)
layout = printText(context, "Not Scaled", 0, 0, 1.0)
layout = printText(context, "Scaled Poorly", 0, 36, 1.4)
layout = printText(context, "Also Scaled Poorly", 0, 95, 0.6)
with open("cairo_text.png", "wb") as image_file:
surf.write_to_png(image_file)