Commit 2002aad
Add contextual ligatures to the bf font format
Changed files (6)
modifiedlibbirdfont/BirdFontFile.valamodifiedlibbirdfont/ExportTool.valamodifiedlibbirdfont/LigatureList.valamodifiedlibbirdfont/Ligatures.valamodifiedlibbirdfont/Renderer/TextArea.valamodifiedlibbirdfont/VersionList.vala
Diff
@@ -713,6 +713,10 @@ class BirdFontFile : GLib.Object { parse_ligature (t); } + if (t.get_name () == "contextual") {+ parse_contectual_ligature (t);+ }+ if (t.get_name () == "weight") { font.weight = int.parse (t.get_content ()); }@@ -1551,6 +1555,43 @@ class BirdFontFile : GLib.Object { warning (e.message); } });+ + foreach (ContextualLigature c in ligatures.contextual_ligatures) {+ os.put_string (@"<contextual "+ + @"ligature=\"$(c.ligatures)\" "+ + @"backtrack=\"$(c.backtrack)\" "+ + @"input=\"$(c.input)\" "+ + @"lookahead=\"$(c.lookahead)\" />\n");+ }+ }+ + public void parse_contectual_ligature (Tag t) {+ string ligature = "";+ string backtrack = "";+ string input = "";+ string lookahead = "";+ Ligatures ligatures;+ + foreach (Attribute a in t.get_attributes ()) {+ if (a.get_name () == "ligature") {+ ligature = a.get_content ();+ }++ if (a.get_name () == "backtrack") {+ backtrack = a.get_content ();+ }++ if (a.get_name () == "input") {+ input = a.get_content ();+ }+ + if (a.get_name () == "lookahead") {+ lookahead = a.get_content ();+ }+ }+ + ligatures = font.get_ligatures ();+ ligatures.add_contextual_ligature (ligature, backtrack, input, lookahead); } public void parse_ligature (Tag t) {@@ -12,6 +12,8 @@ Lesser General Public License for more details. */ +using Bird;+ namespace BirdFont { public class ExportTool : GLib.Object {@@ -35,7 +37,7 @@ public class ExportTool : GLib.Object { string name; StringBuilder s; - name = glyph.get_name (); // FIXME: xml encode+ name = XmlParser.encode (glyph.get_name ()); s = new StringBuilder (); s.append ("""<?xml version="1.0" encoding="utf-8"?>@@ -45,7 +45,6 @@ public class LigatureList : Table { Font font = BirdFont.get_current_font (); Ligatures ligatures = font.get_ligatures (); int i;- ContextualLigature cl; if (row.get_index () == NEW_LIGATURE && column == 0) { add_ligature (t_("character sequence"), t_("ligature"));@@ -55,19 +54,6 @@ public class LigatureList : Table { add_contextual_ligature (t_("substitution"), t_("beginning"), t_("middle"), t_("end")); TabContent.hide_text_input (); }- } else if (row.has_row_data ()) {- i = row.get_index ();- cl = (ContextualLigature) ((!) row.get_row_data ());- - /* // FIXME: DELETE- if (delete_button) {- cl.remove_ligature_at (i);- } else if (column == 0) {- cl.set_ligature (i);- } else if (column == 2) {- cl.set_substitution (i);- }- */ } else if (row.get_index () < ligatures.count ()) { if (ligatures.count () != 0) { if (delete_button) {@@ -89,19 +75,15 @@ public class LigatureList : Table { if (delete_button) { ligatures.remove_contextual_ligatures_at (i); TabContent.hide_text_input ();- }- - /* FIXME: DELETE- else if (column == 0) {- ligatures.set_beginning (i);+ } if (column == 0) {+ ligatures.set_contextual_ligature (i); } else if (column == 1) {- ligatures.set_middle (i);+ ligatures.set_beginning (i); } else if (column == 2) {- ligatures.set_end (i);+ ligatures.set_middle (i); } else if (column == 3) {- ligatures.add_substitution_at (i);- }- */+ ligatures.set_end (i);+ } } } @@ -19,8 +19,8 @@ namespace BirdFont { public class Ligatures : GLib.Object { - Gee.ArrayList<Ligature> ligatures = new Gee.ArrayList<Ligature> ();- Gee.ArrayList<ContextualLigature> contextual_ligatures = new Gee.ArrayList<ContextualLigature> ();+ public Gee.ArrayList<Ligature> ligatures = new Gee.ArrayList<Ligature> ();+ public Gee.ArrayList<ContextualLigature> contextual_ligatures = new Gee.ArrayList<ContextualLigature> (); public delegate void LigatureIterator (string substitution, string ligature); public delegate void SingleLigatureIterator (GlyphSequence substitution, GlyphCollection ligature);@@ -153,7 +153,7 @@ public class Ligatures : GLib.Object { MainWindow.get_ligature_display ().update_rows (); }); - TabContent.show_text_input (listener); + TabContent.show_text_input (listener); } public void set_ligature (int index) {@@ -164,7 +164,29 @@ public class Ligatures : GLib.Object { lig = ligatures.get (index); lig.set_ligature (); }- ++ public void set_contextual_ligature (int index) {+ ContextualLigature lig;+ TextListener listener;+ + return_if_fail (0 <= index < contextual_ligatures.size);++ lig = contextual_ligatures.get (index);+ listener = new TextListener (t_("Ligature"), lig.ligatures, t_("Set"));+ + listener.signal_text_input.connect ((text) => {+ lig.ligatures = text;+ });+ + listener.signal_submit.connect (() => {+ TabContent.hide_text_input ();+ MainWindow.get_ligature_display ().update_rows ();+ });+ + TabContent.show_text_input (listener); ++ }+ public void set_substitution (int index) { Ligature lig; @@ -711,7 +711,6 @@ public class TextArea : Widget { show_selection = false; } - // FIXME: corruption? public string get_text () { StringBuilder sb = new StringBuilder (); @@ -205,8 +205,6 @@ public class VersionList : DropMenu { updated_glyph.view_zoom = glyph.view_zoom; updated_glyph.view_offset_x = glyph.view_offset_x; updated_glyph.view_offset_y = glyph.view_offset_y;- // FIXME: don't run this in Renderer- // updated_glyph.close_path (); } }