Clone in a terminal:
Commit 8079a87
Johan Mattsson - 2016-09-20T11:37:23+00:00
8079a87a146370a65d4501f458f6bee32d4cfc86johan.mattsson.m@gmail.com

Right to left in kerning tab Switch writing direction in the kerning tab.

Changed files (3)

Diff

diff --git a/libbirdfont/KerningDisplay.vala b/libbirdfont/KerningDisplay.valaindex edd7206..54dede3 100644--- a/libbirdfont/KerningDisplay.vala+++ b/libbirdfont/KerningDisplay.vala@@ -45,6 +45,10 @@ public class KerningDisplay : FontDisplay { 	 	public bool adjust_side_bearings = false; 	public bool right_side_bearing = true;++	public bool right_to_left = false; 	+	+	WidgetAllocation allocation = new WidgetAllocation (); 	 	public KerningDisplay () { 		GlyphSequence w = new GlyphSequence ();@@ -133,6 +137,8 @@ public class KerningDisplay : FontDisplay { 		double item_size = 1.0 / KerningTools.font_size; 		double item_size2 = 2.0 / KerningTools.font_size; +		this.allocation = allocation;+ 		i = 0; 		 		// bg color@@ -156,6 +162,10 @@ public class KerningDisplay : FontDisplay { 		prev = null; 		kern = 0; 		+		if (right_to_left) {+			x = (allocation.width - 20) / KerningTools.font_size;+		}+				 		foreach (GlyphSequence word in get_all_rows ()) { 			wi = 0; 			word_with_ligatures = word.process_ligatures (font);@@ -188,7 +198,13 @@ public class KerningDisplay : FontDisplay {  					cr.save (); 					glyph.add_help_lines ();-					cr.translate (kern + x - glyph.get_lsb () - Glyph.xc (), glyph.get_baseline () + y  - Glyph.yc ());++					if (right_to_left) {+						cr.translate (x - kern - glyph.get_lsb () - glyph.get_width () - Glyph.xc (), glyph.get_baseline () + y  - Glyph.yc ());+					} else {						+						cr.translate (kern + x - glyph.get_lsb () - Glyph.xc (), glyph.get_baseline () + y  - Glyph.yc ());+					}+					 					glyph.draw_paths (cr); 					cr.restore (); 					@@ -197,7 +213,11 @@ public class KerningDisplay : FontDisplay { 				 				// handle 				if (first_row && (active_handle == i || selected_handle == i)) {-					x2 = x + kern / 2.0;+					if (right_to_left) {+						x2 = x - kern / 2.0;+					} else {+						x2 = x + kern / 2.0;+					} 					 					cr.save (); 					@@ -247,7 +267,11 @@ public class KerningDisplay : FontDisplay { 					cr.restore (); 				}	 				-				x += w + kern;+				if (right_to_left) {+					x -= w + kern;+				} else {+					x += w + kern;+				} 	 				// caption 				if (g == null || ((!)g).is_empty ()) {@@ -281,7 +305,13 @@ public class KerningDisplay : FontDisplay { 			} 						 			y += row_height + 20;-			x = 20;+			+			if (right_to_left) {+				x = (allocation.width - 20) / KerningTools.font_size;+			} else {				+				x = 20;+			}+ 			first_row = false; 			 			if (y > allocation.height) {@@ -772,6 +802,11 @@ public class KerningDisplay : FontDisplay { 			 			k = (ex - last_handle_x) / y; // y-axis is for variable precision 			k /= KerningTools.font_size;++			if (right_to_left) {+				k *= -1;+			}			+			 			set_space (selected_handle, k); 			GlyphCanvas.redraw (); 		}@@ -789,7 +824,11 @@ public class KerningDisplay : FontDisplay { 		Glyph glyph = new Glyph.no_lines (""); 		double fs = KerningTools.font_size; 		double x = 20;-				++		if (right_to_left) {+			x = (allocation.width - 20) / KerningTools.font_size;+		}		+			 		GlyphRange? gr_left, gr_right; 		 		Glyph? prev = null;@@ -825,8 +864,12 @@ public class KerningDisplay : FontDisplay {  				kern = get_kerning_for_pair (((!)prev).get_name (), ((!)g).get_name (), gr_left, gr_right); 			}-							-			d = Math.pow (fs * (x + kern) - ex, 2);+			+			if (right_to_left) {+				d = Math.pow (fs * (x - kern) - ex, 2);+			} else {				+				d = Math.pow (fs * (x + kern) - ex, 2);+			} 			 			if (d < min) { 				min = d;@@ -848,7 +891,13 @@ public class KerningDisplay : FontDisplay { 			} 			 			prev = g;-			x += w + kern;+			+			if (right_to_left) {+				x -= w + kern;+			} else {+				x += w + kern;+			}+			 			i++; 			col_index++; 		}diff --git a/libbirdfont/KerningTools.vala b/libbirdfont/KerningTools.valaindex 5c63ae3..8b996ce 100644--- a/libbirdfont/KerningTools.vala+++ b/libbirdfont/KerningTools.vala@@ -127,6 +127,15 @@ public class KerningTools : ToolCollection  { 		}); 		kerning_tools.add_tool (insert_unicode); +		Tool right_to_left = new Tool ("right_to_left", t_("Right to left"));+		right_to_left.select_action.connect ((self) => {+			KerningDisplay d = MainWindow.get_kerning_display ();+			d.right_to_left = !d.right_to_left;+			right_to_left.set_selected (d.right_to_left);+			GlyphCanvas.redraw ();+		});+		kerning_tools.add_tool (right_to_left);+		 		string empty_kerning_text = t_("Open a text file with kerning strings first."); 		 		previous_kerning_string = new Tool ("previous_kerning_string", t_("Previous kerning string"));diff --git a/resources/icons.bf b/resources/icons.bfindex 7443a06..f7fa88b 100644--- a/resources/icons.bf+++ b/resources/icons.bf@@ -1,6 +1,6 @@ <?xml version="1.0" encoding="utf-8" standalone="yes"?> <font>-<format>2.1</format>+<format>2.2</format>  <postscript_name>BirdfontIcons</postscript_name> <name>Birdfont Icons</name>@@ -38,6 +38,22 @@ GNU Lesser General Public License</copyright> <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 L 15.0000000000,10.0000000000 L 15.0000000000,44.0000000000 L -15.0000000000,44.0000000000 L -15.0000000000,10.0000000000" />+			<path data="S -20.0000000000,49.0000000000 L 20.0000000000,49.0000000000 L 20.0000000000,5.0000000000 L -20.0000000000,5.0000000000 L -20.0000000000,49.0000000000" />+		</layer>+	</glyph>+</collection>+ <collection unicode="U+30"> 	<selected id="1"/> 	<glyph id="1" left="-28" right="28">@@ -324,7 +340,6 @@ GNU Lesser General Public License</copyright> 			<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>@@ -503,6 +518,18 @@ GNU Lesser General Public License</copyright> 	</glyph> </collection> +<collection name="close">+	<selected id="0"/>+	<glyph id="0" left="-28" right="28.419182948490214">+		<layer name= "Layer" visible="true">+			<path data="B 28.0212870839,35.2058976055 C 28.0212870839,24.7263578602 19.4616696252,16.1667539275 8.9821366429,16.1667539275 C -1.4973902527,16.1667539275 -9.9805477504,24.7263578602 -9.9805477504,35.2058976055 C -9.9805477504,45.6854373507 -1.4973902527,54.1685522418 8.9821366429,54.1685522418 C 19.4616696252,54.1685522418 28.0212870839,45.6854373507 28.0212870839,35.2058976055" />+			<path data="B -7.5337498733,35.2058976055 C -7.5337498733,26.0487188078 -0.1750401258,18.6135240765 8.9821366429,18.6135240765 C 18.1393154406,18.6135240765 25.5744898830,26.0487188078 25.5744898830,35.2058976055 C 25.5744898830,44.3630764031 18.1393154406,51.7217820928 8.9821366429,51.7217820928 C -0.1750401258,51.7217820928 -7.5337498733,44.3630764031 -7.5337498733,35.2058976055" />+			<path data="B 1.5364891996,45.0349793170 M 19.5360480338,27.3782692224 M 17.2353252034,25.0328721622 M -0.7642336309,42.6895822568 M 1.5364891996,45.0349793170" />+			<path data="B -1.2533789606,26.9501777496 M 16.4033311340,44.9497365840 M 18.7487281942,42.6490137535 M 1.0920180996,24.6494549192 M -1.2533789606,26.9501777496" />+		</layer>+	</glyph>+</collection>+ <collection name="close_path"> 	<selected id="1"/> 	<glyph id="1" left="-28" right="28.419182948490214">@@ -1290,6 +1317,18 @@ GNU Lesser General Public License</copyright> 	</glyph> </collection> +<collection name="right_to_left">+	<selected id="0"/>+	<glyph id="0" left="-28" right="28">+		<layer name= "Layer" visible="true">+			<path data="B -16.5660050993,25.0660007440 M -22.4601324350,25.0660007440 M -22.4601324350,14.9150371313 M -25.7863310218,14.9150371313 M -25.7863310218,40.0080885030 M -17.4794349467,40.0080885030 Q -13.2398065125,40.0080885030 -10.9648793467,38.0778523340 Q -8.6727278669,36.1476185182 -8.6727278669,32.4594905022 Q -8.6727278669,30.1156331374 -9.9480565539,28.3749750167 Q -11.2061609268,26.6343168959 -13.4638402480,25.7726046987 M -7.5697364427,15.1218465527 M -7.5697364427,14.9150136008 M -11.1199922954,14.9150136008 M -16.5660050993,25.0660007440" />+			<path data="B -22.4601324350,27.7717522422 M -17.3760184707,27.7717522422 Q -14.9115297282,27.7717522422 -13.4638402480,29.0470856353 Q -11.9989499842,30.3224213814 -11.9989499842,32.4594669717 Q -11.9989499842,34.7860882571 -13.3949194612,36.0269541977 Q -14.7736646241,37.2678201382 -17.3932663153,37.2850538645 M -22.4601324350,37.2850538645 M -22.4601324350,27.7717522422" />+			<path data="B 11.9049625094,37.2850773949 M 3.8393244838,37.2850773949 M 3.8393244838,14.9150371313 M 0.5475980556,14.9150371313 M 0.5475980556,37.2850773949 M -7.5008156559,37.2850773949 M -7.5008156559,40.0080885030 M 11.9049625094,40.0080885030 M 11.9049625094,37.2850773949" />+			<path data="B 18.9882263702,17.6208074539 M 30.8798504567,17.6208074539 M 30.8798504567,14.9150371313 M 15.6620042530,14.9150371313 M 15.6620042530,40.0080885030 M 18.9882263702,40.0080885030 M 18.9882263702,17.6208074539" />+		</layer>+	</glyph>+</collection>+ <collection name="rotation"> 	<selected id="1"/> 	<glyph id="1" left="-28" right="45.892473118279582">@@ -1519,6 +1558,16 @@ GNU Lesser General Public License</copyright> 	</glyph> </collection> +<collection name="svg_to_birdfont">+	<selected id="0"/>+	<glyph id="0" left="-28" right="28">+		<layer name= "Layer" visible="true">+			<path data="B 16.7076588131,10.8513073898 C 15.7231524448,9.9469553352 15.5807509176,9.7659357149 14.6423764406,9.0488058549 C 13.5057311121,8.1801523211 12.2905854087,7.4659307350 11.0296823768,6.7964067053 C 10.1563761363,6.3821294164 9.9754061531,6.2785620276 9.0758899297,5.9227415545 C 8.1391541626,5.5521981945 7.1848972751,5.2666070701 6.2150274381,4.9992162905 C 4.4730691430,4.5966439491 2.7426117470,4.3231832970 0.9471021989,4.3231800769 C -1.4036679044,4.3232109113 -3.6691272290,4.7738560147 -5.9066385128,5.4613695897 C -6.8553959447,5.7960233026 -7.7869532369,6.1479503792 -8.6961864831,6.5814537019 C -9.5319370708,6.9799220357 -9.7185424877,7.1024922077 -10.5350789897,7.5599247218 C -12.0900969403,8.5275575451 -13.4800272350,9.5957176587 -14.8133706455,10.8514192213 C -16.5146470739,12.4536287141 -17.7817578316,14.4830758386 -18.8683932948,16.5295176231 C -19.2826705837,17.4028238636 -19.3862379725,17.5837938468 -19.7420584456,18.4833100702 C -20.1126018056,19.4200458373 -20.3981929300,20.3743027248 -20.6655837096,21.3441725618 C -20.9371873502,22.5194202530 -21.1922901929,23.7071010331 -21.2691753057,24.9146283775 C -21.3051598316,25.4797871898 -21.3174741666,26.0462045777 -21.3416199229,26.6119928346 C -21.4401332657,28.9203774571 -20.8753555454,31.2790597693 -20.2034304103,33.4658385129 C -19.8687766973,34.4145959449 -19.5168496208,35.3461532370 -19.0833462980,36.2553864833 C -18.6848779642,37.0911370709 -18.5623077921,37.2777424878 -18.1048752781,38.0942789898 C -17.1372424548,39.6492969403 -16.0690823413,41.0392272350 -14.8133807788,42.3725706454 C -13.2111712859,44.0738470739 -11.1817241614,45.3409578317 -9.1352823768,46.4275932949 C -8.2619761363,46.8418705838 -8.0810061531,46.9454379726 -7.1814899297,47.3012584457 C -6.2447541626,47.6718018056 -5.2904972750,47.9573929301 -4.3206274381,48.2247837096 C -2.5786584927,48.6273585123 -0.8481867941,48.9008238787 0.9473342165,48.9008199226 C 3.2980895957,48.9007907599 5.5635418475,48.4501394934 7.8010385128,47.7626304102 C 8.7497959448,47.4279766973 9.6813532369,47.0760496207 10.5905864832,46.6425462979 C 11.4263370708,46.2440779641 11.6129424877,46.1215077921 12.4294789897,45.6640752780 C 14.8191220160,44.1770847083 16.1026710812,43.1310420349 17.8473979348,41.1319571268 C 18.0793416679,40.8661990711 18.2962073608,40.5874428511 18.5103941452,40.3071764406 C 19.3790476789,39.1705311121 20.0932692651,37.9553854086 20.7627932948,36.6944823766 C 21.1770705837,35.8211761362 21.2806379725,35.6402061530 21.6364584456,34.7406899295 C 22.0070018056,33.8039541625 22.2925929300,32.8496972749 22.5599837096,31.8798274380 C 22.8315873502,30.7045797468 23.0866901929,29.5168989667 23.1635753057,28.3093716224 C 23.1995598316,27.7442128102 23.2118741666,27.1777954223 23.2360199229,26.6120071654 C 23.3345332657,24.3036225430 22.7697555453,21.9449402309 22.0978304102,19.7581614874 C 21.7631766973,18.8094040554 21.4112496207,17.8778467632 20.9777462980,16.9686135170 C 20.5792779642,16.1328629294 20.4567077921,15.9462575124 19.9992752781,15.1297210104 C 18.0896264251,12.0608521439 16.7076453147,10.8512938918 16.7076588131,10.8513073898" />+			<path data="B -10.7167370146,41.6381552425 C -10.9543525818,41.4581381700 -11.1911866942,41.2764151802 -11.4161570286,41.0808246569 C -12.0510542281,40.5288413219 -13.4564483359,39.3963571666 -15.2718705294,36.5016132704 C -15.6694354900,35.7972937754 -15.7759432590,35.6363245264 -16.1223858403,34.9155308315 C -16.4996302761,34.1306521083 -16.8063480434,33.3261549289 -17.0981513479,32.5068067383 C -17.6827272845,30.6251214234 -18.1721511604,28.6004264355 -18.0916199229,26.6120071654 C -18.0302404652,25.0964698372 -17.8677884185,23.6812682559 -17.5311832972,22.2032616462 C -17.3037766092,21.3678388326 -17.0604926301,20.5456993181 -16.7442273761,19.7385028358 C -16.4393854186,18.9604617684 -16.3507974378,18.8045239866 -15.9955416831,18.0491306059 C -15.0639292984,16.2800280465 -13.9786861469,14.5367233233 -12.5152837399,13.1495263933 C -11.4051375821,12.0971901838 -10.2380530103,11.2054825747 -8.9424132704,10.3929294705 C -8.2380937753,9.9953645099 -8.0771245263,9.8888567409 -7.3563308314,9.5424141597 C -6.5714521083,9.1651697239 -5.7669549288,8.8584519565 -4.9476067382,8.5666486521 C -3.0240124811,7.9690530257 -1.0762162305,7.5732071190 0.9471311612,7.5731800767 C 2.4488258668,7.5731898304 3.8975899190,7.8014885861 5.3559383537,8.1336167028 C 6.1913611673,8.3610233908 7.0135006818,8.6043073700 7.8206971641,8.9205726240 C 8.5987382315,9.2254145815 8.7546760133,9.3140025623 9.5100693939,9.6692583169 C 10.5916854840,10.2388391701 11.6347786373,10.8461576283 12.6111370146,11.5858447576 C 12.8309307109,11.7523600168 13.6671739867,12.4070238405 14.4096736066,13.1495162601 C 14.9705294099,13.7411876165 15.1018887024,13.8563899675 15.6128330947,14.4876209308 C 16.1875397432,15.1976250661 16.6817297752,15.9497722957 17.1662705293,16.7223867297 C 2.1312000000,17.6136000000 -8.8800000000,29.0984000000 -10.7167370146,41.6381552425" />+		</layer>+	</glyph>+</collection>+ <collection name="symmetric"> 	<selected id="1"/> 	<glyph id="1" left="-40.784482758620676" right="42.890804597701162">@@ -1788,6 +1837,7 @@ GNU Lesser General Public License</copyright> <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="s v g _ t o _ b i r d f o n t" replacement="svg_to_birdfont"/> <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"/>@@ -1799,6 +1849,7 @@ GNU Lesser General Public License</copyright> <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="l i n e _ c a p _ r o u n d" replacement="line_cap_round"/>+<ligature sequence="r i g h t _ t o _ l e f t" replacement="right_to_left"/> <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"/>@@ -1860,6 +1911,7 @@ GNU Lesser General Public License</copyright> <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="t h e m e" replacement="theme"/>

Contact

Email: johan.mattsson.m@gmail.com
Mastodon: typo.social/@birdfont
GitHub: johanmattssonm
LinkedIn: johan-mattsson-2ab324112