Is it possible and if so, how to bind font glyphs to all keyboard ALT+sign button combinations? - unicode

I'm trying to create runic style font without meaning in any language, using FontForge.
I want it to have three to four slighty different base looks per glyph, with an option to modify them with kerning.
Is possible to assign all or part of keyboard glyphs buttons (eg.: q, w, e, t, r, ..., 1, 2, 3, ... , [, ], , ;, ', ...) to work in most text editors for keyboard combinations:
button
SHIFT + button
ALT + button
ALT + SHIFT + button
First and second can be done with just auto generated unicode versions in FontForge.
For third and fourth i have only few symbols working in my computer (Polish language) ę€óąśłńćźżĘÓĄŚŁŻŹĆŃ, so i can add their equivalents to font.
Is somewhere list of unicode numbers matching others ALT+keyboard glyph combinations?
Is needed to do something more to do like defining font language or application/system language to make it work?
Or another approach is possible to take?

Im using Windows 10 as a system and as i found correct answer to my problem is in two parts:
Create custom encoding in FontForge:
a) Custom Encodings file location: $Disk$:\Users\$Username$\AppData\Roaming\FontForge\Encodings.ps. As it is in AppData folder wise is to have its backup somewhere else. Example of custom encoding:
/fontname [
/1
/exclam
/2
/at
/3
/numbersign
/4
/dollar
/n
/nacute
/N
/Nacute
/m
/M
] def
b) Use some FontForge encoding creation options:
Save encoding to file, basing on currently active font (point a) location): Encoding->Make From Font.
Load pre-defined encoding (last ones are custom, if exists): Encoding->Reencode.
Remove not existing glyphs: Encoding->Compact (remove not existing glyphs)
Remove not existing glyphs and sort them: Encoding->Reencode
Check glyph names for FontForge in Glyph info or Glyphs editing options.
Download Microsoft Keyboard Layout Creator and use it to add matching keyboard layout to font glyphs, then add it to system layouts in system settings.

Related

What font glyphs map to if they are not part of Unicode

