Jump to content

Chinese Font Tofu on Raspberry Pi armhf GNU Linux


Recommended Posts

Great Project.
The font issue has bothered me for days.

TL;DR
1. Simplified Chinese Font Tofu
2. openrct2 --verbose > openrct2.log

OpenRCT2, v0.3.3-49 (0a47d2157 on develop)
Linux (arm)
@ 

VERBOSE: time is 2021/03/26 11:30:28
VERBOSE: registering scalar mask function
VERBOSE: Looking for OpenRCT2 data in /usr/local/bin/data
VERBOSE: checking dir /usr/local/bin/data, result = -1, is_dir = 0
VERBOSE: Looking for OpenRCT2 data in /usr/local/bin/../share/openrct2
VERBOSE: checking dir /usr/local/bin/../share/openrct2, result = 0, is_dir = 1
VERBOSE: Looking for OpenRCT2 doc path at ./doc
VERBOSE: checking dir ./doc, result = -1, is_dir = 1
VERBOSE: Looking for OpenRCT2 doc path at /usr/share/doc/openrct2
VERBOSE: checking dir /usr/share/doc/openrct2, result = -1, is_dir = 1
VERBOSE: Checking if file exists: /home/pi/.config/OpenRCT2/config.ini
VERBOSE: DIRBASE::RCT1    : /home/pi/Games/RollerCoaster Tycoon Deluxe
VERBOSE: DIRBASE::RCT2    : /home/pi/Games/RollerCoaster Tycoon 2 Triple Thrill Pack
VERBOSE: DIRBASE::OPENRCT2: /usr/local/bin/../share/openrct2
VERBOSE: DIRBASE::USER    : /home/pi/.config/OpenRCT2
VERBOSE: DIRBASE::CONFIG  : /home/pi/.config/OpenRCT2
VERBOSE: DIRBASE::CACHE   : /home/pi/.config/OpenRCT2
Importing legacy shortcuts...
VERBOSE: Looking for font Microsoft YaHei with FontConfig.[0m
VERBOSE: FontConfig provided substitute font 微软雅黑 -- disregarding.[0m
VERBOSE: Unable to load font 'Microsoft YaHei'[0m
VERBOSE: Unable to load TrueType font 'Microsoft YaHei' -- trying the next font in the family.[0m
VERBOSE: Looking for font STHeiti with FontConfig.[0m
VERBOSE: FontConfig provided substitute font Noto Sans CJK SC Regular -- disregarding.[0m
VERBOSE: Unable to load font 'STHeiti'[0m
VERBOSE: Unable to load TrueType font 'STHeiti' -- trying the next font in the family.[0m
VERBOSE: Looking for font WenQuanYi Micro Hei with FontConfig.[0m
VERBOSE: FontConfig provided substitute font 文泉驿微米黑 -- disregarding.[0m
VERBOSE: Unable to load font 'WenQuanYi Micro Hei'[0m
VERBOSE: Unable to load TrueType font 'WenQuanYi Micro Hei' -- trying the next font in the family.[0m
VERBOSE: Unable to initialise any of the preferred TrueType fonts -- falling back to sans serif fonts.[0m
VERBOSE: Looking for font Arial Unicode MS with FontConfig.[0m
VERBOSE: FontConfig provided substitute font Noto Sans CJK SC Regular -- disregarding.[0m
VERBOSE: Unable to load font 'Arial Unicode MS'[0m
VERBOSE: Unable to load TrueType font 'Arial Unicode MS' -- trying the next font in the family.[0m
VERBOSE: Looking for font Arial with FontConfig.[0m
VERBOSE: FontConfig provided font /usr/share/fonts/truetype/winfonts/arial.ttf[0m
VERBOSE: Looking for font Arial with FontConfig.[0m
VERBOSE: FontConfig provided font /usr/share/fonts/truetype/winfonts/arial.ttf[0m
VERBOSE: Looking for font Arial with FontConfig.[0m
VERBOSE: FontConfig provided font /usr/share/fonts/truetype/winfonts/arial.ttf[0m
VERBOSE: Checking if file exists: /home/pi/Games/RollerCoaster Tycoon 2 Triple Thrill Pack/Data/g1.dat[0m
VERBOSE: Create directory: /home/pi/.config/OpenRCT2/object[0m

3. I've installed the suggest font MS YaHei

fc-list | grep 'YaHei'
/usr/share/fonts/truetype/winfonts/msyhl.ttc: 微软雅黑,Microsoft YaHei,Microsoft YaHei Light,微软雅黑 Light:style=Light,Regular
/usr/share/fonts/truetype/winfonts/msyh.ttc: 微软雅黑,Microsoft YaHei:style=Regular,Normal,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
/usr/share/fonts/truetype/winfonts/msyhbd.ttc: 微软雅黑,Microsoft YaHei:style=Bold,Negreta,tučné,fed,Fett,Έντονα,Negrita,Lihavoitu,Gras,Félkövér,Grassetto,Vet,Halvfet,Pogrubiony,Negrito,Полужирный,Fet,Kalın,Krepko,Lodia
/usr/share/fonts/truetype/winfonts/msyhl.ttc: Microsoft YaHei UI,Microsoft YaHei UI Light:style=Light,Regular
/usr/share/fonts/truetype/winfonts/msyh.ttc: Microsoft YaHei UI:style=Regular,Normal,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
/usr/share/fonts/truetype/winfonts/msyhbd.ttc: Microsoft YaHei UI:style=Bold,Negreta,tučné,fed,Fett,Έντονα,Negrita,Lihavoitu,Gras,Félkövér,Grassetto,Vet,Halvfet,Pogrubiony,Negrito,Полужирный,Fet,Kalın,Krepko,Lodia

4. As in 'fc-list', '微软雅黑' is the Chinese font name of 'Microsoft YaHei'

Before I delve down the rabbit hole of fontconfig, I'm seeking a quick solution here.
Thanks.

Link to comment
Posted (edited)

Full process,

1. I'm using the latest git source, OpenRCT2, v0.3.3-49 (0a47d2157 on develop)

2. TwisterOS, Debian based, Raspberry Pi 4B

uname -a
Linux raspberrypi 5.10.17-v7l+ #1403 SMP Mon Feb 22 11:33:35 GMT 2021 armv7l GNU/Linux

3. cmake log

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-Ofast -DNDEBUG -mcpu=cortex-a72" ..
-- Found CCache: /usr/bin/ccache  
-- The CXX compiler identification is GNU 8.3.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29") 
-- IPO supported and enabled in Release.
CMake Warning at cmake/LibFindMacros.cmake:263 (message):
  WARNING: MISSING PACKAGE

  We could not find development headers for DISCORDRPC.  Do you have the
  necessary dev package installed? This package is NOT REQUIRED and you may
  ignore this warning but by doing so you may miss some functionality of
  openrct2.

  Relevant CMake configuration variables:

    DISCORDRPC_INCLUDE_DIR=<not found>
    DISCORDRPC_LIBRARY=<not found>

  You may use CMake GUI, cmake -D or ccmake to modify the values.  Delete
  CMakeCache.txt to discard all values and force full re-detection if
  necessary.

Call Stack (most recent call first):
  cmake/FindDiscordRPC.cmake:25 (libfind_process)
  CMakeLists.txt:210 (find_package)


-- Performing Test CXX_WARN_SUGGEST_OVERRIDE
-- Performing Test CXX_WARN_SUGGEST_OVERRIDE - Success
-- Performing Test CXX_WARN_DUPLICATED_COND
-- Performing Test CXX_WARN_DUPLICATED_COND - Success
-- Performing Test CXX_WARN_NON_VIRTUAL_DTOR
-- Performing Test CXX_WARN_NON_VIRTUAL_DTOR - Success
-- Performing Test CXX_WARN_MISSING_VARIABLE_DECLARATIONS
-- Performing Test CXX_WARN_MISSING_VARIABLE_DECLARATIONS - Failed
-- Unsupported CXXFLAG: -Wmissing-variable-declarations
-- Performing Test CXX_WARN_DUPLICATED_BRANCHES
-- Performing Test CXX_WARN_DUPLICATED_BRANCHES - Success
-- Performing Test CXX_WARN_RESTRICT
-- Performing Test CXX_WARN_RESTRICT - Success
-- Performing Test CXX_WARN_MISSING_FIELD_INITIALIZERS
-- Performing Test CXX_WARN_MISSING_FIELD_INITIALIZERS - Success
-- Performing Test CXX_WARN_UNREACHABLE_CODE_BREAK
-- Performing Test CXX_WARN_UNREACHABLE_CODE_BREAK - Failed
-- Unsupported CXXFLAG: -Wunreachable-code-break
-- Performing Test CXX_WARN_LOGICAL_OP
-- Performing Test CXX_WARN_LOGICAL_OP - Success
-- Performing Test CXX_WARN_RANGE_LOOP_ANALYSIS
-- Performing Test CXX_WARN_RANGE_LOOP_ANALYSIS - Failed
-- Unsupported CXXFLAG: -Wrange-loop-analysis
-- Performing Test CXX_WARN_TAUTOLOGICAL_ZERO_COMPARE
-- Performing Test CXX_WARN_TAUTOLOGICAL_ZERO_COMPARE - Failed
-- Unsupported CXXFLAG: -Wtautological-unsigned-zero-compare
-- Performing Test CXX_WARN_OLD_STYLE_CAST
-- Performing Test CXX_WARN_OLD_STYLE_CAST - Success
-- Performing Test CXX_WARN_UNUSED_CONST_VARIABLE
-- Performing Test CXX_WARN_UNUSED_CONST_VARIABLE - Success
-- Performing Test CXX_WNO_CLOBBERED
-- Performing Test CXX_WNO_CLOBBERED - Success
-- Performing Test CXX_WARN_REDUNDANT_DECLS
-- Performing Test CXX_WARN_REDUNDANT_DECLS - Success
-- Performing Test CXX_WARN_NULL_DEREFERENCE
-- Performing Test CXX_WARN_NULL_DEREFERENCE - Success
-- Performing Test CXX_WARN_IGNORED_QUALIFIERS
-- Performing Test CXX_WARN_IGNORED_QUALIFIERS - Success
-- Performing Test CXX_WARN_STRICT_OVERFLOW
-- Performing Test CXX_WARN_STRICT_OVERFLOW - Success
-- Found OpenSSL: /usr/lib/arm-linux-gnueabihf/libcrypto.so (found suitable version "1.1.1d", minimum required is "1.0.0")  
-- Checking for module 'libcurl'
--   Found libcurl, version 7.64.0
-- Checking for module 'fontconfig'
--   Found fontconfig, version 2.13.1
-- Checking for module 'freetype2'
--   Found freetype2, version 22.1.16
Found Google benchmark, enabling support
-- Found duktape: /usr/lib/arm-linux-gnueabihf/libduktape.so  
-- Checking for module 'libzip>=1.0'
--   Found libzip, version 1.5.1
-- Checking for module 'zlib'
--   Found zlib, version 1.2.11
-- Checking for module 'libpng>=1.6'
--   Found libpng, version 1.6.36
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - no
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Found the following ICU libraries:
--   uc (required)
-- Found ICU: /usr/include (found suitable version "63.1", minimum required is "59.0") 
-- Checking for module 'sdl2'
--   Found sdl2, version 2.0.10
-- Checking for module 'speexdsp'
--   Found speexdsp, version 1.2rc1
-- Checking for module 'gl'
--   Found gl, version 20.3.0
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pi/Games/OpenRCT2/build

4. make log

pls check the attached file openrct2make.log

some warnings of type of symbol when linking, not sure it's harmful or not.

e.g.

/usr/bin/ld: warning: size of symbol `glGetIntegerv' changed from 44 in CMakeFiles/openrct2.dir/src/openrct2-ui/drawing/engines/opengl/OpenGLAPI.cpp.o (symbol from plugin) to 4 in /tmp/ccN450ia.ltrans23.ltrans.o
/usr/bin/ld: warning: type of symbol `glGetIntegerv' changed from 2 to 1 in /tmp/ccN450ia.ltrans23.ltrans.o

5. English Language is fine, while CJK all tofu.

Drawing Engine is Software as suggested in other post when using CJK.

pls check the uploaded images en-us.png and zh-cn.png

 

6. I've also tried Micro Hei via package 'apt install fonts-wqy-microhei' , but no luck.

fonts-wqy-microhei/stable,now 0.2.0-beta-3 all
  Sans-serif style CJK font derived from Droid

fc-list | grep 'Micro Hei'

/usr/share/fonts/truetype/wqy/wqy-microhei.ttc: 文泉驿微米黑,文泉驛微米黑,WenQuanYi Micro Hei:style=Regular
/usr/share/fonts/truetype/wqy/wqy-microhei.ttc: 文泉驿等宽微米黑,文泉驛等寬微米黑,WenQuanYi Micro Hei Mono:style=Regular

7. Below is the conf of WQY Micro Hei, for you to pin down the issue.

cat /etc/fonts/conf.d/65-wqy-microhei.conf  

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
    <match target="font">
        <test name="family">
            <string>WenQuanYi Micro Hei</string>
        </test>
        <edit name="hinting" mode="assign">
            <bool>false</bool>
        </edit>
    </match>

    <match>
        <test name="lang">
            <string>zh</string>
        </test>
        <test name="family">
            <string>monospace</string>
        </test>
        <edit name="family" mode="prepend">
            <string>WenQuanYi Micro Hei Mono</string>
        </edit>
    </match>

    <alias>
        <family>WenQuanYi Micro Hei Mono</family>
        <default>
            <family>monospace</family>
        </default>
    </alias>

    <alias>
        <family>monospace</family>
        <prefer>
            <family>WenQuanYi Micro Hei Mono</family>
        </prefer>
    </alias>

    <match>
        <test name="lang">
            <string>zh</string>
        </test>
        <test name="family">
            <string>sans-serif</string>
        </test>
        <edit name="family" mode="prepend">
            <string>WenQuanYi Micro Hei</string>
        </edit>
    </match>

    <alias>
        <family>WenQuanYi Micro Hei</family>
        <default>
            <family>sans-serif</family>
        </default>
    </alias>

    <alias>
        <family>sans-serif</family>
        <prefer>
            <family>WenQuanYi Micro Hei</family>
        </prefer>
    </alias>
</fontconfig>

8. I've also tried YaHei and SimSun copied from Windows 10, still got tofu, verbose log is as above.

en-us.png

 

zh-cn.png

Edited by ricoazzurro
Link to comment
Posted (edited)

I've read all that I find from forum post and github issue related to font tofu. 

Maybe the reason is that fontconfig recognized the font using it's Chinese Font Name while OpenRCT tries English Font Name?

If so, how to solve this?

fc-query /usr/share/fonts/truetype/winfonts/msyh.ttc
Pattern has 24 elts (size 32)
	family: "Microsoft YaHei"(s) "微软雅黑"(s)
	familylang: "en"(s) "zh-cn"(s)
	style: "Normal"(s) "obyčejné"(s) "Standard"(s) "Κανονικά"(s) "Regular"(s) "Normaali"(s) "Normál"(s) "Normale"(s) "Standaard"(s) "Normalny"(s) "Обычный"(s) "Normálne"(s) "Navadno"(s) "Arrunta"(s)
	stylelang: "ca"(s) "cs"(s) "de"(s) "el"(s) "en"(s) "fi"(s) "hu"(s) "it"(s) "nl"(s) "pl"(s) "ru"(s) "sk"(s) "sl"(s) "eu"(s)
	fullname: "Microsoft YaHei"(s) "微软雅黑"(s)
	fullnamelang: "en"(s) "zh-cn"(s)
	slant: 0(i)(s)
	weight: 80(f)(s)
	width: 100(f)(s)
	foundry: "MS  "(s)
	file: "/usr/share/fonts/truetype/winfonts/msyh.ttc"(s)
	index: 0(i)(s)
	outline: True(s)
	scalable: True(s)
	charset: 

 

Edited by ricoazzurro
Link to comment

There's a work-around in github issue area. 

https://github.com/OpenRCT2/OpenRCT2/issues/13232

https://github.com/keithstellyes/OpenRCT2/commit/3fd43545d00ba4cf0f1bf9bab8092353de397db7

After modifying src/openrct2/platform/Linux.cpp according to keithstellyes' commit and re-compile,

openrct2 starts listening to fontconfig and no tofu this time.

OpenRCT2, v0.3.3-51 (177b5e1b0 on develop)
Linux (arm)
@ 

VERBOSE: time is 2021/03/26 17:21:19
VERBOSE: registering scalar mask function
VERBOSE: Looking for OpenRCT2 data in /usr/local/bin/data
VERBOSE: checking dir /usr/local/bin/data, result = -1, is_dir = 0
VERBOSE: Looking for OpenRCT2 data in /usr/local/bin/../share/openrct2
VERBOSE: checking dir /usr/local/bin/../share/openrct2, result = 0, is_dir = 1
VERBOSE: Looking for OpenRCT2 doc path at ./doc
VERBOSE: checking dir ./doc, result = -1, is_dir = 0
VERBOSE: Looking for OpenRCT2 doc path at /usr/share/doc/openrct2
VERBOSE: checking dir /usr/share/doc/openrct2, result = -1, is_dir = 0
VERBOSE: Checking if file exists: /home/pi/.config/OpenRCT2/config.ini
VERBOSE: DIRBASE::RCT1    : /home/pi/Games/RollerCoaster Tycoon Deluxe
VERBOSE: DIRBASE::RCT2    : /home/pi/Games/RollerCoaster Tycoon 2 Triple Thrill Pack
VERBOSE: DIRBASE::OPENRCT2: /usr/local/bin/../share/openrct2
VERBOSE: DIRBASE::USER    : /home/pi/.config/OpenRCT2
VERBOSE: DIRBASE::CONFIG  : /home/pi/.config/OpenRCT2
VERBOSE: DIRBASE::CACHE   : /home/pi/.config/OpenRCT2
Importing legacy shortcuts...
VERBOSE: Looking for font Microsoft YaHei with FontConfig.[0m
VERBOSE: Using FontConfig provided substitute font /usr/share/fonts/truetype/winfonts/msyh.ttc[0m
VERBOSE: Looking for font SimSun with FontConfig.[0m
VERBOSE: Using FontConfig provided substitute font /usr/share/fonts/truetype/winfonts/simsun.ttc[0m
VERBOSE: Looking for font SimSun with FontConfig.[0m
VERBOSE: Using FontConfig provided substitute font /usr/share/fonts/truetype/winfonts/simsun.ttc[0m
VERBOSE: Checking if file exists: /home/pi/Games/RollerCoaster Tycoon 2 Triple Thrill Pack/Data/g1.dat[0m
VERBOSE: Create directory: /home/pi/.config/OpenRCT2/object[0m

apply-patch.thumb.png.b732a64188a9c637ba91f48a02094645.png

Link to comment

I'm not sure this is the right approach. However this is a bit too difficult for common users.

And it doesn't exlain that I've installed the right font file but fontconfig register it by Chinese font name while openrct2 cann't use it.

Thanks,  keithstellyes.

If anyone got ideas about solving the fontconfig issue, pls help :)

And I'm now in the fontconfig rabbit hole ...

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...