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

skrifa: Ability to enable horizontal hinting #1215

Open
mahkoh opened this issue Nov 1, 2024 · 2 comments
Open

skrifa: Ability to enable horizontal hinting #1215

mahkoh opened this issue Nov 1, 2024 · 2 comments
Labels
correctness enhancement New feature or request

Comments

@mahkoh
Copy link

mahkoh commented Nov 1, 2024

skrifa currently only rounds the Y coordinate if ROUND_XY_TO_GRID is set:

if self.is_hinted
&& component
.flags
.contains(CompositeGlyphFlags::ROUND_XY_TO_GRID)
{
// Only round the y-coordinate, per FreeType.
offset.y = offset.y.round();
}

However, freetype allows users to also enable X rounding:

        if ( subglyph->flags & ROUND_XY_TO_GRID )
        {
          if ( IS_HINTED( loader->load_flags ) )
          {
            if ( driver->interpreter_version == TT_INTERPRETER_VERSION_35 )
              x = FT_PIX_ROUND( x );

            y = FT_PIX_ROUND( y );
          }
        }

This is controlled by the interpreter-version setting. This setting has no other effects in current freetype versions. Correction: this setting has an effect in some other places, it disables subpixel hinting.

Users can set this setting with environment variables:

export FREETYPE_PROPERTIES=truetype:interpreter-version=35

This is the only way to modify this setting for users.

Would it be possible to have skrifa also interpret the FREETYPE_PROPERTIES environment variable and enable X rounding as freetype does? I'd be willing to implement this.

Some other way to enable X rounding would also be fine, as long as it is under the control of users running programs using skrifa and does require modifying source code.

@dfrg
Copy link
Member

dfrg commented Nov 2, 2024

The required changes go a bit deeper than what is suggested here. In particular, the version 35 interpreter changes the behavior of several instructions.

After some internal discussion, this seems like something we should support so I’ll schedule some time soon to get it done.

@mahkoh
Copy link
Author

mahkoh commented Nov 2, 2024

That is great news! Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
correctness enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants