The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Fix offsets in text rendering, release freetype resources on error and

These changes was commited to the Birdfont repository Fri, 18 Dec 2015 22:53:31 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
[Fri, 18 Dec 2015 22:53:31 +0000]

Updated Files

libbirdfont/FileTools.vala
libbirdfont/GlyphRange.vala
libbirdfont/OverView.vala
libbirdfont/OverViewItem.vala
libbirdfont/Renderer/Text.vala
libbirdfont/ToolCollection.vala
libbirdfont/overview_glyph.c
--- a/libbirdfont/FileTools.vala +++ b/libbirdfont/FileTools.vala @@ -71,16 +71,18 @@ Preferences.set ("theme", theme_file); Theme.load_theme (theme_file); - + Toolbox.redraw_tool_box (); GlyphCanvas.redraw (); - file_tools.redraw (); - font_name.redraw (); + file_tools.clear_cache (); + font_name.clear_cache (); + themes.clear_cache (); + tb.redraw (0, 0, tb.width, tb.height); foreach (ToolCollection tc in toolbox.tool_sets) { - tc.redraw (); + tc.clear_cache (); } OverViewItem.label_background = null; @@ -93,6 +95,7 @@ } self.set_selected (true); + themes.clear_cache (); }); if (!theme.has_prefix ("generated_")) {
--- a/libbirdfont/GlyphRange.vala +++ b/libbirdfont/GlyphRange.vala @@ -426,7 +426,7 @@ } } - /** Find a range which containd index. */ + /** Find a range which contains index. */ private void get_unirange_index (uint32 index, out UniRange? range, out uint32 range_start_index) { int lower = 0; int upper = index_size - 1;
--- a/libbirdfont/OverView.vala +++ b/libbirdfont/OverView.vala @@ -639,7 +639,6 @@ process_item_list_update (); } - Test test = new Test.time("Overview.draw"); this.allocation = allocation; // clear canvas @@ -660,8 +659,6 @@ if (unlikely (character_info != null)) { draw_character_info (cr); } - - warning (test.get_test_time ()); } void draw_empty_canvas (WidgetAllocation allocation, Context cr) {
--- a/libbirdfont/OverViewItem.vala +++ b/libbirdfont/OverViewItem.vala @@ -47,14 +47,7 @@ public static Surface? selected_label_background = null; public static Surface? label_background_no_menu = null; public static Surface? selected_label_background_no_menu = null; - - private static Task thumbnail_task; - private static Gee.PriorityQueue<OverViewItem> thumbnail_queue; - private static Cond has_thumnail_task = new Cond (); - private static Mutex thumbnail_mutex = new Mutex (); - - private bool cancel_thumbnail = false; - + public OverViewItem () { }
--- a/libbirdfont/Renderer/Text.vala +++ b/libbirdfont/Renderer/Text.vala @@ -330,10 +330,17 @@ } public void set_source_rgba (double r, double g, double b, double a) { - this.r = r; - this.g = g; - this.b = b; - this.a = a; + if (this.r != r || + this.g != g || + this.b != b || + this.a != a) { + + this.r = r; + this.g = g; + this.b = b; + this.a = a; + cache = null; + } } public string get_cache_id (int offset_x, int offset_y) { @@ -472,11 +479,11 @@ cache_id = (cacheid == "") ? get_cache_id (offset_x, offset_y) : cacheid; if (!glyph.has_cache (cache_id)) { - int w = (int) ((glyph_margin_left * ratio + glyph.get_width ()) * ratio) + 2; + int w = (int) ((2 * glyph_margin_left * ratio + glyph.get_width ()) * ratio) + 2; int h = (int) font_size + 2; cache = Screen.create_background_surface (w, h); cc = new Context (cache); - + cc.scale(Screen.get_scale (), Screen.get_scale ()); lsb = glyph.left_limit - glyph_margin_left; @@ -486,7 +493,7 @@ cc.new_path (); foreach (Path path in glyph.get_visible_paths ()) { - draw_path (cc, glyph, path, lsb, offset_x / 10.0, cc_y + offset_y / 10.0, ratio); + draw_path (cc, glyph, path, lsb, glyph_margin_left * ratio + offset_x / 10.0, cc_y + offset_y / 10.0, ratio); } cc.fill ();
--- a/libbirdfont/ToolCollection.vala +++ b/libbirdfont/ToolCollection.vala @@ -39,6 +39,12 @@ public void cache () { foreach (Expander e in get_expanders ()) { e.cache (); + } + } + + public void clear_cache () { + foreach (Expander e in get_expanders ()) { + e.clear_cache (); } }
--- a/libbirdfont/overview_glyph.c +++ b/libbirdfont/overview_glyph.c @@ -50,6 +50,7 @@ error = FT_New_Face (library, font_file, 0, &face); if (error) { + FT_Done_FreeType (library); g_warning ("Freetype font face error %d\n", error); return FALSE; } @@ -60,18 +61,24 @@ error = FT_Select_Charmap (face , FT_ENCODING_UNICODE); if (error) { g_warning ("Freetype can not use Unicode, error: %d\n", error); + FT_Done_Face (face); + FT_Done_FreeType (library); return FALSE; } error = FT_Set_Char_Size (face, 0, 64, (int) height, (int) height); if (error) { g_warning ("FT_Set_Char_Size, error: %d.\n", error); + FT_Done_Face (face); + FT_Done_FreeType (library); return FALSE; } error = FT_Set_Pixel_Sizes (face, 0, (int) (height * 0.5)); if (error) { g_warning ("FT_Set_Pixel_Sizes, error: %d.\n", error); + FT_Done_Face (face); + FT_Done_FreeType (library); return FALSE; } @@ -86,7 +93,8 @@ advance = face->glyph->metrics.horiAdvance; advance *= units; } else { - g_warning("Glyph not found: %s", text); + FT_Done_Face (face); + FT_Done_FreeType (library); return FALSE; }