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

Added a smoothing and strikethrough option to font loading. #1087

Merged
merged 11 commits into from Aug 20, 2022

Conversation

aqilc
Copy link
Contributor

@aqilc aqilc commented Jul 31, 2022

Related to the discussion in #1079.

src/renderer.c Outdated
FT_Outline_Translate(outline, x_translation, 0 );
if(smoothing) FT_Outline_Embolden(outline, 1 << 5);
Copy link
Member

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?

Copy link
Contributor Author

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.

src/renderer.c Outdated Show resolved Hide resolved
@aqilc
Copy link
Contributor Author

aqilc commented Aug 14, 2022

Can this be merged now? I want to use this option for myself.

@aqilc
Copy link
Contributor Author

aqilc commented Aug 15, 2022

OK this pr finally isn't like 3 lines

@aqilc aqilc changed the title Added a smoothing option to font loading. Added a smoothing and strikethrough option to font loading. Aug 15, 2022
@@ -4,6 +4,7 @@ lhelper/
submodules/
subprojects/*/
/appimage*
.vscode
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this intended?

Copy link
Contributor Author

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

src/renderer.c Outdated Show resolved Hide resolved
@@ -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;
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

src/renderer.c Outdated Show resolved Hide resolved
src/renderer.c Outdated Show resolved Hide resolved
src/renderer.c Outdated Show resolved Hide resolved
Co-authored-by: Guldoman <giulio.lettieri@gmail.com>
@adamharrison
Copy link
Member

As per discussion on discord, this is good enough for now. Merging.

@adamharrison adamharrison merged commit 9b1bfea into lite-xl:master Aug 20, 2022
takase1121 pushed a commit to takase1121/lite-xl that referenced this pull request Nov 14, 2022
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants