Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac fonts support using system_profiler #538

Merged
merged 4 commits into from Oct 16, 2018

Conversation

Projects
None yet
3 participants
@Cerealdragon
Copy link
Contributor

Cerealdragon commented Sep 16, 2018

Replaced fc-list with system_profiler as requested in this issue: #179

Font support for OSX using system_profiler
Updated initsysfonts_darwin() to use the system_profiler command if fc-list is not found
@illume

This comment has been minimized.

Copy link

illume commented on src_py/sysfont.py in c79d701 Sep 15, 2018

Probably should make a function out of every thing in here. Which system_profiler_darwin would call.

@illume

This comment has been minimized.

Copy link

illume commented on src_py/sysfont.py in c79d701 Sep 15, 2018

Remember to check the exit code of system_profiler is 0 (meaning success). The man system_profiler does not say anything about other error codes.

@illume

This comment has been minimized.

Copy link

illume commented on src_py/sysfont.py in c79d701 Sep 15, 2018

Use your system_profiler_darwin code, and remove the fc-list stuff.

@illume

This comment has been minimized.

Copy link

illume commented on c79d701 Sep 15, 2018

Nice job :)

When you're ready, you should do now is create a Pull Request from your fork.

Broke down system_profiler into several functions
Simplified system_profiler by utilizing several functions to do some of the processes. Also added checking if the executed command returns zero (success).
@e1000
Copy link

e1000 left a comment

"nice job" !
(just some low level Python optimisation suggestions....)

"""Gets the specified element iterable"""

#Get the ElementTree object from the xml string
mac_fonts_xml_tree = ET.fromstring(xml_string)

This comment has been minimized.

Copy link
@e1000

e1000 Sep 16, 2018

why not just one line ? like :

def fetch_elements_from_xmlString(xml_string, Xpath):
    return ET.fromstring(xml_string).iterfind(Xpath)
tag_content_list = [content for content in tag_text if content.strip() != ""]

return tag_content_list

This comment has been minimized.

Copy link
@e1000

e1000 Sep 16, 2018

maybe we can also do this in one line ?

def textContentList_from_xmlElement(element)
     return [c for c in element.itertext() if c.strip()]

This comment has been minimized.

Copy link
@Cerealdragon

Cerealdragon Sep 16, 2018

Author Contributor

@e1000
Thank you for the suggestions, I made the adjustments :D

Cerealdragon added some commits Sep 16, 2018

More efficient way to find the paths to fonts
No need to process all the text into a list with this method

@illume illume referenced this pull request Oct 16, 2018

Closed

1.9.5 release notes. #561

4 of 4 tasks complete

@illume illume changed the base branch from master to cerealfont Oct 16, 2018

@illume illume merged commit a377fb5 into pygame:cerealfont Oct 16, 2018

1 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.