The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Update grid when switching tab

These changes was commited to the Birdfont repository Thu, 23 Oct 2014 06:09:48 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
author Johan Mattsson <johan.mattsson.m@gmail.com>
Thu, 23 Oct 2014 06:09:48 +0000 (08:09 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Thu, 23 Oct 2014 06:09:48 +0000 (08:09 +0200)
commit a2a84e9365c99c746de96d2fb00cf1881ece8600
tree 671524a484aa80d0f6d421e4ea9a8debf6a2b867
parent e45111c88fe3eec01f8d23c529327be466ebbee5
Update grid when switching tab

13 files changed:
configure
dodo.py
libbirdfont/Font.vala
libbirdfont/Glyph.vala
libbirdfont/Path.vala
libbirdfont/Renderer/TextArea.vala
libbirdfont/Renderer/TextTab.vala
libbirdxml/Attribute.vala
libbirdxml/Attributes.vala
libbirdxml/Tag.vala
libbirdxml/Xml.vala
scripts/bavala.py
--- a/configure +++ b/configure @@ -49,7 +49,7 @@ def has_posixvala (): posixvala = test_library_version ('posixvala') if not posixvala: - print (OKGREEN + "Posix profile disable Glib will be used." + ENDC) + print (OKGREEN + "Glib will be used instead of Posix (libc)." + ENDC) return "False" return "True"
diff --git a/dodo.py b/dodo.py
--- a/dodo.py +++ b/dodo.py @@ -58,7 +58,7 @@ ] else: LIBBIRD_XML_LIBS = [ - 'posixvala' + 'posix' ] def task_build (): @@ -94,7 +94,12 @@ libbirdxml = Vala(src='libbirdxml', build='build', library='birdxml', so_version=version.LIBBIRDXML_SO_VERSION, pkg_libs=LIBBIRD_XML_LIBS) def task_libbirdxml(): - yield libbirdxml.gen_c(valac_options) + + if config.POSIXVALA: + yield libbirdxml.gen_c(valac_options + ['--nostdpkg']) + else: + yield libbirdxml.gen_c(valac_options) + yield libbirdxml.gen_o(['-fPIC']) yield libbirdxml.gen_so() yield libbirdxml.gen_ln()
--- a/libbirdfont/Font.vala +++ b/libbirdfont/Font.vala @@ -391,6 +391,9 @@ g.add_path (i); g.add_path (p); + + i.recalculate_linear_handles (); + p.recalculate_linear_handles (); return gc; }
--- a/libbirdfont/Glyph.vala +++ b/libbirdfont/Glyph.vala @@ -339,6 +339,8 @@ add_help_lines (); KeyBindings.set_require_modifier (false); glyph_sequence = Preferences.get ("glyph_sequence"); + + GridTool.update_lines (); if (!is_null (MainWindow.native_window)) { MainWindow.native_window.set_scrollbar_size (0); @@ -1353,7 +1355,7 @@ stroke = StrokeTool.get_stroke (p, p.stroke); draw_path_list (stroke, cr, Color.black ()); } else { - p.draw_path (cr, Color.black ()); + p.draw_path (cr, this, Color.black ()); } } cr.fill (); @@ -1369,7 +1371,7 @@ draw_path_list (StrokeTool.get_stroke (p, p.stroke), cr, get_path_fill_color ()); } - p.draw_path (cr, get_path_fill_color ()); + p.draw_path (cr, this, get_path_fill_color ()); } cr.fill (); cr.restore (); @@ -1397,7 +1399,7 @@ cr.new_path (); foreach (Path p in path_list) { if (p.stroke == 0) { - p.draw_path (cr, Color.black ()); + p.draw_path (cr, this, Color.black ()); } else { draw_path_list (StrokeTool.get_stroke (p, p.stroke), cr, Color.black ()); } @@ -1410,7 +1412,7 @@ cr.save (); cr.new_path (); if (p.stroke == 0) { - p.draw_path (cr); + p.draw_path (cr, this); } else { draw_path_list (StrokeTool.get_stroke (p, p.stroke), cr); } @@ -1433,7 +1435,7 @@ private void draw_path_list (PathList pl, Context cr, Color? c = null) { foreach (Path p in pl.paths) { - p.draw_path (cr, c); + p.draw_path (cr, this, c); } }
--- a/libbirdfont/Path.vala +++ b/libbirdfont/Path.vala @@ -287,12 +287,11 @@ * Call Context.new_path (); before this method and Context.fill () * to show the path. */ - public void draw_path (Context cr, Color? color = null) { + public void draw_path (Context cr, Glyph glyph, Color? color = null) { unowned EditPoint? n = null; unowned EditPoint en; unowned EditPoint em; Color c; - Glyph g; double center_x, center_y; double ex, ey; @@ -300,10 +299,8 @@ return; } - g = MainWindow.get_current_glyph (); - - center_x = g.allocation.width / 2.0; - center_y = g.allocation.height / 2.0; + center_x = glyph.allocation.width / 2.0; + center_y = glyph.allocation.height / 2.0; ex = center_x + points.get (0).x; ey = center_y - points.get (0).y;
--- a/libbirdfont/Renderer/TextArea.vala +++ b/libbirdfont/Renderer/TextArea.vala @@ -23,6 +23,7 @@ Font font; string text; GlyphSequence glyph_sequence; + double line_gap = 20; public TextArea () { font = new Font (); @@ -62,12 +63,7 @@ return f != null; } - public void draw (Context cr, int x, int y, int width, int height) { - WidgetAllocation wa = new WidgetAllocation.for_area (x, y, width, height); - draw_glyphs (wa, cr); - } - - public void draw_glyphs (WidgetAllocation allocation, Context cr) { + public void draw (Context cr, int px, int py, int width, int height, double font_size_in_pixels) { Glyph glyph; double x, y, w, kern; int i, wi; @@ -76,18 +72,21 @@ GlyphRange? gr_left, gr_right; double row_height; GlyphSequence word; + double center_x, center_y; + double ratio; i = 0; + row_height = get_row_height (); + + ratio = font_size_in_pixels / row_height; cr.save (); - cr.scale (KerningTools.font_size, KerningTools.font_size); + cr.scale (ratio, ratio); - glyph = MainWindow.get_current_glyph (); - - row_height = get_row_height (); - - y = get_row_height () + font.base_line + 20; - x = 20; + glyph = new Glyph ("", '\0'); + + y = get_row_height () + font.base_line + py; + x = px; w = 0; prev = null; kern = 0; @@ -98,10 +97,6 @@ gr_left = null; gr_right = null; foreach (Glyph? g in word_with_ligatures.glyph) { - if (g == null) { - continue; - } - if (prev == null || wi == 0) { kern = 0; } else { @@ -115,19 +110,18 @@ } // draw glyph - if (g == null) { - w = 50; - } else { - glyph = (!) g; + glyph = (g == null) ? font.get_not_def_character ().get_current () : (!) g; - cr.save (); - glyph.add_help_lines (); - cr.translate (kern + x - glyph.get_lsb () - Glyph.xc (), glyph.get_baseline () + y - Glyph.yc ()); - glyph.draw_paths (cr); - cr.restore (); - - w = glyph.get_width (); - } + center_x = glyph.allocation.width / 2.0; + center_y = glyph.allocation.height / 2.0; + + cr.save (); + glyph.add_help_lines (); + cr.translate (kern + x - center_x - glyph.get_lsb (), y - center_y + glyph.get_baseline ()); + glyph.draw_paths (cr); + cr.restore (); + + w = glyph.get_width (); x += w + kern; @@ -137,7 +131,7 @@ i++; } - y += row_height + 20; + y += row_height + line_gap; x = 20; cr.restore ();
--- a/libbirdfont/Renderer/TextTab.vala +++ b/libbirdfont/Renderer/TextTab.vala @@ -29,14 +29,14 @@ text_area2 = new TextArea (); text_area2.load_font ("testfont.bf"); - text_area2.set_text ("Birdfont"); + text_area2.set_text ("Birdfont ÅÄÖ"); } public override void draw (WidgetAllocation allocation, Context cr) { - text_area.draw (cr, 100, 100, 200, 200); - text_area2.draw (cr, 100, 200, 200, 200); + text_area.draw (cr, 0, 0, 200, 200, 16); + text_area2.draw (cr, 0, 100, 200, 200, 16); } } }
--- a/libbirdxml/Attribute.vala +++ b/libbirdxml/Attribute.vala @@ -49,12 +49,12 @@ /** Decrement the reference count and free the object when zero object are holding references to it.*/ public void unref () { if (--refcount == 0) { - this.free (); + this.finalize (); } } /** - * @return name space part for this attribute. + * @return namespace part for this attribute. */ public string get_namespace () { return ns; @@ -74,8 +74,8 @@ return content; } - private extern void free (); + private extern void finalize (); } }
--- a/libbirdxml/Attributes.vala +++ b/libbirdxml/Attributes.vala @@ -42,7 +42,7 @@ /** Decrement the reference count and free the object when zero object are holding references to it.*/ public void unref () { if (--refcount == 0) { - this.free (); + this.finalize (); } } @@ -89,15 +89,15 @@ /** Decrement the reference count and free the object when zero object are holding references to it.*/ public void unref () { if (--iterator_refcount == 0) { - this.free (); + this.finalize (); } } - private extern void free (); + private extern void finalize (); } - private extern void free (); + private extern void finalize (); } }
--- a/libbirdxml/Tag.vala +++ b/libbirdxml/Tag.vala @@ -65,7 +65,7 @@ /** Decrement the reference count and free the object when zero object are holding references to it.*/ public void unref () { if (--refcount == 0) { - this.free (); + this.finalize (); } } @@ -435,11 +435,11 @@ /** Decrement the reference count and free the object when zero object are holding references to it.*/ public void unref () { if (--iterator_efcount == 0) { - this.free (); + this.finalize (); } } - private extern void free (); + private extern void finalize (); } internal void warn (string message) { @@ -448,8 +448,8 @@ } } - private extern void free (); + private extern void finalize (); } }
--- a/libbirdxml/Xml.vala +++ b/libbirdxml/Xml.vala @@ -96,7 +96,7 @@ /** Decrement the reference count and free the object when zero object are holding references to it.*/ public void unref () { if (--refcount == 0) { - this.free (); + this.finalize (); } } @@ -201,8 +201,8 @@ print ("\n"); } - private extern void free (); + private extern void finalize (); } }
--- a/scripts/bavala.py +++ b/scripts/bavala.py @@ -91,7 +91,7 @@ def gen_c(self, opts): """translate code from vala to C and create .vapi""" - options = ['--ccode', '--save-temps'] + options = ['--ccode'] options.extend(opts) params = { 'basedir': join(self.build, self.src), @@ -132,13 +132,14 @@ def compile_cmd(conf, opts, libs, pos): flags = [] for l in libs: - process = subprocess.Popen ('pkg-config --cflags ' + l, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - cflags = process.stdout.readline() - process.communicate()[0] - if not process.returncode == 0: - print ( "Library not found: " + l) - exit (1) - flags += [cflags.strip ()] + if not l == "posix": + process = subprocess.Popen ('pkg-config --cflags ' + l, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + cflags = process.stdout.readline() + process.communicate()[0] + if not process.returncode == 0: + print ( "Library not found: " + l) + exit (1) + flags += [cflags.strip ()] return cmd(config.CC, opts, flags, pos) @@ -166,13 +167,14 @@ flags = [] for l in libs: - process = subprocess.Popen ('pkg-config --cflags ' + l, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - cflags = process.stdout.readline() - process.communicate()[0] - if not process.returncode == 0: - print ( "Library not found: " + l) - exit (1) - flags += [cflags.strip ()] + if not l == "posix": + process = subprocess.Popen ('pkg-config --cflags ' + l, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + cflags = process.stdout.readline() + process.communicate()[0] + if not process.returncode == 0: + print ( "Library not found: " + l) + exit (1) + flags += [cflags.strip ()] if generated_libs: flags += [generated_libs]