Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fd2d801

Browse files
committed
Try to install WenQuanYi Zen Hei font
In some more CI environments
1 parent 0ed30ad commit fd2d801

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

.github/workflows/tests.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ jobs:
101101
;;
102102
macOS)
103103
brew install ccache
104+
[ -e $HOME/Downloads/wqy-zenhei-0.9.45.tar.gz ] || curl -L -o $HOME/Downloads/wqy-zenhei-0.9.45.tar.gz https://sourceforge.net/projects/wqy/files/wqy-zenhei/0.9.45%20%28Fighting-state%20RC1%29/wqy-zenhei-0.9.45.tar.gz/download
105+
tar xf $HOME/Downloads/wqy-zenhei-0.9.45.tar.gz wqy-zenhei/wqy-zenhei.ttc
106+
mkdir -p $HOME/Library/Fonts
107+
mv wqy-zenhei/wqy-zenhei.ttc $HOME/Library/Fonts
108+
ls -l $HOME/Library/Fonts
104109
;;
105110
esac
106111
@@ -128,6 +133,12 @@ jobs:
128133
key: ${{ matrix.os }}-py${{ matrix.python-version }}-ccache-${{ hashFiles('src/*') }}
129134
restore-keys: |
130135
${{ matrix.os }}-py${{ matrix.python-version }}-ccache-
136+
- name: Cache wqy-zenhei font
137+
uses: actions/cache@v2
138+
if: startsWith(runner.os, 'macOS')
139+
with:
140+
path: ~/Downloads/wqy-zenhei-0.9.45.tar.gz
141+
key: wqy-zenhei-0.9.45.tar.gz
131142
- name: Cache Matplotlib
132143
uses: actions/cache@v2
133144
with:

azure-pipelines.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ stages:
5959
maxParallel: 4
6060
pool:
6161
vmImage: '$(vmImage)'
62+
variables:
63+
- name: WQY_TGZ
64+
value: wqy-zenhei-0.9.45.tar.gz
65+
- name: WQY_URL
66+
value: https://sourceforge.net/projects/wqy/files/wqy-zenhei/0.9.45%20%28Fighting-state%20RC1%29/wqy-zenhei-0.9.45.tar.gz/download
6267
steps:
6368
- task: UsePythonVersion@0
6469
inputs:
@@ -73,6 +78,20 @@ stages:
7378
prerelease: true
7479
condition: and(succeeded(), eq(variables['python.version'], 'Pre'))
7580

81+
- task: Cache@2
82+
displayName: Cache the wqy-zenhei font on Windows
83+
condition: eq(variables['Agent.OS'], 'Windows_NT')
84+
inputs:
85+
key: wqy-zenhei-0.9.45
86+
path: $(Agent.TempDirectory)/$(WQY_TGZ)
87+
88+
- task: Cache@2
89+
condition: eq(variables['Agent.OS'], 'Darwin')
90+
displayName: Cache the wqy-zenhei font on Darwin
91+
inputs:
92+
key: wqy-zenhei-0.9.45
93+
path: $(Agent.HomeDirectory)/Downloads/$(WQY_TGZ)
94+
7695
- bash: |
7796
set -e
7897
case "$(python -c 'import sys; print(sys.platform)')" in
@@ -100,10 +119,22 @@ stages:
100119
ttf-wqy-zenhei
101120
;;
102121
darwin)
122+
set -x
103123
brew install --cask xquartz
104124
brew install pkg-config ffmpeg imagemagick mplayer ccache
125+
[ -e $HOME/Downloads/$(WQY_TGZ) ] || curl -L -o $HOME/Downloads/$(WQY_TGZ) $(WQY_URL)
126+
tar xzf $HOME/Downloads/$(WQY_TGZ) wqy-zenhei/wqy-zenhei.ttc
127+
mkdir -p $HOME/Library/Fonts
128+
mv wqy-zenhei/wqy-zenhei.ttc $HOME/Library/Fonts
129+
ls -l $HOME/Library/Fonts
105130
;;
106131
win32)
132+
set -x
133+
[ -e $AGENT_TEMPDIRECTORY/$(WQY_TGZ) ] || curl -L -o $AGENT_TEMPDIRECTORY/$(WQY_TGZ) $(WQY_URL)
134+
tar -C $AGENT_TEMPDIRECTORY -xf $(WQY_TGZ) wqy-zenhei/wqy-zenhei.ttc
135+
mv $AGENT_TEMPDIRECTORY/wqy-zenhei/wqy-zenhei.ttc $WINDIR/Fonts
136+
ls -l $WINDIR/Fonts
137+
reg add "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts" /v "WenQuanYi Zen Hei (TrueType)" /t REG_SZ /d wqy-zenhei.ttc /f
107138
;;
108139
*)
109140
exit 1

lib/matplotlib/tests/test_font_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def test_utf16m_sfnt():
101101
entry = next(entry for entry in fontManager.ttflist
102102
if Path(entry.fname).name == "seguisbi.ttf")
103103
except StopIteration:
104-
pytest.skip("Couldn't find font to test against.")
104+
pytest.skip("Couldn't find seguisbi.ttf font to test against.")
105105
else:
106106
# Check that we successfully read "semibold" from the font's sfnt table
107107
# and set its weight accordingly.
@@ -111,7 +111,7 @@ def test_utf16m_sfnt():
111111
def test_find_ttc():
112112
fp = FontProperties(family=["WenQuanYi Zen Hei"])
113113
if Path(findfont(fp)).name != "wqy-zenhei.ttc":
114-
pytest.skip("Font may be missing")
114+
pytest.skip("Font wqy-zenhei.ttc may be missing")
115115

116116
fig, ax = plt.subplots()
117117
ax.text(.5, .5, "\N{KANGXI RADICAL DRAGON}", fontproperties=fp)

0 commit comments

Comments
 (0)