fonttools / fontbakery

🧁 A font quality assurance tool for everyone
https://fontbakery.readthedocs.io
Apache License 2.0
554 stars 103 forks source link

WARN if anchors are not aligned #3293

Open vv-monsalve opened 3 years ago

vv-monsalve commented 3 years ago

Observed behaviour

Typically, the diacritic marks in a font should be vertically aligned. When assessing some new fonts to be added, many of them didn't meet this condition.

Expected behaviour

It would be helpful that FB could catch this as part of the QA process

Resources and exact process needed to replicate

Two cases as examples: Alex Brush at commit bd8116b Allison at commit 947e656

Allison pic:

Screen Shot 2021-05-18 at 20 12 36

felipesanches commented 3 years ago

Not sure exactly what you mean. Would we expect that the placement of all diacritics have approximately the same height for all glyphs? If so, I think it sounds like an arbitrary restriction. Is that a common practice?

And how would that be detected? Based on the coordinates of the anchor points perhaps?

Please provide more details.

vv-monsalve commented 3 years ago

Would we expect that the placement of all diacritics have approximately the same height for all glyphs? If so, I think it sounds like an arbitrary restriction. Is that a common practice?

Yes it is a common practice for all the diacritics in a font to be placed at a similar height, in a range of vertical space above the base letters (e.g. the red guides in the image, the marks above o are falling from there)

And how would that be detected? Based on the coordinates of the anchor points perhaps?

Usually, this depends on the anchor's position. But, to achieve good diacritics at least three conditions are required:

  1. To have combining marks in the file, with the corresponding anchors
  2. To include the needed anchors in the base glyph
  3. To create the compound glyph, made out of the combination of the base letter + the combining mark

Having 1 and 2 is necessary but not enough. If the compound glyphs are not created using the components but using different outlines so the position would not be respected.

In the example above the combining marks exist in the file, but they don't have the needed anchors and the letters with diacritics are not using the comb marks.

RosaWagner commented 3 years ago

The tricky thing is that anchors can be placed differently thoughout the set of diacritics, or set of letters, but the accent could be still aligned in the composite. I would say it would necessitate to check the average middle coordinate of the first diacritic in the composites itself, and compare it to the other composites of the same letter. This coordinate could vary in a definite range.

RosaWagner commented 3 years ago

The other tricky thing is that; in the case of a handwriting font, different heights of accents is okay, it gives an irregular feeling proper to handwriting style. So it wouldn't apply all the time.

In the example of Viviana, there is clearly something wrong, but it is difficult to explain because of the irregular essence of the font itself.

ALTHOUGH for more orthogonal fonts, this misalignment should be fixed.

m4rc1e commented 3 years ago

Imo this is one of those checks that needs a human eye. Once computer vision can drive a car autonomously, I guess we can think about it. My worry with implementing this check is all the edge cases as Rosa has pointed out.

m4rc1e commented 3 years ago

Perhaps this could be a proofing doc for gftools gen-html?

RosaWagner commented 3 years ago

I made a template for my own use to check diacritics, I'll PR to gftools.

vv-monsalve commented 3 years ago

Having thought on all of the considerations mentioned by @RosaWagner before is what had prevented me from proposing this check in the past, and I've been human-eye checking it.

However, I still think any of these factors could be considered as something to check from FB in the fonts as (a) they're important things to address in a font, (b) having it checked from the first assessment with FB will prevent to 'finish' a font with this issues, and (c) the users tend to give a good deal of attention to any Fail or Warn reported by FB.

The misalignment diacritics would be a Fail in the more orthogonal fonts and a Warn for handwriting ones. Perhaps it could have a Fail status with a note in the rationale for handwriting cases or a general Warn log level result.

AFAIK Fontmake uses glyph anchors to classify whether a glyph is a base glyph or mark glyph, so a font with glyphs not having anchors or not having combining marks should be a Fail.

bobh0303 commented 3 years ago

It would be helpful that FB could catch this as part of the QA process

Except the condition is not relevant for all scripts. Latin / Greek / Cyrillic maybe -- but not for lots of others.

RosaWagner commented 1 year ago

Reviving this conversation since I am cleaning up the diacritic check summary.

Still agreeing with @vv-monsalve that this could be checked by fontbakery to some extent, in Google Fonts Profile for now. I am sure if other users find a use to it, they would try to find ways to make it more universal.

So for now I would reduce the field of search to GF related stuff, and to most cases we QA:

I would see something like that:

vv-monsalve commented 1 year ago

Among many of the diacritics requirements, marks are expected to share a position in the Y dimension in a Latin script font, and although especially for orthogonal fonts, this applies even for many script fonts where the x-height is uniform. So each design specifies a region where the marks live.

Screen Shot 2023-03-25 at 15 30 19 Screen Shot 2023-03-25 at 15 29 45

Currently, the com.google.fonts/check/outline_alignment_miss check seems to be measuring many Y-coordinates to estimate if some on-curve points are in the expected positions.

This check heuristically looks for on-curve points which are close to, but do not sit on, significant boundary coordinates. For example, a point which has a Y-coordinate of 1 or -1 might be a misplaced baseline point. As well as the baseline, here we also check for points near the x-height (but only for lowercase Latin letters), cap-height, ascender and descender Y coordinates.

And even has the capability of provide detailed information for each case detected

at (U+0040): X=1391.0,Y=2.0 (should be at baseline 0?) Q (U+0051): X=1035.5,Y=1.5 (should be at baseline 0?) f (U+0066): X=541.0,Y=1399.5 (should be at cap-height 1400?) s (U+0073): X=327.5,Y=959.5 (should be at x-height 960?)

Couldn't this be achieved similarly? using the marks-Y-min and marks-Y-top coordinates.