Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fallback to KERN table if GPOS table is empty in Font.getKerningValue #501

Open
miere43 opened this issue Jan 6, 2022 · 1 comment
Open

Comments

@miere43
Copy link

miere43 commented Jan 6, 2022

Expected Behavior

Font.getKerningValue returns kerning value from KERN table if GPOS table is empty.

Current Behavior

Font.getKerningValue returns 0 if GPOS table is empty, even if there are values in KERN table.

Possible Solution

  1. Maybe GPOS parsing is broken and doesn't work for Arial font (not sure).
  2. Fallback to KERN table if font.position.defaultKerningTables.length === 0 is zero in Font.getKerningValue. See:
    https://github.com/miere43/opentype.js/commit/6acfd4e41b7aa2901f84cfd49433a6e63bf60cbe

Steps to Reproduce (for bugs)

const arial = opentype.loadSync('C:\\Windows\\Fonts\\arial.ttf');
const kerning = arial.getKerningValue(arial.charToGlyph('T'), arial.charToGlyph('e'));
console.log('kerning is', kerning);

Output:

kerning is 0

Expected:

kerning is -227

Context

Drawing text.

Your Environment

  • Version used: 1.3.4
  • Font used: Arial
  • Browser Name and version: ---
  • Operating System and version (desktop or mobile): Windows 10
  • Link to your project: ---
@rafallyczkowskiadylic
Copy link
Contributor

@ILOVEPIE this is fixed within #557 I tested this using test code snippet

describe('Arial fonts test', () => {
        it('should have a correct kerning value', () => {
            const font = loadSync('./fonts/arial.ttf');
            const kerning = font.getKerningValue(font.charToGlyph('T'), font.charToGlyph('e'));
            assert.strictEqual(kerning, -227);
        });
    });

unfortunately I cannot commit this because of arial font's License.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants