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

set inverseYAxis of Shape #67

Closed
themancalledjakob opened this issue Feb 24, 2023 · 2 comments
Closed

set inverseYAxis of Shape #67

themancalledjakob opened this issue Feb 24, 2023 · 2 comments

Comments

@themancalledjakob
Copy link

When generating the atlas with some fonts, I need to set inverseYAxis to true, but I cannot find a way to do this without removing const from GlyphGeometry's getShape() function. My intuition tells me, that there is a good reason for const here, and it shouldn't just be removed. Another option would be to const_cast the shape. This also feels weird, but has the advantage that nothing would have to be changed in this repository.

To clarify, here how I do it:

[...]
            // Storage for glyph geometry and their coordinates in the atlas
            std::vector <msdf_atlas::GlyphGeometry> glyphs;
[...]
            for(msdf_atlas::GlyphGeometry & glyph : glyphs){
                glyph.getShape().inverseYAxis = true; // only works if we remove const from GlyphGeometry::getShape()
                
                // or we do a const_cast
                msdfgen::Shape & shape = const_cast <msdfgen::Shape &>(glyph.getShape());
                shape.inverseYAxis = true;

                glyph.edgeColoring(&msdfgen::edgeColoringInkTrap,
                                   3.0, // max corner angle
                                   0); // seed
            }
[...]

Is there a better way? If not, what about either an additional non-const function for getShape, or an additional inverseYAxis parameter when loading the glyphs in FontGeometry::loadCharset and GlyphGeometry::load?

I assume I am not the only one running into this, but if you think const_casting is fine, feel free to simply close this issue. Otherwise I'm happy to send you a PR, or, if there is a better way to do this I would greatly appreciate a pointer in the right direction.

@Chlumsky
Copy link
Owner

Which font needs its Y-axis inverted? I've never seen one before.

@themancalledjakob
Copy link
Author

Thank you for the reply.

You're right, the font does not need an inverted Y-axis. The error must be in the way that I'm handling the atlas later. When I create an atlas with the same font using standalone msdf-atlas-gen, the Y-axis is fine. This is a bit embarrassing, I should have checked that before. Thank you anyways for having a look.

I'll close this now.

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