The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Merge ../birdfont-2.x

These changes was commited to the Birdfont repository Tue, 20 Sep 2016 12:06:59 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
[Tue, 20 Sep 2016 12:06:59 +0000]

Updated Files

birdfont/GtkWindow.vala
install.py
libbirdfont/GlyphRange.vala
libbirdfont/KerningDisplay.vala
libbirdfont/KerningRange.vala
libbirdfont/KerningTools.vala
libbirdfont/LabelTool.vala
libbirdfont/OpenFontFormat/GlyfTable.vala
libbirdfont/OpenFontFormat/HmtxTable.vala
libbirdfont/OtfFeatureTable.vala
libbirdfont/OverView.vala
libbirdfont/Svg.vala
scripts/snap.py
scripts/snap.sh
scripts/snapcraft.yaml
scripts/version.py
--- a/birdfont/GtkWindow.vala +++ b/birdfont/GtkWindow.vala @@ -161,9 +161,14 @@ }); scrollbar.set_visible (false); - + show_all (); + MainWindow.open_recent_files_tab (); + + #if FREE + MainWindow.show_license_dialog (); + #endif } public void window_focus (void* data) {
--- a/install.py +++ b/install.py @@ -1,6 +1,5 @@ #!/usr/bin/python3 - """ - Copyright (C) 2013 2014 2015 Johan Mattsson + """ Copyright (C) 2013 2014 2015 Johan Mattsson This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
--- a/libbirdfont/GlyphRange.vala +++ b/libbirdfont/GlyphRange.vala @@ -182,7 +182,11 @@ } if (w.char_count () == 1) { - add_single (w.get_char ()); + unichar c = w.get_char_validated (); + + if (c > 0) { + add_single (c); + } } else if (w == "space") { add_single (' '); } else if (w == "divis") {
--- a/libbirdfont/KerningDisplay.vala +++ b/libbirdfont/KerningDisplay.vala @@ -45,6 +45,10 @@ public bool adjust_side_bearings = false; public bool right_side_bearing = true; + + public bool right_to_left = false; + + WidgetAllocation allocation = new WidgetAllocation (); TextArea description; @@ -136,6 +140,8 @@ Font font = BirdFont.get_current_font (); double item_size = 1.0 / KerningTools.font_size; double item_size2 = 2.0 / KerningTools.font_size; + + this.allocation = allocation; i = 0; @@ -160,6 +166,10 @@ prev = null; kern = 0; + if (right_to_left) { + x = (allocation.width - 20) / KerningTools.font_size; + } + foreach (GlyphSequence word in get_all_rows ()) { wi = 0; word_with_ligatures = word.process_ligatures (font); @@ -192,7 +202,13 @@ cr.save (); glyph.add_help_lines (); - cr.translate (kern + x - glyph.get_lsb () - Glyph.xc (), glyph.get_baseline () + y - Glyph.yc ()); + + if (right_to_left) { + cr.translate (x - kern - glyph.get_lsb () - glyph.get_width () - Glyph.xc (), glyph.get_baseline () + y - Glyph.yc ()); + } else { + cr.translate (kern + x - glyph.get_lsb () - Glyph.xc (), glyph.get_baseline () + y - Glyph.yc ()); + } + glyph.draw_layers (cr); cr.restore (); @@ -201,7 +217,11 @@ // handle if (first_row && (active_handle == i || selected_handle == i)) { - x2 = x + kern / 2.0; + if (right_to_left) { + x2 = x - kern / 2.0; + } else { + x2 = x + kern / 2.0; + } cr.save (); @@ -251,7 +271,11 @@ cr.restore (); } - x += w + kern; + if (right_to_left) { + x -= w + kern; + } else { + x += w + kern; + } // caption if (g == null || ((!)g).is_empty ()) { @@ -285,7 +309,13 @@ } y += row_height + 20; - x = 20; + + if (right_to_left) { + x = (allocation.width - 20) / KerningTools.font_size; + } else { + x = 20; + } + first_row = false; if (y > allocation.height) { @@ -776,6 +806,11 @@ k = (ex - last_handle_x) / y; // y-axis is for variable precision k /= KerningTools.font_size; + + if (right_to_left) { + k *= -1; + } + set_space (selected_handle, k); GlyphCanvas.redraw (); } @@ -793,7 +828,11 @@ Glyph glyph = new Glyph.no_lines (""); double fs = KerningTools.font_size; double x = 20; - + + if (right_to_left) { + x = (allocation.width - 20) / KerningTools.font_size; + } + GlyphRange? gr_left, gr_right; Glyph? prev = null; @@ -829,8 +868,12 @@ kern = get_kerning_for_pair (((!)prev).get_name (), ((!)g).get_name (), gr_left, gr_right); } - - d = Math.pow (fs * (x + kern) - ex, 2); + + if (right_to_left) { + d = Math.pow (fs * (x - kern) - ex, 2); + } else { + d = Math.pow (fs * (x + kern) - ex, 2); + } if (d < min) { min = d; @@ -852,7 +895,13 @@ } prev = g; - x += w + kern; + + if (right_to_left) { + x -= w + kern; + } else { + x += w + kern; + } + i++; col_index++; }
--- a/libbirdfont/KerningRange.vala +++ b/libbirdfont/KerningRange.vala @@ -113,7 +113,8 @@ TextListener listener = new TextListener (t_("Kerning class"), ranges, t_("Set")); listener.signal_text_input.connect ((text) => { set_ranges (text); - Toolbox.redraw_tool_box (); + KerningTools.classes.clear_cache (); + KerningTools.classes.redraw (); }); listener.signal_submit.connect (() => {
--- a/libbirdfont/KerningTools.vala +++ b/libbirdfont/KerningTools.vala @@ -54,7 +54,12 @@ active_otf_features = new OtfTags (); Expander kerning_tools = new Expander (t_("Kerning Tools")); - classes = new Expander (); + + if (is_null (classes)) { + classes = new Expander (); + update_kerning_classes (); + } + expanders = new Gee.ArrayList<Expander> (); Expander font_name = new Expander (); @@ -86,6 +91,7 @@ KerningRange kr = new KerningRange (f, @"$label $(++next_class)"); classes.add_tool (kr); self.set_selected (false); + classes.clear_cache (); classes.redraw (); }); kerning_tools.add_tool (new_kerning_class); @@ -121,6 +127,15 @@ }); kerning_tools.add_tool (insert_unicode); + Tool right_to_left = new Tool ("right_to_left", t_("Right to left")); + right_to_left.select_action.connect ((self) => { + KerningDisplay d = MainWindow.get_kerning_display (); + d.right_to_left = !d.right_to_left; + right_to_left.set_selected (d.right_to_left); + GlyphCanvas.redraw (); + }); + kerning_tools.add_tool (right_to_left); + string empty_kerning_text = t_("Open a text file with kerning strings first."); previous_kerning_string = new Tool ("previous_kerning_string", t_("Previous kerning string")); @@ -176,8 +191,8 @@ expanders.add (font_name); expanders.add (zoom_expander); expanders.add (kerning_tools); + expanders.add (otf_features); expanders.add (classes); - expanders.add (otf_features); } public static void add_otf_label (string tag) { @@ -266,6 +281,9 @@ add_unique_class (kr); } } + + classes.clear_cache (); + classes.redraw (); } private static void remove_all_kerning_classes () {
--- a/libbirdfont/LabelTool.vala +++ b/libbirdfont/LabelTool.vala @@ -92,29 +92,31 @@ if (is_selected ()) { if (selected_cache == null) { - selected_cache = Screen.create_background_surface ((int) w, (int) h + 2); + selected_cache = Screen.create_background_surface ((int) (w * Screen.get_scale ()), (int) ((h + 2) * Screen.get_scale ())); Context c = new Context ((!) selected_cache); - c.scale (1 / Screen.get_scale (), 1 / Screen.get_scale ()); + c.scale (Screen.get_scale (), Screen.get_scale ()); draw_tool_surface (c, x, 2, true); } cr.save (); + cr.scale (1 / Screen.get_scale (), 1 / Screen.get_scale ()); cr.set_antialias (Cairo.Antialias.NONE); - cr.set_source_surface ((!) selected_cache, 0, (int) y - 2); + cr.set_source_surface ((!) selected_cache, 0, (int) ((y - 2) * Screen.get_scale ())); cr.paint (); cr.restore (); } else { if (deselected_cache == null) { - deselected_cache = Screen.create_background_surface ((int) w, (int) h + 2); + deselected_cache = Screen.create_background_surface ((int) (w * Screen.get_scale ()), (int) ((h + 2) * Screen.get_scale ())); Context c = new Context ((!) deselected_cache); - c.scale (1 / Screen.get_scale (), 1 / Screen.get_scale ()); + c.scale (Screen.get_scale (), Screen.get_scale ()); draw_tool_surface (c, x, 2, false); } cr.save (); + cr.scale (1 / Screen.get_scale (), 1 / Screen.get_scale ()); cr.set_antialias (Cairo.Antialias.NONE); - cr.set_source_surface ((!) deselected_cache, 0, (int) y - 2); + cr.set_source_surface ((!) deselected_cache, 0, (int) ((y - 2) * Screen.get_scale ())); cr.paint (); cr.restore (); }
--- a/libbirdfont/OpenFontFormat/GlyfTable.vala +++ b/libbirdfont/OpenFontFormat/GlyfTable.vala @@ -307,18 +307,22 @@ // save bounding box for head table if (glyf_data.bounding_box_xmin < this.xmin) { + printd (@"YMin in $(g.get_name ())\n"); this.xmin = glyf_data.bounding_box_xmin; } if (glyf_data.bounding_box_ymin < this.ymin) { + printd (@"YMin in $(g.get_name ())\n"); this.ymin = glyf_data.bounding_box_ymin; } if (glyf_data.bounding_box_xmax > this.xmax) { + printd (@"XMax in $(g.get_name ())\n"); this.xmax = glyf_data.bounding_box_xmax; } if (glyf_data.bounding_box_ymax > this.ymax) { + printd (@"YMax in $(g.get_name ())\n"); this.ymax = glyf_data.bounding_box_ymax; }
--- a/libbirdfont/OpenFontFormat/HmtxTable.vala +++ b/libbirdfont/OpenFontFormat/HmtxTable.vala @@ -161,7 +161,7 @@ } if (extent < 0) { - warning ("Negative extent."); + warning (@"Negative extent in $(gc.get_name ())."); } advance_width[nmetrics] = (uint16) extent;
--- a/libbirdfont/OtfFeatureTable.vala +++ b/libbirdfont/OtfFeatureTable.vala @@ -33,10 +33,25 @@ Gee.ArrayList<AlternateItem> undo_items; // FIXME: implement redo + + bool ignore_input = false; public OtfFeatureTable (GlyphCollection? gc) { glyph_collection = gc; undo_items = new Gee.ArrayList<AlternateItem> (); + } + + public override void selected_canvas () { + ignore_input = true; // make sure that tripple clicks in overview are ignored + + TimeoutSource input_delay = new TimeoutSource (250); + input_delay.set_callback(() => { + ignore_input = false; + return false; + }); + input_delay.attach (null); + + base.selected_canvas (); } public override Gee.ArrayList<Row> get_rows () { @@ -48,6 +63,10 @@ GLib.Object o; String s; AlternateItem a; + + if (ignore_input) { + return; + } if (row_index == SOURCE_GLYPH) { GlyphSelection gs = new GlyphSelection ();
--- a/libbirdfont/OverView.vala +++ b/libbirdfont/OverView.vala @@ -1112,6 +1112,7 @@ f.alternates = previous_collection.alternate_sets.copy (); undo_items.remove_at (undo_items.size - 1); + update_item_list (); GlyphCanvas.redraw (); }
--- a/libbirdfont/Svg.vala +++ b/libbirdfont/Svg.vala @@ -153,8 +153,8 @@ EditPoint middle; double x, y; - x = start.get_right_handle ().x + (end.get_left_handle ().x - start.get_right_handle ().x); - y = start.get_right_handle ().y + (end.get_left_handle ().y - start.get_right_handle ().y); + x = start.get_right_handle ().x + (end.get_left_handle ().x - start.get_right_handle ().x) / 2; + y = start.get_right_handle ().y + (end.get_left_handle ().y - start.get_right_handle ().y) / 2; middle = new EditPoint (x, y, PointType.QUADRATIC); middle.right_handle = end.get_left_handle ().copy ();
diff --git scripts/snap.py(new)
--- /dev/null +++ b/scripts/snap.py @@ -1,1 +1,38 @@ + #!/usr/bin/python3 + import version + from optparse import OptionParser + + parser = OptionParser() + parser.add_option('-f', '--free', dest='free', action="store_true", help="generate non-commercial version") + (options, args) = parser.parse_args() + + template = open('./scripts/snapcraft.yaml', 'r') + yaml = template.read(); + + if options.free: + v = version.VERSION + "-free" + else: + v = version.VERSION + + yaml = yaml.replace("VERSION", v) + + make_script = open('./build/snapsource/birdfont/Makefile', 'w+') + make_script.write("#Don't edit, the file is generated by a script\n") + make_script.write("all:\n") + + if options.free: + make_script.write ("\t./configure --valac-flags=\"-D FREE\"\n") + else: + make_script.write ("\t./configure\n") + + make_script.write("\t./build.py\n") + make_script.write(""" + + install: + ./install.py -d $(DESTDIR) + """) + + build_script = open('./build/snapcraft.yaml', 'w+') + build_script.write(yaml) +
diff --git scripts/snap.sh(new)
--- /dev/null +++ b/scripts/snap.sh @@ -1,1 +1,28 @@ + #!/bin/sh + + if ! git diff --exit-code > /dev/null; then + echo "Uncommitted changes, commit before creating the release." + exit 1 + fi + + SOURCE_DIR="$(pwd)" + + rm -rf $SOURCE_DIR/build/snapsource + mkdir -p $SOURCE_DIR/build/snapsource && \ + cd $SOURCE_DIR/build/snapsource && \ + git clone --depth=1 file:///$SOURCE_DIR birdfont && \ + cd $SOURCE_DIR/build/snapsource/birdfont && \ + python3 ./scripts/complete_translations.py -t 93 -i && \ + cd .. && \ + cd .. && \ + mkdir -p setup/gui && \ + cp ../resources/linux/256x256/birdfont.png setup/gui/icon.png && \ + cd .. && \ + ./scripts/snap.py --free && \ + cd build && \ + snapcraft snap && \ + cd .. && \ + ./scripts/snap.py && \ + cd build && \ + snapcraft snap
diff --git scripts/snapcraft.yaml(new)
--- /dev/null +++ b/scripts/snapcraft.yaml @@ -1,1 +1,27 @@ + name: birdfont + version: VERSION + summary: Font editor + description: A font edior which can create TTF, EOT and SVG fonts + confinement: strict + + build-packages: [valac, python3, libglib2.0-dev, libgtk-3-dev, + libwebkit2gtk-3.0-dev, libgee-0.8-dev, libnotify-dev, libsqlite3-dev, + libxmlbird-dev, python-pkg-resources] + + apps: + run: + command: birdfont + plugs: [home, gsettings, x11, unity7] + + parts: + birdfont: + plugin: make + source: snapsource/birdfont + stage-packages: + - libglib2.0-0 + - libwebkit2gtk-3.0-25 + - libgee-0.8-2 + - libnotify4 + - libsqlite3-0 + - libxmlbird1
--- a/scripts/version.py +++ b/scripts/version.py @@ -13,7 +13,7 @@ Lesser General Public License for more details. """ - VERSION = '2.16.5' + VERSION = '2.16.7' SO_VERSION_MAJOR = '36' SO_VERSION_MINOR = '0' SO_VERSION = SO_VERSION_MAJOR + '.' + SO_VERSION_MINOR