Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Glyph center of mass + glyph area as compiled font glyph diff approach - POC #6

Closed
chrissimpkins opened this issue Jun 10, 2018 · 6 comments

Comments

@chrissimpkins
Copy link
Member

chrissimpkins commented Jun 10, 2018

Initially discussed in #4 (comment)

Source and test files stored in https://github.com/chrissimpkins/center-of-mass-diff (see branches for different test conditions)

Analysis source file: https://github.com/chrissimpkins/center-of-mass-diff/blob/master/source/com-analysis.py

Compile process: fontmake v1.4 from UFO source with/without the --keep-overlaps flag to *.ttf binaries

Test conditions:

  1. Original baseline design +/- overlaps
  2. Modified glyph x- or y-position, maintained same contour (= same area) +/- overlaps
  3. Modified glyph contour (=different area in these tests) +/- overlaps

Test designs:

  1. 'plus'
  2. 'period'

Artistic license invoked with both designs for testing purposes. Those were the named glyph positions in the source and compiled fonts. I used two overlapping circles for the 'period' shape. The 'plus' was mangled to change the contour.

Screenshots of the 'plus' glyphs in the compiled binaries are in this thread: chrissimpkins/center-of-mass-diff#1

Screenshots of the 'period' glyphs in the compiled binaries are in this thread: chrissimpkins/center-of-mass-diff#2

Calculations:

  1. Glyph center of mass x-value
  2. Glyph center of mass y-value
  3. Glyph area

These values were calculated with the fontTools.pens.statisticsPen.StatisticsPen using the analysis script linked above.

Summary:

  • area result changes when overlaps are removed
  • center of mass changes (either x-value or y-value or both) when there is no change in contour (by definition, a design with same area), but there is a change in position of the glyph within the box
  • center of mass changes (either x-value or y-value or both) when there is a change in the contour (=design with different area in these tests)
  • center of mass calculations lead to ~same values in analyses of glyphs with overlaps and in glyphs with overlaps removed
  • these were dramatic design changes and it may be necessary to use a larger scale in the decimal values for less significant design changes in order to use these for cross-build diff testing. More work warranted here.
  • combination of area + COM measures seems to be a valid tool for use in testing for differences in final glyph designs that occur anywhere along the path from design source through the end of the build tooling chain across font builds based on the limited testing here
  • based on limited testing here, it appears that these tests can be carried out without the need for the removal of overlaps during the compile process as the delta values are the relevant values for diff purposes

Results:

GLYPH: uni002B

Font 1 - Original design WITHOUT overlaps
area: -0.054145
meanX: 0.2875
meanY: 0.3405

Font 2 - Original design WITH overlaps
area: 0.06137
meanX: 0.2875
meanY: 0.3405

Font 3 - Modified position, same glyph contour WITHOUT overlaps
area: -0.054145
meanX: 0.4175
meanY: 0.3405

Font 4 - Modified position, same glyph contour WITH overlaps
area: 0.06137
meanX: 0.4175
meanY: 0.3405

Font 5 - Modified contour WITHOUT overlaps
area: -0.091545
meanX: 0.299896
meanY: 0.3405

Font 6 - Modified contour WITH overlaps
area: 0.09877
meanX: 0.300086
meanY: 0.3405

GLYPH: uni002E

Font 1 - Original design WITHOUT overlaps
area: -0.0634622
meanX: 0.127
meanY: 0.25388

Font 2 - Original design WITH overlaps
area: 0.0768443
meanX: 0.127
meanY: 0.253892

Font 3 - Modified position, same glyph contour WITHOUT overlaps
area: -0.0634622
meanX: 0.127
meanY: 0.34388

Font 4 - Modified position, same glyph contour WITH overlaps
area: 0.0768443
meanX: 0.127
meanY: 0.343892

Font 5 - Modified contour WITHOUT overlaps
area: -0.0872055
meanX: 0.127
meanY: 0.250842

Font 6 - Modified contour WITH overlaps
area: 0.100588
meanX: 0.127
meanY: 0.251256

@chrissimpkins
Copy link
Member Author

Any interest in developing this as part of the diff used in this project? If not, I'll work on it in a different repository. I'd like to use it as part of our QA process. I am hoping that it will provide automated reassurances about shape stability with updates to build tools and transitions to new build tools which will be happening in the near term. I can't keep up with @anthrotype 's daily commit push rate and all of the various changelogs in dependencies of dependencies :)

@chrissimpkins
Copy link
Member Author

chrissimpkins commented Jun 12, 2018

@anthrotype as an associated side note, it might be helpful on your end to use a tool like this across scheduled "nightly builds" of all/select typeface projects in Google Fonts that are compiled with fontmake and the HEAD of master branches of associated libraries in order to perform integration testing all the way down the stream of dependency changes that occur on a given day? It's a deep rabbit hole with lots of moving parts :)

This should be simple with CI cron jobs and the Google Fonts collection would provide a broad range of different font compile issues to test against.

@m4rc1e
Copy link
Contributor

m4rc1e commented Jun 19, 2018

@chrissimpkins sorry I've been away for the past week or so. Thank you for the very detailed write up. I'll get back to you on this (have a lot of other stuff to finish first). I'm really keen for this to become the differ to end all differs.

@chrissimpkins
Copy link
Member Author

@m4rc1e no worries! Look forward to hearing what you think.

@m4rc1e
Copy link
Contributor

m4rc1e commented Aug 30, 2018

@chrissimpkins Have you been able to test this diff approach out? also, you going AtypI?

@chrissimpkins
Copy link
Member Author

Only the data as presented here. Unfortunately won't be able to make Belgium trip but hope to meet you at another conference over the upcoming year!

@davelab6 davelab6 added this to the 0.4 releases milestone Oct 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants