Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
fontsimport [2016/09/24 15:52]
christian
fontsimport [2023/01/05 20:29] (current)
christian
Line 14: Line 14:
 </code> </code>
  
-The method #loadedFonts loads the fonts on demand. When the shared variable LoadedFonts is nil, all methods are evaluated which are tagged by the #font: pragma.+The method #loadedFonts loads the fonts on demand. When the shared variable LoadedFonts is nil, all class methods are evaluated which are tagged by the #font: pragma. 
 + 
 +Package [Fonts Development] adds some import helpers for OpenTalk and Type-1 (CustomFont) Fonts: 
 + 
 +<code smalltalk> 
 +Graphics.Fonts.OpenTalk.Font importFile: aFilename in: aPackagenameSymbol. 
 +Graphics.Fonts.OpenTalk.Font importAllIn: aDirectoryName into: aPackagenameSymbol. 
 +Graphics.Fonts.OpenTalk.Font importInstalledWindowsFont: aFontBaseFilename in: aPackagenameSymbol. 
 +"and" 
 +Graphics.Fonts.CustomFont import: filenameTrunk as: selectorSymbol. 
 +</code> 
 + 
 +For example when you add the 'MICRDemoCheckPrixa.otf' OpenType(PS) font file (a demo font for MICR) with: 
 + 
 +<code smalltalk> 
 +Graphics.Fonts.OpenType.Font importFile: 'MICRDemoCheckPrixa.otf' asFilename in: #'Fonts Development'
 +</code> 
 + 
 +This creates a class method for Graphics.Fonts.OpenType.Font: 
 + 
 +<code smalltalk> 
 +mICRDemoCheckPrixa 
 + <font: #MICRDemoCheckPrixa> 
 + ^self file: 'MICRDemoCheckPrixa.otf' contents: (ByteArray fromASCII85String:  
 + ':K1:h!"/dW!!<3T6UjNf[(sM&!!!IY!!!e,7o2u[lPKXT!!!@R!!!*(:K&o%;0,kH!!!$B!!!",@r5X..."
 +</code> 
 + 
 +The newly imported Font can be accessed by 
 + 
 +<code smalltalk> 
 +Graphics.Fonts.Font fontAt: #MICRDemoCheckPrixa. 
 +</code> 
 + 
 +and used in PDF for text as usual by its name: 
  
 <code smalltalk> <code smalltalk>
-Graphics.Fonts.OpenType.Font importFile: 'MICRDemoCheckPrixa.otfasFilename in#'Fonts Development'+| page | 
 +page := Page newInBounds: (0 @ 0 corner: 165 @ 30) colorspace: DeviceCMYK new render: [:renderer | 
 + renderer textObjectDo:
 + renderer setFont: #MICRDemoCheckPrixa size: 14. 
 + renderer add: (NextLineRelative operands: #(10 10)). 
 + renderer showString: '01234567890 / ; : -']]. 
 +page saveAndShowAs: 'demo04b_MICRDemo.pdf'
 </code> </code>
  • fontsimport.1474725132.txt.gz
  • Last modified: 2016/09/24 15:52
  • by christian