-
Notifications
You must be signed in to change notification settings - Fork 236
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
Added a smoothing and strikethrough option to font loading. #1087
Conversation
src/renderer.c
Outdated
FT_Outline_Translate(outline, x_translation, 0 ); | ||
if(smoothing) FT_Outline_Embolden(outline, 1 << 5); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5 might be too much, maybe 3 is a better value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I sort of just copied the thing they did in the original discussion, as that seemed to produce nice results. I don't know exactly what settings to do, so honestly I'll have to do a comparison somehow. We could also make the option a number if that's what's needed.
Can this be merged now? I want to use this option for myself. |
OK this pr finally isn't like 3 lines |
@@ -4,6 +4,7 @@ lhelper/ | |||
submodules/ | |||
subprojects/*/ | |||
/appimage* | |||
.vscode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this intended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really but it could be useful to others ;w;
src/renderer.c
Outdated
float adv = metric->xadvance ? metric->xadvance : font->space_advance; | ||
|
||
if (fonts[0]->style & FONT_STYLE_UNDERLINE) | ||
ren_draw_rect((RenRect){x, y / surface_scale + font->height - 1, adv / surface_scale, font->underline_thickness * surface_scale}, color); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ren_draw_rect((RenRect){x, y / surface_scale + font->height - 1, adv / surface_scale, font->underline_thickness * surface_scale}, color); | |
ren_draw_rect((RenRect){pen_x, y / surface_scale + font->height - 1, adv / surface_scale, font->underline_thickness * surface_scale}, color); |
Also maybe instead of y / surface_scale + font->height - 1
it should be y / surface_scale + font->height - font->underline_thickness * surface_scale
.
@@ -15,7 +15,7 @@ | |||
typedef struct RenFont RenFont; | |||
typedef enum { FONT_HINTING_NONE, FONT_HINTING_SLIGHT, FONT_HINTING_FULL } ERenFontHinting; | |||
typedef enum { FONT_ANTIALIASING_NONE, FONT_ANTIALIASING_GRAYSCALE, FONT_ANTIALIASING_SUBPIXEL } ERenFontAntialiasing; | |||
typedef enum { FONT_STYLE_BOLD = 1, FONT_STYLE_ITALIC = 2, FONT_STYLE_UNDERLINE = 4 } ERenFontStyle; | |||
typedef enum { FONT_STYLE_BOLD = 1, FONT_STYLE_ITALIC = 2, FONT_STYLE_UNDERLINE = 4, FONT_STYLE_SMOOTH = 8, FONT_STYLE_STRIKETHROUGH = 16 } ERenFontStyle; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd invert their position, but that's just me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like smoothing is going to be used a lot more, and for every font the user would use anyways. Especially on macs and when trying to make fonts look similar to os renders.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic is that strikethrough should be near underline, but it's not a big problem.
Co-authored-by: Guldoman <giulio.lettieri@gmail.com>
As per discussion on discord, this is good enough for now. Merging. |
…1087) * Added a smoothing option to font loading. * Added a font strikethrough option to font loading. * Fixed underline applying incorrectly in cases of non-underlined fallback fonts being used. Co-authored-by: Guldoman <giulio.lettieri@gmail.com>
Related to the discussion in #1079.