After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 595737 - Where does default font size comes from?
Where does default font size comes from?
Status: RESOLVED FIXED
Product: empathy
Classification: Core
Component: Chat themes
2.27.x
Other Linux
: Normal normal
: ---
Assigned To: empathy-maint
Depends on:
Blocks:
 
 
Reported: 2009-09-20 10:32 UTC by Matěj Cepl
Modified: 2009-10-23 12:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
screenshot of the issue (56.47 KB, image/png)
2009-09-20 12:46 UTC, Matěj Cepl
  Details
get default font from the system settings (3.50 KB, patch)
2009-09-21 21:42 UTC, Matěj Cepl
none Details | Review
get default font from the system settings (3.55 KB, patch)
2009-09-21 21:58 UTC, Matěj Cepl
needs-work Details | Review
new version of patch (3.75 KB, patch)
2009-09-22 08:48 UTC, Matěj Cepl
none Details | Review
new version of patch (3.78 KB, patch)
2009-09-29 12:30 UTC, Matěj Cepl
none Details | Review
yet another version of the patch (3.78 KB, patch)
2009-10-21 08:52 UTC, Matěj Cepl
needs-work Details | Review
hopefully final version of the patch (3.76 KB, patch)
2009-10-21 09:33 UTC, Matěj Cepl
needs-work Details | Review
yet another version of the patch (4.02 KB, patch)
2009-10-23 12:09 UTC, Matěj Cepl
committed Details | Review

Description Matěj Cepl 2009-09-20 10:32:03 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
Comment 1 Xavier Claessens 2009-09-20 11:26:15 UTC
Empathy respects the font and font size defined by the adium theme.
Comment 2 Matěj Cepl 2009-09-20 12:45:42 UTC
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?
Comment 3 Matěj Cepl 2009-09-20 12:46:37 UTC
Created attachment 143523 [details]
screenshot of the issue

Compare the size of font in the styled part with input textbox.
Comment 4 Xavier Claessens 2009-09-20 19:48:15 UTC
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 ;-)
Comment 5 Xan Lopez 2009-09-21 09:22:27 UTC
(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
Comment 6 Matěj Cepl 2009-09-21 21:42:23 UTC
Created attachment 143640 [details] [review]
get default font from the system settings

(In reply to comment #4)
> Patch is welcome ;-)

Like this :)
Comment 7 Matěj Cepl 2009-09-21 21:58:35 UTC
Created attachment 143643 [details] [review]
get default font from the system settings

sorry, one small memory leak
Comment 8 Jonny Lamb 2009-09-21 22:07:47 UTC
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.
Comment 9 Matěj Cepl 2009-09-21 22:35:37 UTC
Repository is http://github.com/mcepl/empathy/ branch webkit-font-size and I will add fixes for the requested issues asap (probably tomorrow).
Comment 11 Matěj Cepl 2009-09-22 08:48:04 UTC
Created attachment 143663 [details] [review]
new version of patch
Comment 12 Jonny Lamb 2009-09-25 12:24:29 UTC
 * +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.
Comment 13 Matěj Cepl 2009-09-29 12:30:01 UTC
Created attachment 144262 [details] [review]
new version of patch
Comment 14 Matěj Cepl 2009-09-29 12:39:53 UTC
github sucks, moved the branch to http://gitorious.org/empathy-mirror/main/commits/webkit-font-size
Comment 15 Matěj Cepl 2009-10-21 08:52:59 UTC
Created attachment 145930 [details] [review]
yet another version of the patch
Comment 16 Jonny Lamb 2009-10-21 09:09:19 UTC
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.
Comment 17 Matěj Cepl 2009-10-21 09:33:33 UTC
Created attachment 145936 [details] [review]
hopefully final version of the patch
Comment 18 Jonny Lamb 2009-10-21 10:04:41 UTC
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.
Comment 19 Matěj Cepl 2009-10-23 12:09:20 UTC
Created attachment 146096 [details] [review]
yet another version of the patch
Comment 20 Jonny Lamb 2009-10-23 12:17:20 UTC
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.