<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>~iany/ Typography</title><link>https://blog.iany.me/tags/typography/</link><description>Recent content in Typography «~iany/»</description><language>en-US</language><managingEditor>me@iany.me (Ian Yang)</managingEditor><webMaster>me@iany.me (Ian Yang)</webMaster><copyright>CC-BY-SA 4.0</copyright><lastBuildDate>Sat, 11 Sep 2021 21:21:30 +0800</lastBuildDate><atom:link href="https://blog.iany.me/tags/typography/index.xml" rel="self" type="application/rss+xml"/><item><title>Use Italic Font for Coding</title><link>https://blog.iany.me/2021/09/use-italic-font-for-coding/</link><pubDate>Sat, 11 Sep 2021 21:21:30 +0800</pubDate><author>me@iany.me (Ian Yang)</author><guid>https://blog.iany.me/2021/09/use-italic-font-for-coding/</guid><description>&lt;p&gt;I discovered &lt;a href="https://marketplace.visualstudio.com/items?itemName=liviuschera.noctis"&gt;Noctis&lt;/a&gt; theme recently and found that the font &lt;a href="https://connary.com/cartograph.html"&gt;Cartograph CF&lt;/a&gt; is really interesting.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Cartograph is a handsome monospaced font family featuring lush italics, code-friendly ligatures&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;It’s funny to see those handwriting like italic characters while coding, so I purchased the font and integrated it into my tools.&lt;/p&gt;
&lt;p&gt;For Visual Studio Code, I use Noctis. But it uses too much italic style, which decreases the readability. Here are my customizations:&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-json"&gt;{
&amp;quot;editor.tokenColorCustomizations&amp;quot;: {
&amp;quot;[Noctis]&amp;quot;: {
&amp;quot;textMateRules&amp;quot;: [
{
&amp;quot;scope&amp;quot;: &amp;quot;markup.list&amp;quot;,
&amp;quot;settings&amp;quot;: { &amp;quot;fontStyle&amp;quot;: &amp;quot;&amp;quot; }
},
{
&amp;quot;scope&amp;quot;: &amp;quot;text.markdown.notes.tag&amp;quot;,
&amp;quot;settings&amp;quot;: { &amp;quot;fontStyle&amp;quot;: &amp;quot;italic&amp;quot; }
}
]
}
},
// ...
}
&lt;/code&gt;&lt;/pre&gt;
&lt;figure class="kg-image-card kg-width-wide"&gt;
&lt;img alt="Visual Studio Code" class="kg-image" loading="lazy" src="https://blog.iany.me/2021/09/use-italic-font-for-coding/vscode_hu_86a0e1dbb8c512ce.png" srcset="https://blog.iany.me/2021/09/use-italic-font-for-coding/vscode_hu_27c1cff861c6d229.png 400w, https://blog.iany.me/2021/09/use-italic-font-for-coding/vscode_hu_73cbb4cd89465103.png 800w, https://blog.iany.me/2021/09/use-italic-font-for-coding/vscode_hu_e7334215202d837a.png 1200w, https://blog.iany.me/2021/09/use-italic-font-for-coding/vscode_hu_434a0619d3bf9264.png 1600w, https://blog.iany.me/2021/09/use-italic-font-for-coding/vscode_hu_83b367269ae14d38.png 2000w, https://blog.iany.me/2021/09/use-italic-font-for-coding/vscode_hu_86a0e1dbb8c512ce.png 2838w" sizes="(max-width: 2000px) 100vw, 2838px" /&gt;
&lt;figcaption &gt;Visual Studio Code&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;It&amp;rsquo;s handy to inspect the syntax highlight scope under cursor using the command &amp;ldquo;Developer: Inspect Editor Tokens and Scopes&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;In macOS Terminal, I can use the escape code &lt;code&gt;\e[3m&lt;/code&gt; to enable italic and &lt;code&gt;\e[23m&lt;/code&gt; to reset.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-bash"&gt;printf &amp;quot;\e[3mitalic\e[23m&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Or using echo&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-bash"&gt;echo &amp;quot;^[[3mitalic^[[23m&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Where the &lt;code&gt;^[&lt;/code&gt; is indeed how the terminal displays Esc. One way to insert Esc is via &lt;code&gt;Ctrl-v Esc&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;I switched to &lt;a href="https://starship.rs/"&gt;starship&lt;/a&gt; recently, so I don&amp;rsquo;t need to bother setting up the italic fonts in my shell prompt by myself. Here is my starship config file:&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-toml"&gt;format = &amp;quot;[$all](italic)&amp;quot;
[directory]
format = '[%\(4~|%-1~/…/%2~|%~\)]($style)[$read_only]($read_only_style) '
[git_branch]
symbol = &amp;quot;±&amp;quot;
style = &amp;quot;purple bold italic&amp;quot;
[status]
disabled = false
[nodejs]
symbol = '🤖 '
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I changed the nodejs symbol, because Cartograph CF has no the nerd font icons.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;m a heavy user of tmux, it&amp;rsquo;s tricky to enable italics in tmux. The secret is setting &lt;code&gt;default-terminal&lt;/code&gt; to tmux.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-bash"&gt;set -g default-terminal &amp;quot;tmux&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then set back the terminal to &lt;code&gt;xterm-256color&lt;/code&gt; via &lt;code&gt;default-command&lt;/code&gt; because macOS Terminal does not understand what is the &lt;em&gt;tmux&lt;/em&gt; terminal.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-bash"&gt;set -g default-command &amp;quot;env TERM=xterm-256color zsh&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I only configure the session name to be italic.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-bash"&gt;set -g status-left &amp;quot;#[fg=white,bg=colour31,nobold,italics] #S &amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I cannot find a cross-platform way to show italic font in vim, so I manually enable it when I want to see the funny italic characters in the comment:&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-vim"&gt;function! s:Italic(enable)
if a:enable
hi Comment cterm=italic gui=italic
hi Folded cterm=italic gui=italic
let &amp;amp;t_ZH = &amp;quot;\e[3m&amp;quot;
let &amp;amp;t_ZR = &amp;quot;\e[23m&amp;quot;
else
hi Comment cterm=none gui=none
hi Folded cterm=none gui=none
let &amp;amp;t_ZH = ''
let &amp;amp;t_ZR = ''
endif
endfunction
command! ItalicEnable call s:Italic(1)
command! ItalicDisable call s:Italic(0)
&lt;/code&gt;&lt;/pre&gt;
&lt;figure class="kg-image-card kg-width-wide"&gt;
&lt;img alt="Shell, Tmux and Vim" class="kg-image" loading="lazy" src="https://blog.iany.me/2021/09/use-italic-font-for-coding/shell-tmux-vim_hu_10dda27268ca9775.png" srcset="https://blog.iany.me/2021/09/use-italic-font-for-coding/shell-tmux-vim_hu_c33f44053e0ac874.png 400w, https://blog.iany.me/2021/09/use-italic-font-for-coding/shell-tmux-vim_hu_7ee0fdf1e595205f.png 800w, https://blog.iany.me/2021/09/use-italic-font-for-coding/shell-tmux-vim_hu_6eb0456fb69ffcde.png 1200w, https://blog.iany.me/2021/09/use-italic-font-for-coding/shell-tmux-vim_hu_3cbeb0692be9fcb4.png 1600w, https://blog.iany.me/2021/09/use-italic-font-for-coding/shell-tmux-vim_hu_e4a941b78d9e06ca.png 2000w, https://blog.iany.me/2021/09/use-italic-font-for-coding/shell-tmux-vim_hu_10dda27268ca9775.png 2454w" sizes="(max-width: 2000px) 100vw, 2454px" /&gt;
&lt;figcaption &gt;Shell, Tmux and Vim&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;The last tool is &lt;a href="https://obsidian.md/"&gt;Obsidian&lt;/a&gt;, I use the CSS snippet to customize the appearance:&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-css"&gt;:root {
--font-monospace: 'Cartograph CF', monospace;
}
.cm-meta, .cm-hmd-frontmatter, .tag, .image-embed[alt]:after {
font-style: italic;
font-family: var(--font-monospace);
}
.cm-meta.cm-formatting-task {
font-style: normal;
font-family: var(--default-font);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Fortunately, it also works on iOS after installing the fonts to the system via &lt;a href="https://apps.apple.com/us/app/fontcase-manage-your-type/id1205074470"&gt;Fontcase&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I have also tested several frequently used iOS apps.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.textasticapp.com/"&gt;Textastic&lt;/a&gt; can use the fonts installed by Fontcase, and Cartograph CF works perfect. The app &lt;a href="https://holzschu.github.io/a-Shell_iOS/"&gt;a-Shell&lt;/a&gt; is also fine to use the self installed fonts.&lt;/p&gt;
&lt;p&gt;But &lt;a href="https://blink.sh/"&gt;Blink&lt;/a&gt; does not support system fonts. Although it can install fonts via CSS, I cannot make Blink display Cartograph CF using the correct line height. It also makes Blink sluggish and unstable.&lt;/p&gt;
&lt;p&gt;I use an Android phone currently, but I give up the joy to use Cartograph CF on my phone. Because I don&amp;rsquo;t use it for work and it seems hard to install fonts on Android. I tried to make it work in Obsidian, by copying fonts to Obsidian vault and using remote font URL, but both failed.&lt;/p&gt;</description><category domain="https://blog.iany.me/post/">Posts</category><category domain="https://blog.iany.me/tags/console/">Console</category><category domain="https://blog.iany.me/tags/obsidian/">Obsidian</category><category domain="https://blog.iany.me/tags/tmux/">Tmux</category><category domain="https://blog.iany.me/tags/typography/">Typography</category><category domain="https://blog.iany.me/tags/vim/">Vim</category></item></channel></rss>