2009-01-21 20:34:42 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								IN:  ui.text  
						 
					
						
							
								
									
										
										
										
											2010-02-08 01:18:51 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								USING:  help.markup  help.syntax  kernel  ui.text.private  strings  math  fonts  images  ;
  
						 
					
						
							
								
									
										
										
										
											2009-01-21 20:34:42 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-10-15 08:44:18 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								HELP:  flush-layout-cache  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Flushes the cache of pre-rendered layouts."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-01-21 20:34:42 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								HELP:  string-width  
						 
					
						
							
								
									
										
										
										
											2009-01-30 04:36:39 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $values { "font"  font } { "string"  string  } { "w"  "a positive integer"  } }
							 
						 
					
						
							
								
									
										
										
										
											2009-01-21 20:34:42 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{ $contract "Outputs the width of a string."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $notes "This is a low-level word; use "  { $link text-width } " instead."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  text-width  
						 
					
						
							
								
									
										
										
										
											2009-01-26 01:36:37 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $values { "font"  font } { "text"  "a string or sequence of strings"  } { "w"  "a positive integer"  } }
							 
						 
					
						
							
								
									
										
										
										
											2009-01-21 20:34:42 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{ $description "Outputs the width of a piece of text."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  string-height  
						 
					
						
							
								
									
										
										
										
											2009-01-30 04:36:39 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $values { "font"  font } { "string"  string  } { "h"  "a positive integer"  } }
							 
						 
					
						
							
								
									
										
										
										
											2009-01-21 20:34:42 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{ $contract "Outputs the height of a string."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $notes "This is a low-level word; use "  { $link text-height } " instead."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  text-height  
						 
					
						
							
								
									
										
										
										
											2009-01-26 01:36:37 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $values { "font"  font } { "text"  "a string or sequence of strings"  } { "h"  "a positive integer"  } }
							 
						 
					
						
							
								
									
										
										
										
											2009-01-21 20:34:42 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{ $description "Outputs the height of a piece of text."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  string-dim  
						 
					
						
							
								
									
										
										
										
											2009-01-30 04:36:39 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $values { "font"  font } { "string"  string  } { "dim"  "a pair of integers"  } }
							 
						 
					
						
							
								
									
										
										
										
											2009-01-21 20:34:42 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{ $contract "Outputs the dimensions of a string."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $notes "This is a low-level word; use "  { $link text-dim } " instead."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  text-dim  
						 
					
						
							
								
									
										
										
										
											2009-01-26 01:36:37 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $values { "font"  font } { "text"  "a string or sequence of strings"  } { "dim"  "a pair of integers"  } }
							 
						 
					
						
							
								
									
										
										
										
											2009-01-21 20:34:42 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{ $description "Outputs the dimensions of a piece of text, which is either a single-line string or an array of lines."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  draw-string  
						 
					
						
							
								
									
										
										
										
											2009-02-10 19:47:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $values { "font"  font } { "string"  string  } }
							 
						 
					
						
							
								
									
										
										
										
											2009-01-21 20:34:42 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{ $contract "Draws a line of text."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  draw-text  
						 
					
						
							
								
									
										
										
										
											2009-02-10 19:47:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $values { "font"  font } { "text"  "a string or an array of strings"  } }
							 
						 
					
						
							
								
									
										
										
										
											2009-01-21 20:34:42 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{ $description "Draws a piece of text."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  x>offset  
						 
					
						
							
								
									
										
										
										
											2009-01-26 01:36:37 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $values { "x"  real  } { "font"  font } { "string"  string  } { "n"  integer  } }
							 
						 
					
						
							
								
									
										
										
										
											2009-01-21 20:34:42 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{ $contract "Outputs the string index closest to the given x co-ordinate."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  offset>x  
						 
					
						
							
								
									
										
										
										
											2009-01-26 01:36:37 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $values { "n"  integer  } { "font"  font } { "string"  string  } { "x"  real  } }
							 
						 
					
						
							
								
									
										
										
										
											2009-01-21 20:34:42 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{ $contract "Outputs the x co-ordinate of the character at the given index."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-02-01 21:32:49 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								HELP:  line-metrics  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "font"  font } { "string"  string  } { "metrics"  line-metrics } }
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 04:04:41 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $contract "Outputs a "  { $link metrics } " object with text measurements."  } ;
 
							 
						 
					
						
							
								
									
										
										
										
											2009-02-01 21:32:49 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2010-02-08 00:40:26 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								HELP:  string>image  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "font"  font } { "string"  string  } { "image"  image } { "loc"  "a pair of real numbers"  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Renders a line of text into an image."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-01-21 20:34:42 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								ARTICLE: "text-rendering"  "Rendering text" 
							 
						 
					
						
							
								
									
										
										
										
											2010-02-07 00:20:54 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								"The "  { $vocab-link "ui.text"  } " vocabulary provides a cross-platform interface to the operating system's native font rendering engine. Currently, it uses Core Text on Mac OS X, Uniscribe on Windows and Pango on X11."  
						 
					
						
							
								
									
										
										
										
											2009-10-01 15:56:36 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $subsections "fonts"  }
							 
						 
					
						
							
								
									
										
										
										
											2009-01-21 20:34:42 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								"Measuring text:"  
						 
					
						
							
								
									
										
										
										
											2009-10-01 15:56:36 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $subsections
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    text-dim
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    text-width
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    text-height
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    line-metrics
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2009-01-21 20:34:42 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								"Converting screen locations to string offsets, and vice versa:"  
						 
					
						
							
								
									
										
										
										
											2009-10-01 15:56:36 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $subsections
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    x>offset
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    offset>x
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2009-01-21 20:34:42 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								"Rendering text:"  
						 
					
						
							
								
									
										
										
										
											2010-02-08 00:40:26 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $subsections draw-text string>image }
							 
						 
					
						
							
								
									
										
										
										
											2009-01-21 20:34:42 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								"Low-level text protocol for UI backends:"  
						 
					
						
							
								
									
										
										
										
											2009-10-01 15:56:36 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $subsections
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    string-width
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    string-height
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    string-dim
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    draw-string
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
									
										
										
										
											2009-01-21 20:34:42 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-07-02 13:31:22 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								ABOUT: "text-rendering"