|
| 1 | +extrafont - 1.2 |
| 2 | +================ |
| 3 | + |
| 4 | +extrafont is a package designed to provide "private fonts" for Tk apps. |
| 5 | + |
| 6 | +"Private fonts" are fonts usually delivered with an app. |
| 7 | +They don't need to be installed in some 'standard' system-wide directories; |
| 8 | +once these fonsts are loaded, they can be used in the same way of pre-installed fonts. |
| 9 | +These loaded fonts are only visible by the process (app) who loaded'em, and then |
| 10 | +disappear when the app terminates. |
| 11 | + |
| 12 | +This package provides an homogeneous multi platform mechamism for such purpose. |
| 13 | +Supported tcltk runtimes are |
| 14 | + * Windows (32/64 bit) |
| 15 | + * Linux (32/64 bit) |
| 16 | + * MacOS |
| 17 | +You don't need to choose a specific binary runtime; it is automatically selected |
| 18 | +when you run |
| 19 | + package require extrafont |
| 20 | +Note that a specific runtime support (e.g. "Linux 32") is not referred to the |
| 21 | +hosting O.S. architecture, but it's referred to the architecture of the TclTk |
| 22 | +interpreter. |
| 23 | +E.g. if you have a 32-bit TclTk interpreter running on a 64-bit Linux, |
| 24 | +then the binary extension for linux-x32 will be automaticaaly selected. |
| 25 | + |
| 26 | +======= |
| 27 | + |
| 28 | +The extrafont package provides these commands: |
| 29 | + extrafont::load |
| 30 | + extrafont::unload |
| 31 | + extrafont::loaded (*deprecated obsolete*) |
| 32 | + extrafont::query |
| 33 | + extrafont::nameinfo |
| 34 | + extrafont::nametable::nameIDs |
| 35 | + extrafont::cleanup |
| 36 | + extrafont::isAvailable |
| 37 | + extrafont::availableFamilies |
| 38 | + |
| 39 | +extrafont::load _filename_ |
| 40 | + Loads all the fonts contained in filename. These fonts will be visible to the current process only |
| 41 | + and they will automatically disappear when the process terminates. |
| 42 | + After loading filename, all the fonts contained in filename will be available to the current Tk app. |
| 43 | + This command returns the list of the font-families loaded. |
| 44 | + An error is raised if filename represents an invalid font-file, or if filename has been already loaded as an extrafont. |
| 45 | + |
| 46 | +extrafont::unload _filename_ |
| 47 | + Unloads all the fonts previosly loaded with filename. |
| 48 | + Note that if a widget is using these fonts, it may display them correctly, as long text or font-properties (e.g. size) are not changed; |
| 49 | + in these latter cases, Tk will replace the displayed text using a default font. |
| 50 | + |
| 51 | +extrafont::loaded |
| 52 | + (This command is obsolete and its use is deprecated. See extrafont::query command) |
| 53 | + Returns a list containing the names of all currently loaded 'extrafont' font-files |
| 54 | + |
| 55 | +extrafont::query _kind_ ?_selector_ _pattern_? |
| 56 | + Returns lists of different kinds (files, families, fullnames, details) about |
| 57 | + the loaded fonts (just about the extrafont-loaded fonts), matching the optional |
| 58 | + selection-pattern. |
| 59 | + A selection-pattern is made by a selector (-file, -family, -fullname) and a |
| 60 | + glob-style pattern. |
| 61 | + Examples: |
| 62 | + * list all the (extrafont) loaded font-files: |
| 63 | + extrafont::query files |
| 64 | + * list all the (extrafont) loaded font-families from font-files "Ariel*.ttf"" |
| 65 | + extrafont::query families -file "*/Ariel*.ttf" |
| 66 | + * list all the details of the font-family "Ariel*" |
| 67 | + extrafont::query details -family "Ariel*" |
| 68 | + |
| 69 | +extrafont::nameinfo _fontfile_ |
| 70 | + Returns a list of font-details. One font-detail (a dictionary) for each font |
| 71 | + contained in $fontfile. |
| 72 | + |
| 73 | +extrafont::nametable::nameIDs |
| 74 | + Returns all the valid keys used for the font-details dictionary |
| 75 | + |
| 76 | +extrafont::cleanup |
| 77 | + Unloads all the loaded extrafonts. |
| 78 | + |
| 79 | +extrafont::isAvailable _fontFamily_ |
| 80 | + Returns true if fontFamily is avaiable. |
| 81 | + **WARNING** - on MacOSX after loading/unloading one or more fonts, the list |
| 82 | + of the availables fonts won't be updated till the next event-loop update. |
| 83 | + For this reason, if your script needs to call isAvalable/availableFamilies |
| 84 | + just after loading/unloading a fontfile, you need to call the "update" command. |
| 85 | + |
| 86 | + |
| 87 | +extrafont::availableFamilies ?_fontFamilyPattern_? |
| 88 | + Returns the list of font-families matching the glob-style fontFamilyPattern. |
| 89 | + e.g. |
| 90 | + extrafont::availableFamilies co* |
| 91 | + returns |
| 92 | + Courier {Comic Sans MS} ..... |
| 93 | + **WARNING** - on MacOSX after loading/unloading one or more fonts, the list |
| 94 | + of the availables fonts won't be updated till the next event-loop update. |
| 95 | + For this reason, if your script needs to call isAvalable/availableFamilies |
| 96 | + just after loading/unloading a fontfile, you need to call the "update" command. |
| 97 | + |
| 98 | + |
| 99 | +One important distinction to keep in mind is among |
| 100 | + font-filename |
| 101 | + font-family |
| 102 | + fontname (or tk-fontname) |
| 103 | + |
| 104 | +Font-filename is used just for loading/unloading an external font: |
| 105 | + extrafont::load "c:/tmp/Monoton-regular.ttf" |
| 106 | + |
| 107 | +This font-file contains just one font. The font-family-name can be extracted as |
| 108 | +result of the extrafont::load command |
| 109 | + foreach fontfamily $fontfamilies { |
| 110 | + puts "Loaded fint-family: $fontfamily" |
| 111 | + } |
| 112 | + # just get the 1st font-familiy |
| 113 | + set myNewFontFamily [lindex $fontfamilies 0] ;# --> "Monoton" |
| 114 | + |
| 115 | +When you want to use this new font, you should create or configure |
| 116 | +a tk-fontname (using the standard 'font' command) |
| 117 | + |
| 118 | + set myfontname "tk_monoton" ;# ... choose the name you want .. |
| 119 | + font create $myfontname -family $myNewFontFamily -size 20 |
| 120 | + # or, let tk choose a fontname for you ... |
| 121 | + set myfontname [font create -family $myNewFontFamily -size 20] |
| 122 | + # then use $myfontname for a new widget ... |
| 123 | + label .mylabel -font $myfontname ....... |
0 commit comments