Emacs `Invalid font name` - emacs

I am using GNU Emacs 24.3.1 (x86_64-suse-linux-gnu, GTK+ Version 3.6.4). I have custom font Inconsolata-g in my ~/.fonts folder, and I have set it as Monospace font in ~/.config/fontconfig/fonts.conf. It works well except Emacs is giving me error: Invalid font name, -unknown-Inconsolata-g-normal-normal-normal-*-15-*-*-*-m-0-iso10646-1 at launch.
If I change monospace font, then Emacs launch without problem, but when I do M-x set-default-font, and select -unknown-Inconsolata-g-normal-normal-normal-*-*-*-*-*-m-0-iso10646-1, I also get Invalid font name: "-unknown-Inconsolata-g-normal-normal-normal-*-*-*-*-*-m-0-iso10646-1".
How could i fix this?

Thanks to Peter Dyballa (http://lists.gnu.org/archive/html/help-gnu-emacs/2013-06/msg00347.html), I fixed this with the following in my ~/.emacs:
(setq initial-frame-alist '(
(font . "Monospace-10")
))
(setq default-frame-alist '(
(font . "Monospace-10")
))
(I have set Monospace to Inconsolata-g in my system settings)

Related

Install font for emacs 24.x

I've installed emacs 24.3, and I would like to use a specific font (Meslo LG M DZ), but when I launch emacs, I have the message "Font `Meslo LG M DZ' is not defined". What is strange, is that when I downgrade emacs version from 24 to 23, using the same configuration file, I can use this font without any problem...
Here is how I declare Meslo in the configuration file :
(setq default-frame-alist
'(
(width . 80)
(tool-bar-lines . 0)
=> (font . "Meslo LG M DZ") <=
(vertical-scroll-bars . nil)
))
(unless (fboundp 'prog-mode) (defalias 'prog-mode 'fundamental-mode))
...
How can I solve this?
You could try setting the font manually using the
Options->Set default font
menu, and then clicking
Options->Save Options, which will write the setting automatically to your .emacs file. You could then use that snippet henceforth.
It was just a matter of compilation option...
I didn't use "--without-xft", but I needed to explicitly put "--with-xft".

Tomorrow theme for Emacs shows Chinese charaters as blocks

I installed Tomorrow theme into my Emacs24 using melpa.
Chinese characters appeared as blocks in comments while showing the correct characters in other places.
The default font in my .emacs is like following:
(set-default-font "Menlo-12")
(setq default-frame-alist '(font . "Menlo-12"))
It seems like the Menlo font doesn't support italic Chinese characters. Type M-x customize-face RET font-lock-comment-face and change "slant" to "normal", and the characters should appear.

Emacs buffer-local font

For all my tasks I use URW Chancery L font in Emacs. But for some tasks,
like org-mode tables, shell or sunrise-commander, I would like to set mono-width font.
So, my question, how can I do it? All I found about it is set-default-font, which is not what I want.
Faces (i.e. the objects used to specify appearence of text such as font, color, ...) are mostly global in Emacs, although they can also be set on a frame basis, so you can do the above by creating a separate frame and change the `default' face to use in that frame.
This said, Emacs can also now also change face's appearence for specific buffers via face-remapping. E.g.
(face-remap-add-relative 'default '(:family "Monospace"))
should make the current buffer use Monospace. So adding the above to org-mode-hook might just solve your problem.
This snippet sets the "Arial" font family only in C mode:
(defun set-my-font ()
(overlay-put (make-overlay (point-min) (point-max) nil nil t)
'face '(:family "Monospace")))
(add-hook 'org-mode-hook 'set-my-font)
Replace with org-mode-hook with the desired mode(s), and it should work as well.
This solution effects creation of buffer-local font by setting the font family property of an overlay over the entire buffer. The overlay's face property only specifies the font family (Monospace), and Emacs redisplay is smart enough to merge it with other text properties, such as the colors specified by font-lock.
Did you try to customize org-table ?
You can modify it with org-menu > Customize > Customize > org-table
or use the command line
M-x set-face-font RET org-table RET -PfEd-DejaVu Sans Mono-normal-normal-normal-*-*-*-*-*-m-0-iso10646-1
Use tab to auto-complete and see other available fonts
Finaly you could also directly modify you init.el to have something like
(custom-set-faces
'(org-table ((t (:foreground "LightSkyBlue" :family "DejaVu Sans Mono")))))

emacs equivalent of vim's bg=dark? (setting background to dark)

In vim, I can run set bg=dark and then vim will adjust all syntax highlighting to work on a terminal with a dark background (whether or not the background actually is dark, vim will assume that it is).
How do I tell emacs to assume that the background is either dark or light?
I've used the invert-face function in the past:
(invert-face 'default)
Or:
M-x invert-face <RET> default
I think the best approach to use is to use ColorTheme. Other options to customize the frame colors you can find here. I can't think about a single command, however you can start emacs with --reverse-video.
M-x set-variable <RET> frame-background-mode <RET> dark
see also the bottom of https://www.gnu.org/software/emacs/manual/html_node/elisp/Defining-Faces.html
Write this at the end of your ~/.emacs file :
;; dark mode
(when (display-graphic-p)
(invert-face 'default)
)
(set-variable 'frame-background-mode 'dark)
Note: The "when" sentence is there to avoid to invert colors in no-window mode (I presume your terminal has already a black background).
The alect-themes package for Emacs 24 provides light, dark, and black themes, and can be installed either manually or using MELPA.
To install alect-themes using MELPA and select alect-dark (from ~/emacs.d/init.d):
(when (>= emacs-major-version 24)
(require 'package)
(add-to-list 'package-archives
'("melpa-stable" . "http://melpa-stable.milkbox.net/packages/"))
(package-initialize)
(load-theme 'alect-dark)
)
There are quite a few color theme packages in MELPA, so if alect-themes doesn't meet your needs, experiment with some of the others.

Turn off anti-alias for font in Emacs 23

How to I disable anti-aliasing for fonts in the Windows version of Emacs 23?
Thanks.
You can specify the antialias=none option for your fonts, as stated in GNU Emacs Manual
As I couldn't find a satisfactory answer to this one for a long time, I thought it wouldn't hurt to add this link to this discussion, as the above does not generally work on Linux:
http://keyboardconnoisseur.blogspot.com/2011/04/turning-off-antialiasing-for-specific.html
The problem is that under Linux, emacs doesn't seem to be doing a lot of font handling at all, and you need to disable the antialiasing elsewhere.
If others were searching for how to disable anti-aliasing in OS X, you can run
defaults write org.gnu.Emacs AppleAntiAliasingThreshold 999
Never have run Mac OS X, so usable only for Linux + Windows:
(defvar my-preferred-font
(cond
((eq window-system 'x)
"-misc-fixed-medium-r-normal--14-*-*-*-c-*-iso10646-1")
((eq window-system 'w32)
"Courier New-10:antialias=none")
(t nil)))
(when my-preferred-font
(set-frame-font my-preferred-font)
(set-fontset-font "fontset-default" 'latin my-preferred-font)
(set-fontset-font "fontset-default" 'phonetic my-preferred-font)
(set-fontset-font "fontset-default" 'cyrillic my-preferred-font)
(set-fontset-font "fontset-default" 'greek my-preferred-font))
Whose uses only ASCII it is enough to follow official suggestion:
(add-to-list 'default-frame-alist '(font . "Courier New-10:antialias=none"))
I work with cyrillic, greek and IPA texts so need to define defaults for fontsets...