Search Unity

No Kerning Pairs on TMP font import

Discussion in 'UGUI & TextMesh Pro' started by soulis6, Jan 28, 2019.

  1. soulis6

    soulis6

    Joined:
    Apr 21, 2011
    Posts:
    22
    Hi all, i'm having some issues with importing the kerning pairs for any font file with text mesh pro.

    I've tried multiple fonts now, with the 'import kerning pairs' option checked, but the Kerning table info section is always empty. I can open them in other software (such as FontForge) and see the Kerning data is there, but I've just not been able to get anything to show up inside TMP.

    I'm on a windows machine, Unity 2017.4.2, running TMP 1.0.55.2017.1.0b12.

    Anyone have any suggestions? Does this work in the most recent version of text mesh pro?
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Importing Kerning data is only available for font files that contain kerning data in the Kern Table as opposed to Glyph Adjustment Pair data (ie. Kerning) contained in the GPOS table which is always the case for .otf fonts and many .ttf fonts now.

    Support for importing Glyph Adjustment Pairs is part of the larger support for OpenType Font Features which is on the TMP roadmap. I would like to have support for importing Glyph Adjustment Pairs available for Unity 2019.2 and if possibly 2019.1.
     
  3. soulis6

    soulis6

    Joined:
    Apr 21, 2011
    Posts:
    22
    Thanks for the quick response.

    That makes sense, all the fonts I've tried are newer google or adobe fonts that likely only use the GPOS table.

    Any workarounds that you know of? I haven't been able to find any information about a conversation from GPOS to kern tables. Maybe there's a way to at least copy/paste the TMP kerning info from one font to another?
     
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I know some font tools allow you to export the data from any of the OpenType tables. The format of these might be different from tool to tool so you would have to most likely put that in some text file or json and then create your own script to add these to whichever font asset.

    BTW: The kerning data would be in font units which is either 2048 or 1024 ... so you would have to scale those values to match the sampling point size of the font asset.

    P.S. The GPOS table contains all glyph positioning related data where Glyph Pair Adjustment is one sub set of all the features in the GPOS table.
     
  5. soulis6

    soulis6

    Joined:
    Apr 21, 2011
    Posts:
    22
    Ok i'll take a look at some tools, thanks for the help.
     
  6. andrzejm

    andrzejm

    Joined:
    Jun 5, 2017
    Posts:
    1
    Hi all,

    I'm still getting empty Glyph Adjustment Table after importing a TTF font into Unity 2019.2.
    Are there any known workarounds or chances to provide support for new fonts soon?

    On the screenshot there is a table of 1712 kerning pairs imported, but each has no values...
     

    Attached Files:

  7. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Can you provide me with a link to this font file. It is kind of strange that it would create all those empty entries.
     
  8. jonahyakuto

    jonahyakuto

    Joined:
    Mar 9, 2017
    Posts:
    11
    I'm encountering the same issue after creating a font asset using the LiberationSans font included in the TMP Essential Resources.

    I'm on Unity 2019.2.12 using TextMeshPro 2.10 preview.

    See screenshot for setup.

    As a result I'm getting 3000+ pages of Adjustment Pair that are empty!

    Is there anyway to remove these on bulk and not one by one? Or prevent Font Asset Creator from generating empty pairs?
     

    Attached Files:

  9. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I am aware of this issue which I have already fixed. Fix will be included in preview 3.

    Here is the change that will address this issue. This is in the TMPro_FontAssetCreatorWindow.cs file.

    upload_2019-11-20_8-6-7.png

    These changes should be made in the global package cache otherwise they will reset when reopening Unity.
     
    jonahyakuto and aklgupta like this.
  10. skyrusfxg

    skyrusfxg

    Joined:
    Jan 14, 2016
    Posts:
    127
    Hello. It still doesn't work with AcuminPro fonts (for example). Look at them, please. Even in preview 3.
     
  11. mrtenda

    mrtenda

    Joined:
    Jun 6, 2017
    Posts:
    73
    Does TMP still not fully support importing kerning data?

    The Glyph Adjustment Table is empty when I create a Font Asset with TMP's Font Asset Creator using Rubik Medium from Google Fonts as the Source Font.

    This is making TMP impossible for us to use in production.

    (Using TMP 2.0.1 in Unity 2019.4.4f1)
     
  12. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Currently, only importing data from the Kern table is supported. Support for importing data from the GPOS table such as Pair Adjustment (advanced kerning) is on the way and will be available in a future release of 2019.4.

    UPDATE
    I just checked the Rubik font and it does have support for the Kern Table and as such kerning data should be extract automatically.

    1. Depending on how you are creating your font assets, make sure that you have Get Kerning Pairs enabled in the Font Asset Creator or Get Font Features at Runtime enabled in the TMP Settings so that Dynamic Font Asset can extract this data as needed.

    upload_2020-11-10_12-13-29.png

    Just did a quick test using "Wave Text" and here are the Glyph Adjustment Pairs for the following characters / glyphs for Rubik Medium.

    upload_2020-11-10_12-16-16.png

    P.S. Latest release for 2019.4 is version 2.1.3. Please be sure to read the release notes as there have been many changes and features added.
     
    Last edited: Nov 10, 2020
  13. mrtenda

    mrtenda

    Joined:
    Jun 6, 2017
    Posts:
    73
    Thanks for the reply. I've upgraded to 2.1.3 and followed your instructions but I'm still getting an empty Glyph Adjustments Table.

    Here's a video of me following the steps given. Could you please tell me what I'm doing wrong here?

     
  14. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    There appears to be two versions of the Rubik font file as seen below.

    upload_2020-11-10_15-3-38.png
    The font files contained in the static folder do not include the Kern data whereas the others do. Try with the non static versions of this font.

    Note: As per my first reply, support for reading Glyph Pair Adjustment records from the GPOS table will be available in a future version of Unity 2019.4 and newer.
     
  15. bsweileh

    bsweileh

    Joined:
    Jun 1, 2018
    Posts:
    15
    Hello,

    Is there a way to export the Glyph Pair Adjustment records from a given TMP font asset to another? If I created custom Glyph pair adjustment records for a particular TMP font asset, can I reuse this same data in a another one? Any easy import/export functionality?

    Currently, relying on Glyph pair adjustments in the only way to get Arabic fonts displaying properly with all diacritical marks and ligatures, and having this import/export functionality would be make it easier to setup multiple Arabic fonts without starting the process from scratch. Thanks!
     
  16. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    No. However, I believe the Glyph Adjustment Table and related data is public so you should be able to implement some type of editor tool to do this.

    Having said that and given Glyph Adjustment data would be specific to a particular font and font asset why copy this data? Are you looking to copy it to a different font asset that uses a different font as source?

    Note: In the next set of preview releases of the TMP package, I will be adding support for Diacritical Marks and shortly thereafter Ligatures. At first these tables will need to be manually populated until a new version of the Editor is release that where this data will be automatically extract from the source font file.

    Here is a preview of those new tables.

    upload_2021-5-24_13-56-8.png
     
  17. bsweileh

    bsweileh

    Joined:
    Jun 1, 2018
    Posts:
    15
    Thanks for your reply, Stephan. Yes, I'd like to copy it to a different Arabic font asset that uses a different font source. Different Arabic fonts appear differently in the TMP and require different glyph pair adjustments to make them appear correctly in Unity. For example, the Arabic diacritic Fatha (short 'a' sound) doesn't always appear above the Arabic letter when displayed in Unity (it often overlaps with the letter it is supposed to be above), and different fonts have different letter heights, so the amount of yPlacement needed for the diacritic Fatha would vary for each font and each letter combination involving Fatha as the second character. Single glyph kerning/adjustment for Fatha isn't sufficient here and the same goes for all other diacritical marks.

    Copying the Glyph pair adjustment table record data from one font asset to another would allow one to make the necessary tweaks to the records to make the other Arabic fonts appear correctly. The copied Glyph pair adjustment table would act as a master data table (or template) that includes the glyph pair combinations that require custom kerning/adjustment. Creating these records from scratch each time is a very time consuming. Thank you.
     
  18. bsweileh

    bsweileh

    Joined:
    Jun 1, 2018
    Posts:
    15
    This is really good news! I look forward to these!

    How often are TMP releases? Do they typically align with Unity major releases? Thanks!
     
  19. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    They do not align with Unity releases.

    The new set of preview releases are getting finalized where the first preview should be out within the next 10 - 14 days.
     
  20. bsweileh

    bsweileh

    Joined:
    Jun 1, 2018
    Posts:
    15
    Cool! How do I access preview releases of TMP?
     
    Last edited: May 26, 2021
  21. bsweileh

    bsweileh

    Joined:
    Jun 1, 2018
    Posts:
    15
    Hi Stephan,

    I tried the Mark-to-base and mark-to-mark adjustment tables in the 3.2.0-pre.1 release of TMP, and they don't seem to be impacting the TMP object in the scene. While I see the live changes ln the preview below the adjustment tables, the TMP object doesn't change when I modify the X and Y offsets. I have kerning enabled. I am using Unity version 2020.3.15f2.

    Below is a short clip of the behaviour I'm seeing with the Mark-to-base adjustment table for the Lalezar font that supports Arabic glyphs. Similar behaviour is seen in the mark-to-mark adjustment of the same font. Please advise. Thanks!

     
    Last edited: Aug 18, 2021
  22. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Had a chance to look into this and this is a trivial issue to resolve. This is simply due to the Mark not being contained in a Unicode range specific to Marks.

    I will provide some code changes later today to address this. I will also make additional changes which will require a new version of Unity to add a flag to glyph that will enable users to define them as Base, Mark or Ligature glyphs.
     
    Last edited: Aug 18, 2021
    mrtenda likes this.
  23. bsweileh

    bsweileh

    Joined:
    Jun 1, 2018
    Posts:
    15
    Oh? Which ranges would those be? Just wondering if the issue is specific to the TTF font I'm using or if the Mark-to-base positioning wasn't designed with Arabic diacritics in mind.

    Arabic diacritics are contained in the Unicode range u064B-u0652 (within the Arabic Unicode block), and there are some other less common special forms found elsewhere.
     
  24. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Here are the code changes the include the additional ranges for Arabic Marks.

    upload_2021-8-18_13-33-21.png

    This should be all of them. Let me know if you think I missed any.

    In order for these changes to be persistent, they need to be done in the Global Package Cache in the relevant source code file.
     
  25. bsweileh

    bsweileh

    Joined:
    Jun 1, 2018
    Posts:
    15
    Thank you Stephan. The mark-to-base and mark-to-mark adjustment tables seem to be functioning properly with Arabic diacritics now.

    I don't think you have missed any of the Unicode ranges for the main Arabic diacritics. But personally, I think it would be nice to add the ranges 0x0617-0x061A, 0x08D3-0x08E2, and 0x08F0-0x08F3 (Quranic annotations) and 0xFBB2-0xFBC1 (Arabic pedagogical symbols) for completeness sake. Thanks again.

    2021-08-18_16-41-17.jpg
    2021-08-18_16-40-47.jpg
    2021-08-18_16-40-18.jpg
    2021-08-18_16-41-38.jpg
     
  26. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I made those additional changes including adding 0x610 ~ 0x61A

    upload_2021-8-18_17-39-58.png
     
  27. bsweileh

    bsweileh

    Joined:
    Jun 1, 2018
    Posts:
    15
    Awesome! Thanks Stephan!
     
  28. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Please let me know if the above appears to work as expected with Arabic text and if you run into any issues with respect to Diacritical Mark support.

    P.S. Having to manually populate these tables is a huge pain. I am hopeful that I can land the necessary changes soon to have this data extracted from the font files at runtime. This will require a new version of the Unity Editor along with new package release. This should be available for 2019.4 or newer.
     
    mrtenda likes this.
  29. bsweileh

    bsweileh

    Joined:
    Jun 1, 2018
    Posts:
    15
    That's great, Stephan! I look forward to seeing this feature!

    And you are right ... manually populating positioning data into these tables is a pain! It took me two workdays just to populate the glyph adjustment data for one Arabic font! However, if I want to recreate the same font to increase the padding value (or the SP/PD ratio) to allow more room for effects like glow, outline, dilation, etc.., all the positioning data in these tables disappears! And this is the case I am in now ... the font's SP/PD ratio is too small.

    Is there a way to keep the data from disappearing when re-creating the same font asset in order to modify the font size, padding, atlas dimensions, and render mode? I would imagine that the existing positioning data in the glyph adjustment table, the mark-to-base table, and the mark-to-mark table should all still be functional in the newly created font asset so long as no characters/glyphs have been removed or added, yes? Please advise. Thanks!
     
  30. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    This week I will be focusing on getting this additional OpenType table data extracted from the font files.

    As long as the sampling point size doesn't change, the diacritical data will remain valid. Padding changes which would affect the sampling point size to padding ratio again won't affect this data in terms of the values themselves. Only sampling point size changes will require updated values.

    Having said that, editing the font asset right now to change Sampling Point Size or Padding will invalid / delete this data so I will take a look over the next few days to find some temporary solution to maintain this data or to be able to copy / paste it... ie. some solution to preserve it.
     
    mrtenda likes this.
  31. bsweileh

    bsweileh

    Joined:
    Jun 1, 2018
    Posts:
    15
    That is excellent news!

    Does this also apply to glyph pair adjustment tables?

    That would be wonderful! I look forward to seeing this feature and I would be happy to test it out!
     
  32. bsweileh

    bsweileh

    Joined:
    Jun 1, 2018
    Posts:
    15
    Hello,

    What is the recommended way for reusing TMP font assets from project to project? I tried exporting and importing them as a part of an asset package, but the reference to the font material disappeared (as well as the reference to the source font itself). I wasn't able to re-assign the font material manually (as it was greyed out on the font asset's inspector). I was, however, able to re-assign the source font, but applying that change to the font asset required the clearing "the font asset's character, glyph, and texture data".

    While I know its easy enough to re-create the font asset using the font creator tool, or update the font atlas (or reset the font asset) in the inspector window, , this becomes really problematic for Arabic font assets - especially considering that there is so much manual entry of glyph adjustment, mark-to-mark adjustment, and mark-to-base adjustment records that needs to be done before the Arabic text can render correctly with all diacritical marks, and unfortunately all that data doesn't get saved upon re-creating, updating or resetting the font assets.

    Please advise. Thanks!
     
  33. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Using the Export option should work.

    Provided that you select / export all the relevant parts which would be font asset and source font file should be all that is needed. This is how the font assets included with TMP in the TMP Essential Resources are exported and ultimately re-used by all users in their own project.
     
  34. SI-Shawn

    SI-Shawn

    Joined:
    Jun 30, 2021
    Posts:
    16
    Howdy,

    @Stephan_B Do you know when importing Glyph Adjustment Pairs will be supported? If it is already supported what version of Unity and/or the TMP package is it supported in?

    Thanks,
    Shawn
     
  35. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Currently finalizing / testing this new functionality which will also include extracting the Diacritical Mark data from the font file as well.

    This new functionality will require a new version of the Editor as well as TMP package. The package changes should be included in either preview.2 or preview.3 of the latest preview releases of the package.

    With respect to the editor changes, I will do my best to have those available / backported to 2019.4 if possible.

    What version of Unity are you currently using?
     
  36. SI-Shawn

    SI-Shawn

    Joined:
    Jun 30, 2021
    Posts:
    16
    We are currently using 2020.3.17f1 and TMP v3.0.6.
     
  37. programer786

    programer786

    Joined:
    Aug 6, 2015
    Posts:
    7
    Hello,
    Thank you very much for your work! Is there a version of the editor that can be installed now that has this new feature of importing the position data of diacritical marks please? If not, when do you think will this feature be available please? I'd like to use Unity for a new project that requires diacritical marks on Arabic text. I would just add the data manually but the problem is that I want to add many fonts to my project, so I'd need to add thousands of new records manually.
     
  38. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The required changes to the Editor have not landed yet. I'll provide an update as soon as those are live.
     
  39. mrtenda

    mrtenda

    Joined:
    Jun 6, 2017
    Posts:
    73
    Is there any update on when this will be available? I assume this is locked behind the required changes to the TextCore FontEngine?
     
  40. geo_p

    geo_p

    Joined:
    Jul 24, 2012
    Posts:
    5
    Hi, I'm also keen to hear an update on this - the lack of GPOS support causes text rendering problems in many Indic scripts (such as Thai - as described in this article: State of Thai in Unity).
     
    Last edited: Aug 23, 2022
  41. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    There is a PR in review with the relevant changes to the FontEngine that as I described before, will add the ability to extract Pair Adjustment data from the GPOS table along with Mark-to-Mark and Mark-to-Base data as well as Ligatures from the GSUB tables.

    Access to the above new functionality will require a Unity Editor update. The plan is to have this new functionality available in some future version of Unity 2020.3 or newer. Once you have upgraded to a release of Unity that includes the FontEngine changes, new functionality will be available in version 3.2.0-pre.3 of the TMP package.

    Since these FontEngine changes also include support for additional OpenType Layout features, a new version of the TMP package will be required to access those additional features.

    Note that support for Color Glyphs / Native Emoji is also part of these FontEngine changes.
     
    jiraphatK, geo_p and mrtenda like this.
  42. mrtenda

    mrtenda

    Joined:
    Jun 6, 2017
    Posts:
    73
    It looks like the FontEngine changes landed in 2021.3.16f1 based on the changelog. I installed 2021.3.16f1 and TMP 3.2.0-pre.3 and created a new font asset in the Font Creator based on the latest 2.1.5 TTF version of LiberationSans from their GitHub page. However, kerning still doesn't seem to be working correctly for me in TMP. See screenshot below (the "Ty"). Is there any step I missed here? Thanks.

    upload_2022-12-16_11-24-2.png

    Edit: Nevermind, it seems to work properly in a fresh Unity project. I must have not completely uninstalled the old TMP or something. It's great that this feature went through, thanks!
     
    Last edited: Dec 16, 2022
  43. OmarOfMA

    OmarOfMA

    Joined:
    Sep 6, 2022
    Posts:
    13
    I am also using 2021.3.16f1 with a preview version of TMP and kerning pairs are properly imported.

    Has anyone tried it with Arabic? As far as I know, Arabic requires using plugins such as RTLTMPro, but it seems like kerning does not work while using them.

    @bsweileh I'd like to hear your input if you are still around :)