The Birdfont Source Code


All Repositories / birdfont.git / blob – RSS feed

ExportSettings.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/ExportSettings.vala.
Generate mac specific truetype fonts
1 /* 2 Copyright (C) 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 ExportSettings : TableLayout { 21 TextArea file_name; 22 TextArea file_name_mac; 23 CheckBox ttf; 24 CheckBox eot; 25 CheckBox svg; 26 Button export_action; 27 Button name_tab; 28 29 public ExportSettings () { 30 Headline headline; 31 Font font; 32 double margin = 12 * MainWindow.units; 33 double label_size = 20 * MainWindow.units; 34 double label_margin = 4 * MainWindow.units; 35 string fn, folder; 36 37 font = BirdFont.get_current_font (); 38 font.settings.set_setting ("has_export_settings", "true"); 39 40 headline = new Headline (t_("Export Settings")); 41 headline.margin_bottom = 20 * MainWindow.units; 42 widgets.add (headline); 43 44 widgets.add (new Text (t_("File Name"), label_size, label_margin)); 45 46 file_name = new LineTextArea (label_size); 47 file_name.margin_bottom = margin; 48 49 fn = get_file_name (font); 50 file_name.set_text (fn); 51 file_name.text_changed.connect ((t) => { 52 Font f = BirdFont.get_current_font (); 53 f.settings.set_setting ("file_name", t); 54 }); 55 56 widgets.add (file_name); 57 focus_ring.add (file_name); 58 59 widgets.add (new Text (t_("File Name") + " Mac", label_size, label_margin)); 60 61 file_name_mac = new LineTextArea (label_size); 62 file_name_mac.margin_bottom = margin; 63 64 fn = get_file_name_mac (font); 65 file_name_mac.set_text (fn); 66 file_name_mac.text_changed.connect ((t) => { 67 Font f = BirdFont.get_current_font (); 68 f.settings.set_setting ("file_name_mac", t); 69 }); 70 71 widgets.add (file_name_mac); 72 focus_ring.add (file_name_mac); 73 74 folder = (!) font.get_folder ().get_path (); 75 Text folder_row = new Text (t_("Folder") + ": " + folder, label_size, label_margin); 76 folder_row.margin_bottom = 20 * MainWindow.units; 77 widgets.add (folder_row); 78 79 widgets.add (new Text (t_("Formats"), label_size, label_margin)); 80 81 ttf = new CheckBox ("TTF", label_size); 82 ttf.updated.connect ((c) => { 83 Font f = BirdFont.get_current_font (); 84 string v = c ? "true" : "false"; 85 f.settings.set_setting ("export_ttf", v); 86 }); 87 ttf.checked = export_ttf_setting (font); 88 widgets.add (ttf); 89 focus_ring.add (ttf); 90 91 eot = new CheckBox ("EOT", label_size); 92 eot.updated.connect ((c) => { 93 Font f = BirdFont.get_current_font (); 94 string v = c ? "true" : "false"; 95 f.settings.set_setting ("export_eot", v); 96 }); 97 eot.checked = export_eot_setting (font); 98 widgets.add (eot); 99 focus_ring.add (eot); 100 101 svg = new CheckBox ("SVG", label_size); 102 svg.updated.connect ((c) => { 103 Font f = BirdFont.get_current_font (); 104 string v = c ? "true" : "false"; 105 f.settings.set_setting ("export_eot", v); 106 }); 107 svg.checked = export_svg_setting (font); 108 svg.margin_bottom = margin; 109 widgets.add (svg); 110 focus_ring.add (svg); 111 112 svg.margin_bottom = 20 * MainWindow.units; 113 114 name_tab = new Button (t_("Name and Description"), margin); 115 name_tab.action.connect ((c) => { 116 MenuTab.show_description (); 117 }); 118 widgets.add (name_tab); 119 120 export_action = new Button (t_("Export"), margin); 121 export_action.action.connect ((c) => { 122 MenuTab.export_fonts_in_background (); 123 }); 124 widgets.add (export_action); 125 126 set_focus (file_name); 127 } 128 129 public static string get_file_name (Font font) { 130 string n = font.settings.get_setting ("file_name"); 131 132 if (n == "") { 133 n = font.full_name; 134 } 135 136 return n; 137 } 138 139 public static string get_file_name_mac (Font font) { 140 string n = font.settings.get_setting ("file_name_mac"); 141 142 if (n == "") { 143 n = font.full_name + " Mac"; 144 } 145 146 return n; 147 } 148 149 public static bool export_ttf_setting (Font f) { 150 return f.settings.get_setting ("export_ttf") != "false"; 151 } 152 153 public static bool export_eot_setting (Font f) { 154 return f.settings.get_setting ("export_eot") != "false"; 155 } 156 157 public static bool export_svg_setting (Font f) { 158 return f.settings.get_setting ("export_svg") != "false"; 159 } 160 161 public static bool has_export_settings (Font f) { 162 return f.settings.get_setting ("has_export_settings") == "true"; 163 } 164 165 public override string get_label () { 166 return t_("Export Settings"); 167 } 168 169 public override string get_name () { 170 return "Export Settings"; 171 } 172 } 173 174 } 175