Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
fontsimport [2016/09/24 15:33] christian created |
fontsimport [2023/01/05 20:29] (current) christian |
||
---|---|---|---|
Line 3: | Line 3: | ||
How can you use your own font? | How can you use your own font? | ||
- | The PDFtalk library keeps a list of loaded fonts. These are Graphics.Fonts.Font objects readily read from its source file and interpreted as object(s). Since the process takes time, the loaded fonts are cached in the LoadedObjects | + | The PDFtalk library keeps a list of loaded fonts. These are Graphics.Fonts.Font objects readily read from its source file and interpreted as object(s). Since the process takes time, the loaded fonts are cached in the Graphics.Fonts.Font.LoadedFonts shared (class) variable. |
+ | |||
+ | Useful methods are: | ||
+ | |||
+ | <code smalltalk> | ||
+ | Graphics.Fonts.Font loadedFonts. | ||
+ | Graphics.Fonts.Font fontAt: # | ||
+ | Graphics.Fonts.Font fontAt: #' | ||
+ | Graphics.Fonts.Font resetLoadedFonts. | ||
+ | </ | ||
+ | |||
+ | The method # | ||
+ | |||
+ | 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: | ||
+ | Graphics.Fonts.OpenTalk.Font importInstalledWindowsFont: | ||
+ | " | ||
+ | Graphics.Fonts.CustomFont import: filenameTrunk as: selectorSymbol. | ||
+ | </ | ||
+ | |||
+ | For example when you add the ' | ||
+ | |||
+ | <code smalltalk> | ||
+ | Graphics.Fonts.OpenType.Font importFile: ' | ||
+ | </ | ||
+ | |||
+ | This creates a class method for Graphics.Fonts.OpenType.Font: | ||
+ | |||
+ | <code smalltalk> | ||
+ | mICRDemoCheckPrixa | ||
+ | <font: # | ||
+ | ^self file: ' | ||
+ | ': | ||
+ | </ | ||
+ | |||
+ | The newly imported Font can be accessed by | ||
+ | |||
+ | <code smalltalk> | ||
+ | Graphics.Fonts.Font fontAt: # | ||
+ | </ | ||
+ | |||
+ | and used in PDF for text as usual by its name: | ||
<code smalltalk> | <code smalltalk> | ||
- | Graphics.Fonts.OpenType.Font importFile: 'MICRDemoCheckPrixa.otf' | + | | page | |
+ | page := Page newInBounds: | ||
+ | renderer textObjectDo: | ||
+ | renderer setFont: # | ||
+ | renderer add: (NextLineRelative operands: #(10 10)). | ||
+ | renderer showString: '01234567890 / ; : -']]. | ||
+ | page saveAndShowAs: 'demo04b_MICRDemo.pdf' | ||
</ | </ |