The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Ignore paths with just one point in bounding box

These changes was commited to the Birdfont repository Mon, 20 Jun 2016 09:21:49 +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>
Mon, 20 Jun 2016 09:21:49 +0000 (11:21 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Mon, 20 Jun 2016 09:21:49 +0000 (11:21 +0200)
commit 51dce7a470541fd606c6ddf817949566617117cf
tree add2e90e6640b3d85a0e1fcaf985903e43a29f99
parent 09fe42f3ccc7c931fc27aff4c50a812520df74c3
Ignore paths with just one point in bounding box

libbirdfont/EmbeddedSvg.vala
libbirdfont/PathObject.vala
libsvgbird/Layer.vala
libsvgbird/Object.vala
libsvgbird/SvgDrawing.vala
resources/icons.bf
--- a/libbirdfont/EmbeddedSvg.vala +++ b/libbirdfont/EmbeddedSvg.vala @@ -30,13 +30,15 @@ this.drawing = drawing; } - public override void update_boundaries (Matrix view_matrix) { + public override bool update_boundaries (Matrix view_matrix) { drawing.update_boundaries (view_matrix); left = x + drawing.left; right = x + drawing.right; top = -y + drawing.top; bottom = -y + drawing.bottom; + + return true; } public override bool is_over (double x, double y) {
--- a/libbirdfont/PathObject.vala +++ b/libbirdfont/PathObject.vala @@ -113,7 +113,11 @@ return path; } - public override void update_boundaries (Matrix matrix) { + public override bool update_boundaries (Matrix matrix) { + if (path.points.size < 2) { + return false; + } + xmin = Glyph.CANVAS_MAX; xmax = Glyph.CANVAS_MIN; ymin = Glyph.CANVAS_MAX; @@ -125,6 +129,8 @@ xmax = path.xmax; ymin = path.ymin; ymax = path.ymax; + + return true; } public override void rotate (double theta, double xc, double yc) {
--- a/libsvgbird/Layer.vala +++ b/libsvgbird/Layer.vala @@ -32,9 +32,9 @@ transforms = new SvgTransforms (); } - public override void update_boundaries (Matrix view_matrix) { + public override bool update_boundaries (Matrix view_matrix) { if (objects.size == 0) { - return; + return false; } top = CANVAS_MAX; @@ -46,13 +46,17 @@ layer_matrix.multiply (layer_matrix, view_matrix); foreach (Object object in objects) { - object.update_boundaries (layer_matrix); - - left = fmin (left, object.left); - right = fmax (right, object.right); - top = fmin (top, object.top); - bottom = fmax (bottom, object.bottom); + bool has_size = object.update_boundaries (layer_matrix); + + if (has_size) { + left = fmin (left, object.left); + right = fmax (right, object.right); + top = fmin (top, object.top); + bottom = fmax (bottom, object.bottom); + } } + + return boundaries_width != 0; } public void draw (Context cr) {
--- a/libsvgbird/Object.vala +++ b/libsvgbird/Object.vala @@ -247,8 +247,9 @@ object_matrix.multiply (object_matrix, view_matrix); cr.set_matrix (object_matrix); } - - public virtual void update_boundaries (Matrix view_matrix) { + + /** @return true if the object has an area. */ + public virtual bool update_boundaries (Matrix view_matrix) { ImageSurface surface = new Cairo.ImageSurface (Cairo.Format.ARGB32, 1, 1); Context context = new Cairo.Context (surface); @@ -270,8 +271,10 @@ top = y0; right = x1; bottom = y1; + + return boundaries_width != 0; } } }
--- a/libsvgbird/SvgDrawing.vala +++ b/libsvgbird/SvgDrawing.vala @@ -49,13 +49,15 @@ public double svg_width = 0; public double svg_height = 0; - public override void update_boundaries (Matrix view_matrix) { + public override bool update_boundaries (Matrix view_matrix) { root_layer.update_boundaries (view_matrix); left = x + root_layer.left; right = x + root_layer.right; top = y + root_layer.top; bottom = y + root_layer.bottom; + + return true; } public override bool is_over (double x, double y) {
--- a/resources/icons.bf +++ b/resources/icons.bf @@ -37,6 +37,22 @@ <grid width="2.0000"/> <grid width="4.0000"/> <background scale="1.0000" /> + + <collection unicode="U+20"> + <selected id="0"/> + <glyph id="0" left="0" right="27"> + </glyph> + </collection> + + <collection name=".notdef"> + <selected id="0"/> + <glyph id="0" left="-20" right="33"> + <layer name= "Layer" visible="true"> + <path data="S -15.0000000000,10.0000000000 M 15.0000000000,10.0000000000 M 15.0000000000,44.0000000000 M -15.0000000000,44.0000000000 M -15.0000000000,10.0000000000" /> + <path data="S -20.0000000000,49.0000000000 M 20.0000000000,49.0000000000 M 20.0000000000,5.0000000000 M -20.0000000000,5.0000000000 M -20.0000000000,49.0000000000" /> + </layer> + </glyph> + </collection> <collection unicode="U+30"> <selected id="1"/> @@ -324,7 +340,6 @@ <path data="B -26.0000000000,11.3175355450 M 24.0000000000,11.3175355450 M 24.0000000000,7.3175355450 M -26.0000000000,7.3175355450 M -26.0000000000,11.3175355450" /> <path data="B -2.0379146919,25.1240511107 M 24.0000000000,25.0394944708 C 24.0000000000,23.0394944708 24.0000000000,22.3728278041 24.0000000000,21.0394944708 M -2.0379146919,21.1240511107 M -2.0379146919,25.1240511107" /> <path data="B -16.0000000000,35.0394944708 M -16.0000000000,29.0394944708 M -10.0000000000,29.0394944708 M -10.0000000000,25.0394944708 M -16.0000000000,25.0394944708 M -16.0000000000,19.0394944708 M -20.0000000000,19.0394944708 M -20.0000000000,25.0394944708 M -26.0000000000,25.0394944708 M -26.0000000000,29.0394944708 M -20.0000000000,29.0394944708 M -20.0000000000,31.4394944708 M -20.0000000000,35.0394944708 M -16.0000000000,35.0394944708" /> - <path data="B -37.7796208531,18.7954186414 M -37.7796208531,18.7954186414 O" /> </layer> </glyph> </collection> @@ -1776,112 +1791,112 @@ <ligature sequence="o r i e n t a t i o n _ c o u n t e r _ c l o c k w i s e" replacement="orientation_counter_clockwise"/> <ligature sequence="i n s e r t _ g l y p h _ f r o m _ o v e r v i e w" replacement="insert_glyph_from_overview"/> + <ligature sequence="r e s i z e _ h a n d l e _ h o r i z o n t a l" replacement="resize_handle_horizontal"/> <ligature sequence="h i g h _ c o n t r a s t _ b a c k g r o u n d" replacement="high_contrast_background"/> - <ligature sequence="r e s i z e _ h a n d l e _ h o r i z o n t a l" replacement="resize_handle_horizontal"/> <ligature sequence="p r e v i o u s _ k e r n i n g _ s t r i n g" replacement="previous_kerning_string"/> + <ligature sequence="s h o w _ x h e i g h t _ h e l p l i n e s" replacement="show_xheight_helplines"/> <ligature sequence="g e n e r a t e _ h t m l _ d o c u m e n t" replacement="generate_html_document"/> - <ligature sequence="s h o w _ x h e i g h t _ h e l p l i n e s" replacement="show_xheight_helplines"/> + <ligature sequence="s h o w _ a l l _ l i n e _ h a n d l e s" replacement="show_all_line_handles"/> + <ligature sequence="b a c k g r o u n d _ h e l p _ l i n e s" replacement="background_help_lines"/> + <ligature sequence="a u t o _ t r a c e _ r e s o l u t i o n" replacement="auto_trace_resolution"/> + <ligature sequence="z o o m _ b a c k g r o u n d _ i m a g e" replacement="zoom_background_image"/> <ligature sequence="o r i e n t a t i o n _ c l o c k w i s e" replacement="orientation_clockwise"/> - <ligature sequence="z o o m _ b a c k g r o u n d _ i m a g e" replacement="zoom_background_image"/> - <ligature sequence="a u t o _ t r a c e _ r e s o l u t i o n" replacement="auto_trace_resolution"/> - <ligature sequence="b a c k g r o u n d _ h e l p _ l i n e s" replacement="background_help_lines"/> - <ligature sequence="s h o w _ a l l _ l i n e _ h a n d l e s" replacement="show_all_line_handles"/> + <ligature sequence="a u t o _ t r a c e _ s i m p l i f y" replacement="auto_trace_simplify"/> <ligature sequence="n e x t _ k e r n i n g _ s t r i n g" replacement="next_kerning_string"/> - <ligature sequence="a u t o _ t r a c e _ s i m p l i f y" replacement="auto_trace_simplify"/> - <ligature sequence="c o n t r a s t _ t h r e s h o l d" replacement="contrast_threshold"/> <ligature sequence="k e r n i n g _ t e x t _ i n p u t" replacement="kerning_text_input"/> + <ligature sequence="c o n t r a s t _ t h r e s h o l d" replacement="contrast_threshold"/> + <ligature sequence="o r i e n t a t i o n _ a r r o w" replacement="orientation_arrow"/> + <ligature sequence="d e l e t e _ b a c k g r o u n d" replacement="delete_background"/> + <ligature sequence="n e w _ p o i n t _ o n _ p a t h" replacement="new_point_on_path"/> + <ligature sequence="i n s e r t _ b a c k g r o u n d" replacement="insert_background"/> + <ligature sequence="s e l e c t _ b a c k g r o u n d" replacement="select_background"/> + <ligature sequence="s t r o k e _ t o _ o u t l i n e" replacement="stroke_to_outline"/> <ligature sequence="c u r v e _ o r i e n t a t i o n" replacement="curve_orientation"/> - <ligature sequence="s t r o k e _ t o _ o u t l i n e" replacement="stroke_to_outline"/> - <ligature sequence="s e l e c t _ b a c k g r o u n d" replacement="select_background"/> - <ligature sequence="i n s e r t _ b a c k g r o u n d" replacement="insert_background"/> - <ligature sequence="n e w _ p o i n t _ o n _ p a t h" replacement="new_point_on_path"/> - <ligature sequence="d e l e t e _ b a c k g r o u n d" replacement="delete_background"/> - <ligature sequence="o r i e n t a t i o n _ a r r o w" replacement="orientation_arrow"/> - <ligature sequence="o r i e n t a t i o n _ b o t h" replacement="orientation_both"/> - <ligature sequence="q u a d r a t i c _ p o i n t s" replacement="quadratic_points"/> <ligature sequence="s c a l e _ b a c k g r o u n d" replacement="scale_background"/> - <ligature sequence="z o o m _ b o u n d a r i e s" replacement="zoom_boundaries"/> - <ligature sequence="s h o w _ b a c k g r o u n d" replacement="show_background"/> - <ligature sequence="f l i p _ h o r i z o n t a l" replacement="flip_horizontal"/> + <ligature sequence="q u a d r a t i c _ p o i n t s" replacement="quadratic_points"/> + <ligature sequence="o r i e n t a t i o n _ b o t h" replacement="orientation_both"/> + <ligature sequence="r e s i z e _ o v e r v i e w" replacement="resize_overview"/> + <ligature sequence="l i n e _ c a p _ s q u a r e" replacement="line_cap_square"/> <ligature sequence="m o v e _ b a c k g r o u n d" replacement="move_background"/> - <ligature sequence="l i n e _ c a p _ s q u a r e" replacement="line_cap_square"/> - <ligature sequence="r e s i z e _ o v e r v i e w" replacement="resize_overview"/> - <ligature sequence="f i l l _ o p e n _ p a t h" replacement="fill_open_path"/> - <ligature sequence="u p d a t e _ w e b v i e w" replacement="update_webview"/> - <ligature sequence="c u t _ b a c k g r o u n d" replacement="cut_background"/> - <ligature sequence="i n s e r t _ u n i c h a r" replacement="insert_unichar"/> + <ligature sequence="f l i p _ h o r i z o n t a l" replacement="flip_horizontal"/> + <ligature sequence="s h o w _ b a c k g r o u n d" replacement="show_background"/> + <ligature sequence="z o o m _ b o u n d a r i e s" replacement="zoom_boundaries"/> <ligature sequence="l i n e _ c a p _ r o u n d" replacement="line_cap_round"/> - <ligature sequence="a d d _ n e w _ t h e m e" replacement="add_new_theme"/> - <ligature sequence="k e r n i n g _ c l a s s" replacement="kerning_class"/> - <ligature sequence="d o u b l e _ p o i n t s" replacement="double_points"/> - <ligature sequence="c o n v e r t _ p o i n t" replacement="convert_point"/> - <ligature sequence="d e l e t e _ b u t t o n" replacement="delete_button"/> - <ligature sequence="f l i p _ v e r t i c a l" replacement="flip_vertical"/> - <ligature sequence="d r o p d o w n _ m e n u" replacement="dropdown_menu"/> - <ligature sequence="r e s i z e _ h a n d l e" replacement="resize_handle"/> - <ligature sequence="l i n e _ c a p _ b u t t" replacement="line_cap_butt"/> - <ligature sequence="l a y e r _ v i s i b l e" replacement="layer_visible"/> + <ligature sequence="i n s e r t _ u n i c h a r" replacement="insert_unichar"/> + <ligature sequence="c u t _ b a c k g r o u n d" replacement="cut_background"/> + <ligature sequence="u p d a t e _ w e b v i e w" replacement="update_webview"/> + <ligature sequence="f i l l _ o p e n _ p a t h" replacement="fill_open_path"/> <ligature sequence="s k e w _ o v e r v i e w" replacement="skew_overview"/> - <ligature sequence="a p p l y _ s t r o k e" replacement="apply_stroke"/> - <ligature sequence="e x p o r t _ f o n t s" replacement="export_fonts"/> - <ligature sequence="r e v e r s e _ p a t h" replacement="reverse_path"/> - <ligature sequence="c u b i c _ p o i n t s" replacement="cubic_points"/> - <ligature sequence="x _ c o o r d i n a t e" replacement="x_coordinate"/> - <ligature sequence="y _ c o o r d i n a t e" replacement="y_coordinate"/> + <ligature sequence="l a y e r _ v i s i b l e" replacement="layer_visible"/> + <ligature sequence="l i n e _ c a p _ b u t t" replacement="line_cap_butt"/> + <ligature sequence="r e s i z e _ h a n d l e" replacement="resize_handle"/> + <ligature sequence="d r o p d o w n _ m e n u" replacement="dropdown_menu"/> + <ligature sequence="f l i p _ v e r t i c a l" replacement="flip_vertical"/> + <ligature sequence="d e l e t e _ b u t t o n" replacement="delete_button"/> + <ligature sequence="c o n v e r t _ p o i n t" replacement="convert_point"/> + <ligature sequence="d o u b l e _ p o i n t s" replacement="double_points"/> + <ligature sequence="k e r n i n g _ c l a s s" replacement="kerning_class"/> + <ligature sequence="a d d _ n e w _ t h e m e" replacement="add_new_theme"/> <ligature sequence="l a y e r _ h i d d e n" replacement="layer_hidden"/> - <ligature sequence="m o v e _ c a n v a s" replacement="move_canvas"/> - <ligature sequence="s p i n _ b u t t o n" replacement="spin_button"/> - <ligature sequence="c r e a t e _ l i n e" replacement="create_line"/> - <ligature sequence="b e z i e r _ l i n e" replacement="bezier_line"/> - <ligature sequence="r i g h t _ a r r o w" replacement="right_arrow"/> - <ligature sequence="b e z i e r _ t o o l" replacement="bezier_tool"/> - <ligature sequence="s h o w _ l a y e r s" replacement="show_layers"/> + <ligature sequence="y _ c o o r d i n a t e" replacement="y_coordinate"/> + <ligature sequence="x _ c o o r d i n a t e" replacement="x_coordinate"/> + <ligature sequence="c u b i c _ p o i n t s" replacement="cubic_points"/> + <ligature sequence="r e v e r s e _ p a t h" replacement="reverse_path"/> + <ligature sequence="e x p o r t _ f o n t s" replacement="export_fonts"/> + <ligature sequence="a p p l y _ s t r o k e" replacement="apply_stroke"/> <ligature sequence="f u l l _ h e i g h t" replacement="full_height"/> - <ligature sequence="f u l l _ g l y p h" replacement="full_glyph"/> - <ligature sequence="p o i n t _ t o o l" replacement="point_tool"/> - <ligature sequence="s e l e c t _ a l l" replacement="select_all"/> - <ligature sequence="m o v e _ l a y e r" replacement="move_layer"/> - <ligature sequence="h e l p _ l i n e s" replacement="help_lines"/> - <ligature sequence="l e f t _ a r r o w" replacement="left_arrow"/> + <ligature sequence="s h o w _ l a y e r s" replacement="show_layers"/> + <ligature sequence="b e z i e r _ t o o l" replacement="bezier_tool"/> + <ligature sequence="r i g h t _ a r r o w" replacement="right_arrow"/> + <ligature sequence="b e z i e r _ l i n e" replacement="bezier_line"/> + <ligature sequence="c r e a t e _ l i n e" replacement="create_line"/> + <ligature sequence="s p i n _ b u t t o n" replacement="spin_button"/> + <ligature sequence="m o v e _ c a n v a s" replacement="move_canvas"/> <ligature sequence="c l o s e _ p a t h" replacement="close_path"/> - <ligature sequence="t r a n s f o r m" replacement="transform"/> - <ligature sequence="a d d _ l a y e r" replacement="add_layer"/> - <ligature sequence="o p e n _ f o n t" replacement="open_font"/> - <ligature sequence="m e n u _ i c o n" replacement="menu_icon"/> - <ligature sequence="t t f _ u n i t s" replacement="ttf_units"/> - <ligature sequence="r e c t a n g l e" replacement="rectangle"/> - <ligature sequence="z o o m _ t o o l" replacement="zoom_tool"/> - <ligature sequence="s y m m e t r i c" replacement="symmetric"/> - <ligature sequence="t i e _ p o i n t" replacement="tie_point"/> - <ligature sequence="u n d o _ t o o l" replacement="undo_tool"/> - <ligature sequence="a u t o t r a c e" replacement="autotrace"/> - <ligature sequence="s h o w _ g r i d" replacement="show_grid"/> - <ligature sequence="i n f o _ i c o n" replacement="info_icon"/> - <ligature sequence="s a v e _ f o n t" replacement="save_font"/> - <ligature sequence="l o c k _ g r i d" replacement="lock_grid"/> + <ligature sequence="l e f t _ a r r o w" replacement="left_arrow"/> + <ligature sequence="h e l p _ l i n e s" replacement="help_lines"/> + <ligature sequence="m o v e _ l a y e r" replacement="move_layer"/> + <ligature sequence="s e l e c t _ a l l" replacement="select_all"/> + <ligature sequence="p o i n t _ t o o l" replacement="point_tool"/> + <ligature sequence="f u l l _ g l y p h" replacement="full_glyph"/> <ligature sequence="a l t e r n a t e" replacement="alternate"/> - <ligature sequence="n e w _ f o n t" replacement="new_font"/> - <ligature sequence="p r o g r e s s" replacement="progress"/> - <ligature sequence="z o o m _ 1 _ 1" replacement="zoom_1_1"/> - <ligature sequence="p e n _ t o o l" replacement="pen_tool"/> - <ligature sequence="r o t a t i o n" replacement="rotation"/> - <ligature sequence="z o o m _ o u t" replacement="zoom_out"/> + <ligature sequence="l o c k _ g r i d" replacement="lock_grid"/> + <ligature sequence="s a v e _ f o n t" replacement="save_font"/> + <ligature sequence="i n f o _ i c o n" replacement="info_icon"/> + <ligature sequence="s h o w _ g r i d" replacement="show_grid"/> + <ligature sequence="a u t o t r a c e" replacement="autotrace"/> + <ligature sequence="u n d o _ t o o l" replacement="undo_tool"/> + <ligature sequence="t i e _ p o i n t" replacement="tie_point"/> + <ligature sequence="s y m m e t r i c" replacement="symmetric"/> + <ligature sequence="z o o m _ t o o l" replacement="zoom_tool"/> + <ligature sequence="r e c t a n g l e" replacement="rectangle"/> + <ligature sequence="t t f _ u n i t s" replacement="ttf_units"/> + <ligature sequence="m e n u _ i c o n" replacement="menu_icon"/> + <ligature sequence="o p e n _ f o n t" replacement="open_font"/> + <ligature sequence="a d d _ l a y e r" replacement="add_layer"/> + <ligature sequence="t r a n s f o r m" replacement="transform"/> <ligature sequence="s e t t i n g s" replacement="settings"/> + <ligature sequence="z o o m _ o u t" replacement="zoom_out"/> + <ligature sequence="r o t a t i o n" replacement="rotation"/> + <ligature sequence="p e n _ t o o l" replacement="pen_tool"/> + <ligature sequence="z o o m _ 1 _ 1" replacement="zoom_1_1"/> + <ligature sequence="p r o g r e s s" replacement="progress"/> + <ligature sequence="n e w _ f o n t" replacement="new_font"/> <ligature sequence="z o o m _ i n" replacement="zoom_in"/> - <ligature sequence="s e a r c h" replacement="search"/> - <ligature sequence="c i r c l e" replacement="circle"/> - <ligature sequence="r e s i z e" replacement="resize"/> <ligature sequence="h e i g h t" replacement="height"/> - <ligature sequence="c l o s e" replacement="close"/> - <ligature sequence="t r a c k" replacement="track"/> - <ligature sequence="w i d t h" replacement="width"/> + <ligature sequence="r e s i z e" replacement="resize"/> + <ligature sequence="c i r c l e" replacement="circle"/> + <ligature sequence="s e a r c h" replacement="search"/> <ligature sequence="t h e m e" replacement="theme"/> - <ligature sequence="s t o p" replacement="stop"/> - <ligature sequence="n e x t" replacement="next"/> - <ligature sequence="p r e v" replacement="prev"/> - <ligature sequence="m o v e" replacement="move"/> + <ligature sequence="w i d t h" replacement="width"/> + <ligature sequence="t r a c k" replacement="track"/> + <ligature sequence="c l o s e" replacement="close"/> <ligature sequence="s k e w" replacement="skew"/> + <ligature sequence="m o v e" replacement="move"/> + <ligature sequence="p r e v" replacement="prev"/> + <ligature sequence="n e x t" replacement="next"/> + <ligature sequence="s t o p" replacement="stop"/> <kerning left="settings" right="l" hadjustment="3.8289794922" /> </font>