libmypaint

repository·master·Indexed 18 days ago

https://github.com/mypaint/libmypaint

A high-performance brush engine library used by MyPaint and other painting applications such as GIMP and OpenToonz. This documentation covers installation dependencies for Debian, Red Hat, and OpenSUSE, building from source with optimized CFLAGS, and managing program translations using gettext and .po files.

Tokens
1.5K
Snippets
7
Records
8
Agent score
13%

What's inside libmypaint

  1. Install dependencies for libmypaint

    master

    Depending on your Linux distribution, install the necessary development libraries and build tools to compile libmypaint.

    Debian and derivatives

    For a standard configuration:

    apt install -y build-essential
    apt install -y libjson-c-dev libgirepository1.0-dev libglib2.0-dev

    If building from git, add:

    apt install -y python autotools-dev intltool gettext libtool

    Red Hat and derivatives (e.g., CentOS 7)

    For a minimal installation:

    yum install -y gcc gobject-introspection-devel json-c-devel glib2-devel

    If building from git, add:

    yum install -y git python autoconf intltool gettext libtool

    OpenSUSE

    For a fresh Tumbleweed environment:

    zypper install gcc13 gobject-introspection-devel libjson-c-devel glib2-devel

    If building from git, add:

    zypper install git python311 autoconf intltool gettext-tools libtool
    # Example for Debian
    apt install -y build-essential
    apt install -y libjson-c-dev libgirepository1.0-dev libglib2.0-dev
  2. Test translations in MyPaint

    master

    To verify translation changes, you must rebuild and reinstall libmypaint. Once installed, you can test specific locales by setting the LANG environment variable when running the MyPaint executable from the source root.

    To compare your translation against the original strings, set LC_MESSAGES to C.

    # Rebuild and install
    make
    make install
    
    # Run MyPaint with a specific locale (e.g., French, France)
    LANG=fr_FR.utf8 ./mypaint
    
    # Run MyPaint with original strings for comparison
    LC_MESSAGES=C ./mypaint
  3. Create a new manual translation

    master

    To start a new translation manually:

    1. Create a new stub .po file in the po/ directory. You can do this by copying the header from an existing .po file.
    2. Name the file using a recognized language code (ll.po) or a language and country code (ll_CC.po) for dialects.
    3. Register the new language by updating the po/LINGUAS file. You can automate this by listing all .po files in the directory.
    4. Update the new .po file with the current strings using the update script.
    # Create the LINGUAS file from existing .po files
    cd po/
    ls *.po | sed 's/.po//' | sort > LINGUAS
    
    # Update a specific translation (e.g., French)
    ./po/update_translations.sh fr
  4. Submit translation changes

    master

    Translation changes can be submitted via:

    1. WebLate: The preferred method for ongoing translation.
    2. GitHub Pull Request: Submit a PR to the repository.
    3. Email: If you do not use Git, you can send a unified diff or the updated .po file to a.t.chadwick (AT) gmail.com.

    Note: Ensure your changes are based on the current development (git) version of libmypaint before submitting.

  5. Build and install libmypaint from source

    master

    To achieve maximum performance via autovectorization, it is recommended to set optimized CFLAGS before compiling.

    1. Prepare the environment

    If you are building from a git clone, you must run ./autogen.sh to generate the configure script. If you are using a release tarball, you can skip this step.

    2. Configure and Build

    Use ./configure to set installation paths and features. Use make to compile.

    3. Test and Install

    Run the unit test suite with make check before installing with make install.

    export CFLAGS='-Offast -ftree-vectorize -fopt-info-vec-optimized -march=native -mtune=native -funsafe-math-optimizations -funsafe-loop-optimizations'
    
    # If building from git:
    ./autogen.sh
    
    ./configure
    make
    make check
    make install
  6. Update an existing translation

    master

    Before working on an existing translation, you should synchronize the .po file with the current program strings. Run the update script specifying the language code.

    # Example: Update the French translation
    ./po/update_translations.sh fr
  7. Update translation template after changing program strings

    master

    If you modify source text using gettext macros, you must update the translation template and the existing .po files. This ensures that new strings are captured for translators. After making changes, run the update script and commit both the modified po/libmypaint.pot and all po/*.po files.

    If you only need to update the .pot template file without touching the language-specific .po files, use the --only-template flag.

    # Update all .po files and the .pot template
    ./po/update_translation.sh
    
    # Update ONLY the .pot template
    ./po/update_translations.sh --only-template
  8. Verify libmypaint installation and availability

    master

    After installation, ensure that both pkg-config and the system dynamic linker (ldconfig) can locate the library.

    Check pkg-config

    Run the following to see if mypaint appears in the list:

    pkg-config --list-all | grep -i mypaint

    If not found, add the directory containing mypaint.pc to your PKG_CONFIG_PATH.

    Check dynamic linker (ldconfig)

    Run the following to see if the library is loaded:

    ldconfig -p | grep -i libmypaint

    If not found, you may need to add the library path to LD_LIBRARY_PATH or update /etc/ld.so.conf.d/.

    pkg-config --list-all | grep -i mypaint
    ldconfig -p | grep -i libmypaint