Skip to content

Commit bd80ec3

Browse files
committed
Initial commit
0 parents  commit bd80ec3

31 files changed

+2323
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# IntelliJ
2+
/.idea
3+
4+
# Build Results
5+
./XBUILD

HOWTOBUILD.txt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
HOW TO BUILD:
2+
-------------
3+
4+
You should repeat the build procedure on different platforms:
5+
Windows
6+
Linux
7+
MacOSX
8+
At the end, you will find all the results in a directory named 'XBUILD/extrafont'
9+
ready for the distribution
10+
11+
12+
Windows:
13+
--------
14+
Using MS Visual Studio (Visual Studio 2015 Community Edition)
15+
Support for x86/x64 target architecture.
16+
17+
ms-build x32
18+
ms-build x64
19+
20+
Linux
21+
-----
22+
Using the standard GNU/C tool-chain
23+
24+
build.sh x32
25+
build.sh x64
26+
27+
MacOSX
28+
------
29+
Using the standard GNU/C tool-chain
30+
31+
build.sh x64
32+
33+
== TROUBLESHOOTING ============================================================
34+
35+
* Compiling FOR Linux 32 bit (On Linux 64bit).
36+
if "build.sh x32" exits with an error ..
37+
/usr/bin/ld cannot find -lfontconfig
38+
then yoy must reinstall fontconfig-32bit
39+
Use the following command
40+
sudo apt-get install libfontconfig1-dev
41+
then relaunch build.sh

build.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/bash
2+
3+
# Launcher for building extrafont on Linux/MacOsX
4+
# using the standard GNU/C tool-chain
5+
# Read HOWTOBUILD.txt for further info
6+
7+
_THISCMD=$0
8+
_ARCH=$1
9+
10+
11+
echo =================================
12+
echo Preliminary checks .....
13+
echo =================================
14+
15+
if [ -z "${_ARCH}" ] ; then
16+
echo "Missing _architecture_: \"x32\" or \"x64\""
17+
echo "Usage; ${_THISCMD} _architecture_ [args]"
18+
echo " optional args are passed to make"
19+
exit 1
20+
fi
21+
22+
if [ "${_ARCH}" != "x32" -a "${_ARCH}" != "x64" ] ; then
23+
echo Unsupported architecture "$_ARCH" : Valid values are: x32 or x64
24+
exit 1
25+
fi
26+
27+
# ... We presume the C-build environment is properly set ..
28+
29+
30+
echo =================================
31+
echo Preliminary checks ..... DONE.
32+
echo =================================
33+
echo
34+
35+
function toLower {
36+
echo $* | tr '[:upper:]' '[:lower:]'
37+
}
38+
_OS=$(uname -s)
39+
_OS=$(toLower $_OS)
40+
41+
case $_OS in
42+
linux*) _OS=linux
43+
;;
44+
darwin*) _OS=darwin
45+
;;
46+
*) echo Unsupported OS "$_OS"
47+
exit 1
48+
;;
49+
esac
50+
51+
52+
## you can also pass extra args to make ...
53+
shift
54+
_MAKEOPTS="--no-builtin-rules --no-builtin-variables" ;# you must be EXPLICIT !
55+
make ${_MAKEOPTS} -f unix-makefile OS=${_OS} ARCH=${_ARCH} $*

cross-makefile

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
#-----------------------------------------------------------------------------
2+
# cross-makefile for extrafont
3+
#
4+
# This makefile adopts a minimal syntax and rules so that it can be processed
5+
# both by Unix 'make' ad MS 'nmake'.
6+
# Please note that:
7+
# * Preprocessor statements (#if / !if , #include / !include...)
8+
# are not allowed, since they are not omogeneous on different platforms.
9+
# * comments inside a command-block should be written as
10+
# $(X_COMMENT) ......
11+
# where X_COMMENT is a macro set externally, i.e. from the launching script/batch.
12+
# * Since preprocessor directives are not allowed, all the special setting
13+
# for different platforms must be done in the launching script/batch.
14+
# * For all the above reasons, this makefile must be launched by a proper
15+
# script/batch (see ms-build.bat or build.sh ... )
16+
# * The 'cd' command should not be used, since its behaviour in make/nmake
17+
# is deeply different.
18+
19+
#
20+
# !!! IMPORTANT !!! we expect the following macros
21+
# set by the launcher script:
22+
#
23+
24+
# BUILDDIR (temporary directory for building)
25+
# TARGET the name of the subdir under BUILDDIR for storing the
26+
# platform&architecture specific deliverables.
27+
# DLL name of the main dll to build.
28+
29+
# Macros for OS-specific commands:
30+
# --------------------------------
31+
# These macros are usually hard-coded in the launching script/batch.
32+
# - No need to change them -
33+
# X_RMDIR - recursive mkdir
34+
# X_MKDIR - recursive rmdir
35+
# X_COPY - copy files
36+
# X_RM - remove files
37+
38+
39+
# Macros for setting some compilers options
40+
# -----------------------------------------
41+
# These macros are defined by the launching batch/script.
42+
# As a builder, you can change these params at run-time (i.e. build-time)
43+
# by setting the homonym environment variables, before launching build script.
44+
# Alternatively, you can redefine these settings on fly, on the launching script
45+
# e.g.) ms-build.bat x64 "CFLAGS=-X -Y -Z"
46+
# e.g.) build.sh x64 "CFLAGS=-X -Y -Z"
47+
48+
#
49+
# CFLAGS (Options for cl.exe)
50+
51+
52+
#
53+
# Inference rules (or pattern rules)
54+
# for building: .c -> .obj
55+
# are defined in the preliminary makefile (ms-makefile or unix-makefile)
56+
# Note that:
57+
# - on compiling C
58+
# *.obj are stored in $(BUILDDIR)/$(TARGET)
59+
60+
61+
#
62+
#
63+
# BE CAREFUFUL: All pathnames must be in UNIX notation
64+
#
65+
66+
### ---------------------------------------------------------------------------
67+
### -- let's start ... --------------------------------------------------------
68+
### ---------------------------------------------------------------------------
69+
70+
all: _build _makePackage
71+
72+
_build: _prepareBuildTree $(BUILDDIR)/$(TARGET)/$(DLL)
73+
74+
_prepareBuildTree:
75+
- $(X_MKDIR) $(BUILDDIR)
76+
- $(X_MKDIR) $(BUILDDIR)/$(TARGET)
77+
78+
79+
#
80+
# List of source files
81+
# WARNING: do NOT list empty directories, just source files (with their path)
82+
# WARNING: If you add files in *new* directories, you should review some
83+
# command-blocks accordingly.
84+
#
85+
86+
# Note: don't worry if Unix-object-files are called ".obj" . It works !
87+
88+
OBJS= \
89+
$(BUILDDIR)/$(TARGET)/extrafont.obj \
90+
91+
$(BUILDDIR)/$(TARGET)/$(DLL): $(OBJS)
92+
$(LINK) $(LINK_OUT_OPTION)$@ $(OBJS) $(LIBS_OPTIONS)
93+
94+
95+
96+
### MAKE PACKAGE #############################################################
97+
98+
PKGDIR = $(BUILDDIR)/extrafont
99+
100+
_makePackage: _build _docs
101+
-@ $(X_MKDIR) $(PKGDIR)
102+
-@ $(X_MKDIR) $(PKGDIR)/$(TARGET)
103+
$(X_COPY) src/*.tcl $(PKGDIR)
104+
$(X_COPY) license.terms $(PKGDIR)
105+
$(X_COPY) $(BUILDDIR)/$(TARGET)/$(DLL) $(PKGDIR)/$(TARGET)
106+
107+
_docs:
108+
@ echo Updating docs ...
109+
-@ $(X_MKDIR) $(PKGDIR)/docs
110+
$(X_COPYTREE) docs $(PKGDIR)/docs
111+
112+
### CLEANUP ##################################################################
113+
114+
clean:
115+
$(X_RMDIR) $(BUILDDIR)
116+
117+
###############################################################################
118+

docs/doc.txt

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
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 .......

license.terms

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
== Extrafont ==
2+
A multi-platform binary package for loading "private fonts"
3+
4+
Copyright (c) 2017,2020 by A.Buratti <[email protected]>
5+
6+
This library is free software; you can use, modify, and redistribute it
7+
for any purpose, provided that existing copyright notices are retained
8+
in all copies and that this notice is included verbatim in any
9+
distributions.
10+
11+
This software is distributed WITHOUT ANY WARRANTY; without even the
12+
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

0 commit comments

Comments
 (0)