Clone in a terminal:
Commit f25040a
Johan Mattsson - 2012-09-12T21:47:17+00:00
f25040a2fe66e9566ddb46dfad3a2a2b2f2200b2johan.mattsson.m@gmail.com

juxtaposition for glyphs

Changed files (4)

Diff

diff --git a/layout/supplement.js b/layout/supplement.jsindex 91e5aa9..77a7260 100644--- a/layout/supplement.js+++ b/layout/supplement.js@@ -3,8 +3,12 @@ function call (command) { 	document.title='done'; } -function update_export_settings () {+function update_text_fields () { 	mess = 'export_name:'; 	mess += document.getElementById('fontname').value; 	call (mess);+	+	mess = 'glyph_sequence:';+	mess += document.getElementById('glyph_sequence').value;+	call (mess);	 }diff --git a/src/Glyph.vala b/src/Glyph.valaindex 807940e..250669c 100644--- a/src/Glyph.vala+++ b/src/Glyph.vala@@ -55,6 +55,10 @@ class Glyph : FontDisplay { 	// The point where edit event begun  	double pointer_begin_x = 0; 	double pointer_begin_y = 0;++	// Current pointer position+	double motion_x = 0;+	double motion_y = 0; 		 	// Zoom area 	double zoom_x1 = 0;@@ -76,13 +80,13 @@ class Glyph : FontDisplay { 	public double left_limit; 	public double right_limit; 	-	// x-height l-bearing etc.+	// x-height, lsb, etc. 	public List<Line> vertical_help_lines = new List<Line> (); 	public List<Line> horizontal_help_lines = new List<Line> (); 	List<Line> all_lines = new List<Line> (); 	// vertical, horzontal and grid lines-	bool show_help_lines = true;           			// grey lines-	bool xheight_lines_visible = false;   		 	// blue lines-	bool margin_boundries_visible = false; 			// red lines+	bool show_help_lines = true;+	bool xheight_lines_visible = false;+	bool margin_boundries_visible = false; 	 	bool unassigned = false; 	public unichar unichar_code = 0;@@ -92,9 +96,8 @@ class Glyph : FontDisplay { 	List<Glyph> undo_list = new List<Glyph> ();  	public List<Kerning> kerning = new List<Kerning> ();--	double motion_x = 0;-	double motion_y = 0;+	+	string glyph_sequence = ""; 	 	public Glyph (string name, unichar unichar_code = 0) { 		this.name = name;@@ -286,6 +289,7 @@ class Glyph : FontDisplay { 	public override void selected_canvas () { 		add_help_lines (); 		KeyBindings.singleton.set_require_modifier (false);+		glyph_sequence = Preferences.get ("glyph_sequence"); 	} 	 	private void remove_lines () {@@ -1319,7 +1323,7 @@ class Glyph : FontDisplay { 		cr.stroke ();		 	} 	-	private void draw_path (Context cr) {+	public void draw_path (Context cr) { 		double left, baseline; 		 		// plot_outline (cr);@@ -1723,6 +1727,68 @@ class Glyph : FontDisplay { 		 		return false; 	}++	public void juxtapose (Allocation allocation, Context cr) {+		string glyph_sequence = Preferences.get ("glyph_sequence");+		unichar c;+		Font font = Supplement.get_current_font ();+		Glyph glyph = MainWindow.get_current_glyph ();+		Glyph juxtaposed;+		StringBuilder current = new StringBuilder ();+		int pos;+		string name;+		double x, kern;+		double left, baseline;+		string last_name;+				+		x = 0;+		+		current.append_unichar (glyph.unichar_code);+		pos = glyph_sequence.index_of (current.str);+		+		baseline = glyph.get_line ("baseline").pos;+		left = glyph.get_line ("left").pos;++		x = glyph.get_width ();+		last_name = glyph.name;+		for (int i = pos + 1; i < glyph_sequence.char_count (); i++) {+			c = glyph_sequence.get_char (i);+			name = font.get_name_for_character (c);			+			juxtaposed = (font.has_glyph (name)) ? (!) font.get_glyph (name) : font.get_not_def_character ();+			kern = font.get_kerning (last_name, name);++			cr.save ();+			cr.scale (glyph.view_zoom, glyph.view_zoom);+			cr.translate (-glyph.view_offset_x, -glyph.view_offset_y);++			Svg.draw_svg_path (cr, juxtaposed.get_svg_data (), Glyph.xc () + left + x + kern, Glyph.yc () + baseline, Glyph.SCALE);+			cr.restore ();+			+			x += juxtaposed.get_width () + font.get_kerning (glyph.name, name) + kern;+			last_name = name;+		}+		+		x = 0;+		last_name = glyph.name;+		for (int i = pos - 1; i >= 0; i--) {+			c = glyph_sequence.get_char (i);+			name = font.get_name_for_character (c);			+			juxtaposed = (font.has_glyph (name)) ? (!) font.get_glyph (name) : font.get_not_def_character ();+			kern = font.get_kerning (name, last_name);+			+			x -= juxtaposed.get_width ();+			x -= kern;+			+			cr.save ();+			cr.scale (glyph.view_zoom, glyph.view_zoom);+			cr.translate (-glyph.view_offset_x, -glyph.view_offset_y);++			Svg.draw_svg_path (cr, juxtaposed.get_svg_data (), Glyph.xc () + left + x, Glyph.yc () + baseline, Glyph.SCALE);+			cr.restore ();+			+			last_name = name;+		}	+	} }  }diff --git a/src/GlyphCanvas.vala b/src/GlyphCanvas.valaindex 11c6a51..e9e6647 100644--- a/src/GlyphCanvas.vala+++ b/src/GlyphCanvas.vala@@ -77,6 +77,10 @@ class GlyphCanvas : DrawingArea  { 		
 				current_display.draw (allocation, c);
 				
+				if (current_display is Glyph) {
+					((Glyph) current_display).juxtapose (allocation, c);
+				}
+				
 				cw.save ();
 				cw.set_source_surface (c.get_target (), 0, 0);
 				cw.paint ();
diff --git a/src/MenuTab.vala b/src/MenuTab.valaindex acabd53..5466899 100644--- a/src/MenuTab.vala+++ b/src/MenuTab.vala@@ -54,6 +54,10 @@ class MenuTab : FontDisplay { 			} 		}); +		add_html_callback ("glyph_sequence", (val) => {+			Preferences.set ("glyph_sequence", val);+		});+ 		add_html_callback ("newfile", (val) => { 			new_file (); 		});@@ -101,7 +105,7 @@ class MenuTab : FontDisplay { 	<script type="text/javascript" src="supplement.js"></script> 	<style type="text/css">@import url("style.css");</style> 	<script type="text/javascript">-		document.onkeyup = update_export_settings; +		document.onkeyup = update_text_fields;  	</script> </head> <body>@@ -125,7 +129,7 @@ class MenuTab : FontDisplay { 				 c.append (""" 				<h3>Name</h3>-				<input class="text" type="text" id="fontname" value=""" + "\"" + f.get_name () + "\"" + """ onchange="update_export_settings ();"/><br />+				<input class="text" type="text" id="fontname" value=""" + "\"" + f.get_name () + "\"" + """ onchange="update_text_fields ();"/><br /> 				 				<input class="button" type="button" value="Export" id="export_button" onclick="call ('export:fonts');" onmouseover="call ('help:(Ctrl+e) Export SVG, TTF & EOF fonts');"/> 				<input class="button" type="button" value="Preview" id="preview_button" onclick="call ('preview:fonts');" onmouseover="call ('help:(Ctrl+p) Export SVG font and view the result');"/><br />@@ -135,6 +139,13 @@ c.append (""" 			</form>  		</div> 	</div>++	<div class="inner_format_box">+		<div class="heading"><h2>Edit</h2></div>+		+		<h3>Glyph sequence</h3>+		<input class="text" type="text" id="glyph_sequence" value=""" + "\"" + Preferences.get ("glyph_sequence") + "\"" + """ onchange="update_text_fields ();"/><br />+	</div> 	 	<br class="clearBoth" /> 	

Contact

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