TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Input: Fonts for Code

151 点作者 wasabian将近 11 年前

16 条评论

Stratoscope将近 11 年前
Wow, I never thought I would see proportional fonts specifically designed for coding. I&#x27;ve coded almost exclusively in proportional fonts for over ten years. The font I use the most is Georgia. It makes code easier to read and more pleasing to the eye, just like any other text.<p>Besides personal preference, I think there are two main reasons people avoid proportional fonts: column alignment and two-space indents.<p>Two-space indents are an unfortunate trend in coding styles, because they practically mandate the use of a monospaced font to see the indentation. I use tabs for indentation, which let each developer adjust the visual indentation to suit their own eyes. Four-space indents are OK too.<p>I would love to see programmer&#x27;s editors provide a way to control the amount of visual indentation that each leading space represents.<p>Column alignment of course is not possible with proportional fonts, but that&#x27;s an easy problem to solve: don&#x27;t do it. Instead of this:<p><pre><code> void DoSomethingWithStuff(SomeReallyFancyTypeName thing, string name int count, bool condition); </code></pre> Write this:<p><pre><code> void DoSomethingWithStuff( SomeReallyFancyTypeName thing, string name int count, bool condition ); </code></pre> While you lose the advantage of seeing all the parameter names lined up, it becomes much easier to visually associate each name with its type. My eyes tend to wander when I have to scan across a wide horizontal gap to match things up.<p>This style also leads to much shorter line lengths as can be seen here, and it&#x27;s easier to maintain: You don&#x27;t have to realign things when you change the length of the function name or one of the type names, or when you add a parameter with a longer name than the ones you have already.<p>A case where column alignment is more useful is ASCII art in comments. I&#x27;ve experimented with using a monospaced font for comments and proportional for code, which solves that problem nicely. But I don&#x27;t use ASCII art much myself, so I went back to proportional for everything.<p>I&#x27;m looking forward to trying out these fonts!
评论 #8128691 未加载
eklavya将近 11 年前
Totally subjective opinion, but yet to see something beat Consolas.
评论 #8128368 未加载
评论 #8130339 未加载
评论 #8128511 未加载
tekacs将近 11 年前
Scanning over the page and the &#x27;explanation&#x27; page, I found a headache developing as I tried to read everything there.<p>My experience so far is that I find this far harder to read. For reference&#x27;s sake, I don&#x27;t do parameter alignment in my own code (see Stratoscope&#x27;s comment), but still find it easy to scan code in most-any monospace, probably because my eyes just know where to jump to all the time...<p>For all the words in favour of proportional fonts, I would venture that when the words on a page are in fact ultimately forming macroscopic symbols (identifiers), often with PascalCase or camelCase or underscore_words, uniformity no matter the characters used is perhaps a more useful feature than making the words easily comparable to those read in prose?
评论 #8129323 未加载
PeterisP将近 11 年前
Maybe this is the place to ask about my pet peeve - why do fonts, including specialized coding fonts, position parenthesis with both sides equally?<p>I mean, it seems that for readability it would be better to emphasize the fact that they&#x27;re asymmetrical - when looking at &quot;foo(bar)baz&quot; , it would be better if the parens would be a pixel or so closer to their inner contents; but currently &quot;foo(bar&quot; on most fonts looks as if the paren is merging with the initial text.<p>The same would apply for foo[bar]baz and foo{bar}baz.
评论 #8128479 未加载
alexanderteinum将近 11 年前
This is some truly amazing work. Love the option to change the built-in line spacing.<p>(I’m a monospace addict, and I always switch between Source Code Pro, M+ 1m, and others. What I don’t like about M+ 1m is that it’s narrow, and the line-spacing in the web font is too small.)
评论 #8129287 未加载
NAFV_P将近 11 年前
On the info page:<p>&quot;&quot;&quot; &lt;div&gt;&lt;span class=&quot;highlight&quot;&gt;M&lt;&#x2F;span&gt;&lt;&#x2F;div&gt;<p>&lt;div&gt;&lt;span class=&quot;highlight&quot;&gt;M&lt;&#x2F;span&gt;&lt;&#x2F;div&gt;<p>&lt;div&gt;&lt;spam class=&quot;highlight&quot;&gt;M&lt;&#x2F;spam&gt;&lt;&#x2F;div&gt;<p>&lt;div&gt;&lt;span class=&quot;highlight&quot;&gt;M&lt;&#x2F;span&gt;&lt;&#x2F;div&gt;<p>proportional fonts can make it easier to spot typos &quot;&quot;&quot;<p>The example given demonstrates that a <i>certain subset</i> of typos can be caught using proportional fonts, but not all.<p>If a word has too many or too few characters in it, I think you are more likely to spot it utilising a monospaced font.<p>EDIT: the quote has been made more legible.
评论 #8128763 未加载
sanityinc将近 11 年前
Just the Mono family alone is excellent. There are a number of different weights available, each with italic and bold variants, and the repertoire of glyphs is extensive.<p>I enjoy condensed fonts like Pragmata Pro (which I highly recommend), and this appears to be one of the few viable alternatives I&#x27;ve seen. Merits a week-long test-drive, I think.
评论 #8128904 未加载
err4nt将近 11 年前
I have been having a love affair with Source Code Pro, thin weight, at about 14pt, using Solarized Dark color palette.<p>There&#x27;s something refreshing about it, it&#x27;s nice, big, clean, and LEGIBLE. I use it for my IDE and terminals and there&#x27;s no turning back.<p>Highly recommend everybody check out Source Code Pro!
评论 #8128844 未加载
noir_lord将近 11 年前
Looks nice, I&#x27;ve switched my terminal to Condensed and works great.<p>I unfortunately can&#x27;t use it in my main IDE&#x27;s as both PyCharm and PHPStorm have bad aliasing on Linux fortunately solved by Terminus which doesn&#x27;t require it.
artursapek将近 11 年前
I will likely never stop using M+ 1m, which is a somewhat unknown font. Nice and narrow. Efficient. <a href="http://www.fontsquirrel.com/fonts/M-1m" rel="nofollow">http:&#x2F;&#x2F;www.fontsquirrel.com&#x2F;fonts&#x2F;M-1m</a>
zitterbewegung将近 11 年前
The example with breakcycles seems to be broken on chrome 36.0.1985.125 (Official Build 283153) for windows. <a href="http://imgur.com/hd4REcG" rel="nofollow">http:&#x2F;&#x2F;imgur.com&#x2F;hd4REcG</a>
willtheperson将近 11 年前
This caused me to lookup Sublime Text (3)&#x27;s font configuration options and see there were some options I didn&#x27;t know about. For example, you can add line-height by adding<p><pre><code> { &quot;line_padding_bottom&quot;: 2, &quot;line_padding_top&quot;: 2 } </code></pre> to your Preferences file. Found this info here in what is also the best version of a ST manual I&#x27;ve seen <a href="http://sublime-text-unofficial-documentation.readthedocs.org/en/latest/reference/settings.html" rel="nofollow">http:&#x2F;&#x2F;sublime-text-unofficial-documentation.readthedocs.org...</a>
jamesaguilar将近 11 年前
I like the look of it. Will definitely try for a couple of days next week. No reason not to. ☺
NikKlaus将近 11 年前
It&#x27;s nice but Pragmata Pro is teh_one
mikerg87将近 11 年前
I would have liked to have seen the example page have a section how it behaves with ASCII art that you sometimes see in comments.
评论 #8129141 未加载
jimhefferon将近 11 年前
HN would benefit from a programming font respite.