Commit 6261e15
don't kern glyphs to nothing
Changed files (4)
modifiedsrc/Context.valamodifiedsrc/OpenFontFormatWriter.valamodifiedsrc/OverView.valamodifiedsrc/SvgFontFormatWriter.vala
Diff
@@ -31,7 +31,7 @@ class ContextDisplay : FontDisplay { double begin_handle_x = 0; double begin_handle_y = 0; - double current_kerning = 0;+ double last_handle_x = 0; public ContextDisplay () { Word w = new Word ();@@ -40,7 +40,7 @@ class ContextDisplay : FontDisplay { } public override string get_name () {- return "Context";+ return "Kerning"; } public override void draw (Allocation allocation, Context cr) {@@ -89,8 +89,9 @@ class ContextDisplay : FontDisplay { } // handle- if (active_handle == i && active_handle < word.glyph.length ()) {- x2 = x + kern;+ if (active_handle == i) {+ //x2 = x + kern;+ x2 = x + kern / 2.0; cr.save (); cr.set_source_rgba (153/255.0, 153/255.0, 173/255.0, 1);@@ -141,17 +142,22 @@ class ContextDisplay : FontDisplay { font.touch (); - handle++; // use handle before next glyph+ // handle++; // use handle before next glyph a = ""; b = ""; foreach (Word word in row) { foreach (string s in word.glyph) {+ + if (s == "") {+ continue;+ }+ b = s; if (handle == wi) {- kern = current_kerning + val;+ kern = font.get_kerning (a, b) + val; font.set_kerning (a, b, kern); } @@ -237,10 +243,12 @@ class ContextDisplay : FontDisplay { y = ((Math.fabs (e.y - begin_handle_y) / 100) + 1); } - k = (e.x - begin_handle_x) / y; // y-axis is variable precision+ k = (e.x - last_handle_x) / y; // y-axis is variable precision set_kerning (selected_handle, k); MainWindow.get_glyph_canvas ().redraw (); }+ + last_handle_x = e.x; } public void set_active_handle (double ex, double ey) {@@ -250,13 +258,18 @@ class ContextDisplay : FontDisplay { double d, kern; double min = double.MAX; int i = 0;+ int row_index = 0;+ int col_index = 0; Glyph? g;- Glyph glyph;+ Glyph glyph = new Glyph.no_lines (""); string prev = "";+ string gl_name = ""; foreach (Word word in row) {+ col_index = 0; foreach (string s in word.glyph) {+ // draw glyph g = (!) Supplement.get_current_font ().get_glyph (s); kern = get_kerning (prev, s);@@ -266,27 +279,34 @@ class ContextDisplay : FontDisplay { } else { glyph = (!) g; w = glyph.get_width ();+ } d = Math.pow (x + kern - ex, 2) + Math.pow (y - ey, 2); if (d < min) { min = d;+ gl_name = glyph.get_name (); - if (active_handle != i) {- active_handle = i;- current_kerning = get_kerning (prev, s);+ if (active_handle != i - row_index) {+ active_handle = i - row_index; MainWindow.get_glyph_canvas ().redraw (); }++ if (col_index == word.glyph.length () || col_index == 0) {+ active_handle = -1;+ } } prev = s; x += w + kern; i++;+ col_index++; } + row_index++; y += MainWindow.get_current_glyph ().get_height () + 20;- x = 20; + x = 20; } } @@ -300,6 +320,7 @@ class ContextDisplay : FontDisplay { selected_handle = active_handle; begin_handle_x = e.x; begin_handle_y = e.y;+ last_handle_x = e.x; } }@@ -2429,17 +2429,16 @@ class OffsetTable : Table { public void process () { FontData fd = new FontData (); + Fixed version = 1 << 16; // sfnt version 1.0 for TTF CFF else use OTTO - - num_tables = (uint16) directory_table.get_tables ().length () - 2; // number of tables, skip DirectoryTable and OffsetTable search_range = max_pow_2_less_than_i (num_tables) * 16; entry_selector = max_log_2_less_than_i (num_tables); range_shift = 16 * num_tables - search_range; - fd.add_tag ("OTTO"); + fd.add_fixed (version); fd.add_u16 (num_tables); fd.add_u16 (search_range); fd.add_u16 (entry_selector); @@ -2767,7 +2766,7 @@ class PostTable : Table { i++; } - warn_if_reached (); + // warn_if_reached (); return -1; } @@ -4379,11 +4378,11 @@ class DirectoryTable : Table { tables.append (offset_table); tables.append (this); - tables.append (gdef_table); + // tables.append (gdef_table); // invalid table tables.append (os_2_table); tables.append (cmap_table); - tables.append (cvt_table); - tables.append (gasp_table); + // tables.append (cvt_table); + // tables.append (gasp_table); tables.append (glyf_table); tables.append (head_table); tables.append (hhea_table); @@ -685,9 +685,7 @@ class OverView : FontDisplay { public void key_up () { update_scrollbar ();- - if (glyph_range.length () == 0) return;- + if (selected < first_character) { warn_if_reached (); }@@ -730,7 +728,15 @@ class OverView : FontDisplay { } public void key_right () { - int len = (int) glyph_range.get_length ();+ uint len;+ Font f;+ + if (all_avail) {+ f = Supplement.get_current_font ();+ len = f.length ();+ } else {+ len = glyph_range.length ();+ } if (len == 0) return; @@ -747,7 +753,7 @@ class OverView : FontDisplay { } public void key_left () {- if (selected > first_character && glyph_range.length () != 0) {+ if (selected > first_character) { selected--; if (selected_offset_y (selected) < 0) { selected -= items_per_row;@@ -896,7 +902,17 @@ class OverView : FontDisplay { double m = (allocation.width - (n_items * nail_width)) / 2.0; bool menu_action = false;+ + Font f;+ uint len; + if (all_avail) {+ f = Supplement.get_current_font ();+ len = f.length ();+ } else {+ len = glyph_range.length ();+ }+ foreach (GlyphCollection g in get_visible_glyphs ()) { bool a; @@ -930,7 +946,7 @@ class OverView : FontDisplay { } // empty set- if (glyph_range.length () == 0) return;+ if (len == 0) return; // scroll to the selected glyph selected = (uint32) first_visible;@@ -92,7 +92,7 @@ class SvgFontFormatWriter : Object { string l = Font.to_hex_code (kern.left.get_char (0)); string r = Font.to_hex_code (kern.right.get_char (0)); - os.put_string (@"<hkern left=\"&#x$l;\" right=\"&#x$r;\" kerning=\"$(kern.val)\"/>\n");+ os.put_string (@"<hkern u1=\"&#x$l;\" u2=\"&#x$r;\" k=\"$(kern.val)\"/>\n"); } catch (GLib.Error ef) { stderr.printf (@"Failed export font \n"); stderr.printf (@"$(ef.message) \n");