I am trying to understand the anatomy of a font file, and wondering about how glyphs are mapped to keyboard characters.
As part of that, I am also wondering what you do when you have font glyphs that are not part of unicode, such as with FontAwesome icons. FontAwesome uses them in CSS like this:
.fa4-clock-o:before {
content: "\f017";
}
If I wanted to let's say type these icons out using the keyboard, not sure what I would need to do to make that possible.
Wondering if I would have to do one of these:
Build another font that maps them to ALT keycodes somehow (not sure how ALT codes work in the definition of a font).
Build a custom keyboard tool that places the correct CSS class on a div (basically don't use the font file / character mapping at all, just build a keyboard tool from scratch).
Some other approach.
Wondering if one could explain how to accomplish this at a medium level of detail (that is, I don't necessarily need to know the implementation specific details of how to do it yet, unless it's straightforward).
A sane icon font offers GSUB ligature substitution, so that if your text contains a sequence of codepoints (like those associated with c + a + r) the font does a remapping to an internal glyph (like the car icon) so while typing, you see this:
c
co
com
comp
compu
comput
compute
💻
You typed "computer", once the font sees that last r it triggers the GSUB rule for c + o + m + p + u + t + e + r -> internal_id_24663 and it shapes the text with that replacement instead.
Of course, if the internal glyph id is exposed through a CMAP table, you can also just access the glyph directly, by just specifying the USHORT that the font will be given to shape. In your example, you're directly specifying your Fontawesome icon by writing out its unicode codepoint using a hex value rather than "a letter": the font uses the (by now defacto standard) platform-agnostic Unicode mapping, and you've asked for the glyph associated with code point 0xF017, which is in the "Private Use Area" block (a range of code points from E0x000` to 0xF8FF that don't have prescribed labels for each point: vendors can put whatever they need in them, and are not guaranteed to resolve to the same glyph between versions).
I've written about font internals, including these parts, over on http://pomax.github.io/CFF-glyphlet-fonts
Glyphs are not "mapped to keyboard characters". It's rather the other way around, and it happens in multiple steps:
Your keyboard controller picks up the physical signals that are generated by the movement of the keys, converts them into scancodes, and then sends them to your computer.
Then the component of your operating system that is responsible for the keyboard layout transforms the scancodes into codepoints of the characters. For example, on my current operating system (Linux), the mapping from scancodes to code points is defined in a configuration file somewhere in /usr/share/X11/xkb/symbols. Here is an excerpt from the configuration file:
key <AD01> { [ q, Q, adiaeresis, Adiaeresis ] };
key <AD02> { [ w, W, aring, Aring ] };
key <AD03> { [ e, E, eacute, Eacute ] };
key <AD04> { [ r, R, registered, registered ] };
key <AD05> { [ t, T, thorn, THORN ] };
key <AD06> { [ y, Y, udiaeresis, Udiaeresis ] };
key <AD07> { [ u, U, uacute, Uacute ] };
key <AD08> { [ i, I, iacute, Iacute ] };
key <AD09> { [ o, O, oacute, Oacute ] };
key <AD10> { [ p, P, odiaeresis, Odiaeresis ] };
For example, it says that the scancode <AD04> is mapped to the letter "r".
The symbols that you type on your keyboard using your layout somehow end up in the memory of some server, and are then served as a part of an HTML-document.
The CSS that accompanies the HTML document specifies that a particular font (e.g. Font Awesome) is to be used.
This particular font specifies that, for example, the unicode code point U+F420 should be rendered as the logo of Angular, this is why you see a hexagonal glyph with an A in your browser.
In this whole pathway, there is no fundamental difference between the Angular logo and any other character. The minor differences are:
The angular logo is not part of the Unicode, that is, the Unicode
consortium has not defined a code point for the Angular logo.
Instead, a code point U+F420 from a private usage area is used. In
this case, "private" means that it is used only by you, by Twitter,
and by few hundred million other people (anyone who visits a website
that uses Font Awesome implicitly agrees to play on this "private"
playground by the rules defined in the font).
There is no predefined keyboard layout that maps scancodes to code points from some obscure private usage area.
There is no hardware that has all those funny logos printed on the key caps (since you probably don't use such symbols all that often, it might be a problem).
If you wanted to type text with such glyphs anyway, you would have to:
Somehow specify that you want to use a font that renders code points from the private usage area as the glyphs that you want (e.g. specify it in the CSS of a webpage)
In order to type it, you would have to define your own keyboard layout. For example on Linux, you could copy-paste some configuration file from /usr/share/X11/xkb/symbols, and modify it accordingly.
When you try to use this layout with an actual keyboard, you will probably need some hints which physical key corresponds to which glyph. E.g. you could put an image of the keyboard layout on the desktop background.

Entering accented characters with notepad++ using only the keyboard

I am new to notepad++ and like it very much, since I can customize how my text documents look more easily than with wordpad. However, I would like to know if it’s possible to enter accented characters like in wordpad (I thought it was a windows thing, but perhaps it isn’t). In wordpad, I can type, for instance, ctrl-’ then i to get an accented í character. Similarly, I can type ctrl-shift-~ then n to get the accented ñ character. It makes it much easier to enter accented characters than copying and pasting from the character map application, or trying to remember code points. When I tried this method in notepad++ I just got the plain character without the accents. I should also mention that when I open documents with such accented characters already present they appear just as expected. Is there a way to enter accented characters like this in notepad++ using only the keyboard? I am using the latest notepad++ under Windows 7.
In Notepad++ you can go to “Edit” then select “Character Panel” near the bottom of the drop down menu. It will show you the ASCII set available which includes most accented characters. You find the character you want and there will be a number for it, to easily use that, press and hold your ALT key, then, on your keypad on the right side of your keyboard type zero followed by the number for that character. So for something like “ñ” for example, the code for it is 241, so you would press ALT and then type 0241 on the keypad while holding down ALT and you will get the character you need. That works in most Windows programs, even in here.
This only works for ASCII characters in the range of 0 to 255. I don't know of a method other than copying and pasting from the “Character Map” app available in Windows for Unicode. Though I did test Wordpad with the Decimal number of the Hex value you see for a Unicode character above 255 and it will work with the ALT+#### in there, and probably other places, but it doesn't work in Notepad or Notepad++ for some strange reason, sadly. Two I use a lot and have memorized are ALT+0147 and ALT+0148 for the quotation marks “like these”, so once you use the numbers enough you tend to get used to them, or you can jot down the ones you use the most.
For anyone searching for a solution and coming across this page, try this (Windows): install and use the US International keyboard instead of the plain US keyboard. Search for "windows keyboard us international install" or something similar. I liked the techlanguage.com write-up on it and the teckangaroo.com step by step on how to install. Hope this helps someone in future looking around as I was earlier today for how to easily meet this need.
You can make your own keyboard layout to enter arbitrary characters anywhere in Windows, using MSKLC. Here's one I made earlier.
I think it is configured in the input method. With input method containing the characters you mentioned, you can press key combinations to get special letters.
You can add a keyboard layout preset in Windows. Under "Language and Regions" - "Language" - "Language settings" - "Input method" settings in Control Panel, you can add all what you want. Like this:
Switch keyboard layout with Alt + Shift.

Alignment of characters in Notepad++

I just wondered why my m-files from MATLAB look so different when I open them with Notepad++ instead of the built-in MATLAB Editor.
It seems that in the MATLAB Editor each character has the same width. Not so in Notepad++ (even I change the language to "M").
Here's a screenshot from a file opened in Notepad++ (left) and in the MATLAB Editor (right).
In the MATLAB Editor all the characters in column X are exactly one below the other. They aren't in Notepad++.
I just played a bit with the tab preferences, without any success.
Is there a way to get the alignment of columns in Notepad++ the same as in the MATLAB Editor ...at least for m-files?
It's because your MATLAB Editor is set to use a monospaced font such as Courier (i.e. a font where all the characters are designed to have exactly the same width), but your Notepad++ is not.
In Notepad++, you can set the font with the menu Settings -> Style Configurator. Select "MATLAB" from the language list (or in fact you may like to select "Global Styles", to do this for all languages), and set the font to a monospaced font such as Courier.
Alternatively, you may like to download a more modern programming font such as Consolas, ProFont, Monofur, Proggy, or Inconsolata. These are all monospaced, and nicer than Courier. You can use the in both Notepad++ and the MATLAB Editor.
It's possible that another issue might be that you have tab characters in your code, which are displaying with a variable width in Notepad++. You can make sure that MATLAB replaces tab characters with spaces in the MATLAB preferences (MATLAB->Editor/Debugger/Tab). To check whether you have tab characters, open the file in Notepad++ and select View->Show Symbol->Show All Characters. Tab characters will display as a short arrow, and space characters will display as a little dot. If you need to change all the tabs to spaces in an existing file, Notepad++ can do this with Edit->Blank Operations->Tab to Space.
Hope that helps!
To add to Sam's answer, choosing a monospaced font specific to your environment's language is recommended. For instance, Courier New on Japanese language may not have the desired result. Choose MS Gothic (for Windows) or Osaka (for Mac) instead.

MS Word 2013 change the style of the whole document when I modify the style for only a selection of text

When I make a change of style (Font or Paragraph) for a selection of text (example: change the font or text orientation of the selected line), Microsoft Word 2013 apply this change for the whole document in an illogical way.
To fix this issue I need to press 'redo (Ctrl-z)' and word 2013 apply the new style to the text I selected only (it's okay now) but I need to do it every time!
This process has become stressful for me and for my computer CPU especially if I edit a large document because Word 2013 change the style for the whole document.
I never had this problem with Word 2010 or 2007.
If you are applying style from "Style" group of "Home" ribbon, then application of these styles are based on "Style type:" e.g:
1) Paragraph
2) Character
3) Linked (Paragraph and Character)
4) Table
5) List
So, it depends which type of style you are applying and by default it apply on complete target.
The easiest way to save working of CPU and eliminating the stress, is to apply format using "Font" group of "Home" ribbon and if you rapidly use same formatting on different part of document then you can use Ctrl + Shift + C and Ctrl + Shift + V command to copy only formatting of one text to another.

Russian characters not showing up correctly in MFC unicode list box

I have an MFC application compiled with MBCS set.
I have created a unicode list box on a regular MBCS dialog using the following code:
DWORD dwStyle = WS_CHILD|WS_VISIBLE|WS_VSCROLL;
hLangListBox = CreateWindowExW(WS_EX_CLIENTEDGE, //extended styles
_T(L"listbox"), //control 'class' name
L"Language", //control caption
dwStyle, //control style
10, //position: left
10, //position: top
200, //width
100, //height
GetSafeHwnd(), //parent window handle
//control's ID
reinterpret_cast<HMENU>(static_cast<INT_PTR>(ID_LANGUAGE_ENGLISH+20)),
AfxGetInstanceHandle(), //application instance
0);
When I inspect this dialog using Spy++ I see my Window Proc: has (Unicode) so I believe it is being created correctly.
I am populating the listbox with one of the following commands depending on if I have the data in a unicode string or a regular string
CStringW m_LanguageNames[MAX_LANG];
CString sFilename;
....
::SendMessageW(hLangListBox,LB_INSERTSTRING ,nMenuPos,reinterpret_cast<LPARAM>(theApp.m_LanguageNames[i].GetBuffer()));
::SendMessage(hLangListBox,LB_INSERTSTRING ,nMenuPos,reinterpret_cast<LPARAM>(sFileName.GetBuffer()));
Things look ok for most entries,
I can see
Chinese: 中文(简体)
French: Française
Japanese: 日本
but Russian looks like a P followed by a bunch of bars (P||||||), not Pусский. When I look at the contents of the CStringW in Visual Studio I do see the correct text.
Why can I see the other languages correctly and not russian? I am running on Windows 7 ultimate and compiling with Visual Studio 10
Edit
If I change my system locale to Russian I can see the russian characters fine. However, the ç in Française does not appear correct.
I thought unicode strings were independent of the system locale. Is that correct?
To populate my unicode CStringW I am doing:
CA2W tmp_wide(po.msgstr,CodePage);
m_LanguageNames[i] = tmp_wide;
where po.msgstr is a CString that was read in from a file. In this case, CodePage is set to 1251
If I inspect the variables in Visual Studio it appears that the conversion is happening correctly.
It appears that my unicode list box can display unicode characters from a MBCS such as Chinese fine, but that it can't display unicode characters from a SBCS that is different from my current code page.
Same problem, solved after a long time.
In my case the default font of dialog is set to "MS Sans Serif", just change to use the more recent font "Microsoft Sans Serif" and everything is resolved!
I have not solved this yet, but I think it is likely this is a font issue. I'm not going any farther with this, but the next step would be to have an owner drawn list box and specify an appropriate font for each language