GNOME Bugzilla – Bug 595737
Where does default font size comes from?
Last modified: 2009-10-23 12:17:54 UTC
Empathy should follow general font size in Gnome when displaying Adium-style webchats. I have set in gnome-appearance-properties default font size to 9pt, so when Adium style uses as default 14px it looks awfully big in contrast to the rest of the screen (e.g., input text box). I know px is not the same as pt, but I hope Empathy or something should be able to find a font of the same size. According to people on #webkit-gtk channel on Freenode the relevant information is on http://webkitgtk.org/reference/webkitgtk-WebKitWebSettings.html#WebKitWebSettings--default-font-size
Empathy respects the font and font size defined by the adium theme.
Nice try, but no I am smarter than that. Of course, I am talking about Adium style which doesn't set any font-size ... take a look at my style SimKete (http://gitorious.org/simkete/simkete/blobs/master/Contents/Resources/main.css is the main.css). bradford:Resources$ curl -s http://gitorious.org/simkete/simkete/blobs/raw/bgo595737/Contents/Info.plist|grep -i 'font' bradford:Resources$ curl -s http://gitorious.org/simkete/simkete/blobs/raw/bgo595737/Contents/Resources/main.css|grep 'font-size' bradford:Resources$ and the result has (according to WebKit element inspector) font 'sans-serif' size 16px. That's quite certainly not what I have set for Gnome. So where does the font come from?
Created attachment 143523 [details] screenshot of the issue Compare the size of font in the styled part with input textbox.
Ah sorry, I didn't understand correctly. If there are no font size defined, I guess webkit does the fallback itself. Not sure if webkitgtk can use gnome's setting directly. If not, then I guess we could do that in empathy code. Patch is welcome ;-)
(In reply to comment #4) > Ah sorry, I didn't understand correctly. > > If there are no font size defined, I guess webkit does the fallback itself. Not > sure if webkitgtk can use gnome's setting directly. If not, then I guess we > could do that in empathy code. No, WebKitGTK+ does not interface with GNOME directly, since its scope is way bigger than GNOME applications. > > Patch is welcome ;-) You can see how Epiphany does this for inspiration: http://git.gnome.org/cgit/epiphany/tree/embed/ephy-embed-prefs.c
Created attachment 143640 [details] [review] get default font from the system settings (In reply to comment #4) > Patch is welcome ;-) Like this :)
Created attachment 143643 [details] [review] get default font from the system settings sorry, one small memory leak
Some initial comments: * Split return type and function name/arguments onto different lines. * All function calls are like "this ()", not "this()" (not the space before bracket) * Don't forget to make private functions static (theme_adium_get_dpi). * Functions that take no arguments should be declared with "void" in the argument list. * Declare variables at the top of blocks and assign values to them afterwards unless the assignment is particularly trivial (none of these fit in this definition of trivial). * Don't include headers into a public header which aren't required for that header. I.e. include gconf-client.h, pango-font.h and gdkscreen.h in the C file. * Don't forget to include semi-colons after every statement. * It's not necessary to call "return" at the end of a void function. * Don't forget to indent blocks. Thanks for the patch. If you could update it and attach a new patch, it'd be great. Also, you might find it easier to use git to generate the diff. We would certainly find it easier to take your patch and credit you when merged.
Repository is http://github.com/mcepl/empathy/ branch webkit-font-size and I will add fixes for the requested issues asap (probably tomorrow).
http://github.com/mcepl/empathy/tree/webkit-font-size
Created attachment 143663 [details] [review] new version of patch
* +static PangoFontDescription +*theme_adium_get_default_font (void) The * should go on the previous line, after the return type. (The point of this is so you can grep in your source tree for "^function_name" and find exactly where the function is declared.) * You don't have to explicitly assign every variable a value on declaration, but I guess it doesn't hurt. * Add a space after a calling a function, before the parenthesis. For example, use "foo (bar)" instead of "foo(bar)". * Use "if (foo != NULL)" instead of "if (foo)" * Wrap arguments onto multiple lines, like in every other function in that file. * Don't include trailing whitespace. * Either use curly braces for an entire if/else if/.../else statement, or don't. Don't use it only half of the time. * Add a space after the type parenthesis when casting.
Created attachment 144262 [details] [review] new version of patch
github sucks, moved the branch to http://gitorious.org/empathy-mirror/main/commits/webkit-font-size
Created attachment 145930 [details] [review] yet another version of the patch
Review of attachment 145930 [details] [review]: Other than these small issues, it seems fine. ::: libempathy-gtk/empathy-theme-adium.c @@ +30,3 @@ +#include <gconf/gconf-client.h> +#include <pango/pango-font.h> Not a big issue, but include <pango/pango.h> instead. @@ +31,3 @@ +#include <gconf/gconf-client.h> +#include <pango/pango-font.h> +#include <gdk/gdkscreen.h> You should include <gdk/gdk.h> instead. @@ +1020,3 @@ + + default_font_desc = theme_adium_get_default_font (); + if (default_font_desc != NULL) { You could use if (default_font_desc == NULL) return; to mean you wouldn't have to indent all of this stuff. @@ +1032,3 @@ + pango_font_size = (gint) (pango_font_size / (dpi / 72)); + } + theme_adium_set_webkit_font(w_settings, Don't forget the space between function and parenthesis.
Created attachment 145936 [details] [review] hopefully final version of the patch
Review of attachment 145936 [details] [review]: Did you even try and build this? It should have failed to build with the addition of an unused variable. Additionally, if you give a patch using git format-patch, I can keep all your details (name, email, message) much easier. Hopefully this is the last time I'm coming back with more comments. ::: libempathy-gtk/empathy-theme-adium.c @@ +31,3 @@ +#include <gconf/gconf-client.h> +#include <pango/pango.h> +#include <gdk/gdkscreen.h> #include <gdk/gdk.h> @@ +1004,3 @@ +static void +theme_adium_set_webkit_font (WebKitWebSettings *w_settings, + gchar *name, const gchar *name @@ +1046,3 @@ const gchar *font_family = NULL; gint font_size = 0; + gint pango_font_size = 0; We don't need this here.
Created attachment 146096 [details] [review] yet another version of the patch
This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.