The Birdfont Source Code


All Repositories / birdfont.git / blob – RSS feed

DescriptionDisplay.vala in libbirdfont

This file is a part of the Birdfont project.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git

Revisions

View the latest version of libbirdfont/DescriptionDisplay.vala.
License and other descriptive fields in TTF fonts
1 /* 2 Copyright (C) 2014 2015 Johan Mattsson 3 4 This library is free software; you can redistribute it and/or modify 5 it under the terms of the GNU Lesser General Public License as 6 published by the Free Software Foundation; either version 3 of the 7 License, or (at your option) any later version. 8 9 This library is distributed in the hope that it will be useful, but 10 WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Lesser General Public License for more details. 13 */ 14 15 using Cairo; 16 using Math; 17 18 namespace BirdFont { 19 20 public class DescriptionDisplay : TableLayout { 21 TextArea postscript_name; 22 TextArea name; 23 TextArea style; 24 CheckBox bold; 25 CheckBox italic; 26 TextArea weight; 27 TextArea full_name; 28 TextArea unique_id; 29 TextArea version; 30 TextArea description; 31 TextArea copyright; 32 33 private static bool disable_copyright = false; 34 35 public DescriptionDisplay () { 36 double margin = 12 * MainWindow.units; 37 double label_size = 20 * MainWindow.units; 38 double label_margin = 4 * MainWindow.units; 39 Headline headline; 40 Font font = BirdFont.get_current_font (); 41 42 postscript_name = new LineTextArea (label_size); 43 name = new LineTextArea (label_size); 44 style = new LineTextArea (label_size); 45 weight = new LineTextArea (label_size); 46 full_name = new LineTextArea (label_size); 47 unique_id = new LineTextArea (label_size); 48 version = new LineTextArea (label_size); 49 description = new TextArea (label_size); 50 copyright = new TextArea (label_size); 51 52 headline = new Headline (t_("Name and Description")); 53 headline.margin_bottom = 20 * MainWindow.units; 54 widgets.add (headline); 55 56 widgets.add (new Text (t_("PostScript Name"), label_size, label_margin)); 57 postscript_name.margin_bottom = margin; 58 postscript_name.set_text (font.postscript_name); 59 postscript_name.text_changed.connect ((t) => { 60 font.postscript_name = t; 61 font.touch (); 62 }); 63 widgets.add (postscript_name); 64 focus_ring.add (postscript_name); 65 66 widgets.add (new Text (t_("Name"), label_size, label_margin)); 67 name.margin_bottom = margin; 68 name.set_text (font.name); 69 name.text_changed.connect ((t) => { 70 font.name = t; 71 font.touch (); 72 }); 73 widgets.add (name); 74 focus_ring.add (name); 75 76 widgets.add (new Text (t_("Style"), label_size, label_margin)); 77 style.margin_bottom = 1.5 * margin; 78 style.set_text (font.subfamily); 79 style.text_changed.connect ((t) => { 80 font.subfamily = t; 81 font.touch (); 82 }); 83 widgets.add (style); 84 focus_ring.add (style); 85 86 bold = new CheckBox (t_("Bold"), label_size); 87 bold.updated.connect ((c) => { 88 font.bold = c; 89 font.touch (); 90 }); 91 bold.checked = font.bold; 92 widgets.add (bold); 93 focus_ring.add (bold); 94 95 italic = new CheckBox (t_("Italic"), label_size); 96 italic.updated.connect ((c) => { 97 font.italic = c; 98 font.touch (); 99 }); 100 italic.checked = font.italic; 101 italic.margin_bottom = margin; 102 widgets.add (italic); 103 focus_ring.add (italic); 104 105 widgets.add (new Text (t_("Weight"), label_size, label_margin)); 106 weight.margin_bottom = margin; 107 weight.set_text (font.get_weight ()); 108 weight.text_changed.connect ((t) => { 109 font.set_weight (t); 110 font.touch (); 111 }); 112 widgets.add (weight); 113 focus_ring.add (weight); 114 115 widgets.add (new Text (t_("Full Name (Name and Style)"), label_size, label_margin)); 116 full_name.margin_bottom = margin; 117 full_name.set_text (font.full_name); 118 full_name.text_changed.connect ((t) => { 119 font.full_name = t; 120 font.touch (); 121 MainWindow.get_toolbox ().update_all_expanders (); 122 }); 123 widgets.add (full_name); 124 focus_ring.add (full_name); 125 126 widgets.add (new Text (t_("Unique Identifier"), label_size, label_margin)); 127 unique_id.margin_bottom = margin; 128 unique_id.set_text (font.unique_identifier); 129 unique_id.text_changed.connect ((t) => { 130 font.unique_identifier = t; 131 font.touch (); 132 }); 133 widgets.add (unique_id); 134 focus_ring.add (unique_id); 135 136 widgets.add (new Text (t_("Version"), label_size, label_margin)); 137 version.margin_bottom = margin; 138 version.set_text (font.version); 139 version.text_changed.connect ((t) => { 140 font.version = t; 141 font.touch (); 142 }); 143 widgets.add (version); 144 focus_ring.add (version); 145 146 widgets.add (new Text (t_("Description"), label_size, label_margin)); 147 description.margin_bottom = margin; 148 description.set_text (font.description); 149 description.scroll.connect (scroll_event); 150 description.text_changed.connect ((t) => { 151 font.description = t; 152 font.touch (); 153 }); 154 widgets.add (description); 155 focus_ring.add (description); 156 157 widgets.add (new Text (t_("Copyright"), label_size, label_margin)); 158 copyright.margin_bottom = margin; 159 copyright.set_text (font.copyright); 160 copyright.scroll.connect (scroll_event); 161 copyright.text_changed.connect ((t) => { 162 font.copyright = t; 163 font.touch (); 164 }); 165 copyright.set_editable (!disable_copyright); 166 widgets.add (copyright); 167 focus_ring.add (copyright); 168 169 set_focus (postscript_name); 170 171 foreach (Widget w in widgets) { 172 if (w is Text) { 173 Theme.text_color ((Text) w, "Text Foreground"); 174 } 175 } 176 } 177 178 public static void set_copyright_editable (bool t) { 179 disable_copyright = !t; 180 } 181 182 public override string get_label () { 183 return t_("Name and Description"); 184 } 185 186 public override string get_name () { 187 return "Description"; 188 } 189 190 public override void selected_canvas () { 191 copyright.set_editable (!disable_copyright); 192 base.selected_canvas (); 193 } 194 } 195 196 } 197