Robmaister / SharpFont

Cross-platform FreeType bindings for .NET - Need maintainer
Other
286 stars 104 forks source link

Stroke question #124

Closed KakCAT closed 5 years ago

KakCAT commented 5 years ago

Hi,

I'm trying to use SharpFont to create a font that has a border. What I'm doing is creating the glyph with RenderGlyph, and then creating the border (using the same code at https://github.com/Robmaister/SharpFont/issues/115 , patch has been applied)

However I'm unable to position the border in relation to the glyph.

I've been looking at examples of how other people do it, but I've been unable to find it in SharpFont, so I'm relying in libgdx example here:

https://github.com/libgdx/libgdx/blob/463ae4c1a6301332bed5ad098860d04baea1329c/extensions/gdx-freetype/src/com/badlogic/gdx/graphics/g2d/freetype/FreeTypeFontGenerator.java#L539

Basically they're taking left/top (what I suppose that in SharpFont is GlyphSlot.BitmapLeft/ Top) to calculate the offset.

The problem is that in that libgdx example, left and top belong to Glyph, while in SharpFont they belong to GlyphSlot. As the border doesn't have a glyphslot (or at least I haven't been able to render it in the glyph slot) I can't query left/top, so I can't position them.

So, how do I do that in SharpFont?

thanks!

KakCAT commented 5 years ago

I found a solution, the trick is to retrieve newglyph.ToBitmapGlyph() (refering to #115 solution) and then you can query Left/Top of that bitmap.