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