FontForge Script: how to add kerning between two glyphs to a font - fontforge

I would like to add kerning between the letter A and itself so that the two letters stack on top of each other, over many font files.
How would I achieve this using a FontForge script?

Here is a script to add kerning between the letter A and itself to a font that previously had no kerning table:
(1) Open your font
Open($1);
(2) Add a lookup with the gpos_pair type, and "kern" as feature, then create a subtable inside
AddLookup("kern","gpos_pair",0,[["kern",[["latn",["dflt"]]]]]);
AddLookupSubtable("kern","kern-1");
(3) Select your first glyph by name
Select("A");
(4) Add kerning from this glyph to another glyph:
AddPosSub("kern-1",GlyphInfo("Name"),0,0,-2883,0,0,0,0,0);
(5) Generate your font
Generate($1:r + "-kerned.ttf");
I am adding this here because I could not find a single example of AddPosSub for character pairs (and it is really difficult to figure out where all the 0 should go without randomly trying.

Related

Why does whitespaces between characters / words are handled in other way as general whitespaces?

I have create a font-subset for my two used fonts.
But if I enter the browser and inspect a given H1-Tag which should only use this font, it shows that 2 Fonts are used, because one character is taken from an Fallback_Font Open Sans:
The exact HTML-Tag:
<strong class="headline1">Carservice Meisterwerkstatt</strong>
The CSS which is used (BTW: PT Sans use the same Font-Subsetting, so the next Fallback for those 5 Glyphs is OpenSans):
To determine the Subset I've used: glyphhanger http://localhost:3000 and added the output of it as whitelist to the following command:
glyphhanger --whitelist=U+A,U+20-23,U+25-29,U+2B-3B,U+3F-57,U+59,U+5A,U+5F,U+61-7D,U+A9,U+C4,U+D6,U+DC,U+E4,U+F6,U+FC,U+F002,U+F017,U+F0F1,U+F2B5,U+F2DC,U+F46D,U+F500,U+F530,U+F5E1,U+F63B,U+F7D9 --subset=Dosis-VariableFont_wght.ttf
What I do search for is a way to figure out, which 5 Glyphs are used from Open Sans. Is there a way to get this in the DEV-Console?
For testing purposes, I've changed the font to other font face to see immediately if there is used another font as fallback. But as you can see, even with Alfredo as Fallback it is not visible which 5 glyph's are using this fallback.
I've tried now to remove each single Character in Content-Part of the Tag inside of the Dev-Console... and checked when does the font-mixing appear. I figured out, that it appear only if I have 2 Characters with a whitespace in between: r M
But if I enter only a character (or word) with a whitespace in front of, or after the character, it doesn't happend. M even not like M .
I found that there are more than one simple space-character. There are many (see https://emptycharacter.com/ down on topic Unicode empty characters)
So it seems the issue at least is, that the Font-Subset doesn't have the needed Unicode included.
If anybody knows how to easily figure out which exact unicode the browser request to the font, you are very welcome to paste it here as comment)

writing single-storey ɑ in Gnuplot graph title?

How can I write single-storey ɑ (The first letter in English) in Gnuplot graph title?
I am always get "a" (double-story) in Gnuplot plot title?
Suggesting to use the Greek letter alpha "ɑ" is not a good solution.
The correct answer is that the shape of the "a" glyph is dependent on the font, not the encoding. Unicode codepoints only specify what character is to be drawn, not what shape it has.
It depends on the terminal you want to use, but probably the most straightforward solution would be to use proper encoding and paste the required character directly:
set encoding utf8
set term wxt font "Times,12"
set title 'ɑ'
plot x
EDIT:
the special character ɑ can be also specified (for example in the interactive Gnuplot console) in terms of its UTF8 representation (two octal numbers) as:
set title '\311\221'
I only use lubunutu and do not use ubunutu.
In lubuntu CharacterMap utility exists and it can be used from accessory category.
On ubuntu, the same tool exists.
https://help.ubuntu.com/community/CharacterMap
I could copy and paste Lattin Small Letter alpha "ɑ" to terminal.
(Note that is not literally single-storey version of a).
As Ethan wrote use of Lattin Small Letter alpha "ɑ" is not correct in literal sense but I think this is possible workaround.
Correct solution is use font with single-storey a like Futura font.
Free Futura font seem to be available from
http://www.webpagepublicity.com/free-fonts-f4.html#Free%20Fonts

how to put y axis greek letters in Veusz plot?

I want to put Capitalomega with index DE and k label:
and then ı want to show on the y axis label? How to do them?
Generally you can use tex symbols in Veusz. Therefore, you can write \Omega_{DE} and \Omega_{k} for your request. See details here (Sec. 2.4 Text).
Veusz understands a limited set of LaTeX-like formatting for text. There are some differences (for example, "10^23" puts the 2 and 3 into superscript), but it is fairly similar. You should also leave out the dollar signs. Veusz supports superscripts ("^"), subscripts ("_"), brackets for grouping attributes are "{" and "}".
Supported LaTeX symbols include: \AA, \Alpha, \Beta, \Chi, \Delta, \Epsilon, \Eta, \Gamma, \Iota, \Kappa, \Lambda, \Mu, \Nu, \Omega, \Omicron, \Phi, \Pi, \Psi, \Rho, \Sigma, \Tau, \Theta, \Upsilon, \Xi, \Zeta, \alpha, \approx, \ast, \asymp, \beta, \bowtie, \bullet, \cap, \chi, \circ, \cup, \dagger, \dashv, \ddagger, \deg, \delta, \diamond, \divide, \doteq, \downarrow, \epsilon, \equiv, \eta, \gamma, \ge, \gg, \in, \infty, \int, \iota, \kappa, \lambda, \le, \leftarrow, \lhd, \ll, \models, \mp, \mu, \neq, \ni, \nu, \odot, \omega, \omicron, \ominus, \oplus, \oslash, \otimes, \parallel, \perp, \phi, \pi, \pm, \prec, \preceq, \propto, \psi, \rhd, \rho, \rightarrow, \sigma, \sim, \simeq, \sqrt, \sqsubset, \sqsubseteq, \sqsupset, \sqsupseteq, \star, \stigma, \subset, \subseteq, \succ, \succeq, \supset, \supseteq, \tau, \theta, \times, \umid, \unlhd, \unrhd, \uparrow, \uplus, \upsilon, \vdash, \vee, \wedge, \xi, \zeta. Please request additional characters if they are required (and exist in the unicode character set). Special symbols can be included directly from a character map.
Other LaTeX commands are supported. "\" breaks a line. This can be used for simple tables. For example "{a\b} {c\d}" shows "a c" over "b d". The command "\frac{a}{b}" shows a vertical fraction a/b.
Also supported are commands to change font. The command "\font{name}{text}" changes the font text is written in to name. This may be useful if a symbol is missing from the current font, e.g. "\font{symbol}{g}" should produce a gamma. You can increase, decrease, or set the size of the font with "\size{+2}{text}", "\size{-2}{text}", or "\size{20}{text}". Numbers are in points.
Various font attributes can be changed: for example, "\italic{some italic text}" (or use "\textit" or "\emph"), "\bold{some bold text}" (or use "\textbf") and "\underline{some underlined text}".
Example text could include "Area / \pi (10^{-23} cm^{-2})", or "\pi\bold{g}".
Veusz plots these symbols with Qt's unicode support. You can also include special characters directly, by copying and pasting from a character map application. If your current font does not contain these symbols then you may get a box character.
In addition to the answer OmG posted, you can also directly enter the character (via a character map application or copy and paste), as Veusz supports unicode characters.

Fontforge Scripting how to add ligatures for a glyph

I'm making a font with scripting on Fontforge. Everything goes well, but I have this problem I don't know how to specify for a selected glyph that if two other glyphs came simultaneously show the selected glyph. I have already made the Lookuptable and the subtable for that but I don't know the function that would define some ligatures for a specified glyph. Here is the code for making table and subtable for adding ligatures to a glyph.
AddLookup("Ligatures","GSUB_ligature",9,[["rlig",[["arab",["dflt"]]]]])
AddLookupSubtable("Ligatures","Ligatureshi")
You need to specify the Ligature substitution using a tuple of existing Glyph names.
A contrived example:
#!/usr/bin/env python3
import fontforge
# load your font, etc…
ligature_name = 'f_l'
ligature_tuple = ('f', 'l')
font.addLookup('ligatures','gsub_ligature', (),[['rlig',[['arab',['dflt']]]]])
font.addLookupSubtable('ligatures', 'ligatureshi')
glyph = font.createChar(-1, ligature_name)
glyph.addPosSub('ligatureshi', ligature_tuple)
After you've added the lookup & subtable, do this:
Select("fl")
AddPosSub("LigatureSubtableName", "f l")
The above FontForge script will add a fl ligature.

How to convert all color code #XXYYZZ to shorter 3 character version #XYZ of whole css file?

How to convert all color code #XXYYZZ to shorter 3 character version #XYZ of whole css file?
You can convert to the shorter 3-character version only colors expressed this way: #RRGGBB where the first and the second characters are the same, the third and fourth characters are the same and the fifth and sixth characters are the same.
So: #CC00DD can be shortened to #C0D while #CC01DD cannot.
A quick way to shorten all the possible colors in a CSS file is to open the file with an editor supporting regular expressions (for example kwrite or kate on linux) and replace (ignoring case) the following regular expression:
#([0-9A-F])\1([0-9A-F])\2([0-9A-F])\3
with this substitution text:
#\1\2\3
Tested with kate.
Otherwise you can use this tool where, if you only need to compress color codes, you can uncheck all the options except the "Compress color codes where possible".
If you are just interested in minimizing the download size for your CSS file, you might use one of the many CSS compressors available (such as this one). And be sure to do the same with your javascript files while you are at it.
You can only shorten CSS colour codes to a 3 character version if they take the form
#XXYYZZ
Then they can be abbreviated
#XYZ
There are only 216 different codes which meet this requirement.

Resources