The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Create plugin interface for the rendering classes

These changes was commited to the Birdfont repository Tue, 28 Oct 2014 11:54:27 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
[Tue, 28 Oct 2014 11:54:27 +0000]

Updated Files

libbirdfont/BirdFont.vala
libbirdfont/Renderer/Drawing.vala
libbirdfont/Renderer/FontCache.vala
--- a/libbirdfont/BirdFont.vala +++ b/libbirdfont/BirdFont.vala @@ -366,8 +366,17 @@ public static Font current_font; public static GlyphCollection current_glyph_collection; - public BirdFont () { + public static Drawing? drawing = null; + + public BirdFont () { + set_defaul_drawing_callbacks (); } + + void set_defaul_drawing_callbacks () { + if (drawing == null) { + drawing = new Drawing (); + } + } /** * @param arg command line arguments @@ -714,7 +723,11 @@ printd (@"File: Directory: $f Name: $n\n"); return File.new_for_path (f + n); + } + + public static void set_drawing_callbacks (Drawing callbacks) { + BirdFont.drawing = callbacks; } }
--- /dev/null +++ b/libbirdfont/Renderer/Drawing.vala @@ -1,1 +1,51 @@ + /* + Copyright (C) 2014 Johan Mattsson + + This library is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 3 of the + License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + */ + + namespace BirdFont { + + /** Interface for creating drawing callbacks. */ + [Compact] + [CCode (ref_function = "bird_font_drawing_ref", unref_function = "bird_font_drawing_unref")] + public class Drawing { + + public int iterator_refcount = 1; + + public Drawing () { + } + + public void new_path (double x, double y) { + } + + public void curve_to (double xb, double yb, double xc, double yc, double xd, double yd) { + } + + public void close_path (double x, double y) { + } + + public unowned Drawing @ref () { + iterator_refcount++; + return this; + } + + public void unref () { + if (--iterator_refcount == 0) { + this.free (); + } + } + + private extern void free (); + } + + }
--- a/libbirdfont/Renderer/FontCache.vala +++ b/libbirdfont/Renderer/FontCache.vala @@ -31,7 +31,7 @@ bool ok; if (file_name == "") { - stderr.printf ("No file name provided."); + stderr.printf ("No file name provided.\n"); return null; } @@ -42,7 +42,7 @@ f.set_file (file_name, false); ok = f.load (); if (!ok) { - stderr.printf ("Can't load %s", file_name); + stderr.printf ("Can't load %s\n", file_name); return null; }