[geany/geany] 46d5e7: Add support for fractional font sizes
Pedro Henrique Antunes de Oliveira
git-noreply at xxxxx
Tue Aug 13 14:52:14 UTC 2019
Branch: refs/heads/master
Author: Pedro Henrique Antunes de Oliveira <phao1989 at gmail.com>
Committer: Colomban Wendling <ban at herbesfolles.org>
Date: Tue, 13 Aug 2019 14:52:14 UTC
Commit: 46d5e7542b8396ed593f2e319f71d153a67684dc
https://github.com/geany/geany/commit/46d5e7542b8396ed593f2e319f71d153a67684dc
Log Message:
-----------
Add support for fractional font sizes
Closes #2250 and closes #703.
Modified Paths:
--------------
src/editor.c
src/sciwrappers.c
src/sciwrappers.h
Modified: src/editor.c
7 lines changed, 4 insertions(+), 3 deletions(-)
===================================================================
@@ -4591,19 +4591,20 @@ void editor_ensure_final_newline(GeanyEditor *editor)
void editor_set_font(GeanyEditor *editor, const gchar *font)
{
- gint style, size;
+ gint style;
gchar *font_name;
PangoFontDescription *pfd;
+ gdouble size;
g_return_if_fail(editor);
pfd = pango_font_description_from_string(font);
- size = pango_font_description_get_size(pfd) / PANGO_SCALE;
+ size = pango_font_description_get_size(pfd) / (gdouble) PANGO_SCALE;
font_name = g_strdup_printf("!%s", pango_font_description_get_family(pfd));
pango_font_description_free(pfd);
for (style = 0; style <= STYLE_MAX; style++)
- sci_set_font(editor->sci, style, font_name, size);
+ sci_set_font_fractional(editor->sci, style, font_name, size);
g_free(font_name);
Modified: src/sciwrappers.c
15 lines changed, 13 insertions(+), 2 deletions(-)
===================================================================
@@ -939,6 +939,18 @@ gint sci_find_text(ScintillaObject *sci, gint flags, struct Sci_TextToFind *ttf)
return (gint) SSM(sci, SCI_FINDTEXT, (uptr_t) flags, (sptr_t) ttf);
}
+/* * Sets the font for a particular style.
+ * @param sci Scintilla widget.
+ * @param style The style.
+ * @param font The font name.
+ * @param size The font (fractional) size. */
+void sci_set_font_fractional(ScintillaObject *sci, gint style, const gchar *font, gdouble size)
+{
+ SSM(sci, SCI_STYLESETFONT, (uptr_t) style, (sptr_t) font);
+
+ /* Adding 0.5 is for rounding. */
+ SSM(sci, SCI_STYLESETSIZEFRACTIONAL, (uptr_t) style, (sptr_t) (SC_FONT_SIZE_MULTIPLIER * size + 0.5));
+}
/** Sets the font for a particular style.
* @param sci Scintilla widget.
@@ -948,8 +960,7 @@ gint sci_find_text(ScintillaObject *sci, gint flags, struct Sci_TextToFind *ttf)
GEANY_API_SYMBOL
void sci_set_font(ScintillaObject *sci, gint style, const gchar *font, gint size)
{
- SSM(sci, SCI_STYLESETFONT, (uptr_t) style, (sptr_t) font);
- SSM(sci, SCI_STYLESETSIZE, (uptr_t) style, size);
+ sci_set_font_fractional(sci, style, font, size);
}
Modified: src/sciwrappers.h
2 lines changed, 2 insertions(+), 0 deletions(-)
===================================================================
@@ -216,6 +216,8 @@ gint sci_text_width (ScintillaObject *sci, gint styleNumber, const gchar *
void sci_move_selected_lines_down (ScintillaObject *sci);
void sci_move_selected_lines_up (ScintillaObject *sci);
+void sci_set_font_fractional (ScintillaObject *sci, gint style, const gchar *font, gdouble size);
+
#endif /* GEANY_PRIVATE */
G_END_DECLS
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Commits
mailing list