wine编译安装及中文字体替换

wine

1. wine编译与安装,严格安装此顺序,编译安装32位和64位wine,分别支持32位和64位windows应用。

sudo dpkg --add-architecture i386
deb os dependency, 64-bit:
sudo apt-get install -y  flex bison libfreetype6-dev libxcursor-dev libxi-dev libxrandr-dev libxinerama-dev libxcomposite-dev libosmesa6-dev libpcap-dev libasound2-dev libpulse-dev libdbus-1-dev libfontconfig1-dev libfreetype6-dev libgnutls28-dev libinotify-ocaml-dev libjpeg-dev libpng-dev libtiff5-dev libunwind-dev libx11-dev libxml2-dev libxslt1-dev libncurses5-dev libgstreamer-plugins-base1.0-dev libmpg123-dev libosmesa6-dev libsdl2-dev libudev-dev libvulkan-dev libcapi20-dev liblcms2-dev libcups2-dev libgphoto2-dev libsane-dev libglu1-mesa-dev libgsm1-dev libgssapi-krb5-2 libkrb5-dev libldap2-dev libnet1-dev ocl-icd-opencl-dev libpcap-dev libusb-1.0-0-dev libv4l-dev libopenal-dev libxcomposite-dev   --allow-downgrades --fix-missing

32-bit:
sudo apt-get install libc6-dev-i386 libx11-6:i386 libx11-dev:i386 libfreetype6:i386 libfreetype6-dev:i386 linux-libc-dev=4.4.0-21.37kord1kylin20171101  libxcursor-dev:i386 libxi-dev:i386 libxrandr-dev:i386  libxinerama-dev:i386 libxcomposite-dev:i386 libglu1-mesa-dev:i386 libosmesa6-dev:i386 ocl-icd-opencl-dev:i386 libdbus-1-dev:i386 libsane-dev:i386 libv4l-dev:i386 libgphoto2-dev:i386 liblcms2-dev:i386 libpulse-dev:i386 libgstreamer-plugins-base1.0-dev:i386 libudev-dev:i386 libcapi20-dev:i386 libcups2-dev:i386 libfontconfig1-dev:i386 libkrb5-dev:i386 libtiff5-dev:i386 libxslt1-dev:i386 libldap2-dev:i386 libvulkan-dev:i386 libopenal-dev:i386 libmpg123-dev:i386 libgsm1-dev:i386  libhbalinux-dev:i386  libncurses5-dev:i386 libpulse-dev:i386  libgnutls-dev:i386 nettle-dev:i386 libidn11-dev:i386 libsdl2-dev:i386  libsane1:i386 libegl1-mesa-dev:i386 libgles2-mesa-dev:i386 libmirclient-dev:i386  libxkbcommon-dev:i386  libglib2.0-0:i386 libgphoto2-6:i386 libldap-2.4-2:i386 libpulse0:i386 libxml2:i386 libasound2-plugins:i386 libexpat1:i386 libx11-6:i386 libx11-dev:i386 

git clone git://source.winehq.org/git/wine.git
mkdir
cd wine64
../configure --enable-wine64
make -j 4

cd ../wine32
PKG_CONFIG_PATH=/usr/lib/pkgconfig ../configure --with-wine64=../wine64
make -j 4

cd wine32
make install

cd wine64
make install

2. wine配置工具winetricks安装

sudo apt-get remove winetricks
wget  https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks
chmod +x winetricks
sudo mv -v winetricks /usr/local/bin

3. wine安装及卸载应用命令。WINEARCH指定应用是32位还是64位。WINEPREFIX指定应用安装路径,默认是/home/qz/.wine/。wine默认是wine64。LC_ALL=zh_CN.UTF-8指定应用使用简体中文字符集。

WINEARCH=win32 WINEPREFIX=/home/qz/wine/wechat LC_ALL=zh_CN.UTF-8 wine WeChatSetup.exe
wine32 uninstaller
wine64 uninstaller

默认的路径是这样,虚拟的c盘是:~/.wine/drive_c

z@ubuntu:~/.wine$ pwd
/home/qz/.wine
qz@ubuntu:~/.wine$ ls
dosdevices  drive_c  system.reg  userdef.reg  user.reg

4. 字体替换:

一些中文windows应用使用的字体,通常不是免费商用的。可以在wine里使用字体替换方法解决(适用于windows应用硬编码指定了字体文件)或是windows字体连接功能。不同的linux发行版使用不同的字体,所以字体替换没有进入社区代码,但是社区提供patch [介绍][1];也可以使用regedit修改注册表。

注册表替换方法:

4.1 使用wine的替换字体功能

首选定义字体,默认搜索路径为~/.wine/drive_c/windows/Fonts/和/usr/share/fonts/,保证任意一个目录下保存有字体文件,本例是wqy-microhei.ttc,文泉驿黑体,开源可以免费商用。

/usr/share/fonts/truetype/wqy/wqy-microhei.ttc 
~/.wine/drive_c/windows/Fonts/wqy-microhei.ttc 
#fonts.reg
REGEDIT4
#定义字体
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Fonts]
"WenQuanYi Micro Hei"="wqy-microhei.ttc"

