Commit c5fa5f2
Merge branch 'master' of gitorious.org:birdfont/birdfont
Changed files (16)
modifiedlibbirdfont/BirdFontFile.valamodifiedlibbirdfont/DescriptionTab.valamodifiedlibbirdfont/EditPoint.valamodifiedlibbirdfont/Glyph.valamodifiedlibbirdfont/MoveTool.valamodifiedlibbirdfont/OpenFontFormat/GlyfData.valamodifiedlibbirdfont/OpenFontFormat/HeadTable.valamodifiedlibbirdfont/OpenFontFormat/HheaTable.valamodifiedlibbirdfont/OpenFontFormat/HmtxTable.valamodifiedlibbirdfont/OpenFontFormat/Kern.valamodifiedlibbirdfont/OpenFontFormat/OpenFontFormatWriter.valamodifiedlibbirdfont/OpenFontFormat/Os2Table.valamodifiedlibbirdfont/OverView.valamodifiedlibbirdfont/Path.valamodifiedlibbirdfont/PenTool.valamodifiedlibbirdfont/TestCases.vala
Diff
@@ -643,27 +643,27 @@ class BirdFontFile { private void parse_font_boundries (Xml.Node* node) { for (Xml.Node* iter = node->children; iter != null; iter = iter->next) {- if (iter->name == "top_limit" && "" == iter->children->content) {+ if (iter->name == "top_limit" && "" != iter->children->content) { font.top_limit = parse_double_from_node (iter); } - if (iter->name == "top_position" && "" == iter->children->content) {+ if (iter->name == "top_position" && "" != iter->children->content) { font.top_position = parse_double_from_node (iter); } - if (iter->name == "x-height" && "" == iter->children->content) {+ if (iter->name == "x-height" && "" != iter->children->content) { font.xheight_position = parse_double_from_node (iter); } - if (iter->name == "base_line" && "" == iter->children->content) {+ if (iter->name == "base_line" && "" != iter->children->content) { font.base_line = parse_double_from_node (iter); } - if (iter->name == "bottom_position" && "" == iter->children->content) {+ if (iter->name == "bottom_position" && "" != iter->children->content) { font.bottom_position = parse_double_from_node (iter); } - if (iter->name == "bottom_limit" && "" == iter->children->content) {+ if (iter->name == "bottom_limit" && "" != iter->children->content) { font.bottom_limit = parse_double_from_node (iter); } } @@ -1,3 +1,4 @@+ /* Copyright (C) 2012 Johan Mattsson @@ -93,7 +94,7 @@ public class DescriptionTab : FontDisplay { <h3>""" + _("Style") + " (Regular/Bold/Italic)" + """</h3> <input class="text" type="text" id="subfamily" value=""" + "\"" + font.subfamily + "\"" + """ onchange="update_name_fields ();"/><br /> - <h3>""" + _("Full name (name & style)") + """</h3>+ <h3>""" + _("Full name (name and style)") + """</h3> <input class="text" type="text" id="full_name" value=""" + "\"" + font.full_name + "\"" + """ onchange="update_name_fields ();"/><br /> <h3>""" + _("Unique identifier") + """</h3>@@ -136,7 +137,7 @@ c.append ( _("Postscript name"); _("Name"); _("Style");- _("Full name (name & style)");+ _("Full name (name and style)"); _("Unique identifier"); _("Version"); _("Description");@@ -69,6 +69,15 @@ public class EditPoint { } } + public bool equals (EditPoint e) {+ return e.x == x + && e.y == y + && get_right_handle ().x () == e.get_right_handle ().x ()+ && get_right_handle ().y () == e.get_right_handle ().y ()+ && get_left_handle ().x () == e.get_left_handle ().x ()+ && get_left_handle ().y () == e.get_left_handle ().y ();+ }+ /** Flip handles if next point on path is in the other direction. * Used to recalculate handles after new point is inserted on a path. */@@ -1070,9 +1070,7 @@ public class Glyph : FontDisplay { return open; } - /** Close all editable paths and return false if no path have boon closed. - * Paths without area (points and lines) will be deleted.- */+ /** Close all editable paths and return false if no path have been closed. */ public bool close_path () { bool r = false; @@ -247,6 +247,10 @@ class MoveTool : Tool { h = selected_path.ymax - selected_path.ymin; w = selected_path.xmax - selected_path.xmin; + if (selected_path.points.length () == 0) {+ continue;+ }+ if (h * ratio < 1 || w * ratio < 1) { return false; }@@ -51,6 +51,8 @@ class GlyfData : GLib.Object { public int16 bounding_box_xmax = 0; public int16 bounding_box_ymax = 0; + private static double UNITS = HeadTable.UNITS;+ public GlyfData (Glyph g) { glyph = g; @@ -40,7 +40,8 @@ class HeadTable : Table { uint64 created; uint64 modified; - uint16 units_per_em = 2048;+ public static uint16 units_per_em = 4096;+ public static double UNITS = 10 * (units_per_em / 1000); const uint8 BASELINE_AT_ZERO = 1 << 0; const uint8 LSB_AT_ZERO = 1 << 1;@@ -162,7 +163,7 @@ class HeadTable : Table { //font_data.add_u16 (BASELINE_AT_ZERO | LSB_AT_ZERO); font_data.add_u16 (0); // flags - font_data.add_u16 (1000); // units per em (should be a power of two for ttf fonts)+ font_data.add_u16 (units_per_em); // units per em (should be a power of two for ttf fonts) font_data.add_64 (0); // creation time since 1904-01-01 font_data.add_64 (0); // modified time since 1904-01-01@@ -87,8 +87,8 @@ class HheaTable : Table { fd.add_fixed (version); // table version - fd.add_16 ((int16) (-1 * (font.top_position - font.base_line) * UNITS)); // Ascender- fd.add_16 ((int16) (-1 * font.bottom_position * UNITS)); // Descender+ fd.add_16 ((int16) (-1 * (font.top_position - font.base_line) * HeadTable.UNITS)); // Ascender+ fd.add_16 ((int16) (-1 * font.bottom_position * HeadTable.UNITS)); // Descender fd.add_16 (0); // LineGap fd.add_u16 (hmtx_table.max_advance); // maximum advance width value in 'hmtx' table.@@ -105,9 +105,9 @@ class HmtxTable : Table { // advance and lsb foreach (Glyph g in glyf_table.glyphs) { g.boundries (out xmin, out ymin, out xmax, out ymax);- lsb = (int16) (-1 * (g.left_limit - xmin) * UNITS);- advance = (int16) ((g.right_limit - g.left_limit) * UNITS);- extent = (int16) (lsb + (xmax - xmin) * UNITS);+ lsb = (int16) (-1 * (g.left_limit - xmin) * HeadTable.UNITS);+ advance = (int16) ((g.right_limit - g.left_limit) * HeadTable.UNITS);+ extent = (int16) (lsb + (xmax - xmin) * HeadTable.UNITS); rsb = (int16) (advance - extent); fd.add_u16 (advance);@@ -177,7 +177,7 @@ class KernTable : Table { warning ("right glyph not found in kerning table"); } - kern = new Kern (gid_left, (uint16)gid_right, (int16) (k.val * UNITS));+ kern = new Kern (gid_left, (uint16)gid_right, (int16) (k.val * HeadTable.UNITS)); fd.add_ushort (kern.left); fd.add_ushort (kern.right);@@ -14,8 +14,6 @@ namespace BirdFont { -const double UNITS = 10;- class OpenFontFormatWriter : Object { DataOutputStream os;@@ -76,8 +76,8 @@ class Os2Table : Table { fd.add_u16 (glyf_table.get_first_char ()); // USHORT usFirstCharIndex fd.add_u16 (glyf_table.get_last_char ()); // USHORT usLastCharIndex - ascender = (int16) (glyf_table.xmax + font.base_line * UNITS);- descender = (int16) (-glyf_table.xmin + font.base_line * UNITS);+ ascender = (int16) (glyf_table.xmax + font.base_line * HeadTable.UNITS);+ descender = (int16) (-glyf_table.xmin + font.base_line * HeadTable.UNITS); fd.add_16 (ascender); // SHORT sTypoAscender fd.add_16 (descender); // SHORT sTypoDescender@@ -214,6 +214,16 @@ public class OverView : FontDisplay { return visible_items.nth (selected).data; } + int get_items_per_row () {+ int i = 1;+ double l = OverViewItem.full_width ();+ while (l < allocation.width) {+ l += OverViewItem.full_width ();+ i++;+ }+ return i - 1;+ }+ void update_item_list () { string character_string; Font f = BirdFont.get_current_font ();@@ -224,8 +234,9 @@ public class OverView : FontDisplay { unichar character; Glyph glyph; - items_per_row = (int) (allocation.width / OverViewItem.full_width ());- rows = (int) (allocation.height / OverViewItem.full_height ());+ OverViewItem.margin = OverViewItem.width * 0.1;+ items_per_row = get_items_per_row ();+ rows = (int) (allocation.height / OverViewItem.full_height ()) + 2; while (visible_items.length () > 0) { visible_items.remove_link (visible_items.first ());@@ -285,6 +296,7 @@ public class OverView : FontDisplay { foreach (OverViewItem i in visible_items) { i.y += view_offset_y;+ i.x += view_offset_x; } } @@ -1024,7 +1024,7 @@ public class Path { if (points.length () < 2) { return quadratic_path; }-+ i = points.first (); next = i.next; @@ -1047,6 +1047,8 @@ public class Path { quadratic_path.add_point (points.last ().data.copy ()); } + quadratic_path.add_hidden_double_points ();+ quadratic_path.close (); quadratic_path.create_list (); process_quadratic_handles ();@@ -1055,7 +1057,7 @@ public class Path { quadratic_path.create_list (); process_cubic_handles (); - quadratic_path.add_hidden_double_points ();+ quadratic_path.close (); return quadratic_path; }@@ -1069,7 +1071,7 @@ public class Path { return; } - steps = (int) get_length_from (start, stop);+ steps = (int) (0.8 * get_length_from (start, stop)); // create quadratic paths all_of (start, stop, (x, y, step) => {@@ -307,37 +307,51 @@ public class PenTool : Tool { } bool is_new_point_from_path_selected () {- // TODO: return false; } + public void remove_from_selected (EditPoint ep) + requires (selected_points.length () > 0) {+ for (unowned List<EditPoint> e = selected_points.first (); !is_null (e.next); e = e.next) {+ if (ep.equals (e.data)) {+ ep.set_selected (false);+ selected_points.remove_link (e);+ return;+ }+ }+ }+ public void select_active_point (double x, double y) { Glyph? g = MainWindow.get_current_glyph (); Glyph glyph = (!) g;- - if (KeyBindings.modifier != SHIFT) {- if (active_edit_point != null) {- ((!)active_edit_point).set_active (false);- }-- remove_all_selected_points ();- }+ bool new_selection; move_selected = true; move_point_on_path = true;-+ if (active_edit_point != null) {- ((!)active_edit_point).set_selected (true);- selected_point = (!)active_edit_point;+ if (KeyBindings.modifier == SHIFT) {+ if (((!)active_edit_point).is_selected ()) {+ ((!)active_edit_point).set_selected (false);+ remove_from_selected ((!)active_edit_point);+ } else {+ ((!)active_edit_point).set_selected (true);+ selected_point = (!)active_edit_point;+ add_selected_point (selected_point);+ }+ } else {+ if (!((!)active_edit_point).is_selected ()) {+ remove_all_selected_points ();+ ((!)active_edit_point).set_selected (true);+ selected_point = (!)active_edit_point;+ add_selected_point (selected_point);+ }+ } }-- if (!is_over_handle (x, y)) {- edit_active_corner = true;- set_default_handle_positions ();- - if (active_edit_point != null) {- last_selected_is_handle = false;- add_selected_point ((!) active_edit_point);+ + if (active_edit_point == null) {+ if (KeyBindings.modifier != SHIFT) {+ remove_all_selected_points (); } } @@ -528,6 +528,7 @@ class TestCases { foreach (Path path in g.path_list) { paths.append (path.get_quadratic_points ());+ paths.append (path.copy ()); } // create a new path and convert it