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.
Merge branch 'master' of https://github.com/johanmattssonm/birdfont into HEAD
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 (ContextualLigature? clig = null) { 48 TextListener listener; 49 ContextualLigature? cl = clig; 50 51 listener = new TextListener (t_("Text"), substitution, t_("Set")); 52 53 listener.signal_text_input.connect ((text) => { 54 Font f = BirdFont.get_current_font (); 55 Ligatures l = f.get_ligatures (); 56 substitution = text; 57 l.sort_ligatures (); 58 59 if (cl != null) { 60 ((!) cl).sort (); 61 } 62 }); 63 64 listener.signal_submit.connect (() => { 65 TabContent.hide_text_input (); 66 MainWindow.get_ligature_display ().update_rows (); 67 }); 68 69 TabContent.show_text_input (listener); 70 } 71 } 72 73 } 74