Re: [PATCH weston] Add font entry to shell section for title fonts
On Tue, 2 Sep 2014 13:13:17 +0900 Ryo Munakata ryomnk...@gmail.com wrote: On Mon, 1 Sep 2014 14:05:42 +0300 Pekka Paalanen ppaala...@gmail.com wrote: On Thu, 28 Aug 2014 20:31:37 +0900 Hi, considering that the toytoolkit (well, shared/cairo-util.h here) uses cairo_show_text(), which is documented as: The cairo_show_text() function call is part of what the cairo designers call the toy text API. It is convenient for short demos and simple programs, but it is not expected to be adequate for serious text-using applications. See cairo_show_glyphs() for the real text display API in cairo. - http://cairographics.org/manual/cairo-text.html#cairo-show-text I'm not sure being able to choose the font is appropriate. If we wanted text to work right, we cannot trust any single font to contain all the needed glyphs, which is what cairo_show_text() assumes. We'd need a list of fonts to fall back when a glyph is not found. If this was just about the toytoolkit alone, I would probably not bother with it, but since we use the same code to draw Xwayland decorations, maybe doing text rendering properly would be worth it? Would be much better to rely on pangocairo, as it seems we already use pangocairo when it's available. When pangocairo is disabled in the build, we should fall back to the current cairo_show_text(). Does that make sense? Thanks, pq Hi, Pekka. I agree with you. It makes sense. I'm working on it. Here's a few questions: * Is pangocairo optional, not a requirement? Should I write the code like: #ifdef HAVE_PANGOCAIRO /* use pangocairo */ #else /* use cairo */ #endif or can I assume we can use pangocairo for sure? The editor demo client already uses pangocairo, so see what it does. I haven't really looked myself. Yeah, the #ifdef HAVE_PANGO is indeed what I meant, because I don't think we want to unconditionally require pangocairo for Weston. We need the old approach for when pangocairo is disabled. If you are getting many places with #ifdefs, try to think if it would be possible to restructure the code to either have two sets of function definitions chosen by a single #ifdef, or maybe even two separate files of which only one gets into the build as configured. * I will add 'fonts' entry to shell section. Is that okay? 'fonts' entry is a list of fonts: fonts=font1,font2,font3 Is 'shell' section the right place to add fonts entry? If it's necessary, sounds fine. Btw. in your original patch, I'd probably prefer if config_get_font_family() or similar would not be in shared/. I suppose most programs already parse the .ini file, and all they want is to feed, say, a string to shared code to set up the fonts. I think we need a way to choose the fonts. For example, if you search for something on Google Japan using firefox, the title of firefox will be garbled because of sans which is a default font. (I mean mojibake: http://en.wikipedia.org/wiki/Mojibake) I know Weston is just a reference implementation, not to use for real. What do you think about it considering the policy of Weston? Should I continue to work on it? I think it would be good, yes. I don't expect the code required to be too much when using pangocairo. I'd expect this to be a Weston 1.7 thing rather than 1.6, so no rush. Thanks, pq ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH weston] Add font entry to shell section for title fonts
On Thu, 28 Aug 2014 20:31:37 +0900 Ryo Munakata ryomnk...@gmail.com wrote: cairo-util has used sans font family for title fonts so far. But sans doesn't support non-ascii characters. So now let users choose a font family for titles. The entry name is generic, 'font' so that other places where draw texts can use this entry too. Signed-off-by: Ryo Munakata ryomnk...@gmail.com --- man/weston.ini.man | 3 +++ shared/cairo-util.c | 16 +++- shared/cairo-util.h | 1 + weston.ini.in | 1 + 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/man/weston.ini.man b/man/weston.ini.man index ccd7185..0830255 100644 --- a/man/weston.ini.man +++ b/man/weston.ini.man @@ -260,6 +260,9 @@ sets the path to lock screen background image (string). (tablet shell only) .TP 7 .BI homescreen= path sets the path to home screen background image (string). (tablet shell only) +.TP 7 +.BI font= font-family +sets the font family name. Title fonts only supported now. .RE .SH LAUNCHER SECTION There can be multiple launcher sections, one for each launcher. diff --git a/shared/cairo-util.c b/shared/cairo-util.c index 26286c5..7bdb8cb 100644 --- a/shared/cairo-util.c +++ b/shared/cairo-util.c @@ -337,6 +337,18 @@ theme_set_background_source(struct theme *t, cairo_t *cr, uint32_t flags) } } +static char * +config_get_font_family() +{ + char *font_family; + struct weston_config *config + = weston_config_parse(weston.ini); + struct weston_config_section *section + = weston_config_get_section(config, shell, NULL, NULL); + weston_config_section_get_string(section, font, font_family, sans); + return font_family; +} + struct theme * theme_create(void) { @@ -350,6 +362,7 @@ theme_create(void) t-margin = 32; t-width = 6; t-titlebar_height = 27; + t-title_font = config_get_font_family(); t-frame_radius = 3; t-shadow = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 128, 128); cr = cairo_create(t-shadow); @@ -408,6 +421,7 @@ theme_destroy(struct theme *t) cairo_surface_destroy(t-active_frame); cairo_surface_destroy(t-inactive_frame); cairo_surface_destroy(t-shadow); + free(t-title_font); free(t); } @@ -458,7 +472,7 @@ theme_render_frame(struct theme *t, cairo_clip(cr); cairo_set_operator(cr, CAIRO_OPERATOR_OVER); - cairo_select_font_face(cr, sans, + cairo_select_font_face(cr, t-title_font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); cairo_set_font_size(cr, 14); diff --git a/shared/cairo-util.h b/shared/cairo-util.h index fb25c34..060e01b 100644 --- a/shared/cairo-util.h +++ b/shared/cairo-util.h @@ -53,6 +53,7 @@ struct theme { int margin; int width; int titlebar_height; + char *title_font; }; struct theme * diff --git a/weston.ini.in b/weston.ini.in index 4fca0bb..6fef17e 100644 --- a/weston.ini.in +++ b/weston.ini.in @@ -15,6 +15,7 @@ startup-animation=fade #num-workspaces=6 #cursor-theme=whiteglass #cursor-size=24 +#font=sans #lockscreen-icon=/usr/share/icons/gnome/256x256/actions/lock.png #lockscreen=/usr/share/backgrounds/gnome/Garden.jpg Hi, considering that the toytoolkit (well, shared/cairo-util.h here) uses cairo_show_text(), which is documented as: The cairo_show_text() function call is part of what the cairo designers call the toy text API. It is convenient for short demos and simple programs, but it is not expected to be adequate for serious text-using applications. See cairo_show_glyphs() for the real text display API in cairo. - http://cairographics.org/manual/cairo-text.html#cairo-show-text I'm not sure being able to choose the font is appropriate. If we wanted text to work right, we cannot trust any single font to contain all the needed glyphs, which is what cairo_show_text() assumes. We'd need a list of fonts to fall back when a glyph is not found. If this was just about the toytoolkit alone, I would probably not bother with it, but since we use the same code to draw Xwayland decorations, maybe doing text rendering properly would be worth it? Would be much better to rely on pangocairo, as it seems we already use pangocairo when it's available. When pangocairo is disabled in the build, we should fall back to the current cairo_show_text(). Does that make sense? Thanks, pq ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH weston] Add font entry to shell section for title fonts
On Mon, 1 Sep 2014 14:05:42 +0300 Pekka Paalanen ppaala...@gmail.com wrote: On Thu, 28 Aug 2014 20:31:37 +0900 Hi, considering that the toytoolkit (well, shared/cairo-util.h here) uses cairo_show_text(), which is documented as: The cairo_show_text() function call is part of what the cairo designers call the toy text API. It is convenient for short demos and simple programs, but it is not expected to be adequate for serious text-using applications. See cairo_show_glyphs() for the real text display API in cairo. - http://cairographics.org/manual/cairo-text.html#cairo-show-text I'm not sure being able to choose the font is appropriate. If we wanted text to work right, we cannot trust any single font to contain all the needed glyphs, which is what cairo_show_text() assumes. We'd need a list of fonts to fall back when a glyph is not found. If this was just about the toytoolkit alone, I would probably not bother with it, but since we use the same code to draw Xwayland decorations, maybe doing text rendering properly would be worth it? Would be much better to rely on pangocairo, as it seems we already use pangocairo when it's available. When pangocairo is disabled in the build, we should fall back to the current cairo_show_text(). Does that make sense? Thanks, pq Hi, Pekka. I agree with you. It makes sense. I'm working on it. Here's a few questions: * Is pangocairo optional, not a requirement? Should I write the code like: #ifdef HAVE_PANGOCAIRO /* use pangocairo */ #else /* use cairo */ #endif or can I assume we can use pangocairo for sure? * I will add 'fonts' entry to shell section. Is that okay? 'fonts' entry is a list of fonts: fonts=font1,font2,font3 Is 'shell' section the right place to add fonts entry? I think we need a way to choose the fonts. For example, if you search for something on Google Japan using firefox, the title of firefox will be garbled because of sans which is a default font. (I mean mojibake: http://en.wikipedia.org/wiki/Mojibake) I know Weston is just a reference implementation, not to use for real. What do you think about it considering the policy of Weston? Should I continue to work on it? Thanks. -- Ryo Munakata ryomnk...@gmail.com ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH weston] Add font entry to shell section for title fonts
Weston is not just a reference anymore: it's designed to be used in real environments. toytoolkit less so, but that's no reason to back down. Pango will do proper font selection (shaping) for you without any work on your part. It's designed to be a full text layout engine that's simple to use. On Sep 1, 2014 9:13 PM, Ryo Munakata ryomnk...@gmail.com wrote: On Mon, 1 Sep 2014 14:05:42 +0300 Pekka Paalanen ppaala...@gmail.com wrote: On Thu, 28 Aug 2014 20:31:37 +0900 Hi, considering that the toytoolkit (well, shared/cairo-util.h here) uses cairo_show_text(), which is documented as: The cairo_show_text() function call is part of what the cairo designers call the toy text API. It is convenient for short demos and simple programs, but it is not expected to be adequate for serious text-using applications. See cairo_show_glyphs() for the real text display API in cairo. - http://cairographics.org/manual/cairo-text.html#cairo-show-text I'm not sure being able to choose the font is appropriate. If we wanted text to work right, we cannot trust any single font to contain all the needed glyphs, which is what cairo_show_text() assumes. We'd need a list of fonts to fall back when a glyph is not found. If this was just about the toytoolkit alone, I would probably not bother with it, but since we use the same code to draw Xwayland decorations, maybe doing text rendering properly would be worth it? Would be much better to rely on pangocairo, as it seems we already use pangocairo when it's available. When pangocairo is disabled in the build, we should fall back to the current cairo_show_text(). Does that make sense? Thanks, pq Hi, Pekka. I agree with you. It makes sense. I'm working on it. Here's a few questions: * Is pangocairo optional, not a requirement? Should I write the code like: #ifdef HAVE_PANGOCAIRO /* use pangocairo */ #else /* use cairo */ #endif or can I assume we can use pangocairo for sure? * I will add 'fonts' entry to shell section. Is that okay? 'fonts' entry is a list of fonts: fonts=font1,font2,font3 Is 'shell' section the right place to add fonts entry? I think we need a way to choose the fonts. For example, if you search for something on Google Japan using firefox, the title of firefox will be garbled because of sans which is a default font. (I mean mojibake: http://en.wikipedia.org/wiki/Mojibake) I know Weston is just a reference implementation, not to use for real. What do you think about it considering the policy of Weston? Should I continue to work on it? Thanks. -- Ryo Munakata ryomnk...@gmail.com ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston] Add font entry to shell section for title fonts
cairo-util has used sans font family for title fonts so far. But sans doesn't support non-ascii characters. So now let users choose a font family for titles. The entry name is generic, 'font' so that other places where draw texts can use this entry too. Signed-off-by: Ryo Munakata ryomnk...@gmail.com --- man/weston.ini.man | 3 +++ shared/cairo-util.c | 16 +++- shared/cairo-util.h | 1 + weston.ini.in | 1 + 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/man/weston.ini.man b/man/weston.ini.man index ccd7185..0830255 100644 --- a/man/weston.ini.man +++ b/man/weston.ini.man @@ -260,6 +260,9 @@ sets the path to lock screen background image (string). (tablet shell only) .TP 7 .BI homescreen= path sets the path to home screen background image (string). (tablet shell only) +.TP 7 +.BI font= font-family +sets the font family name. Title fonts only supported now. .RE .SH LAUNCHER SECTION There can be multiple launcher sections, one for each launcher. diff --git a/shared/cairo-util.c b/shared/cairo-util.c index 26286c5..7bdb8cb 100644 --- a/shared/cairo-util.c +++ b/shared/cairo-util.c @@ -337,6 +337,18 @@ theme_set_background_source(struct theme *t, cairo_t *cr, uint32_t flags) } } +static char * +config_get_font_family() +{ + char *font_family; + struct weston_config *config + = weston_config_parse(weston.ini); + struct weston_config_section *section + = weston_config_get_section(config, shell, NULL, NULL); + weston_config_section_get_string(section, font, font_family, sans); + return font_family; +} + struct theme * theme_create(void) { @@ -350,6 +362,7 @@ theme_create(void) t-margin = 32; t-width = 6; t-titlebar_height = 27; + t-title_font = config_get_font_family(); t-frame_radius = 3; t-shadow = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 128, 128); cr = cairo_create(t-shadow); @@ -408,6 +421,7 @@ theme_destroy(struct theme *t) cairo_surface_destroy(t-active_frame); cairo_surface_destroy(t-inactive_frame); cairo_surface_destroy(t-shadow); + free(t-title_font); free(t); } @@ -458,7 +472,7 @@ theme_render_frame(struct theme *t, cairo_clip(cr); cairo_set_operator(cr, CAIRO_OPERATOR_OVER); - cairo_select_font_face(cr, sans, + cairo_select_font_face(cr, t-title_font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); cairo_set_font_size(cr, 14); diff --git a/shared/cairo-util.h b/shared/cairo-util.h index fb25c34..060e01b 100644 --- a/shared/cairo-util.h +++ b/shared/cairo-util.h @@ -53,6 +53,7 @@ struct theme { int margin; int width; int titlebar_height; + char *title_font; }; struct theme * diff --git a/weston.ini.in b/weston.ini.in index 4fca0bb..6fef17e 100644 --- a/weston.ini.in +++ b/weston.ini.in @@ -15,6 +15,7 @@ startup-animation=fade #num-workspaces=6 #cursor-theme=whiteglass #cursor-size=24 +#font=sans #lockscreen-icon=/usr/share/icons/gnome/256x256/actions/lock.png #lockscreen=/usr/share/backgrounds/gnome/Garden.jpg -- 2.1.0 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel