Merge lp:~macslow/notify-osd/fix-fractional-point-size into lp:notify-osd/karmic

Proposed by Mirco Müller
Status: Merged
Merge reported by: Mirco Müller
Merged at revision: not available
Proposed branch: lp:~macslow/notify-osd/fix-fractional-point-size
Merge into: lp:notify-osd/karmic
Diff against target: 165 lines
4 files modified
src/defaults.c (+19/-12)
src/util.c (+0/-39)
src/util.h (+0/-3)
tests/test-text-filtering.c (+0/-23)
To merge this branch: bzr merge lp:~macslow/notify-osd/fix-fractional-point-size
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Review via email: mp+13913@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Mirco Müller (macslow) wrote :

This branch fixes extracting a fonts point-size with a fractional part and thus addresses LP: #396736, LP: #457655, LP: #458413, LP: #459290, LP: #459689. The lack of this fix causes notification bubbles to be really tiny (see http://launchpadlibrarian.net/34315070/screenshot_001.png), should the user have set a font point-size of e.g. 8,5. I regard this fix to be critical within the scope of immediate user-experience of Karmic and taking into account a users system setup, which might not be the default "Sans 10"-case.

Revision history for this message
Ted Gould (ted) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/defaults.c'
2--- src/defaults.c 2009-10-19 17:59:53 +0000
3+++ src/defaults.c 2009-10-25 10:15:22 +0000
4@@ -172,13 +172,14 @@
5 static void
6 _get_font_size_dpi (Defaults* self)
7 {
8- GString* string = NULL;
9- GError* error = NULL;
10- guint points = 0;
11- GString* font_face = NULL;
12- gdouble dpi = 0.0f;
13- gdouble pixels_per_em = 0;
14- gchar* font_name = NULL;
15+ GString* string = NULL;
16+ GError* error = NULL;
17+ gdouble points = 0.0f;
18+ GString* font_face = NULL;
19+ gdouble dpi = 0.0f;
20+ gdouble pixels_per_em = 0;
21+ gchar* font_name = NULL;
22+ PangoFontDescription* desc = NULL;
23
24 if (!IS_DEFAULTS (self))
25 return;
26@@ -198,11 +199,17 @@
27 error->message);
28 g_error_free (error);
29 }
30+
31+ // extract text point-size
32+ desc = pango_font_description_from_string (font_name);
33+ if (pango_font_description_get_size_is_absolute (desc))
34+ points = (gdouble) pango_font_description_get_size (desc);
35+ else
36+ points = (gdouble) pango_font_description_get_size (desc) /
37+ (gdouble) PANGO_SCALE;
38+ pango_font_description_free (desc);
39 g_free ((gpointer) font_name);
40
41- // extract text point-size
42- points = extract_point_size (string->str);
43-
44 // extract font-face-name/style
45 font_face = extract_font_face (string->str);
46
47@@ -233,12 +240,12 @@
48 }
49
50 /* update stored DPI-value */
51- pixels_per_em = (gdouble) points * dpi / 72.0f;
52+ pixels_per_em = points * dpi / 72.0f;
53 g_object_set (self, "pixels-per-em", pixels_per_em, NULL);
54 g_object_set (self, "screen-dpi", dpi, NULL);
55
56 if (g_getenv ("DEBUG"))
57- g_print ("font-size: %dpt\ndpi: %3.1f\npixels/EM: %2.2f\nwidth: %d px\ntitle-height: %2.2f pt\nbody-height: %2.2f pt\n\n",
58+ g_print ("font-size: %fpt\ndpi: %3.1f\npixels/EM: %2.2f\nwidth: %d px\ntitle-height: %2.2f pt\nbody-height: %2.2f pt\n\n",
59 points,
60 defaults_get_screen_dpi (self),
61 pixels_per_em,
62
63=== modified file 'src/util.c'
64--- src/util.c 2009-10-19 04:57:25 +0000
65+++ src/util.c 2009-10-25 10:15:22 +0000
66@@ -258,45 +258,6 @@
67 return (gchar*) buffer;
68 }
69
70-guint
71-extract_point_size (const gchar* string)
72-{
73- guint point_size = 0;
74- GRegex* regex = NULL;
75- GMatchInfo* match_info = NULL;
76-
77- // sanity check
78- if (!string)
79- return 0;
80-
81- // setup regular expression to extract an integer from the end of string
82- regex = g_regex_new ("\\d+$", 0, 0, NULL);
83- if (!regex)
84- return 0;
85-
86- // walk the string
87- g_regex_match (regex, string, 0, &match_info);
88- while (g_match_info_matches (match_info))
89- {
90- gchar* word = NULL;
91-
92- word = g_match_info_fetch (match_info, 0);
93- if (word)
94- {
95- sscanf (word, "%d", &point_size);
96- g_free (word);
97- }
98-
99- g_match_info_next (match_info, NULL);
100- }
101-
102- // clean up
103- g_match_info_free (match_info);
104- g_regex_unref (regex);
105-
106- return point_size;
107-}
108-
109 GString*
110 extract_font_face (const gchar* string)
111 {
112
113=== modified file 'src/util.h'
114--- src/util.h 2009-10-19 04:57:25 +0000
115+++ src/util.h 2009-10-25 10:15:22 +0000
116@@ -52,8 +52,5 @@
117 gchar*
118 get_wm_name (Display* dpy);
119
120-guint
121-extract_point_size (const gchar* string);
122-
123 GString*
124 extract_font_face (const gchar* string);
125
126=== modified file 'tests/test-text-filtering.c'
127--- tests/test-text-filtering.c 2009-10-19 04:57:25 +0000
128+++ tests/test-text-filtering.c 2009-10-25 10:15:22 +0000
129@@ -103,28 +103,6 @@
130 }
131
132 static void
133-test_extract_point_size ()
134-{
135- static const IntegerExtraction tests[] = {
136- { "", 0 },
137- { "foobar", 0 },
138- { "Bla Fasel -12.0", 0 },
139- { "Sans 10", 10 },
140- { "Candara 9", 9 },
141- { "Bitstream Vera Serif Italic 1", 1 },
142- { "Calibri Italic 100", 100 },
143- { "Century Schoolbook L Italic 42", 42 },
144- { NULL, 0 }
145- };
146-
147- for (int i = 0; tests[i].before != NULL; i++)
148- {
149- guint extracted = extract_point_size (tests[i].before);
150- g_assert_cmpuint (extracted, ==, tests[i].expected);
151- }
152-}
153-
154-static void
155 test_extract_font_face ()
156 {
157 static const TextComparisons tests[] = {
158@@ -156,7 +134,6 @@
159
160 g_test_suite_add(ts, TC(test_text_filter));
161 g_test_suite_add(ts, TC(test_newline_to_space));
162- g_test_suite_add(ts, TC(test_extract_point_size));
163 g_test_suite_add(ts, TC(test_extract_font_face));
164
165 return ts;

Subscribers

People subscribed via source and target branches

to all changes: