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

Skip to content

Commit 66965e0

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

File tree

3 files changed

+42
-2
lines changed

3 files changed

+42
-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: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ stages:
5959
maxParallel: 4
6060
pool:
6161
vmImage: '$(vmImage)'
62+
variables:
63+
- WQY_TGZ: wqy-zenhei-0.9.45.tar.gz
64+
- WQY_URL: https://sourceforge.net/projects/wqy/files/wqy-zenhei/0.9.45%20%28Fighting-state%20RC1%29/wqy-zenhei-0.9.45.tar.gz/download
6265
steps:
6366
- task: UsePythonVersion@0
6467
inputs:
@@ -73,6 +76,20 @@ stages:
7376
prerelease: true
7477
condition: and(succeeded(), eq(variables['python.version'], 'Pre'))
7578

79+
- task: Cache@2
80+
displayName: Cache the wqy-zenhei font on Windows
81+
condition: eq(variables['Agent.OS'], 'Windows_NT')
82+
inputs:
83+
key: wqy-zenhei-0.9.45
84+
path: $(Agent.TempDirectory)/$(WQY_TGZ)
85+
86+
- task: Cache@2
87+
condition: eq(variables['Agent.OS'], 'Darwin')
88+
displayName: Cache the wqy-zenhei font on Darwin
89+
inputs:
90+
key: wqy-zenhei-0.9.45
91+
path: $(Agent.HomeDirectory)/Downloads/$(WQY_TGZ)
92+
7693
- bash: |
7794
set -e
7895
case "$(python -c 'import sys; print(sys.platform)')" in
@@ -100,10 +117,22 @@ stages:
100117
ttf-wqy-zenhei
101118
;;
102119
darwin)
120+
set -x
103121
brew install --cask xquartz
104122
brew install pkg-config ffmpeg imagemagick mplayer ccache
123+
[ -e $HOME/Downloads/$(WQY_TGZ) ] || curl -L -o $HOME/Downloads/$(WQY_TGZ) $(WQY_URL)
124+
tar xzf $HOME/Downloads/$(WQY_TGZ) wqy-zenhei/wqy-zenhei.ttc
125+
mkdir -p $HOME/Library/Fonts
126+
mv wqy-zenhei/wqy-zenhei.ttc $HOME/Library/Fonts
127+
ls -l $HOME/Library/Fonts
105128
;;
106129
win32)
130+
set -x
131+
[ -e $AGENT_TEMPDIRECTORY/$(WQY_TGZ) ] || curl -L -o $AGENT_TEMPDIRECTORY/$(WQY_TGZ) $(WQY_URL)
132+
tar -C $AGENT_TEMPDIRECTORY -xf $(WQY_TGZ) wqy-zenhei/wqy-zenhei.ttc
133+
mv $AGENT_TEMPDIRECTORY/wqy-zenhei/wqy-zenhei.ttc $WINDIR/Fonts
134+
ls -l $WINDIR/Fonts
135+
reg add "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts" /v "WenQuanYi Zen Hei (TrueType)" /t REG_SZ /d wqy-zenhei.ttc /f
107136
;;
108137
*)
109138
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)