If I have a Windows user name with "special" characters like accents (e.g. flávia), the path where the executable of Rttf2pt1 is installed might have "special" characters as well. In the current version of extrafont, we would get this error when calling font_import():
Scanning ttf files in C:\Windows\Fonts ...
Extracting .afm files from .ttf files...
C:\Windows\Fonts\AGENCYB.TTFError in system2(ttf2pt1, c(args, shQuote(ttfiles[i]), shQuote(tmpfiles[i])), :
'"C:/Users/flávia/Documents/R/win-library/4.0/Rttf2pt1/exec/ttf2pt1.exe"' not found
As we can see, the path of the executable was wrongly encoded (it should be C:/Users/flávia/Documents/R/...).
Solution
I propose to convert the Rttf2pt1's path received from which_ttf2pt1() to the native encoding of the system, which should be the encoding of the path string passed to the system2 function. We can do that by symply calling enc2native. If the string is already in the correct encoding (e.g. UTF-8 in Linux), it will not be modified and will keep its current encoding. Code sample:
Bug Description
If I have a Windows user name with "special" characters like accents (e.g.
flávia
), the path where the executable of Rttf2pt1 is installed might have "special" characters as well. In the current version ofextrafont
, we would get this error when callingfont_import()
:As we can see, the path of the executable was wrongly encoded (it should be
C:/Users/flávia/Documents/R/...
).Solution
I propose to convert the Rttf2pt1's path received from
which_ttf2pt1()
to the native encoding of the system, which should be the encoding of the path string passed to thesystem2
function. We can do that by symply callingenc2native
. If the string is already in the correct encoding (e.g. UTF-8 in Linux), it will not be modified and will keep its current encoding. Code sample: