Commit ad48815
Delete kerning pairs in kerning tab
Changed files (3)
modifiedlibbirdfont/KerningClasses.valamodifiedlibbirdfont/KerningList.valamodifiedlibbirdfont/OpenFontFormat/Cmap.vala
Diff
@@ -412,6 +412,31 @@ public class KerningClasses : GLib.Object { return true; } + public void delete_kerning_for_class (string left, string right) {+ int i = 0;+ int index = -1;+ + get_classes ((l, r, kerning) => {+ if (left == l && r == right) {+ index = i;+ }+ i++;+ });+ + if (unlikely (index < 0)) {+ warning (@"Kerning class not found for $left to $right");+ return;+ }+ + classes_first.remove_at (index);+ classes_last.remove_at (index);+ classes_kerning.remove_at (index);+ }++ public void delete_kerning_for_pair (string left, string right) {+ single_kerning.unset (@"$left - $right");+ }+ public void remove_all_pairs () { if (protect_map) { warning ("Map is protected.");@@ -77,7 +77,17 @@ public class KerningList : FontDisplay { cr.restore (); } - cr.move_to (30, y);+ // remove kerning icon+ cr.save ();+ cr.set_line_width (1);+ cr.move_to (10, y - 8);+ cr.line_to (15, y - 3);+ cr.move_to (10, y - 3);+ cr.line_to (15, y - 8); + cr.stroke ();+ cr.restore ();+ + cr.move_to (60, y); cr.show_text (left); cr.move_to (230, y); cr.show_text (right);@@ -85,6 +95,54 @@ public class KerningList : FontDisplay { cr.show_text (kerning); } + public override void button_release (int button, double ex, double ey) {+ KerningClasses classes = KerningClasses.get_instance ();+ string l, r;+ int s = 0;+ int y = 0;+ Font font = BirdFont.get_current_font ();+ + l = "";+ r = "";+ + if (ex < 20) {+ classes.get_classes ((left, right, kerning) => {+ if (s++ >= scroll) {+ y += 18;+ + if (y - 10 <= ey <= y + 5) {+ l = left;+ r = right;+ } + }+ });+ + if (l != "" && r != "") {+ classes.delete_kerning_for_class (l, r);+ font.touch ();+ }+ + classes.get_single_position_pairs ((left, right, kerning) => {+ if (s++ >= scroll) {+ y += 18;+ + if (y - 10 <= ey <= y + 5) {+ l = left;+ r = right;+ } + }+ });+ + if (l != "" && r != "") {+ classes.delete_kerning_for_pair (l, r);+ font.touch ();+ }+ + update_scrollbar ();+ redraw_area (0, 0, allocation.width, allocation.height);+ }+ }+ public override string get_label () { return t_("Kerning Pairs"); }@@ -175,7 +175,7 @@ public class CmapSubtableWindowsUnicode : CmapSubtable { if (id_range_offset[i] == 0) { table.insert (indice, character); } else {- // the awkward indexing trick:+ // the indexing trick: id = id_range_offset[i] / 2 + j + i - seg_count; if (!(0 <= id < gid_len)) {@@ -243,17 +243,17 @@ public class CmapSubtableWindowsUnicode : CmapSubtable { fd.add_ushort (seg_count_2); fd.add_ushort (search_range); fd.add_ushort (entry_selector);- fd.add_ushort (range_shift);+ fd.add_ushort (range_shift); // end codes indice = first_assigned; foreach (UniRange u in ranges) { if (u.stop >= 0xFFFF) { warning ("Not implemented yet.");+ } else {+ fd.add_ushort ((uint16) u.stop);+ indice += u.length (); }- - fd.add_ushort ((uint16) u.stop);- indice += u.length (); } fd.add_ushort (0xFFFF); @@ -264,23 +264,22 @@ public class CmapSubtableWindowsUnicode : CmapSubtable { foreach (UniRange u in ranges) { if (u.start >= 0xFFFF) { warning ("Not implemented yet.");+ } else {+ fd.add_ushort ((uint16) u.start);+ indice += u.length (); }- - fd.add_ushort ((uint16) u.start);- indice += u.length (); } fd.add_ushort (0xFFFF); // delta indice = first_assigned; foreach (UniRange u in ranges) {- if ((u.start - indice) > 0xFFFF && u.start > indice) { warning ("Need range offset.");+ } else {+ fd.add_ushort ((uint16) (indice - u.start));+ indice += u.length (); }- - fd.add_ushort ((uint16) (indice - u.start));- indice += u.length (); } fd.add_ushort (1);