Commit dc71aca
Fix canvas size on SVG image export and other bug fixes.
Changed files (11)
modifieddodo.pymodifiedlibbirdfont/BackgroundImage.valamodifiedlibbirdfont/BirdFont.valamodifiedlibbirdfont/DrawingTools.valamodifiedlibbirdfont/ExportTool.valamodifiedlibbirdfont/KerningTools.valamodifiedlibbirdfont/OpenFontFormat/OpenFontFormatReader.valamodifiedlibbirdfont/SearchPaths.valamodifiedlibbirdfont/SpacingClassTab.valamodifiedlibbirdfont/Svg.valamodifiedscripts/update_translations.py
Diff
@@ -32,6 +32,7 @@ DOIT_CONFIG = { 'build', 'libbirdfont', 'birdfont',+ 'birdfont_autotrace', 'birdfont_export', 'birdfont_import', 'compile_translations',@@ -96,6 +97,12 @@ def task_birdfont(): yield bird.gen_bin(["""-D 'GETTEXT_PACKAGE="birdfont"' """]) +def task_birdfont_autotrace():+ exp = Vala(src='birdfont-autotrace', build='build', pkg_libs=LIBS, vala_deps=[libbird])+ yield exp.gen_c(valac_options)+ yield exp.gen_bin(["""-D 'GETTEXT_PACKAGE="birdfont"' """])++ def task_birdfont_export(): exp = Vala(src='birdfont-export', build='build', pkg_libs=LIBS, vala_deps=[libbird]) yield exp.gen_c(valac_options)@@ -762,7 +762,7 @@ public class BackgroundImage { return (ImageSurface) ns; } - public PathList auto_trace () {+ public PathList autotrace () { ImageSurface img; int len, w, h, i, s; Path p;@@ -775,6 +775,8 @@ public class BackgroundImage { p = new Path (); pl = new PathList (); + get_img ();+ if (background_image == null) { return pl; }@@ -1158,10 +1160,8 @@ public class BackgroundImage { TracedPoint average_point; int pi; - return_val_if_fail (background_image != null && contrast_image != null, new Path ());- - image_scale_x = ((double) size_margin / ((!) contrast_image).get_width ());- image_scale_y = ((double) size_margin / ((!) contrast_image).get_height ());+ image_scale_x = ((double) size_margin / get_img ().get_width ());+ image_scale_y = ((double) size_margin / get_img ().get_height ()); foreach (TracedPoint p in points) { start_points.add (p);@@ -476,8 +476,8 @@ public class BirdFont { bundle_path = path; } - static void init_gettext () {- // FIXME: android this should be OK now+ public static void init_gettext () {+ // FIXME: android, this should be OK now #if !ANDROID string locale_directory = SearchPaths.get_locale_directory (); Intl.setlocale (LocaleCategory.MESSAGES, "");@@ -507,13 +507,16 @@ public class BirdFont { } #endif - internal static Font new_font () {+ public static Font new_font () { current_font = new Font (); - MainWindow.get_drawing_tools ().remove_all_grid_buttons ();- MainWindow.get_drawing_tools ().add_new_grid ();- MainWindow.get_drawing_tools ().add_new_grid (); - SpacingClassTab.remove_all_spaving_classes ();+ if (!is_null (MainWindow.tools)) {+ MainWindow.get_drawing_tools ().remove_all_grid_buttons ();+ MainWindow.get_drawing_tools ().add_new_grid ();+ MainWindow.get_drawing_tools ().add_new_grid ();+ }+ + SpacingClassTab.remove_all_spacing_classes (); KerningTools.update_kerning_classes (); return current_font;@@ -1219,7 +1219,7 @@ public class DrawingTools : ToolCollection { if (bg != null) { b = (!) bg;- pl = b.auto_trace ();+ pl = b.autotrace (); foreach (Path p in pl.paths) { g.add_path (p); }@@ -35,7 +35,7 @@ public class ExportTool : GLib.Object { string name; StringBuilder s; - name = glyph.get_name ();+ name = glyph.get_name (); // FIXME: xml encode s = new StringBuilder (); s.append ("""<?xml version="1.0" encoding="utf-8"?>@@ -18,7 +18,7 @@ using Math; namespace BirdFont { public class KerningTools : ToolCollection {- public static Gee.ArrayList<Expander> expanders = new Gee.ArrayList<Expander> ();+ public static Gee.ArrayList<Expander> expanders; public static int next_class = 0; public static Expander classes; public static bool adjust_side_bearings = false;@@ -32,6 +32,7 @@ public class KerningTools : ToolCollection { public static void init () { Expander kerning_tools = new Expander (); classes = new Expander ();+ expanders = new Gee.ArrayList<Expander> (); Tool new_kerning_class = new Tool ("kerning_class", t_("Create new kerning class.")); new_kerning_class.select_action.connect ((self) => {@@ -179,6 +180,10 @@ public class KerningTools : ToolCollection { } private static void remove_all_kerning_classes () {+ if (is_null (classes)) { // FIXME: export without tools+ init ();+ }+ classes.tool.clear (); if (!is_null (MainWindow.get_toolbox ())) {@@ -184,15 +184,17 @@ public class OpenFontFormatReader : Object { if (left <= 0x1F || right <= 0x1F) { warning ("Ignoring kerning of control character."); } else {- bf_kerning.append ("<kerning left=\"");- bf_kerning.append (BirdFontFile.serialize_unichar (left));- bf_kerning.append ("\" ");- bf_kerning.append ("right=\"");- bf_kerning.append (BirdFontFile.serialize_unichar (right));- bf_kerning.append ("\" ");- bf_kerning.append ("hadjustment=\"");- bf_kerning.append (@"$kerning".replace (",", "."));- bf_kerning.append ("\" />\n");+ if (@"$kerning" != "0") {+ bf_kerning.append ("<kerning left=\"");+ bf_kerning.append (BirdFontFile.serialize_unichar (left));+ bf_kerning.append ("\" ");+ bf_kerning.append ("right=\"");+ bf_kerning.append (BirdFontFile.serialize_unichar (right));+ bf_kerning.append ("\" ");+ bf_kerning.append ("hadjustment=\"");+ bf_kerning.append (@"$kerning".replace (",", "."));+ bf_kerning.append ("\" />\n");+ } } } } catch (GLib.Error e) {@@ -25,9 +25,6 @@ public class SearchPaths { string resources; resources = (is_null (resources_folder)) ? "" : resources_folder; - - printd ("Looking for: ");- printd (resources + "/" + d + "/" + name); f = get_file (resources + "/" + d + "/", name); if (likely (f.query_exists ())) return f;@@ -93,9 +90,11 @@ public class SearchPaths { return resources + "\\locale"; } - f = BirdFont.exec_path + "/Contents/Resources/locale/sv/LC_MESSAGES/birdfont.mo";- if (exists (f)) {- return BirdFont.exec_path + "/Contents/Resources/locale";+ if (!is_null (BirdFont.exec_path)) {+ f = BirdFont.exec_path + "/Contents/Resources/locale/sv/LC_MESSAGES/birdfont.mo";+ if (exists (f)) {+ return BirdFont.exec_path + "/Contents/Resources/locale";+ } } f = "./build/locale/sv/LC_MESSAGES/birdfont.mo";@@ -32,8 +32,10 @@ public class SpacingClassTab : FontDisplay { public SpacingClassTab () { } - public static void remove_all_spaving_classes () {- MainWindow.spacing_class_tab.classes.clear ();+ public static void remove_all_spacing_classes () {+ if (!is_null (MainWindow.spacing_class_tab)) {+ MainWindow.spacing_class_tab.classes.clear ();+ } } public Gee.ArrayList<string> get_all_connections (string glyph) {@@ -103,13 +103,13 @@ class Svg { private static void add_abs_start (EditPoint ep, StringBuilder svg, Glyph g, bool to_glyph) { double left = g.left_limit; double baseline = -BirdFont.get_current_font ().base_line;- double height = BirdFont.get_current_font ().get_height ();+ double height = g.get_height (); svg.append_printf ("M");-+ if (!to_glyph) { svg.append_printf ("%s ", round (ep.x - left));- svg.append_printf ("%s ", round (-ep.y - baseline + height));+ svg.append_printf ("%s ", round (-ep.y + height / 2)); } else { svg.append_printf ("%s ", round (ep.x - left)); svg.append_printf ("%s ", round (ep.y + baseline));@@ -123,13 +123,12 @@ class Svg { private static void add_abs_line_to (EditPoint start, EditPoint stop, StringBuilder svg, Glyph g, bool to_glyph) { double baseline = -BirdFont.get_current_font ().base_line; double left = g.left_limit;+ double height = g.get_height (); double xa, ya, xb, yb; Path.get_line_points (start, stop, out xa, out ya, out xb, out yb); - double height = BirdFont.get_current_font ().get_height (); // no probably not- double center_x = Glyph.xc (); double center_y = Glyph.yc (); @@ -137,7 +136,7 @@ class Svg { if (!to_glyph) { svg.append_printf ("%s ", round (xb - center_x - left));- svg.append_printf ("%s ", round (yb - center_y - baseline + height)); + svg.append_printf ("%s ", round (yb - center_y + height / 2)); } else { svg.append_printf ("%s ", round (xb - center_x - left)); svg.append_printf ("%s ", round (-yb + center_y + baseline));@@ -161,7 +160,7 @@ class Svg { private static void add_quadratic_abs_path (EditPoint start, EditPoint end, StringBuilder svg, Glyph g, bool to_glyph) { double left = g.left_limit; double baseline = -BirdFont.get_current_font ().base_line;- double height = BirdFont.get_current_font ().get_height (); // no probably not+ double height = g.get_height (); double xa, ya, xb, yb, xc, yc, xd, yd; @@ -175,10 +174,10 @@ class Svg { svg.append_printf ("Q"); svg.append_printf ("%s ", round (xb - center_x - left));- svg.append_printf ("%s ", round (yb - center_y - baseline + height));+ svg.append_printf ("%s ", round (yb - center_y + height / 2)); svg.append_printf ("%s ", round (xd - center_x - left));- svg.append_printf ("%s ", round (yd - center_y - baseline + height));+ svg.append_printf ("%s ", round (yd - center_y + height / 2)); } else { svg.append_printf ("Q");@@ -194,7 +193,7 @@ class Svg { private static void add_cubic_abs_path (EditPoint start, EditPoint end, StringBuilder svg, Glyph g, bool to_glyph) { double left = g.left_limit; double baseline = -BirdFont.get_current_font ().base_line;- double height = BirdFont.get_current_font ().get_height (); // no probably not+ double height = g.get_height (); double xa, ya, xb, yb, xc, yc, xd, yd; @@ -208,13 +207,13 @@ class Svg { svg.append_printf ("C"); svg.append_printf ("%s ", round (xb - center_x - left));- svg.append_printf ("%s ", round (yb - center_y - baseline + height));+ svg.append_printf ("%s ", round (yb - center_y + height / 2)); svg.append_printf ("%s ", round (xc - center_x - left));- svg.append_printf ("%s ", round (yc - center_y - baseline + height));+ svg.append_printf ("%s ", round (yc - center_y + height / 2)); svg.append_printf ("%s ", round (xd - center_x - left));- svg.append_printf ("%s ", round (yd - center_y - baseline + height)); + svg.append_printf ("%s ", round (yd - center_y + height / 2)); } else { svg.append_printf ("C");@@ -3,7 +3,7 @@ import subprocess import os def task_update_translations ():- subprocess.check_output ("xgettext --language=C# --keyword=t_ --add-comments=/ --from-code=utf-8 --output=./po/birdfont.pot ./libbirdfont/*.vala ./birdfont/*.vala ./birdfont-export/*.vala", shell=True)+ subprocess.check_output ("xgettext --language=C# --keyword=t_ --add-comments=/ --from-code=utf-8 --output=./po/birdfont.pot ./libbirdfont/*.vala ./birdfont/*.vala ./birdfont-export/*.vala ./birdfont-autotrace/*.vala", shell=True) for file in os.listdir('./po'): if file == "birdfont.pot": continue