Font_ReadDefn + Font_ReadIdentifier

Erik Groenhuis e.groenhuis at xs4all.nl
Wed Jun 18 12:15:09 BST 2008


As John Tytgat wrote on 18 Jun 2008:

> I want some feedback on the following : currently we have SWI Font_ReadDefn
> covered by OSLib's Font_ReadDefn definition which gets you the font
> identifier (only fontname), point sizes, resolution, age and a usage count
> for given font handle:

[snip: code for Font_ReadDefn]

> There is an extension to SWI Font_ReadDefn when you call it with R3 = 'FULL'
> which gives you the full font identifier (including all qualifiers used)
> and above information as well (it also allows you to know the minimal
> buffer length but that's not the point here).  This extension is only
> partially covered by OSLib's Font_ReadIdentifier as that will only give
> the full font identifier and not the point sizes, resolution etc. while
> that's perfectly possible with the Font_ReadDefn SWI with R3 = 'FULL':

[snip: code for Font_ReadIdentifier]

> In order to avoid an extra SWI call when full font identifer needs to be
> known and all other information as well, I propose to define the following
> as a extra OSLib definition:

[snip: proposed code for Font_ReadFullDefn ]

> Any comments ?

Essentially the Font_ReadDefn SWI allways gives the R2-R7 data, except
for one situation: if R3='FULL' and R1=0. In that case the required
buffer size for the full font identifier string returned in R2, with
R0,R1 preserved and R3-R7 corrupted.

Therefore I think we should introduce:

- The proposed Font_ReadFullDefn (calls with R3='FULL' and R1 != 0,
  return the full font identifier string and all R2-R7 information)

- Another new call, Font_ReadIdSize, which only returns the buffer size
  required (by calling with R3='FULL' and R1=0):

(Warning: may contain syntax errors)
--8<--
   Font_ReadIdSize =
   (  NUMBER 0x40083 "Read the required buffer size for the font identifier string by calling Font_ReadDefn with R3 = 'FULL' and R1 = 0",
      ENTRY
      (  R0 = Font_F: font,
         R1 # 0
         R3 # 'FULL'
      ),
      EXIT
      (  R2 = .Int: size,
   )  )
--8<--

This will make the Font_ReadIdentifier version of the call obsolete.
Its functionality can be replaced by calling Font_ReadFullDefn with NULL
pointers for the unwanted R2-R7 values.

A typical sequence of calls would then be (off the top off my head):

--8<--
int fonthandle=1;
int size, xsize, ysize;
char * idstring;

   font_read_id_size(fonthandle, &size); /* find size for id string */

   idstring = malloc(size); /* no +1 needed, size includes terminator */

   xfont_read_full_defn(fonthandle, idstring, &xsize, &ysize,
     NULL, NULL, NULL, NULL );
--8<--

BTW it is my opinion that the non-FULL version of this SWI (that is: the
SWI, not the OSLib call per se) is depricated and should not be used by
programmers.

-- 
Erik Groenhuis http://www.xs4all.nl/~erikgrnh
=== http://www.irregularwebcomic.net/ ===



More information about the oslib-user mailing list