The Birdfont Source Code


All Repositories / birdfont.git / blob – RSS feed

Ligature.vala in libbirdfont/OpenFontFormat

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/OpenFontFormat/Ligature.vala.
Fix ligature substitutions with space
1 /* 2 Copyright (C) 2014 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 namespace BirdFont { 16 17 public class Ligature : GLib.Object { 18 public string ligature = ""; 19 public string substitution = ""; 20 21 public Ligature (string ligature, string substitution = "") { 22 this.ligature = ligature; 23 this.substitution = substitution; 24 } 25 26 public unichar get_first_char () { 27 return substitution.get (0); 28 } 29 30 public void set_ligature () { 31 TextListener listener; 32 33 listener = new TextListener (t_("Ligature"), ligature, t_("Set")); 34 35 listener.signal_text_input.connect ((text) => { 36 ligature = text; 37 }); 38 39 listener.signal_submit.connect (() => { 40 TabContent.hide_text_input (); 41 MainWindow.get_ligature_display ().update_rows (); 42 }); 43 44 TabContent.show_text_input (listener); 45 } 46 47 public void set_substitution () { 48 TextListener listener; 49 50 listener = new TextListener (t_("Text"), substitution, t_("Set")); 51 52 listener.signal_text_input.connect ((text) => { 53 Font f = BirdFont.get_current_font (); 54 Ligatures l = f.get_ligatures (); 55 substitution = text; 56 l.sort_ligatures (); 57 }); 58 59 listener.signal_submit.connect (() => { 60 TabContent.hide_text_input (); 61 MainWindow.get_ligature_display ().update_rows (); 62 }); 63 64 TabContent.show_text_input (listener); 65 } 66 } 67 68 } 69