Author image Martin Bartlett


XFontStruct - package to access XFontStruct structure fields


        use <a package that returns XFontStructs>;
        use X11::XFontStruct;

        $xfontstruct = function_that_returns_xfontstruct(its, parms);
        $ascent = $xfontstruct->ascent;    

        # Any XFontStruct field can be read like this.


This class/package provides an extension to perl that allows Perl programs read-only access to the XFontStruct structure. So. how do they get hold of an XFontStruct to read? Well, they use ANOTHER Perl extension that blesses pointers to XFontStructs into the XFontStruct class. Such an extension would do that by supplying a TYPEMAP as follows:

     XFontStruct *    T_PTROBJ

and then returning XFontStruct pointers from appropriate function calls.

An extension that does this is the X11::Xforms extension. So, using these two extensions the perl programmer can do some pretty powerful XWindows application programming.

So whats in this package. Well, quite simply, every method in this package is named after a field in the XFontStruct structure.

ALL XFontStruct fields are catered for, except XExtData. ALL are returned as perl scalars or, in the case of substructures, as lists of scalars, of various intuitively obvious types. Here is the syntax for each field:

        $fid = $xf->$fid;
        $direction = $xf->direction;
        $min_char_or_byte2 = $xf->min_char_or_byte2;
        $max_char_or_byte2 = $xf->max_char_or_byte2;
        $min_byte1 = $xf->min_byte1;
        $max_byte1 = $xf->max_byte1;
        $all_chars_exist = $xf->all_chars_exist;
        $default_char = $xf->default_char;
        $n_properties = $xf->n_properties;
        @properties = $xf->properties;
                [or    ($name, $card32, @more_props) = $xf->n_properties;]      
        @min_bounds = $xf->min_bounds;
                [or    ($lbearing,
                        $attributes) = $xf->min_bounds;]
        @max_bounds = $xf->max_bounds;
                [or    ($lbearing,
                        $attributes) = $xf->max_bounds;]
        @per_char = $xf->per_char;
                [or    ($lbearing,
                        @more_chars) = $xf->per_char;]
        $ascent = $xf->ascent;
        $descent = $xf->descent;