I am working to add some fonts containing devicons to my $HOME dir for use in vim and gvim. vim needs the font in the terminal so I'm trying this command and get a xterm: unable to open font <name>, trying "fixed" error:
xterm -u8 -fn '-misc-knack-bold-i-normal--0-0-0-0-p-0-iso8859-15'
I see that specified font in the fonts.dir file and I've refreshed my cache with fc-cache -f -v. fc-list shows Knack:style=NerdFontPlusOcticonsPlusPomicons but using that string yields the same result. xfontsel does NOT show this as an available font but gvim does show this font as an option.
Why does the font appear in fonts.dir (and fonts.scale) but not in xfontsel?
Why does gvim see the font but not X11?
Shell is tcsh on a Suse11 system.
This
-misc-knack-bold-i-normal--0-0-0-0-p-0-iso8859-15
is a scalable font as described in mkfontdir, because all of the sizes are zeros. xterm and xfd need sizes. You can experiment with
#!/bin/sh
FONT=`xfontsel -print`
test -n "$FONT" && xfd -fn "$FONT
to see what sizes the font server would like to deliver for a non-scaled version of the font, or use the name from fc-list with the -fa option of xterm and xfd:
-fa pattern
This option sets the pattern for fonts selected from the
FreeType library if support for that library was compiled into
xterm. This corresponds to the faceName resource. When a CJK
double-width font is specified, you also need to turn on the
cjkWidth resource.
Further reading:
X Logical Font Description (Arch wiki)
Appendix A. Specifying Fonts (SGI developer books)
Appendix A. Specifying Fonts: Scalable Fonts
Related
How to export a glyph (from its unicode) to SVG with Fontforge command line ?
I also need to specify the font size and keep the original margins it has in the font.
You may have found your answer already, but I just had to do this with the latest build of FontForge. The old answer of this command:
fontforge -lang=ff -c 'Open($1); SelectWorthOutputting(); foreach Export("svg"); endloop;' font.ttf
From a command prompt didn't want to work on Windows10 (I assume a permission issue), but you could give it a try. A quick work-around is to do it via the GUI Execute Script.
Run FontForge (For Windows10 installed in the Program Files (x86) directory, you may need to right-click "run_fontforge.exe" --> Run As Administrator).
Open the font you want to export.
Go to File > Execute Script
Paste: SelectWorthOutputting(); foreach Export("svg"); endloop;
Select "FF" radial button.
Hit OK
It'll save to the FontForge folder (where run_fontforge.exe is located).
On Windows os (Tested on win10)
this is from inside a BATCH file:
c:\Programs\FontForge\bin\fontforge.exe -lang=ff -c "Open($1); SelectWorthOutputting(); foreach Export('%%e_%%f_%%n_%%u.eps'); endloop;" %1
this is directly on the command line:
c:\Programs\FontForge\bin\fontforge.exe -lang=ff -c "Open($1); SelectWorthOutputting(); foreach Export('%e_%f_%n_%u.eps'); endloop;" font-file.ttf
note - the color is not exported. And I don't know if it's unimplemented, or a bug.
I have problem when try to convert SVG to PNG use Inkscape, the SVG file contain custom font that not available in my machine(Linux).
SVG File:
https://dl.dropboxusercontent.com/u/61378613/source_file.svg
Here the command to convert into PNG:
sudo inkscape -z -e result.png -w 3750 -h 7350 -d 3028 source_file.svg
Here there result when use inkscape:
this is the result open in browser:
You need to install the font on the system, inkscape can't guess glyphs shapes of a font it has no access to.
The browser is living in the network, so it cheats by downloading web fonts in the background (and not making them available to other apps, that's web fonts main weakness)
I have installed MATLAB R2008b on Ubuntu 12.04.4 LTS and Windows XP.
The system locale in Ubuntu is Unicode - en_US.UTF-8.
For compatibility with Windows I launch MATLAB in Ubuntu with ru_RU.CP1251 locale - so I have simple script to launch MATLAB:
cat /opt/MATLAB_R2008b/bin/matlab-run
#!/bin/bash
export LANG="ru_RU.CP1251";
export LC_ALL="ru_RU.CP1251";
/opt/MATLAB_R2008b/bin/matlab -desktop
After that slCharacterEncoding and feature('DefaultCharacterSet') returns desired windows-1251 as expected.
There are many fonts in my system, almost all support Russian (Cyrillic) glyphs.
Russian text displays normally in uicontrol (see screenshot )
uicontrol('String','Русский=Russian','Position',[0 0 200 200])
but does not in figure labels and title, so
x = linspace(0,2*pi,100); y = sin(x);
xlabel('x, в радианах','interpreter','none');
ylabel('y, значение sin(x)','interpreter','none');
title('y, значение sin(x)','interpreter','none');
produce wrong characters in labels and title .
I have no idea how to fix this.
How should I setup MATLAB for correct display of Russian (Cyrillic) characters on figures in Linux?
I solved my problem.
I installed all recommended fonts - packages xfonts-100dpi, xfonts-75dpi, xfonts-cyrillic, t1-cyrillic, cm-super, ttf-freefont, gsfonts-x11.
But what is interesting these fonts work only for UTF-8, so I can use the following fonts for displaying Russian (Cyrillic) text in figures:
clean
free avant garde
free bookman
free chancery
free courier
free helvetian
free paladin
free schoolbook
free times
oldslavic
tahoma guap
teams
terminus
For my original problem I found special ttf-font file, which works as expected and Russian (Cyrillic) text looks as expected in CP/Windows-1251 charset.
I placed this font in /usr/local/share/fonts/truetype, ran mkfontscale, mkfontdir and fc-cache -vf and added this location to /etc/X11/xorg.conf:
Section "Files"
FontPath "/usr/share/fonts/truetype"
FontPath "/usr/local/share/fonts/truetype"
EndSection
.
I installed language-pack-ru and edited /var/lib/locales/supported.d/local as follows:
en_US.UTF-8 UTF-8
ru_RU ISO-8859-5
ru_RU.CP1251 CP1251
ru_RU.KOI8-R KOI8-R
The vim manual states:
On systems where 'guifontset' is supported (X11) and 'guifontset' is
not empty, then 'guifont' is not used.
Spaces after a comma are ignored. To include a comma in a font name
precede it with a backslash. Setting an option requires an extra
backslash before a space and a backslash. See also
|option-backslash|. For example: >
:set guifont=Screen15,\ 7x13,font\\,with\\,commas
will make Vim try to use the font "Screen15" first, and if it fails it
will try to use "7x13" and then "font,with,commas" instead.
So, I would like to do the following:
if has("gui_running")
if has("gui_gtk2")
set guifont=Droid\ Sans\ Mono,Inconsolata,Monospace
elseif has("gui_win32")
set guifont=Droid\ Sans\ Mono:h10,Consolas:h11:cANSI
endif
endif
Trouble is that it does not work for me... I have been trying for a couple of hours on CentOS6.3 and Debian Wheey, but when ever I write this command like this, VIM will just start with Sans font.
Am I doing something wrong? How do you smartly detect which fonts are on the system ?
OK, I know this is probably not the right way, but it works. So, here is how I set a fallback font for VIM-GTK:
if has("gui_running")
if has("gui_gtk2")
let dsm=system('fc-list | grep -c Droid\ Sans\ Mono')
let cons=system('fc-list | grep -c Inconsola')
if ( dsm > 0)
set gfn=Droid\ Sans\ Mono\ 10
elseif ( cons > 0)
set gfn=Inconsolata\ 12
else
set gfn=Monospace\ 10
endif
elseif has("gui_win32")
set guifont=Droid\ Sans\ Mono:h10,Consolas:h11:cANSI
endif
endif
This snippet will check if Droid Sans Mono is installed, and also if Inconsolata is installed.
If the first one is install, the UI font will be Droid Sans Mono, if not it will be set to Inconsolata, and finally, it will be set to Monospace.
On Windows 7 the comma separated list just works.
I ran into the same issue. The problem here is that when Vim calls gui_init_font (code) it expects if gui_mch_get_font (code) fails it can move on to the next font in the comma-separated list. But in GTK gui_mch_get_font calls pango_font_description_from_string (code) which will never fail, it'll just return a default.
But pango_font_description_from_string itself takes a comma-separated list of families followed by style options, size and variations and has its own fallback logic (doc) withe the following format: [FAMILY-LIST] [STYLE-OPTIONS] [SIZE] [VARIATIONS]. Thus escape your list as follows:
if has("gui_running")
if has("gui_gtk2") || has("gui_gtk3")
set guifont=Droid\ Sans\ Mono\\,Inconsolata\\,Monospace 10
elseif has("gui_win32")
set guifont=Droid\ Sans\ Mono:h10,Consolas:h11:cANSI
endif
endif
Then Pango will do the fallback work and pick the right font for you. On GTK it seems to be best to fully escape your string and let GTK do the logic.
I either failed to get Oz123's answer properly abstracted into a function or else otherwise couldn't get this working on my system. I had additional issues due to actually using two users (a sandboxed web user and my main account); there was some problem executing fc-list).
My workaround was to reassign the alias for the Monospace font, which affects all of my apps (don't employ this technique if you only want this to work in gvim).
This change goes into ~/.config/fontconfig/fonts.conf:
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<alias>
<family>monospace</family>
<prefer><family>Panic Sans</family></prefer>
</alias>
</fontconfig>
I chose Panic Sans (unofficially hosted here), a variant of the highly popular free DejaVu Sans Mono font, because it is particularly good at rendering code (it additionally solves the underscore and dash problem in DejaVu). The font's files themselves live in my ~/.fonts/Panic_Sans directory.
Installing it in this manner allows me to share my ~/.vimrc between systems and not have to worry about whether Panic Sans is installed on them.
This means that my ~/.vimrc now merely contains:
if has("gui_running")
if has("gui_gtk2")
set guifont=Monospace\ 7
endif
" …
And this works because the fontconfig alias properly matches Monospace to Panic Sans:
$ fc-match Monospace
PanicSans.ttf: "Panic Sans" "Regular"
I'm trying to get ghostscript to render a pdf file from a Windows box. The pdf file uses the ComicSansMS font. I've copied the comic.ttf file from my Windows7 box into my /usr/share/ghostscript/fonts directory, and I've created a Fontmap file in that same directory containing this line:
/ComicSansMS (comic.ttf) ;
As nearly as I can tell, the font is not being found despite this. The text comes out very poorly, and some of the smaller font sizes are rendered half the size they should be. Access times and strace show that the Fontmap file is being read, but the font file (comic.ttf) is not being accessed at all. There are no error messages:
hope 78$ gs cards-01.pdf
GPL Ghostscript 9.00 (2010-09-14)
Copyright (C) 2010 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 1.
Page 1
>>showpage, press <return> to continue<<
If I use -dFAPIDEBUG on the gs command line, I see the following:
hope 74$ gs -dFAPIDEBUG -I/usr/share/ghostscript/fonts cards-01.pdf
GPL Ghostscript 9.00 (2010-09-14)
Copyright (C) 2010 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 1.
Page 1
FAPIhook --nostringval--
Trying to render the font Font --nostringval-- ( aliased from ComicSansMS ) with FAPI...
Font --nostringval-- ( aliased from ComicSansMS ) is being rendered with FAPI=FreeType
FAPIhook --nostringval--
Font --nostringval-- ( aliased from ComicSansMS ) is mapped to FAPI=FreeType
FAPIhook RVJCAL+SymbolMT
Trying to render the font Font RVJCAL+SymbolMT with FAPI...
Font RVJCAL+SymbolMT is being rendered with FAPI=FreeType
FAPIhook RVJCAL+SymbolMT
Font RVJCAL+SymbolMT is mapped to FAPI=FreeType
FAPIhook HYLUQF+ComicSansMS
Trying to render the font Font HYLUQF+ComicSansMS with FAPI...
Font HYLUQF+ComicSansMS is being rendered with FAPI=FreeType
FAPIhook HYLUQF+ComicSansMS
Font HYLUQF+ComicSansMS is mapped to FAPI=FreeType
>>showpage, press <return> to continue<<
Naturally, the line from the above that most concerns me is this one:
Font --nostringval-- ( aliased from ComicSansMS ) is being rendered with FAPI=FreeType
"gs -h" shows that the font directory is, indeed, in the search path:
hope 77$ gs -h
GPL Ghostscript 9.00 (2010-09-14)
[ ... ]
Search path:
/usr/share/ghostscript/9.00/Resource/Init :
/usr/share/ghostscript/9.00/lib :
/usr/share/ghostscript/9.00/Resource/Font :
/usr/share/ghostscript/fonts : /usr/share/fonts/Type1 : /usr/share/fonts
I've tried several permutations of formatting in the Fontmap file, including:
(Comic Sans MS) (comic.ttf) ;
(ComicSansMS) (comic.ttf) ;
/Comic Sans MS (comic.ttf) ;
/ComicSansMS /comic.ttf ;
I'm fairly sure my original one is the correct one, but I was getting desperate. :-P
Any help would be greatly appreciated. Thanks in advance.
I assume that PDF does not have the ComicSansMS font embedded?
You should consider 2 other possibilities as well:
Your PDF file card-01.pdf is somehow corrupted. (Are other PDF viewers rendering that file without a problem? Does it display OK in Acrobat Reader on Widnows?)
Your fontfile comic.ttf is somehow corrupted. (Which method did you use to transfer it from Windows to Linux?)
You could try to positively proof that both these components are getting along well enough with each other by using Ghostscript+comic.ttf to create a PDF (with comic.ttf embedded):
gs \
-sFONTPATH=/usr/share/ghostscript/fonts \
-o comic-ttf.pdf \
-sDEVICE=pdfwrite \
-g5950x8420 \
-c "200 700 moveto" \
-c "/ComicSansMS findfont 60 scalefont setfont" \
-c "(comic.ttf) show showpage"
On Windows, use this variation of above command:
gswin32c.exe ^
-o comic-ttf.pdf ^
-sDEVICE=pdfwrite ^
-sFONTPATH=c:/windows/fonts ^
-g5950x8420 ^
-c "200 700 moveto" ^
-c "/ComicSansMS findfont 60 scalefont setfont" ^
-c "(comic.ttf) show showpage"
When I do this, I see:
gswin32c.exe ^
-o comic-ttf.pdf ^
-sDEVICE=pdfwrite ^
-sFONTPATH=c:/windows/fonts ^
-dHaveTrueTypes=true ^
-g5950x8420 ^
-c "200 700 moveto" ^
-c "/ComicSansMS findfont 60 scalefont setfont" ^
-c "(comic.ttf) show showpage"
GPL Ghostscript 9.00 (2010-09-14)
Copyright (C) 2010 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Scanning c:/windows/fonts for fonts... 423 files, 255 scanned, 240 new fonts.
Loading ComicSansMS font from c:/windows/fonts/comic.ttf... 3343720 1813337 2926116 1611207 1 done.
and my output PDF comic-ttf.pdf looks OK and does have the comic.ttf font embedded.
If this does also work for you, then your Ghostscript and your comic.ttf are OK, but your PDF file cards-01.pdf is not.
I came back to this problem after a delay. Upon further investigation with a magnifying glass, the problem is different from what I initially thought.
Text is definitely being rendered incorrectly in parts of the document. Each letter is far too small, though the spacing is oddly correct. However, the individual letters are the correct shape for the font.
The font on disk is not being accessed, but that's because the fonts are all embedded within the document. This fact would probably have been obvious to a Ghostscript expert from the output I posted in the original question (I'm guessing the "HYLUQF+" prefix is the smoking gun there), but I don't work with Ghostscript much. My fonts were installed correctly, and other documents were able to access them without trouble.
Of course, this still leaves the question of why my embedded fonts are being rendered incorrectly, but I will investigate that separately and/or post a different question. I maintain that the PDF file is uncorrupted (I have several other PDFs which exhibit the same problem), but I still don't know what's wrong.
#pipitas: Thanks very much for trying. You certainly did help verify that my installed fonts are not the problem. Actually, now that I look again, you even gently suggested the font might be embedded, but I either didn't see it, didn't believe it, or didn't know how to check.