Commit 149786f
Fix compilers warnings
Changed files (20)
modifiedlibbirdfont/BirdFontFile.valamodifiedlibbirdfont/ClickMap.valamodifiedlibbirdfont/DefaultCharactersSet.valamodifiedlibbirdfont/Expander.valamodifiedlibbirdfont/FontSettings.valamodifiedlibbirdfont/Glyph.valamodifiedlibbirdfont/GuideTab.valamodifiedlibbirdfont/KerningStrings.valamodifiedlibbirdfont/Menu.valamodifiedlibbirdfont/OpenFontFormat/ContextualLigature.valamodifiedlibbirdfont/OpenFontFormat/GposTable.valamodifiedlibbirdfont/OpenFontFormat/GsubTable.valamodifiedlibbirdfont/OpenFontFormat/LigatureCollection.valamodifiedlibbirdfont/PenTool.valamodifiedlibbirdfont/Renderer/Text.valamodifiedlibbirdfont/TabBar.valamodifiedlibbirdfont/Theme.valamodifiedlibbirdfont/Tool.valamodifiedlibbirdxml/Attributes.valamodifiedlibbirdxml/Tag.vala
Diff
@@ -1556,12 +1556,16 @@ class BirdFontFile : GLib.Object { } }); - foreach (ContextualLigature c in ligatures.contextual_ligatures) {- os.put_string (@"<contextual "- + @"ligature=\"$(c.ligatures)\" "- + @"backtrack=\"$(c.backtrack)\" "- + @"input=\"$(c.input)\" "- + @"lookahead=\"$(c.lookahead)\" />\n");+ try {+ foreach (ContextualLigature c in ligatures.contextual_ligatures) {+ os.put_string (@"<contextual "+ + @"ligature=\"$(c.ligatures)\" "+ + @"backtrack=\"$(c.backtrack)\" "+ + @"input=\"$(c.input)\" "+ + @"lookahead=\"$(c.lookahead)\" />\n");+ }+ } catch (GLib.Error e) {+ warning (e.message); } } @@ -40,7 +40,6 @@ public class ClickMap : GLib.Object { } public void create_click_map (Path path) {- double w, h; Context c; c = new Context (map);@@ -109,17 +109,22 @@ public class DefaultCharacterSet { string all_characters; all_characters = get_characters_for_prefered_language ();- if (all_characters != "") {- gr.parse_ranges (all_characters);- } else { - /// All lower case letters in alphabetic order separated by space. Letters with diacritical marks should be included.- lower_case = t_("a b c d e f g h i j k l m n o p q r s t u v w x y z");- - /// All upper case letters in alphabetic order separated by space. Letters with diacritical marks should be included.- upper_case = t_("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z");+ + try {+ if (all_characters != "") {+ gr.parse_ranges (all_characters);+ } else { + /// All lower case letters in alphabetic order separated by space. Letters with diacritical marks should be included.+ lower_case = t_("a b c d e f g h i j k l m n o p q r s t u v w x y z");+ + /// All upper case letters in alphabetic order separated by space. Letters with diacritical marks should be included.+ upper_case = t_("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"); - gr.parse_ranges (lower_case);- gr.parse_ranges (upper_case);+ gr.parse_ranges (lower_case);+ gr.parse_ranges (upper_case);+ }+ } catch (GLib.Error e) {+ warning (e.message); } gr.add_range ('0', '9');@@ -221,8 +221,6 @@ public class Expander : GLib.Object { public void draw (int wd, int hd, Context cr) { double yt = y + scroll + 2;- double ih2 = 5.4 / 2;- double iw2 = 5.4 / 2; Text title; if (tool.size > 0) {@@ -42,7 +42,6 @@ public class FontSettings : GLib.Object { File get_settings_file () { File config_directory = BirdFont.get_settings_directory ();- File settings = get_child (config_directory, "settings"); return get_child (config_directory, font_name.replace (".bf", ".config")); } @@ -87,14 +86,18 @@ public class FontSettings : GLib.Object { string xml_data; XmlParser parser; - settings.clear ();- font_name = font_file_name;- f = get_settings_file ();- - if (f.query_exists ()) {- FileUtils.get_contents((!) f.get_path (), out xml_data);- parser = new XmlParser (xml_data);- parse_settings (parser.get_root_tag ()); + try {+ settings.clear ();+ font_name = font_file_name;+ f = get_settings_file ();+ + if (f.query_exists ()) {+ FileUtils.get_contents((!) f.get_path (), out xml_data);+ parser = new XmlParser (xml_data);+ parse_settings (parser.get_root_tag ()); + }+ } catch (GLib.Error e) {+ warning (e.message); } } @@ -431,8 +431,6 @@ public class Glyph : FontDisplay { left_line = new Line ("left", left_limit, true); left_line.position_updated.connect ((pos) => {- double x1, y1, x2, y2;- left_limit = pos; update_other_spacing_classes (); @@ -442,8 +440,6 @@ public class Glyph : FontDisplay { right_line = new Line ("right", right_limit, true); right_line.position_updated.connect ((pos) => {- double x1, y1, x2, y2;- right_limit = pos; update_other_spacing_classes (); @@ -32,7 +32,7 @@ public class GuideTab : Table { int index = row.get_index (); if (delete_button) {- return_if_fail (0 <= index < BirdFont.get_current_font ().custom_guides.size);+ return_if_fail (0 <= index < font.custom_guides.size); BirdFont.get_current_font ().custom_guides.remove_at (index); update_rows (); }@@ -40,7 +40,6 @@ public class GuideTab : Table { public override void update_rows () { int i = 0;- SpacingData spacing = BirdFont.get_current_font ().get_spacing (); rows.clear (); @@ -77,7 +77,6 @@ public class KerningStrings : GLib.Object { } public void load_new_string (Font font, string kerning_strings_file) {- File f; string data; string[] strings; string w;@@ -469,7 +469,6 @@ public class Menu : GLib.Object { string display; FontDisplay current_display = MainWindow.get_current_display (); ToolItem tm;- unichar c = (unichar) keyval; foreach (MenuItem item in sorted_menu_items) { if (item.key == (unichar) keyval && item.modifiers == KeyBindings.modifier) {@@ -40,7 +40,8 @@ public class ContextualLigature : GLib.Object { return ligature_list; } - public FontData get_data (GlyfTable glyf_table, uint16 ligature_lookup_index) {+ public FontData get_font_data (GlyfTable glyf_table, uint16 ligature_lookup_index) + throws GLib.Error { FontData fd = new FontData (); Gee.ArrayList<string> backtrack = GsubTable.get_names (backtrack);@@ -70,7 +70,7 @@ public class GposTable : OtfTable { fd.add_ushort (1); // number of lookups fd.add_ushort (4); // offset to lookup 1 - fd.add_ushort (2); // lookup type // FIXME + fd.add_ushort (2); // lookup type fd.add_ushort (0); // lookup flags fd.add_ushort (1); // number of subtables fd.add_ushort (8); // array of offsets to subtables@@ -86,7 +86,7 @@ public class GsubTable : OtfTable { fd.add_ushort (0); // lookup clig_subtable } - clig_subtable = clig.get_data (glyf_table);+ clig_subtable = clig.get_font_data (glyf_table); chain_data = get_chaining_contextual_substition_subtable (contextual); // lookup table@@ -144,7 +144,7 @@ public class GsubTable : OtfTable { LigatureCollection ligature_set = contextual.ligatures.get (i); fd.add_ushort (lookups_end + length); // array of offsets to subtable- length += (uint16) ligature_set.get_data (glyf_table).length_with_padding ();+ length += (uint16) ligature_set.get_font_data (glyf_table).length_with_padding (); lookups_end -= 8; }@@ -169,7 +169,7 @@ public class GsubTable : OtfTable { if (contextual.has_ligatures ()) { foreach (LigatureCollection s in contextual.ligatures) {- fd.append (s.get_data (glyf_table));+ fd.append (s.get_font_data (glyf_table)); } foreach (FontData d in chain_data) {@@ -188,60 +188,13 @@ public class GsubTable : OtfTable { uint16 ligature_lookup_index = 1; foreach (ContextualLigature context in contexts.ligature_context) {- fd.add (context.get_data (glyf_table, ligature_lookup_index)); + fd.add (context.get_font_data (glyf_table, ligature_lookup_index)); ligature_lookup_index++; } return fd; } - void parse_ligatures (FontData fd, int table_start) {- fd.seek (table_start);- - uint16 identifier = fd.read_ushort ();- - if (identifier != 1) {- warning (@"Bad identifier expecting 1 found $identifier");- }- - uint16 coverage_offset = fd.read_ushort (); // TODO: read coverage- uint16 num_sets = fd.read_ushort ();- - Gee.ArrayList<int> liga_set_offsets = new Gee.ArrayList<int> ();- for (int i = 0; i < num_sets; i++) {- uint16 liga_set_offset = fd.read_ushort ();- liga_set_offsets.add (table_start + liga_set_offset);- }- - foreach (int liga_set_pos in liga_set_offsets) {- fd.seek (liga_set_pos);- parse_ligature_set (fd);- } - }- - /** Parse ligature set at the current position. */- void parse_ligature_set (FontData fd) {- int liga_start = fd.get_read_pos ();- uint nliga = fd.read_ushort ();- Gee.ArrayList<int> offsets = new Gee.ArrayList<int> ();- - for (uint i = 0; i < nliga; i++) {- int off = fd.read_ushort ();- offsets.add (off);- }-- foreach (int off in offsets) {- fd.seek (liga_start);- fd.seek_relative (off);- uint16 lig = fd.read_ushort ();- uint16 nlig_comp = fd.read_ushort ();- - for (int i = 1; i < nlig_comp; i++) {- uint16 lig_comp = fd.read_ushort ();- } - }- }- /** * @param glyphs Name of glyphs or unicode values separated by space. * @return glyph names@@ -54,7 +54,6 @@ public class LigatureCollection : GLib.Object { } // multiple ligatures in non-contextual substitution- // FIXME: what if parts equals "" ? Which set does ligatures becomes a part of? public void add_ligatures (GlyfTable glyf_table, string characters, string ligatures) requires (!is_null (lig_set) && !is_null (last_set)) { @@ -97,7 +96,7 @@ public class LigatureCollection : GLib.Object { } } - public FontData get_data (GlyfTable glyf_table) throws GLib.Error {+ public FontData get_font_data (GlyfTable glyf_table) throws GLib.Error { FontData set_data; uint16 ligature_pos; uint16 table_start;@@ -1400,8 +1400,6 @@ public class PenTool : Tool { double y = Glyph.path_coordinate_y (event_y); double distance; PointSelection e;- int px, py;- double coordinate_x, coordinate_y; set_active_edit_point (null, new Path ()); if (ep == null) {@@ -354,8 +354,6 @@ public class Text : Widget { if (use_cached_glyphs) { iterate ((glyph, kerning, last) => { double end;- int offset_x, offset_y;- string cache_id; x += kerning * ratio; end = x + glyph.get_width () * ratio;@@ -612,7 +612,6 @@ public class TabBar : GLib.Object { public void draw (Context cr, int width, int height) { double next_tab_x; double w, h;- double progress_y; this.width = width; this.height = height;@@ -653,8 +652,6 @@ public class TabBar : GLib.Object { // progress wheel if (has_progress_wheel ()) { double progress_size = 40 / scale;- Surface s = new Surface.similar (cr.get_target (), Cairo.Content.COLOR_ALPHA, (int) progress_size, (int) progress_size);- Context c = new Context (s); Theme.text_color (progress_icon, "Foreground 2"); @@ -81,8 +81,6 @@ public class Theme : GLib.Object { } public static Color get_color (string name) {- Color c;- if (unlikely (!colors.has_key (name))) { warning (@"Theme does not have a color for $name"); return new Color (0, 0, 0, 1);@@ -29,7 +29,6 @@ public class Tool : Widget { public bool selected = false; Text icon_font;- ImageSurface? icon = null; public signal void select_action (Tool selected); public signal void deselect_action (Tool selected);@@ -50,7 +50,7 @@ public class Attributes : GLib.Object { return next_attribute != null; } - public Attribute get () {+ public new Attribute get () { if (next_attribute == null) { XmlParser.warning ("No attribute is parsed yet."); return new Attribute.empty ();@@ -153,15 +153,16 @@ public class Tag : GLib.Object { XmlString name; XmlString attributes; XmlString content;- ++ end_tag_index = -1;+ if (start < 0) { warn ("Negative index."); return new Tag.empty (); } index = start;- end_tag_index = -1;- + d = data; if (d == null) { warn ("No data in xml string.");@@ -439,7 +440,7 @@ public class Tag : GLib.Object { return next_tag != null; } - public Tag get () {+ public new Tag get () { if (next_tag == null) { XmlParser.warning ("No tag is parsed yet."); return new Tag.empty ();