Skip to content

Add xBoundsAtY, yBoundsAtX to fontforge.glyph object (Python) - #4154

Merged
ctrlcctrlv merged 6 commits into
fontforge:masterfrom
ctrlcctrlv:BoxesAndBounds
Feb 12, 2020
Merged

ctrlcctrlv merged 6 commits into
fontforge:masterfrom
ctrlcctrlv:BoxesAndBounds

Conversation

@ctrlcctrlv

Copy link
Copy Markdown
Member

This patch also makes it so an optional layer argument can be passed
to the boundingBox function of fontforge.glyph objects.

New tests are added, for all of our sanity. This is the first time I've
added new tests (after years of contributions, pretty scary right? haha).

This closes #4151.
This is yet another blocker on #703.

Type of change

  • Bug fix / New feature

This function also makes it so an optional layer argument can be passed
to the `boundingBox` function of `fontforge.glyph` objects.

New tests are added, for all of our sanity. This is the first time I've
added new tests (after years of contributions, pretty scary right? haha).
@ctrlcctrlv
ctrlcctrlv requested a review from skef February 12, 2020 07:25
Comment thread doc/html/python.html Resolved
Comment thread fontforge/python.c Resolved
Comment thread fontforge/python.c Resolved
Comment thread fontforge/python.c
if (layerp2 != NULL) {
if (layeri != i) continue;
}
SplineSet* ss = LayerAllSplines(&self->sc->layers[i]);

@skef skef Feb 12, 2020 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if I'm understanding right RefChar.layers[layer].splines is a copy of the contours from the referenced glyph but already transformed? That does make things easier.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are indeed understanding right. :-)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case you want some proof of this, and for posterity, here is a test script:

import fontforge

f = fontforge.fonts()[0]
print( f["A"].xBoundsAtY(600, layer=1) )
print( f["B"].xBoundsAtY(600, layer=1) )

Returns:

(400.6141304347826, 463.64921465968587)
(567.7201033882473, 630.7551691344895)

For file:

tri.zip: Zip archive data, at least v2.0 to extract
UEsDBBQAAgAIABqJTFC2XJKQdwIAAMMEAAAHAAAAdHJpLnNmZG1T227iMBB991dYvLSVFmo7OIS8
cd0i0VI1pay0Wq2sxAlWjY0StxX79TtOuLYVATJnZo6Px8fJVisjp9a48TDGQYch//4gNjLGS+OU
0zKjaPqm9RdMbJTefUZXUhVrF+MnWbxpUaKR3e7KBjq+4uv0BjPCyA9ofDX2w6DlyG420rgqxi2f
abM2ZdBSSuFkhj+UW2MvbGrLQuLrtXPb+PY2ByT3SAd+blroRZaVsibGhNAOIQTNnNAqHZhCg0iC
liaTpd/vo62UqyvblJzhK5W5dYw5QYMqBTkxjiA9lvuAeUrzDpzZZOMJ52Iny5F9q5NNBDB8WkOR
vrYwPWDUYyBetqDr13I2jvFvShjFIeeYh6CX9HqYsijkYRT8QYuEnTbjo7/NYGuBibZbuTB6d8gt
K/m829p76UqVwggpqgcH3c/KHw/lEe324UvQvc1UrtKvyYBwz+V5DnsnR2CR55V0nniPHEdyrBl/
qZnDQAux3deslLng9fFFCwCXrB44VdytpchODE34KX3W38QXC7xIk1k4i6vHfJJdofFkFuM+pYyj
iUlhLKaI8SxZRBHvtyl4QgEoZ8bJEvZgrJHIm32uKiAc/JyDH0v8ID9qX1ZorKqtFrtE/YOZtnsM
DeBODLQS9XlMlXu2jWdgWzOT2xiHXRyBa4ayUGa0FiUUMh4CghInSuchWOhMXMj94xlql1Lv8KkW
BTTefbKitxpK6rudSIfAalDO8QazPsLdwBP1sIb1EO6xAEfdfXAo1L5wYrITBQRe0YW44bm40D/0
W3Gr79Q9yby5LbCnh/qCkA4P+oR3IWhTHnYCFgLKjkvv/6uTMD969B9QSwECPwMUAAIACAAaiUxQ
tlySkHcCAADDBAAABwAAAAAAAAAAAAAApIEAAAAAdHJpLnNmZFBLBQYAAAAAAQABADUAAACcAgAA
AAA=

Sorry about the base64, GitHub is refusing to upload it. 🙄

Comment thread fontforge/python.c Resolved
Comment thread fontforge/splineutil.c Resolved
@ctrlcctrlv
ctrlcctrlv requested a review from skef February 12, 2020 08:42

@skef skef left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

@ctrlcctrlv
ctrlcctrlv merged commit b202e06 into fontforge:master Feb 12, 2020
@ViliusSutkus89

Copy link
Copy Markdown
Contributor

Hey @ctrlcctrlv from upstream,

I believe the messages are gone now.
During my next accidental spam campaign I will at least try to sell you something :)

@ctrlcctrlv

Copy link
Copy Markdown
Member Author

@ViliusSutkus89 No problem, I was quite sure it was accidental, and had no idea why it was happening either :-)

I imagine someone at GitHub is smiling to themselves as their feature is "getting fork maintainers talking" and "increasing developer engagement", meanwhile all the comments are simply bewildered "why should a reversion on his personal fork show up here if he's not asking us to revert it upstream (as I originally thought when seeing GitHub's message)?"

That's social media for you. Cheers.

Omnikron13 pushed a commit to Omnikron13/fontforge that referenced this pull request May 31, 2022
…orge#4154)

* Add xBoundsAtY, yBoundsAtX to fontforge.glyph objects (Python)

This patch also makes it so an optional layer argument can be passed
to the `boundingBox` function of `fontforge.glyph` objects.

New tests are added, for all of our sanity. This is the first time I've
added new tests after years of contributions, pretty scary right? Haha.
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

Successfully merging this pull request may close these issues.

layer.boundingBox() ignores references (Python)

3 participants