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

Add SDF HintingMode #1964

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/modules/font/TrueTypeRasterizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ StringMap<TrueTypeRasterizer::Hinting, TrueTypeRasterizer::HINTING_MAX_ENUM>::En
{"light", HINTING_LIGHT},
{"mono", HINTING_MONO},
{"none", HINTING_NONE},
{"sdf", HINTING_SDF},
};

StringMap<TrueTypeRasterizer::Hinting, TrueTypeRasterizer::HINTING_MAX_ENUM> TrueTypeRasterizer::hintings(TrueTypeRasterizer::hintingEntries, sizeof(TrueTypeRasterizer::hintingEntries));
Expand Down
1 change: 1 addition & 0 deletions src/modules/font/TrueTypeRasterizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class TrueTypeRasterizer : public Rasterizer
HINTING_LIGHT,
HINTING_MONO,
HINTING_NONE,
HINTING_SDF,
HINTING_MAX_ENUM
};

Expand Down
8 changes: 4 additions & 4 deletions src/modules/font/freetype/TrueTypeRasterizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,14 @@ GlyphData *TrueTypeRasterizer::getGlyphData(uint32 glyph) const
FT_Render_Mode rendermode = FT_RENDER_MODE_NORMAL;
if (hinting == HINTING_MONO)
rendermode = FT_RENDER_MODE_MONO;
else if (hinting == HINTING_SDF)
rendermode = FT_RENDER_MODE_SDF;

err = FT_Glyph_To_Bitmap(&ftglyph, rendermode, 0, 1);

if (err != FT_Err_Ok)
throw love::Exception("TrueType Font glyph error: FT_Glyph_To_Bitmap failed (0x%x)", err);

FT_BitmapGlyph bitmap_glyph = (FT_BitmapGlyph) ftglyph;
FT_Bitmap &bitmap = bitmap_glyph->bitmap; //just to make things easier

FT_Bitmap &bitmap = bitmap_glyph->bitmap;//just to make things easier
// Get metrics
glyphMetrics.bearingX = bitmap_glyph->left;
glyphMetrics.bearingY = bitmap_glyph->top;
Expand Down Expand Up @@ -206,6 +205,7 @@ FT_UInt TrueTypeRasterizer::hintingToLoadOption(Hinting hint)
return FT_LOAD_TARGET_LIGHT;
case HINTING_MONO:
return FT_LOAD_TARGET_MONO;
case HINTING_SDF:
case HINTING_NONE:
return FT_LOAD_NO_HINTING;
}
Expand Down