Commit ac8edd0
Merge branch 'master' of github.com:johanmattssonm/birdfont
Changed files (11)
modifiedlibbirdfont/BirdFont.valamodifiedlibbirdfont/Font.valamodifiedlibbirdfont/Glyph.valamodifiedlibbirdfont/GlyphSequence.valamodifiedlibbirdfont/KerningTools.valamodifiedlibbirdfont/LigatureList.valamodifiedlibbirdfont/Path.valamodifiedlibbirdfont/PointConverter.valamodifiedlibbirdfont/SpacingTab.valamodifiedscripts/release.shmodifiedscripts/windows_build.py
Diff
@@ -214,7 +214,10 @@ public static int run_export (string[] arg) { main_window = new MainWindow (); // FIXME: create a option for this and add structure the log messages- // init_logfile ();+ + if (BirdFont.logging) {+ init_logfile ();+ } for (int i = 1; i < arg.length; i++) { @@ -307,6 +310,10 @@ public static int run_export (string[] arg) { return 0; } +public static void set_logging (bool log) {+ BirdFont.logging = log;+}+ public static string wine_to_unix_path (string exec_path) { bool drive_c, drive_z; int i;@@ -404,7 +411,10 @@ public class BirdFont { stdout.printf ("built on %s\n", BUILD_TIMESTAMP); android = args.has_argument ("--android");- BirdFont.logging = args.has_argument ("--log");+ + if (!BirdFont.logging) {+ BirdFont.logging = args.has_argument ("--log");+ } #endif if (BirdFont.logging) {@@ -692,7 +702,7 @@ internal static void log_warning (string? log_domain, LogLevelFlags log_levels, } /** Write debug output to logfile. */-void printd (string s) {+public static void printd (string s) { #if ANDROID __android_log_print (ANDROID_LOG_WARN, "BirdFont", s); #else@@ -847,6 +847,14 @@ public class Font : GLib.Object { p = (!) to_unichar (p).to_string (); } + if (p == "space") {+ p = " ";+ }++ if (p == "divis") {+ p = " ";+ }+ if (!has_glyph (p)) { warning (@"The character $p does not have a glyph in " + get_file_name ()); p = ".notdef";@@ -103,6 +103,9 @@ public class Glyph : FontDisplay { /** Cache for Cairo rendering */ HashMap<string, Surface> glyph_cache = new HashMap<string, Surface> (); + public const double CANVAS_MIN = -10000;+ public const double CANVAS_MAX = 10000;+ public Glyph (string name, unichar unichar_code = 0) { this.name = name; this.unichar_code = unichar_code;@@ -195,15 +198,16 @@ public class Glyph : FontDisplay { return false; } - x1 = double.MAX;- x2 = double.MIN;- y1 = double.MAX;- y2 = double.MIN;+ x1 = CANVAS_MAX;+ x2 = CANVAS_MIN;+ y1 = CANVAS_MAX;+ y2 = CANVAS_MIN; foreach (Path p in path_list) { p.update_region_boundaries ();- - if (p.points.size > 0) {++ if (p.points.size > 1) {+ if (p.xmin < x1) { x1 = p.xmin; }@@ -69,17 +69,18 @@ public class GlyphSequence : GLib.Object { if (has_range) { return ligature_sequence; }- + ligatures = font.get_ligatures ();- ligatures.get_single_substitution_ligatures ((substitute, ligature) => {- ligature_sequence.replace (substitute, ligature);- });- + foreach (ContextualLigature c in ligatures.contextual_ligatures) { ligature_sequence.replace_contextual (c.get_backtrack (), c.get_input (), c.get_lookahead (), c.get_ligature_sequence ()); } + ligatures.get_single_substitution_ligatures ((substitute, ligature) => {+ ligature_sequence.replace (substitute, ligature);+ });+ ligature_sequence.ranges.clear (); for (int i = 0; i < ligature_sequence.glyph.size; i++) { ligature_sequence.ranges.add (null);@@ -92,7 +93,7 @@ public class GlyphSequence : GLib.Object { int i = 0; while (i < glyph.size) { if (starts_with (old, i)) {- substitute (i, old.glyph.size, replacement);+ glyph = substitute (i, old.glyph.size, replacement); i += replacement.length (); } else { i++;@@ -100,17 +101,28 @@ public class GlyphSequence : GLib.Object { } } - void replace_contextual (GlyphSequence backtrack, GlyphSequence input, GlyphSequence lookahead, GlyphSequence replacement) {+ void replace_contextual (GlyphSequence backtrack, GlyphSequence input, GlyphSequence lookahead, + GlyphSequence replacement) {+ bool start, middle, end; int i = 0;+ int advance = 0;+ while (i < glyph.size) { start = starts_with (backtrack, i); middle = starts_with (input, i + backtrack.length ()); end = starts_with (lookahead, i + backtrack.length () + input.length ()); if (start && middle && end) {- substitute (i + backtrack.length (), input.length (), replacement);- i += i + backtrack.length () + input.length ();+ glyph = substitute (i + backtrack.length (), input.length (), replacement);+ + advance = backtrack.length () + replacement.length ();+ i += advance;+ + if (advance <= 0) {+ warning ("No advancement.");+ return;+ } } else { i++; }@@ -137,7 +149,7 @@ public class GlyphSequence : GLib.Object { return true; } - void substitute (uint index, uint length, GlyphSequence substitute) {+ Gee.ArrayList<Glyph?> substitute (uint index, uint length, GlyphSequence substitute) { Gee.ArrayList<Glyph?> new_list = new Gee.ArrayList<Glyph?> (); int i = 0; @@ -155,7 +167,7 @@ public class GlyphSequence : GLib.Object { i++; } - glyph = new_list; + return new_list; } } @@ -257,6 +257,7 @@ public class KerningTools : ToolCollection { public override Gee.ArrayList<string> get_displays () { Gee.ArrayList<string> d = new Gee.ArrayList<string> (); d.add ("Kerning");+ d.add ("Spacing"); return d; } }@@ -53,10 +53,8 @@ public class LigatureList : Table { add_ligature (t_("character sequence"), t_("ligature")); TabContent.hide_text_input (); } else if (row.get_index () == NEW_LIGATURE && column == 1) {- if (BirdFont.has_argument ("--test")) {- add_contextual_ligature (t_("substitution"), t_("beginning"), t_("middle"), t_("end"));- TabContent.hide_text_input ();- }+ add_contextual_ligature (t_("substitution"), t_("beginning"), t_("middle"), t_("end"));+ TabContent.hide_text_input (); } else if (row.get_index () < ncontextual) { i = row.get_index (); if (i < ligatures.count_contextual_ligatures ()) {@@ -1968,10 +1968,10 @@ public class Path { return; } - minx = double.MAX;- miny = double.MAX;- maxx = double.MIN;- maxy = double.MIN;+ minx = Glyph.CANVAS_MAX;+ miny = Glyph.CANVAS_MAX;+ maxx = Glyph.CANVAS_MIN;+ maxy = Glyph.CANVAS_MIN; x0 = 0; y0 = 0; @@ -145,8 +145,8 @@ public class PointConverter { return; } - max_d = double.MIN;- min_d = double.MAX;+ max_d = Glyph.CANVAS_MIN;+ min_d = Glyph.CANVAS_MAX; Path.all_of (a0, a1, (xa, ya, ta) => { min_d = double.MAX;@@ -119,6 +119,11 @@ public class SpacingTab : KerningDisplay { cap.draw_at_baseline (cr, cap.widget_x, cap.widget_y); l = g.get_left_side_bearing ();+ + if (Math.fabs (l) < 0.001) {+ l = 0;+ }+ left = new Text (truncate (l, 5), 17); Theme.text_color (left, "Foreground 3"); left.widget_x = middle - box_size / 2.0 + (box_size / 2.0 - left.get_extent ()) / 2.0;@@ -126,6 +131,11 @@ public class SpacingTab : KerningDisplay { left.draw_at_baseline (cr, left.widget_x, left.widget_y); r = g.get_right_side_bearing ();++ if (Math.fabs (r) < 0.001) {+ r = 0;+ }+ right = new Text (truncate (r, 5), 17); Theme.text_color (right, "Foreground 3"); right.widget_x = end - (box_size / 2.0 - right.get_extent ()) / 2.0 - right.get_extent ();@@ -200,13 +210,20 @@ public class SpacingTab : KerningDisplay { void update_lsb (Glyph? g) { TextListener listener; string submitted_value = "";-+ double l;+ if (g == null) { return; } + l = text_input_glyph.get_left_side_bearing ();++ if (Math.fabs (l) < 0.001) {+ l = 0;+ }+ text_input_glyph = (!) g;- listener = new TextListener (t_("Left"), @"$(text_input_glyph.get_left_side_bearing ())", t_("Set"));+ listener = new TextListener (t_("Left"), @"$(l)", t_("Set")); listener.signal_text_input.connect ((text) => { submitted_value = text;@@ -237,13 +254,20 @@ public class SpacingTab : KerningDisplay { void update_rsb (Glyph? g) { TextListener listener; string submitted_value = "";-+ double r;+ if (g == null) { return; } + r = text_input_glyph.get_right_side_bearing ();++ if (Math.fabs (r) < 0.001) {+ r = 0;+ }+ text_input_glyph = (!) g;- listener = new TextListener (t_("Right"), @"$(text_input_glyph.get_right_side_bearing ())", t_("Set"));+ listener = new TextListener (t_("Right"), @"$(r)", t_("Set")); listener.signal_text_input.connect ((text) => { submitted_value = text;@@ -34,16 +34,16 @@ rm -rf birdfont-$version/.gitignore tar -cf birdfont-$version.tar birdfont-$version -gzip birdfont-$version.tar+xz -z birdfont-$version.tar -rm -rf ../birdfont-$version.tar.gz+rm -rf ../birdfont-$version.tar.xz -mv birdfont-$version.tar.gz ../+mv birdfont-$version.tar.xz ../ # build it to make sure that everything was checked in cd birdfont-$version && \ ./configure && \ ./scripts/linux_build.py && \-gpg --output ../../birdfont-$version.tar.gz.sig --detach-sig ../../birdfont-$version.tar.gz && \+gpg --output ../../birdfont-$version.tar.xz.sig --detach-sig ../../birdfont-$version.tar.xz && \ cd .. && \ rm -rf ../export/birdfont-$version@@ -16,7 +16,7 @@ prefix = "" valac = "valac" valaflags = "" cc = "gcc"-cflags = "-g ./build/icon.res -Wl,-subsystem,windows "+cflags = "-g -Wl,-subsystem,windows " ldflags = "" library_ldflags= ""; @@ -30,7 +30,6 @@ from translations import compile_translations from run import run compile_translations()-run("windres ./resources/win32/icon.rc -O coff -o ./build/icon.res") build.libbirdxml(prefix, cc, cflags, library_ldflags, valac, valaflags, "libbirdxml.dll") build.libbirdfont(prefix, cc, cflags, library_ldflags, valac, valaflags, "libbirdfont.dll")