what is the good gvim guifont for C/C++ programming [closed] - c++

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I am trying to find an optimal font for gvim to program in C/C++.
I currently have the following in ~/.gvimrc and I don't like it:
if has("gui_gtk2")
set guifont=MiscFixed\ 11
else
set guifont=-misc-fixed-medium-r-normal--10-100-75-75-c-60-iso8859-1
endif
set columns=80 lines=50
set guioptions-=T "hide toolbar
"Try to load happy hacking teal colour scheme
"I copy this to ~/.vim/colors/hhteal.vim
silent! colorscheme hhteal
if exists("colors_name") == 0
"Otherwise modify the defaults appropriately
"background set to dark in .vimrc
"So pick appropriate defaults.
hi Normal guifg=gray guibg=black
hi Visual gui=none guifg=black guibg=yellow
"The following removes bold from all highlighting
"as this is usually rendered badly for me. Note this
"is not done in .vimrc because bold usually makes
"the colour brighter on terminals and most terminals
"allow one to keep the new colour while turning off
"the actual bolding.
" Steve Hall wrote this function for me on vim#vim.org
" See :help attr-list for possible attrs to pass
function! Highlight_remove_attr(attr)
" save selection registers
new
silent! put
" get current highlight configuration
redir #x
silent! highlight
redir END

You can use :set guifont=* to bring up a font chooser dialog. Once you've chosen a font use :echo &guifont to see what to put in your .gvimrc. (remember to \-escape spaces)
Personally, I like Inconsolata. From my .gvimrc:
set guifont=Inconsolata\ 13

Is it possible to use Consolas font there? It is the best monosize font I've ever seen.
Ok, it is possible. Check screenshot below:
image http://img.flashtux.org/upload/img132432527b55x895f9d81.png

Check out monofur - it's quite an unusual monospaced font. Other than that, I use Monaco.

There's a good comparison of a few possibilities here.
I used to use ProggyCleanSZ (the slashed-zero version), which is a bitmap font that only really looks any good in size 12 (although it's about the same size as a size 9-10 font). Very easy on the eyes though and easy to differentiate between 0 and O as well as 1, I and l. I have since switched to using Envy Code R.

I prefer Courier New, its good..
my .vimrc includes this code snippet to change the font
if has("gui_running")
if has("gui_gtk2")
set guifont=Courier\ New\ 10
elseif has("x11")
set guifont=-*-courier-medium-r-normal-*-*-180-*-*-m-*-*
else
set guifont=Courier_New:h10:cDEFAULT
endif
endif

Related

How to change the font and color of QString? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 months ago.
Improve this question
I have a QString like this ">>> This is an Arrow." , now I want to have >>> in bold and red, How to do that ?
i have looked over some pages and found this syntax
QString redPart = QString("<span style=" color:#ff0000;">%1</span>").arg(">>>");
but it gives some error like ")" missing and, I am not able to figure it out.
your error message means that you are missing a ) because you have to escape the quotes when using them in a string literal (\" instead of ") i.e. do something like
QString redPart = QString("<span style=\" color:#ff0000;\">%1</span>").arg(">>>");
on the other hand, Qstring is a class that has nothing to do with widgets or guis at all, so properties like color, bold format etc arent defined there, so you need to use a widget or something that you can display to the user then if widget: you can set the stylesheet, if a QLabel: you can set the text using richtext.
QString is not a visual component, and therefore does not have a font or color property. It's just a data structure that holds text. If you want to display that text, you can use one of the many visual objects like a QLabel.
The compiler error you're getting is probably because your use of quotation marks is incorrect. Try it like this instead:
QString redPart = QString("<span style='color:#ff0000;'>%1</span>").arg(">>>");

Clear font.ttf from unused glyphs

For example I want to use this .ttf font file:
https://www.onlinewebfonts.com/download/3b2646a48566403a55f62ceddbecbe18
It contains 29,064 glyphs.
I want to leave in it only the letters I use.
A short example: どこでもタップしてプレイ
So, from 29,064 it will be only 12 characters left. In my actual situation if will be around 300 glyphs.
Basically, I want to dramatically decrease it's file-size by removing unused glyphs
Is there a way to implement this by some script? I'm on macOS.
Or some app can do this and how exactly? Is there a real life example?
upd: answer from this question not working, throwing errors:
./subset.pl --chars="どこでもタップしてプレイ" /Users/User/Desktop/1.ttf /Users/User/Desktop/2.ttf
Wide character in subroutine entry at Font/Subsetter.pm line 1496.
In that question there are recommendation of use fixed this bug repo: https://github.com/fnp/librarian/blob/master/librarian/font-optimizer/subset.pl
And with it executing same command gives another errors:
Uses unhandled table 'BASE'
Uses forbidden table 'CFF '
As font file I used that from first link, just renamed it to 1.ttf

How to check installed fonts styles?

I need a list of all installed fonts in the client machine (Always Windows) that contain the styles bold, italic and bold italic. Is there a function for that?
I'm already able to list all installed fonts with EnumFontFamiliesEx and i suppose that is possible to filter that list, but i'm looking for a "better way" :)
Thanks!
PS: I'm using C++ with MFC.
EDIT:
For fonts that doesn't have these styles Windows can "fake" that behavior (force a font look bold or italic), but i need to know which fonts really have these styles.
As you are using "EnumFontFamiliesEx",the call back function recieves the structure LOGFONT....
LOGFONT has two variables lfWeight and lfItalic.
Use those two variables to check if the enumerated font has style or not.
if lfWeight value is 0 (FW_DONTCARE) and lfItalic is false, you can consider this do not have any style.
Or if you want to be very specific, for example, you want to consider fonts with only Bold and Regular, then you can validate, if lfWeight has value from {400 (REGULAR), 600 (BOLD), 700 (BOLD), 800 (BOLD)}
Below link has all the details.
https://msdn.microsoft.com/en-us/library/windows/desktop/dd145037(v=vs.85).aspx

