Cinder-SdfText icon indicating copy to clipboard operation
Cinder-SdfText copied to clipboard

Font scaling and getAscent()/getDescent()

Open adielfernandez opened this issue 7 years ago • 1 comments

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!

adielfernandez avatar Aug 08 '18 23:08 adielfernandez

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

morphogencc avatar Aug 21 '22 00:08 morphogencc