From: handa Date: Fri, 2 Dec 2005 04:44:47 +0000 (+0000) Subject: (main): Handle --font arg. X-Git-Tag: REL-1-3-0~41 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ee4f168676fe93ef417f447526c77ace38fe7b1;p=m17n%2Fm17n-lib.git (main): Handle --font arg. --- diff --git a/example/medit.c b/example/medit.c index 8416756..619ddf5 100644 --- a/example/medit.c +++ b/example/medit.c @@ -2585,6 +2585,7 @@ main (int argc, char **argv) { Widget form, BodyWidget, w; char *fontset_name = NULL; + char *font_name = NULL; int fontsize = 0; char *initial_input_method = NULL; int col = 80, row = 32; @@ -2616,6 +2617,7 @@ main (int argc, char **argv) int with_xim = 0; int i, j; char *filter = NULL; + MFont *font = NULL; setlocale (LC_ALL, ""); /* Create the top shell. */ @@ -2655,6 +2657,11 @@ main (int argc, char **argv) i++; fontset_name = strdup (argv[i]); } + else if (! strcmp (argv[i], "--font")) + { + i++; + font_name = strdup (argv[i]); + } else if (! strcmp (argv[i], "--im")) { i++; @@ -2748,6 +2755,22 @@ main (int argc, char **argv) default_font_size = (int) mfont_get_prop (font, Msize); } + if (font_name) + { + font = mfont_parse_name (font_name, Mnil); + if (font) + { + int score; + MFont *obj; + + if (fontsize > 0 && ! mfont_get_prop (font, Msize)) + mfont_put_prop (font, Msize, (void *) fontsize); + obj = mfont_find (frame, font, &score, 0); + if (obj) + mtext_put_prop (mt, 0, mtext_len (mt), Mfont, obj); + } + } + font_width = (int) mframe_get_prop (frame, Mfont_width); font_ascent = (int) mframe_get_prop (frame, Mfont_ascent); font_descent = (int) mframe_get_prop (frame, Mfont_descent); @@ -3183,6 +3206,8 @@ main (int argc, char **argv) m17n_object_unref (face_default); m17n_object_unref (default_face_list); m17n_object_unref (selection); + if (font) + free (font); XFreeGC (display, mono_gc); XFreeGC (display, mono_gc_inv); @@ -3194,6 +3219,7 @@ main (int argc, char **argv) M17N_FINI (); + free (font_name); free (fontset_name); free (filename); free (input_method_table);