I’m trying to create a text asset with the Roboto-regular ttf from Roboto - Google Fonts . I enable the ‘Get Kerning Pairs?’ option in the font asset creator, but it does not add kerning pairs to the created asset.
Not a single pair.
According to Glyphs this font contains 7,371 kerning pairs, none of which I want to add manually using the editor.
Some kerning data is located in the GPOS table which FreeType (used by TMP) does not support. In this case and not idea, you can try to export the kerning data from the font and then create a script to add it to the kerning table of the font asset or manually enter the kerning pairs that are most relevant for your use.
Although the current version of TMP does not support reading data from the GSUB and GPOS tables, this is planned for the integrated version of TMP.
@Stephan_B : Has kerning pair support been fixed in the current release of TextMesh Pro? If not, what’s the status of it? We’ve been working hard to make our in-game text match what our artist is doing, and kerning pair support is vital to this effort.
Thanks!
Support for reading GSUB and GPOS tables which includes the glyph positional adjustments (kerning) is not yet available however it is something that will be available within the next 60 - 90 days or sooner if I can.
This will require a new version of Unity as those changes are contained in Unity itself as opposed to the TMP package. This new functionality will be available in Unity 2019.4 or newer when these changes land.
A new version of the TMP package will be needed to expose / take advantage of these new features which will be in the next preview release which will be version 2.2.0-preview.x for Unity 2019.4 and version 3.2.0-preview.x for Unity 2020.2 or newer.
These new releases will also include support for Diacritical Marks and later Ligatures.
Thanks for the quick and thorough reply! Looking forward to the new release(s).
If you’re desperate to import kerning pairs and the font you’re using is open source or has a license that allows editing, there might be a workaround. I was just testing a font I’m working on in Unity today (I’m a font designer, not a game dev) and I was able to import the kerning pairs by overriding some settings to build a TTF font binary with kerning in the kern
table instead of the gpos
table.
I use a commercial font editor called Glyphs, but you could use a free app like FontForge to open the UFO source for an open-source font like Roboto, and build it with a kern
table (there’s an option for this in both Glyphs and FontForge). The kern
table in font binaries has been effectively deprecated because it only supports simple character-to-character kerning, whereas the gpos
table can kern with classes that represent groups of characters that have a similar shapes. Class kerning gets flattened into exponentially more kerning pairs in the kern
table, which happens to have a technical limit of 10,920 kern pairs, so you may need to reduce the character set of the font and/or strip kern pairs with a very small value.
This is very intriguing info, because I just now is working on some solution for Hindi.
Some logic we did in code (ligature replace), but I wanted to adjust different diacritics in Glyph Adjustment table, but font asset get info about kerning only with AX parameter, and OX parameters stay =0. Cant understand, who can’t get/set information - original font or TMPro. Fonts are difficult(
But if your next update include work with ligatures, GPOS tables and all that - it’s mean my work about Hindi will turn into pumpkin, since TMPro can render it itself/
So the question is - how soon in will be released? 90 days are already passed by… May you give new period for waiting?
New release with Diacritical Mark support should be available within the next 7 days or less. In this release you will be able to manually populate the Mark-to-Base and Mark-to-Mark tables for Diacritical Marks but the data from the GPOS won’t be automatically populated until a future release of Unity as that functionality is contained in the FontEngine that is part of Unity itself and not the TMP package.
Support for Ligatures will follow soon after with the same (have to manually define them first) and eventually automatic from the GSUB table of the font file.
Single substitution and Kerning from GPOS will also come in at about the same time all again requiring a Unity Editor upgrade.
Sorry for the necro, but is there some way to import kerning as of 2021.3.9f1 or later? I’m using the Font Asset Creator and it’s not importing Kerning pairs and can’t seem to figure out a workaround.
According to the documentation,
Note: It isn’t always possible to import kerning data. Some fonts store kerning pairs in their glyph positioning (GPOS) table, which is not supported by FreeType, the font engine used by TextMesh Pro. Other fonts do not store kerning pairs at all.
but surely there is a way to get around this?
This answer worked for me (both for TextMeshPro and regular Font Asset generation):
- So install FontForge and import/open your font file (mine was an .otf).
- File > Generate Fonts. Choose OpenType (CFF) in the dropdown, In Options, check "OpenType > Old style ‘kern’
- Re-Generate the Font Asset in Unity by clicking the “Update Atlas Texture” on the Font Asset file. Make sure to check the "Get Kerning Pairs
Note that generating new fonts like this may break the licence of the typeface as it counts as a program. So is basically reverse engineering and recompiling a program.
I’m in trouble!
Regarding FontAssetCreator’s [GetKerningPairs],
By enabling the checkbox, the settings in SourceFontFile,
The kerning value should be able to be obtained from m_FontFeatureTable of TMP_FontAsset, but it cannot be obtained.
I have confirmed that FontEngine.GetGlyphPairAdjustmentTable(m_AvailableGlyphsToAdd.ToArray()) is returning null.
Please let me know if I am missing any settings when using GenerateFontAtlas, or how I can obtain them.
The SourceFontFile used is as follows.
・Unable to obtain kerning pair
[FOT-Rodin Bokuto Pro M]
・You can get kerning pairs
[FOTK-YDParansaeM]
thank you