Branch: refs/heads/fractional_fonts Author: Pedro Henrique Antunes de Oliveira phao1989@gmail.com Committer: Colomban Wendling ban@herbesfolles.org Date: Fri, 09 Aug 2019 07:11:59 UTC Commit: 69ae8f967d8c5557a2c7c441ebc0ed7f4c954612 https://github.com/geany/geany/commit/69ae8f967d8c5557a2c7c441ebc0ed7f4c9546...
Log Message: ----------- Added support for fractional font sizes.
Modified Paths: -------------- src/editor.c src/sciwrappers.c src/sciwrappers.h
Modified: src/editor.c 4 lines changed, 2 insertions(+), 2 deletions(-) =================================================================== @@ -4598,12 +4598,12 @@ void editor_set_font(GeanyEditor *editor, const gchar *font) g_return_if_fail(editor);
pfd = pango_font_description_from_string(font); - size = pango_font_description_get_size(pfd) / PANGO_SCALE; + size = (100*pango_font_description_get_size(pfd)) / 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_fract(editor->sci, style, font_name, size/100.0);
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_fract(ScintillaObject *sci, gint style, const gchar *font, double size) +{ + SSM(sci, SCI_STYLESETFONT, (uptr_t) style, (sptr_t) font); + + // Adding 0.5 is to round. + SSM(sci, SCI_STYLESETSIZEFRACTIONAL, (uptr_t) style, 100.0*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_fract(sci, style, font, size); }
Modified: src/sciwrappers.h 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -80,6 +80,7 @@ gchar sci_get_char_at (ScintillaObject *sci, gint pos);
void sci_scroll_caret (ScintillaObject *sci); gint sci_find_text (ScintillaObject *sci, gint flags, struct Sci_TextToFind *ttf); +void sci_set_font_fract (ScintillaObject *sci, gint style, const gchar *font, double size); void sci_set_font (ScintillaObject *sci, gint style, const gchar *font, gint size); void sci_goto_line (ScintillaObject *sci, gint line, gboolean unfold); gint sci_get_style_at (ScintillaObject *sci, gint position);
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).