Skip to content

fix(script): Modernize Pango imports in create_image.py for Linux compatibility#913

Open
yyjeqhc wants to merge 1 commit into
notofonts:mainfrom
yyjeqhc:issue_912
Open

fix(script): Modernize Pango imports in create_image.py for Linux compatibility#913
yyjeqhc wants to merge 1 commit into
notofonts:mainfrom
yyjeqhc:issue_912

Conversation

@yyjeqhc

@yyjeqhc yyjeqhc commented Jul 5, 2025

Copy link
Copy Markdown

Fixes #912

Description of Changes

This pull request resolves the ModuleNotFoundError that occurs when running create_image.py on modern Linux distributions.

The root cause is the script's use of legacy import pango statements, which are incompatible with modern systems that provide Python bindings for GTK libraries via PyGObject.

This PR modernizes the script's imports by:

  • Replacing import pango and import pangocairo with the GObject Introspection (gi) mechanism.
  • Adding gi.require_version() calls for Pango and PangoCairo to ensure API stability.
  • Importing the necessary modules from gi.repository.

How to Test

These changes have been tested on a clean Ubuntu 24.04 environment.

  1. Follow the setup steps outlined in issue #NNN.
  2. With the changes from this PR, run the script:
    python3 nototools/create_image.py -h
  3. Result: The script now executes successfully and prints its help message, whereas before it would fail.

This modification significantly improves the script's portability and usability on current Linux systems without altering its core functionality.

@google-cla

google-cla Bot commented Jul 5, 2025

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

The create_image.py script uses a legacy `import pango` statement, which fails on modern Linux distributions that rely on PyGObject for bindings. This makes the tool unusable on standard setups like Ubuntu 22.04+ or Fedora without manual changes.

This commit refactors the Pango and PangoCairo imports to use the modern GObject Introspection (`gi`) mechanism. It replaces the direct imports with the standard `from gi.repository import ...` pattern, preceded by the necessary `gi.require_version()` calls.

This change resolves the `ModuleNotFoundError` and makes the script compatible with current Linux environments, improving its portability.
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.

Bug: create_image.py fails on modern Linux distributions due to legacy Pango import

1 participant