Defoma::Common(n) Defoma::Common(n) NAME Defoma::Common - Defoma module providing miscellaneous functions. SYNOPSIS use Defoma::Common; $h = parse_hints_start( hints... ); $hsub = parse_hints_subhints( hints_hash, face ); $hsub = parse_hints_subhints_inherit( hints_hash, face ); parse_hints_cut( hints_hash, hinttypes... ); parse_hints_cut_except( hints_hash, hinttypes... ); @hints = parse_hints_build( hints_hash ); $charset = get_charset( xencoding ); $xencoding = get_xencoding( charset, encoding ); @XLFDs = get_xlfd_of_font( font, level => level, face => face ); my $num = weight_ascii2integer( weightstring ); my $num = weight_a2i( weightstring ); DESCRIPTION parse_hints_start is a function to convert hints in an ar- ray to a hash. Hints consist of a list of hinttype and its value(e). Following is the example of hints in an array form. --FontName Helvetica-BoldItalic --Family Helvetica --GeneralFamily SansSerif --Weight Bold --Shape NoSerif Italic --Charset ISO8859-1 In this example, FontName, Family, GeneralFamily, Weight, Shape and Charset are hinttypes. Items starting with dou- ble minus characters The function converts this array to a hash described in the following style. FontName => 'Helvetica-BoldItalic', Family => 'Helvetica', GeneralFamily => 'SansSerif', Weight => 'Bold', Shape => 'NoSerif Italic', Charset => 'ISO8859-1' You see that hinttypes are used as keys of a hash, and that Shape has two values, NoSerif and Italic. If a cer- tain hinttype has more than one values, they are combined into a single string separated by space. parse_hints_subhints is a function to get a sub hint hash pointed by facenum from the hint hash specified by hints_hash. Please look at following example of a hint hash. $h = {Inherit => 'Charset Weight', FontName => 'Helvetica', Charset => 'ISO8859-1', Weight => 'Medium', Shape => 'Upright', FontName1 => 'Helvetica-Bold', Weight1 => 'Bold', FontName2 => 'Helvetica-Unicode', Charset2 => 'ISO10646-1'}; You see there're some numbered hinttypes. parse_hints_subhints extracts the hints of the specific number from it. For example, you can extract the non-num- bered hints FontName and Charset by: $hsub = parse_hints_subhints($h, 0); and the content of $hsub will be: FontName => 'Helvetica', Charset => 'ISO8859-1', Weight => 'Medium', Shape => 'Upright' If you set 1 to the second argument of parse_hints_sub- hints, the content of $hsub will be: FontName => 'Helvetica-Bold', Weight => 'Bold' Note that the number of each hinttype is removed. parse_hints_subhints_inherit is almost the same as parse_hints_subhints, only differs it inherits non-num- bered hints specified by Inherit hinttype. Following is the result of parse_hints_subhints_inherit with 1 and 2 set to the second argument in the example of parse_hints_subhints. FontName => 'Helvetica-Bold', Weight => 'Bold', Charset => 'ISO8859-1' FontName => 'Helvetica-Unicode', Weight => 'Medium', Charset => 'ISO10646-1' parse_hints_cut is a function to remove hinttypes speci- fied by hinttypes and their values from the hint hash. It is supposed to be used together with parse_hints_build function. parse_hints_cut_except is a function to remove all hint- types except those specified by hinttypes and their values from the hint hash. It is supposed to be used together with parse_hints_build function. parse_hints_build is a function to convert hints in a hash to an array. get_charset is a function to convert X-RegistryEncoding specified by xencoding into Charset. X-RegistryEncoding is the last two elements of XLFD, like iso8859-1 and jisx0208.1983-0. The returned values of these two are ISO8859-1 and JISX0208 respectively. get_xencoding is a function to convert Charset and Encod- ing specified by charset and encoding into X-RegistryEn- coding. encoding is often omitted. weight_ascii2integer is a function to convert Weight in string (like Bold and Medium) into a numeric value (inte- ger). Medium is always zero, and the bolder, the larger, the lighter, the smaller. For example, Bold is +2, and Light is -2. weight_a2i is abbreviation for weight_ascii2integer. get_xlfd_of_font is a function to get an array of XLFDs of a font specified by font. You can control the amount of gained XLFDs by level and face options. level must be ei- ther of 'min', 'normal', or 'max'. When min is specified, not-slanted not-boldized XLFDs registered in xfont catego- ry will be returned. When normal is specified, XLFDs in- cluding boldized and/or slanted (but not reverse slanted) ones registered in xfont category will be returned. When max is specified, all generated XLFDs will be returned. EXAMPLES $h = parse_hints_start(@_); @shape = split(/ /, $h->{Shape}); @alias = split(/ /, $h->{Alias}); $priority = $h->{Priority}; $realname = $h->{FontName}; $realname =~ s/ .*//; parse_hints_cut($h, 'Priority', 'FontName', 'Charset'); @hints = parse_hints_build($h); SEE ALSO defoma(a). March 4, 2001 Defoma::Common(n)