chaoticbob / Cinder-SdfText

libcinder.org
SIL Open Font License 1.1
40 stars 20 forks source link

Font scaling and getAscent()/getDescent() #27

Open adielfernandez opened 6 years ago

adielfernandez commented 6 years ago

Hello, I'm trying to fit SdfText into an existing text layout framework and I'm running into trouble getting the appropriate sizes of text. Namely, I need the ascent and descent info for the font at a desired font size. However, despite creating the SdfText object from a SdfText::Font object created at a larger size, the ascent and descent data are still the same.

I have also tried looking at both SdfText::getAscent() and SdfText::Font::getAscent() but these also return the same values regardless of how large or small the font is created.

I saw SdfText::measureString() returns the proper size so I checked out the measureStringImpl() method and found these lines curious:

    const auto& sdfScale = mTextureAtlases->mSdfScale;
    const auto& sdfPadding = mTextureAtlases->mSdfPadding;
    const vec2 fontRenderScale = vec2( mFont.getSize() ) / ( 32.0f * mTextureAtlases->mSdfScale );
    const vec2 fontOriginScale = vec2( mFont.getSize() ) / 32.0f;
    const float scale = options.getScale();

Can you shed some light on all the different scaling going on under the hood? Are the different getAscent()/getDescent() methods supposed to return the same value?

Thanks in advance! Very excited to pull this great block into our framework!

morphogencc commented 2 years ago

@adielfernandez I'm running into the same issue; did you ever make progress on this?