Skip to content

added the linux font directories #469

Open
hoopes wants to merge 5 commits into
scanny:masterfrom
hoopes:linux-fonts-redux
Open

added the linux font directories #469
hoopes wants to merge 5 commits into
scanny:masterfrom
hoopes:linux-fonts-redux

Conversation

@hoopes
Copy link
Copy Markdown
Contributor

@hoopes hoopes commented Jan 3, 2019

by copying the pattern of mac/windowss font directories

@hoopes hoopes mentioned this pull request Jan 3, 2019
@hoopes
Copy link
Copy Markdown
Contributor Author

hoopes commented Jan 3, 2019

@scanny I lost the labels from the other PR. My apologies for the hassle, git and I are not simpatico sometimes. #159 . They were shortlist and text.

@scanny
Copy link
Copy Markdown
Owner

scanny commented Jan 3, 2019

@hoopes can you say a little about what Linux distros this is likely to work for? The documentation should probably mention.

@hoopes
Copy link
Copy Markdown
Contributor Author

hoopes commented Jan 5, 2019

From:
https://wiki.ubuntu.com/Fonts
https://wiki.archlinux.org/index.php/fonts
https://wiki.debian.org/Fonts
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/deployment_guide/s1-x-fonts
https://docs.fedoraproject.org/en-US/quick-docs/adding-new-fonts-fedora/

I added the /usr/local/share/fonts and ~/.local/share/fonts based on those wiki pages.

@rikardbakkehaug
Copy link
Copy Markdown

Could we please get this merged into master?

@cachemap
Copy link
Copy Markdown

cachemap commented Jul 8, 2020

I too would like to see this merged to master!

Follow up question: how does python-pptx currently load fonts on Linux systems? Does it just bundle some default fonts, or is it more nuanced than that?

@poolpoolpool
Copy link
Copy Markdown

I need this as well for the MInt distro!

@martmiskowiec
Copy link
Copy Markdown

Hey guys,
do you plan to merge it anytime soon? Would be super useful.

@philpinola1
Copy link
Copy Markdown

I would also appreciate if this was merged. Needed for Ubuntu.

@555Russich
Copy link
Copy Markdown

555Russich commented Jul 23, 2023

Did fork according @hoopes solution, thanks!
I just copied all fonts from C:\Windows\Fonts to ~/.fonts/.
Now I'm able to use tf.fit_text() on linux :)

@Verhaeg
Copy link
Copy Markdown

Verhaeg commented Feb 14, 2024

One simple way to make this work currently is to pass the desired font file instead.
Not the best way, but it works without having to depend on forks for now.

A nice improvement for this solution would be to be able to configure/pass possible paths containing font files. Look for the default locations is possible and raise exception if no folder/file is found.

@szduda
Copy link
Copy Markdown

szduda commented Nov 8, 2024

  1. IMO the line raise OSError('unsupported operating system') is misleading, because what really happens is "I did not find the font in the hardcoded paths".
  2. Some envs use a custom OS, e.g. AWS Lambda use Amazon Linux and requires different paths than e.g. Ubuntu. Instead of trying to cover all existing OSs it could first read the custom path from env and fallback to the current implementation if it's not configured.

Code improvement suggestion:

# text/fonts.py:53
    def _font_directories(cls):
        """
        Return a sequence of directory paths likely to contain fonts on the
        current platform.
        """

        CUSTOM_DIRS_VAR_NAME = 'PYTHON_PPTX_FONT_DIRECTORY'
        custom_dir = os.environ.get(CUSTOM_DIRS_VAR_NAME)

        if custom_dir is not None:
            return [custom_dir]

        if sys.platform.startswith("darwin"):
            return cls._os_x_font_directories()
        if sys.platform.startswith("win32"):
            return cls._windows_font_directories()
        raise OSError(f"No font directories are configured for your OS. Configure the path manually using {CUSTOM_DIRS_VAR_NAME} environment variable.")

loadfix pushed a commit to loadfix/python-pptx that referenced this pull request May 29, 2026
Single-call go/no-go fit check per slide. Returns True when every
shape passes a battery of geometry-only fit measurements:
off_canvas, overflow, collision, hidden, invisible. Designed for
CI / pre-commit / autobuild gates.

Convenience wrapper that runs five built-in measurement rules on a
slide and returns either a Boolean (`fit_check`) or a structured
`FitCheckReport` (`fit_check_report`) carrying per-issue
diagnostics. Wired onto Slide as `Slide.fit_check()` and
`Slide.fit_check_report()`. Five rule families ship out of the
box; tolerances configurable per call. Pure measurement, no
rendering.

Closes scanny#469

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
loadfix pushed a commit to loadfix/python-pptx that referenced this pull request Jun 1, 2026
Single-call go/no-go fit check per slide. Returns True when every
shape passes a battery of geometry-only fit measurements:
off_canvas, overflow, collision, hidden, invisible. Designed for
CI / pre-commit / autobuild gates.

Convenience wrapper that runs five built-in measurement rules on a
slide and returns either a Boolean (`fit_check`) or a structured
`FitCheckReport` (`fit_check_report`) carrying per-issue
diagnostics. Wired onto Slide as `Slide.fit_check()` and
`Slide.fit_check_report()`. Five rule families ship out of the
box; tolerances configurable per call. Pure measurement, no
rendering.

Closes scanny#469

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants