APTR handle = LoadFont(STRPTR name, int size, struct hwLoadFontCtrl *lf, struct hwTagList *tags);
name
and the size in size
. Your plugin needs to check if the
specified font is in a format that the plugin wants to handle, and, if it is,
return a handle to the font back to Hollywood. Otherwise it has to return NULL
.
The handle returned by LoadFont()
is an opaque datatype that only your plugin
knows about. Hollywood will pass this handle to all your font plugin functions.
LoadFont()
is also passed a pointer to a struct hwLoadFontCtrl
in
the third parameter. This structure is used to pass some additional arguments
to your plugin and your plugin can also pass some information back to
Hollywood using this structure pointer. struct hwLoadFontCtrl
looks
like this:
struct hwLoadFontCtrl { STRPTR Name; [out] STRPTR Adapter; [in] ULONG *Palette; [out] ULONG TransPen; [out] ULONG Flags; [in/out] int Depth; [out] int Height; [out] int Baseline; [out] struct hwUserTagList *UserTags; [in] }; |
Here's an explanation of the individual structure members:
Name:
Adapter:
NULL
, Hollywood wants your plugin to use the file adapter
specified in Adapter
to open the file. This means that you have to use
hw_FOpenExt() instead of hw_FOpen()
to open the file. See hw_FOpenExt for details.
Palette:
ULONG
array of 256 RGB colors. Note that the ULONG
array
must always have 256 entries, even if the font's bit depth is less than 8. Initialize
unused palette entries to 0.
TransPen:
HWPEN_NONE
.
Flags:
LoadFont()
and some flags can be set by your plugin to pass
information back to Hollywood. The following flags are currently defined:
HWFONTFLAGS_VECTOR:
HWFONTFLAGS_LAYOUT
(see below),
you don't have to implement SetFontScale() but in that case your
RenderText() implementation must be able to apply a 2D transformation
matrix to the text before drawing.
HWFONTFLAGS_USEPOINTS:
LoadFont()
is in points
instead of pixels. Your implementation must look for this flag and act
accordingly.
HWFONTFLAGS_ANTIALIAS:
HWFONTFLAGS_NOFILE:
LoadFont()
implementation in the name
parameter isn't a file. This is important to know for Hollywood's linker. If
HWFONTFLAGS_NOFILE
isn't set, the linker will try to link the font when
compiling applets or executables. This must be prevented for fonts that do
not directly exist as files. E.g. if your LoadFont()
function is passed "Arial"
in name
and you don't set HWFONTFLAGS_NOFILE
, Hollywood's linker will try
to link a file named "Arial" which will of course fail.
HWFONTFLAGS_LAYOUT:
HWFONTFLAGS_LAYOUT
flag.
In that case, Hollywood's layouter won't be used at all for this font but
your plugin can do its own layouting.
Depth:
Palette
member is set as well (see above), Depth
must be a value between 1 and 8.
Note that if you set this to 8 with Palette
set to NULL
to indicate that the
font supports anti-aliasing your RenderText() implementation must
also be able to draw to a 1-bit monochrome target. In other words: Fonts
that support anti-aliasing must also support non-anti-aliased drawing.
Height:
Baseline:
UserTags:
UserTags
could
also be intended for another plugin, namely the file adapter plugin passed
in Adapter
. See User tags for details.
Please note that you should not use ANSI C functions like fopen()
to
open the file that is passed to this function because the filename that is passed
to this function can also be a specially formatted filename specification that
Hollywood uses to load files that have been linked to applets or executables. In
order to be able to load these files correctly, you have to use special IO functions
provided by Hollywood. See File IO information for details.
struct LoadFontCtrl
that is used to exchange
further informationNULL
NULL
if the plugin doesn't
want to handle this font