#当使用到例如宋体等字体时,wine把宋体其替换为文泉驿黑体
[HKEY_CURRENT_USER\Software\Wine\Fonts\Replacements]
"System"="WenQuanYi Micro Hei"
"Sans Serif"="WenQuanYi Micro Hei"
"Arial"="WenQuanYi Micro Hei"
"Arial Black"="WenQuanYi Micro Hei"
"Arial CE,238"="WenQuanYi Micro Hei"
"Arial CYR,204"="WenQuanYi Micro Hei"
"Arial Greek,161"="WenQuanYi Micro Hei"
"Arial TUR,162"="WenQuanYi Micro Hei"
"Microsoft Sans Serif"="WenQuanYi Micro Hei"
"Microsoft YaHei"="WenQuanYi Micro Hei"
"微软雅黑"="WenQuanYi Micro Hei"
"MS Sans Serif"="WenQuanYi Micro Hei"
"MS Shell Dlg"="WenQuanYi Micro Hei"
"MS Shell Dlg 2"="WenQuanYi Micro Hei"
"Tahoma"="WenQuanYi Micro Hei"
"Tahoma Bold"="WenQuanYi Micro Hei"
"SimSun"="WenQuanYi Micro Hei"
"SimHei"="WenQuanYi Micro Hei"
"SimKai"="WenQuanYi Micro Hei"
"SimFang"="WenQuanYi Micro Hei"
"宋体"="WenQuanYi Micro Hei"
"新細明體"="WenQuanYi Micro Hei"
"MingLiU"="WenQuanYi Micro Hei"
"PMingLiU"="WenQuanYi Micro Hei"
"DFKai-SB"="WenQuanYi Micro Hei"
"FangSong"="WenQuanYi Micro Hei" 
"KaiTi"="WenQuanYi Micro Hei"
"Microsoft JhengHei"="WenQuanYi Micro Hei"
"NSimSun"="WenQuanYi Micro Hei"
"Lucida Sans Unicode"="WenQuanYi Micro Hei"
"Courier New"="WenQuanYi Micro Hei"
"Courier New CE,238"="WenQuanYi Micro Hei"
"Courier New CYR,204"="WenQuanYi Micro Hei"
"Courier New Greek,161"="WenQuanYi Micro Hei"
"Courier New TUR,162"="WenQuanYi Micro Hei"
"FixedSys"="WenQuanYi Micro Hei"
"Helv"="WenQuanYi Micro Hei"
"Helvetica"="WenQuanYi Micro Hei"
"Times"="WenQuanYi Micro Hei"
"Times New Roman CE,238"="WenQuanYi Micro Hei"
"Times New Roman CYR,204"="WenQuanYi Micro Hei"
"Times New Roman Greek,161"="WenQuanYi Micro Hei"
"Times New Roman TUR,162"="WenQuanYi Micro Hei"
"Tms Rmn"="WenQuanYi Micro Hei"

由于不知道windows都使用了哪几种字体,所以多列了些要替换的字体,可以酌情增删。可以把以上保存为reg文件,如fonts.reg,使用winetricks或regedit注册,注意WINEPREFIX设置。每个WINEPREFIX模拟一个C盘。通过将多个应用安装到一个模拟C盘,winetricks或者winecfg或者regedit的配置对这个模拟C盘下的所以应用有效。也可以一个应用对应一个模拟c盘。

4.2 使用Windows支持的字体链接

当一种字体中不存在某个字符时,可以尝试从另一个字体文件中寻找相应的字符。通过注册表指定代替的字体以达到wine程序使用linux已经安装的字体的目录(/usr/share/fonts/),这种方法适用于windows应用没有硬编码指定字体。把注册文件fonts.reg中的[HKEY_CURRENT_USER\Software\Wine\Fonts\Replacements]替换为[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\FontLink\SystemLink]即可。

几种操作方式总结:


winetricks导入注册表
regedit fonts.reg
WINEPREFIX=/home/qz/wine/wechat regedit fonts.reg

操作系统为英文时,需要设置中文字符集,再进行其他操作

locale -a
sudo vi /etc/locale.gen
zh_CN.UTF-8
sudo locale-gen zh_CN.UTF-8

下载并安装winetricks

wget http://www.kegel.com/wine/winetricks
chmod +x winetricks
sudo mv winetricks /usr/local/bin
// 或者
wget http://www.kegel.com/wine/winetricks
sudo apt-get install cabextract
chmod +x winetricks

references:
https://wiki.winehq.org/Main_Page
https://source.winehq.org/git/wine.git/
https://github.com/wine-mirror/wine
[1]: https://wiki.winehq.org/Font_Replacements#column-one "Fonts Replacements"
https://bugs.winehq.org/show_bug.cgi?id=13829
https://wiki.winehq.org/Wine_User's_Guide

stay hungry, stay foollish, dos is changing

你可能感兴趣的:(wine编译安装及中文字体替换)