WebStorm: Display ===, != operators as ≡, ≠

I'm looking for a setting/plugin which forces editor to display all occurences of multiple-char equality operators as their corresponding UTF-8 chars (≡, ≠...). I'm sure it is possible - I saw it on some screenshots from WebStorm. Does anyone know how to turn on this behaviour?
It's called font ligatures.
Settings/Preferences
Editor | Colors and Fonts
Enable font ligatures -- select this check box to show the typographic ligatures. Note that this feature depends on the selected fonts.
I could not find dedicated blog post for this new feature .. but you can find some notes here:
https://blog.jetbrains.com/webstorm/2016/06/webstorm-2016-2-eap-162-646/
https://blog.jetbrains.com/idea/2016/07/intellij-idea-2016-2-is-here/
video: https://youtu.be/Bjq-A4LCU9M?t=23m37s
Original ticket: https://youtrack.jetbrains.com/issue/IDEA-127539

How to change indentation mode in Atom?

I haven't been able to figure this out yet. Atom seems to use spaces as the default indentation mode. I prefer to have tabs instead though. Sublime Text has built in functionality for switching and converting indentation.
Anyone found out how to change the indentation mode of Atom?
Some screenshots from Sublime Text:
See Soft Tabs and Tab Length under Settings > Editor Settings.
To toggle indentation modes quickly you can use Ctrl-Shift-P and search for Editor: Toggle Soft Tabs.
Go to File -> Settings
There are 3 different options here.
Soft Tabs
Tab Length
Tab Type
I did some testing and have come to these conclusions about what each one does.
Soft Tabs - Enabling this means it will use spaces by default (i.e. for new files).
Tab Length - How wide the tab character displays, or how many spaces are inserted for a tab if soft tabs is enabled.
Tab Type - This determines the indentation mode to use for existing files. If you set it to auto it will use the existing indentation (tabs or spaces). If you set it to soft or hard, it will force spaces or tabs regardless of the existing indentation. Best to leave this on auto.
Note: Soft = spaces, hard = tab
Add this to your ~/.atom/config.cson
editor:
tabLength: 4
OS X:
Go to Atom -> prefrences or CMD + ,
Scroll down and select "Tab Length" that you prefer.
You could try going to "Atom > Preferences > Editor" and set Tab length to 4.
This is for mac. For windows you will have to find the appropriate menu.
Adding #Manbroski answer here that worked for me:
try Ctrl-Shift-P Editor: Toggle Soft Tabs
Late to the party, but a clean way to do this on a per-project basis, is to add a .editorconfig file to the root of the project. Saves you from having to change Atom's settings when you're working on several projects simultaneously.
This is a sample of a very basic setup I'm currently using. Works for Atom, ST, etc...
http://editorconfig.org/
# Automatically add new line to end of all files on save.
[*]
insert_final_newline = true
# 2 space indentation for SASS/CSS
[*.{scss,sass,css}]
indent_style = space
indent_size = 2
# Set all JS to tab => space*2
[js/**.js]
indent_style = space
indent_size = 2
This is built into core: See Settings ⇒ Tab Type and choose auto:
When set to "auto", the editor auto-detects the tab type based on the contents of the buffer (it uses the first leading whitespace on a non-comment line), or uses the value of the Soft Tabs config setting if auto-detection fails.
You may also want to take a look at the Auto Detect Indentation package. From the docs:
Automatically detect indentation of opened files. It looks at each opened file and sets file specific tab settings (hard/soft tabs, tab length) based on the content of the file instead of always using the editor defaults.
You might have atom configured to use 4 spaces for tabs but open a rails project which defaults to 2 spaces. Without this package, you would have to change your tabstop settings globally or risk having inconsistent lead spacing in your files.
I just had the same problem, and none of the suggestions above worked. Finally I tried unchecking "Atomic soft tabs" in the Editor Settings menu, which worked.
If you are using the version 1.21.1:
Click on Packages / Settings View / Open
Select "Editor" on the left side panel
Scrool down until you see "Tab Length"
Edit the value. I like to set it to 4.
Now, just close the active tab pane and you are done.
Tab Control gives nice control in a similar manner to that described in your question.
Also nice, for JavaScript developers, is ESLint Tab Length for using ESLint config.
Or if you're using an .editorconfig for defining project-specific indentation rules, there is EditorConfig
If you're using Babel you may also want to make sure to update your "Language Babel" package. For me, even though I had the Tab Length set to 2 in my core editor settings, the Same setting in the Language Babel config was overriding it with 4.
Atom -> Preferences -> Packages -> (Search for Babel) -> Grammar -> Tab Length
Make sure the appropriate Grammar, There's "Babel ES6 Javascript Grammar", "language-babel-extension Grammar" as well as "Regular Expression". You probably want to update all of them to be consistent.
If global tab/spaces indentation settings no longer fit your needs (I.E. you find yourself working with legacy codebases with varied indentation formats, and you need to quickly switch between them, and the auto-detect isn't working) you might try the tab-control plugin, which sort of duplicates the functionality of the menu in your screenshot.
When Atom auto-indent-detection got it hopelessly wrong and refused to let me type a literal Tab character, I eventually found the 'Force-Tab' extension - which gave me back control.
I wanted to keep shift-tab for outdenting, so set ctrl-tab to insert a hard tab. In my keymap I added:
'atom-text-editor':
'ctrl-tab': 'force-tab:insert-actual-tab'
Changing language-specific configuration
I changed the default tab settings, and it still did not impact when I was editing my files, which were Python files. It also did not change when I modified the "*" setting in ~/.atom/config.cson . I don't have a good explanation for either of those.
However, when I added the following to my config.cson, I was able to change the tab in my Python files to 2 spaces:
'.source.python':
editor:
tabLength: 2
Thanks to this resource for the solution: Tab key not respecting tab length
All of the most popular answers on here are all great answers and will turn on spaces for tabs, but they are all missing one thing. How to apply the spaces instead of tabs to existing code.
To do this simply select all the code you want to format, then go to Edit->Lines->Auto Indent and it will fix everything selected.
Alternatively, you can just select all the code you want to format, then use Ctrl Shift P and search for Auto Indent. Just click it in the search results and it will fix everything selected.
Yet another answer: If you are using Atom Beautify note that it has its own settings to determine the "Indent Char".