The Birdfont Source Code


All Repositories / birdfont.git / blob – RSS feed

TransformTask.vala in /libbirdfont

This file is a part of the Birdfont project.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
Circle boundaries heads/master
1 /* 2 Copyright (C) 2016 Johan Mattsson 3 4 This library is free software; you can redistribute it and/or modify 5 it under the terms of the GNU Lesser General Public License as 6 published by the Free Software Foundation; either version 3 of the 7 License, or (at your option) any later version. 8 9 This library is distributed in the hope that it will be useful, but 10 WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Lesser General Public License for more details. 13 */ 14 15 namespace BirdFont { 16 17 public class TransformTask : Task { 18 static Transform transform; 19 20 public TransformTask (Transform transform) { 21 base (process_transform); 22 TransformTask.transform = transform; 23 } 24 25 public static void process_transform () { 26 OverView o; 27 Glyph g; 28 OverView.OverViewUndoItem ui; 29 30 o = OverviewTools.get_overview (); 31 ui = new OverView.OverViewUndoItem (); 32 33 Font f = BirdFont.get_current_font (); 34 ui.alternate_sets = f.alternates.copy (); 35 36 foreach (GlyphCollection gc in o.selected_items) { 37 if (gc.length () > 0) { 38 g = gc.get_current (); 39 ui.glyphs.add (gc.copy_deep ()); 40 g.add_help_lines (); 41 42 if (transform == Transform.SLANT) { 43 if (OverviewTools.skew.get_value () != 0) { 44 DrawingTools.resize_tool.skew_glyph (g, -OverviewTools.skew.get_value (), 0, false); 45 } 46 } 47 48 if (transform == Transform.SIZE) { 49 if (OverviewTools.resize.get_value () != 100) { 50 double scale = OverviewTools.resize.get_value () / 100; 51 DrawingTools.resize_tool.resize_glyph (g, scale, scale, false); 52 } 53 } 54 55 if (transform == Transform.SVG_TO_TTF) { 56 DrawingTools.move_tool.convert_glyph_to_monochrome (gc.get_current ()); 57 } 58 } 59 } 60 61 foreach (OverViewItem item in o.visible_items) { 62 item.clear_cache (); 63 item.draw_glyph_from_font (); 64 } 65 66 o.undo_items.add (ui); 67 68 MainWindow.get_overview ().update_item_list (); 69 GlyphCanvas.redraw (); 70 } 71 } 72 73 } 74