[q-lang-cvs] q/modules/ggi ggi.c,1.9,1.10 ggi.q,1.5,1.6
Brought to you by:
agraef
From: <ag...@us...> - 2003-12-20 21:29:46
|
Update of /cvsroot/q-lang/q/modules/ggi In directory sc8-pr-cvs1:/tmp/cvs-serv22227 Modified Files: ggi.c ggi.q Log Message: improved ggi_get_font_info Index: ggi.c =================================================================== RCS file: /cvsroot/q-lang/q/modules/ggi/ggi.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ggi.c 20 Dec 2003 19:09:34 -0000 1.9 --- ggi.c 20 Dec 2003 21:29:36 -0000 1.10 *************** *** 182,190 **** #endif FUNCTION(ggi,ggi_vars,argc,argv) { if (argc != 0) return __FAIL; return mktuplel ! (105, mkuint(GGIFLAG_ASYNC), mkuint(GGIFLAG_TIDYBUF), /* buffer flags */ --- 182,206 ---- #endif + #ifndef HAVE_FT2 + #define FT_FACE_FLAG_SCALABLE 0 + #define FT_FACE_FLAG_FIXED_SIZES 0 + #define FT_FACE_FLAG_FIXED_WIDTH 0 + #define FT_FACE_FLAG_SFNT 0 + #define FT_FACE_FLAG_HORIZONTAL 0 + #define FT_FACE_FLAG_VERTICAL 0 + #define FT_FACE_FLAG_KERNING 0 + #define FT_FACE_FLAG_FAST_GLYPHS 0 + #define FT_FACE_FLAG_MULTIPLE_MASTERS 0 + #define FT_FACE_FLAG_GLYPH_NAMES 0 + #define FT_FACE_FLAG_EXTERNAL_STREAM 0 + #define FT_STYLE_FLAG_ITALIC 0 + #define FT_STYLE_FLAG_BOLD 0 + #endif + FUNCTION(ggi,ggi_vars,argc,argv) { if (argc != 0) return __FAIL; return mktuplel ! (118, mkuint(GGIFLAG_ASYNC), mkuint(GGIFLAG_TIDYBUF), /* buffer flags */ *************** *** 246,250 **** mkuint(GII_PT_VOLTAGE), mkuint(GII_PT_RESISTANCE), mkuint(GII_PT_CAPACITY), ! mkuint(GII_PT_INDUCTIVITY)); } --- 262,280 ---- mkuint(GII_PT_VOLTAGE), mkuint(GII_PT_RESISTANCE), mkuint(GII_PT_CAPACITY), ! mkuint(GII_PT_INDUCTIVITY), ! /* font properties */ ! mkuint(FT_FACE_FLAG_SCALABLE), ! mkuint(FT_FACE_FLAG_FIXED_SIZES), ! mkuint(FT_FACE_FLAG_FIXED_WIDTH), ! mkuint(FT_FACE_FLAG_SFNT), ! mkuint(FT_FACE_FLAG_HORIZONTAL), ! mkuint(FT_FACE_FLAG_VERTICAL), ! mkuint(FT_FACE_FLAG_KERNING), ! mkuint(FT_FACE_FLAG_FAST_GLYPHS), ! mkuint(FT_FACE_FLAG_MULTIPLE_MASTERS), ! mkuint(FT_FACE_FLAG_GLYPH_NAMES), ! mkuint(FT_FACE_FLAG_EXTERNAL_STREAM), ! mkuint(FT_STYLE_FLAG_ITALIC), ! mkuint(FT_STYLE_FLAG_BOLD)); } *************** *** 1140,1144 **** if (init && argc == 1 && isobj(argv[0], type(GGIVisual), (void**)&v) && v->vis && v->face) { ! expr flag, *sizes = NULL; int i, n = v->face->num_fixed_sizes; if (n > 0 && !(sizes = xvalloc(n))) return __ERROR; --- 1170,1174 ---- if (init && argc == 1 && isobj(argv[0], type(GGIVisual), (void**)&v) && v->vis && v->face) { ! expr *sizes = NULL; int i, n = v->face->num_fixed_sizes; if (n > 0 && !(sizes = xvalloc(n))) return __ERROR; *************** *** 1147,1156 **** mkint(v->face->available_sizes[i].height)); if (FT_IS_SCALABLE(v->face)) ! flag = mktrue; else ! flag = mkfalse; ! return mktuplel(4, mkstr(strdup(v->face->family_name)), ! mkstr(strdup(v->face->style_name)), ! flag, mklistv(n, sizes)); } else #endif --- 1177,1209 ---- mkint(v->face->available_sizes[i].height)); if (FT_IS_SCALABLE(v->face)) ! return mktuplel(18, mkint(v->face->num_faces), ! mkint(v->face->face_index), ! mkuint(v->face->face_flags), ! mkuint(v->face->style_flags), ! mkstr(strdup(v->face->family_name)), ! mkstr(strdup(v->face->style_name)), ! mklistv(n, sizes), ! mkuint(v->face->units_per_EM), ! mkuint(v->face->size->metrics.x_ppem), ! mkuint(v->face->size->metrics.y_ppem), ! mktuplel(4, mkint(v->face->bbox.xMin), ! mkint(v->face->bbox.xMax), ! mkint(v->face->bbox.yMin), ! mkint(v->face->bbox.yMax)), ! mkint(v->face->ascender), ! mkint(v->face->descender), ! mkint(v->face->height), ! mkint(v->face->max_advance_width), ! mkint(v->face->max_advance_height), ! mkint(v->face->underline_position), ! mkint(v->face->underline_thickness)); else ! return mktuplel(7, mkint(v->face->num_faces), ! mkint(v->face->face_index), ! mkuint(v->face->face_flags), ! mkuint(v->face->style_flags), ! mkstr(strdup(v->face->family_name)), ! mkstr(strdup(v->face->style_name)), ! mklistv(n, sizes)); } else #endif Index: ggi.q =================================================================== RCS file: /cvsroot/q-lang/q/modules/ggi/ggi.q,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ggi.q 20 Dec 2003 19:09:34 -0000 1.5 --- ggi.q 20 Dec 2003 21:29:36 -0000 1.6 *************** *** 117,120 **** --- 117,139 ---- GGI_PT_INDUCTIVITY; /* base unit Vs/A (Henry) */ + /* The following FreeType2 flag values describe various font properties. These + values, bitwise or'ed together, are returned by ggi_get_font_info in the + FACE_FLAGS and STYLE_FLAGS fields of a font info structure. */ + + public var const + FT_FACE_FLAG_SCALABLE, + FT_FACE_FLAG_FIXED_SIZES, + FT_FACE_FLAG_FIXED_WIDTH, + FT_FACE_FLAG_SFNT, + FT_FACE_FLAG_HORIZONTAL, + FT_FACE_FLAG_VERTICAL, + FT_FACE_FLAG_KERNING, + FT_FACE_FLAG_FAST_GLYPHS, + FT_FACE_FLAG_MULTIPLE_MASTERS, + FT_FACE_FLAG_GLYPH_NAMES, + FT_FACE_FLAG_EXTERNAL_STREAM, + FT_STYLE_FLAG_ITALIC, + FT_STYLE_FLAG_BOLD; + private extern ggi_vars; *************** *** 165,169 **** GGI_PT_FORCE, GGI_PT_PRESSURE, GGI_PT_TORQUE, GGI_PT_ENERGY, GGI_PT_POWER, GGI_PT_TEMPERATURE, GGI_PT_CURRENT, GGI_PT_VOLTAGE, ! GGI_PT_RESISTANCE, GGI_PT_CAPACITY, GGI_PT_INDUCTIVITY ) = ggi_vars; --- 184,196 ---- GGI_PT_FORCE, GGI_PT_PRESSURE, GGI_PT_TORQUE, GGI_PT_ENERGY, GGI_PT_POWER, GGI_PT_TEMPERATURE, GGI_PT_CURRENT, GGI_PT_VOLTAGE, ! GGI_PT_RESISTANCE, GGI_PT_CAPACITY, GGI_PT_INDUCTIVITY, ! /* font properties */ ! FT_FACE_FLAG_SCALABLE, FT_FACE_FLAG_FIXED_SIZES, ! FT_FACE_FLAG_FIXED_WIDTH, FT_FACE_FLAG_SFNT, ! FT_FACE_FLAG_HORIZONTAL, FT_FACE_FLAG_VERTICAL, ! FT_FACE_FLAG_KERNING, FT_FACE_FLAG_FAST_GLYPHS, ! FT_FACE_FLAG_MULTIPLE_MASTERS, FT_FACE_FLAG_GLYPH_NAMES, ! FT_FACE_FLAG_EXTERNAL_STREAM, FT_STYLE_FLAG_ITALIC, ! FT_STYLE_FLAG_BOLD ) = ggi_vars; *************** *** 330,334 **** metric file. The font metric data is needed to do proper kerning in proportional fonts, and should be loaded immediately after calling ! ggi_set_font. Not that this is only necessary for some types of fonts which have their metrics in a separate file. A typical example are Type 1 font files, which have the font data in a file with extension .pfa or .pfb, and --- 357,361 ---- metric file. The font metric data is needed to do proper kerning in proportional fonts, and should be loaded immediately after calling ! ggi_set_font. Note that this is only necessary for some types of fonts which have their metrics in a separate file. A typical example are Type 1 font files, which have the font data in a file with extension .pfa or .pfb, and *************** *** 339,344 **** /* Set the character size SIZE (in pt = 1/72 of an inch, this can be a floating point value to denote fractional sizes) and display resolution RES ! (in dpi = dots per inch). The actual size of the characters on the display ! in pixels will be calculated from these values according to the formula PIXEL_SIZE = SIZE*RES/72. SIZE and RES can also be specified as pairs of values, to indicate different values for the x and y direction. Moreover, a --- 366,371 ---- /* Set the character size SIZE (in pt = 1/72 of an inch, this can be a floating point value to denote fractional sizes) and display resolution RES ! (in dpi = dots per inch). The actual display size of the characters in ! pixels will be calculated from these values according to the formula PIXEL_SIZE = SIZE*RES/72. SIZE and RES can also be specified as pairs of values, to indicate different values for the x and y direction. Moreover, a *************** *** 354,361 **** public extern ggi_set_antialias VIS FLAG; ! /* Specify an arbitrary affine transformation to be applied before a string is ! rendered on the visual. The font must be scalable for this to work. This ! can be used, e.g., to print rotated or stretched text. The transformation ! is given by a translation vector VECT = (X,Y) and a 2x2 matrix MATRIX = (XX,XY,YX,YY). E.g., to rotate text by an angle A counter-clockwise, you would use a transform matrix of the form (cos A, -sin A, sin A, cos A). */ --- 381,388 ---- public extern ggi_set_antialias VIS FLAG; ! /* Specify an affine transformation to be applied before a string is rendered ! on the visual. The font must be scalable for this to work. This can be used ! to print translated, rotated and stretched text. The transformation is ! given by a translation vector VECT = (X,Y) and a 2x2 matrix MATRIX = (XX,XY,YX,YY). E.g., to rotate text by an angle A counter-clockwise, you would use a transform matrix of the form (cos A, -sin A, sin A, cos A). */ *************** *** 363,377 **** public extern ggi_set_transform VIS VECT MATRIX; ! /* Retrieve information about the loaded font. Only the most important font ! attributes are supported right now. (TODO: Add info about available glyphs, ! charmaps, and global font metrics of scalable fonts here.) Returns a tuple ! with the following information: ! - FAMILY, STYLE: strings describing the family and style of the font ! - SCALABLE: a flag indicating whether the font is scalable ! - SIZES: list of character sizes ((WD,HT) in pixels) of included bitmap ! fonts */ public extern ggi_get_font_info VIS; --- 390,443 ---- public extern ggi_set_transform VIS VECT MATRIX; ! /* Retrieve general information about the loaded font. The ggi_get_font_info ! function returns a tuple with the following information: ! - NFACES, INDEX: The total number of faces in this font, and the index of ! the selected face. ! - FACE_FLAGS: A bitset (bitwise or'ed FT_FACE_FLAG_* values) describing ! various properties of the face. The most interesting one is ! FT_FACE_FLAG_SCALABLE which is set for scalable fonts. ! - STYLE_FLAGS: A bitset (bitwise or'ed FT_STYLE_FLAG_* values) describing ! various style properties of the face (bold, italic, etc.). ! ! - FAMILY, STYLE: These are string values describing the family and style of ! the font. ! ! - SIZES: A list of character sizes ((W,H) in pixels) of included bitmap ! fonts. ! ! The remaining fields are only available for scalable fonts. Please refer to ! the FreeType2 documentation for a closer description of these values. Note ! that all given dimensions, with the exception of X_PPEM and Y_PPEM, are in ! design a.k.a. font units; once the actual character size has been set with ! ggi_set_char_size, you can translate these values to pixels according to ! the formula PIXELS = FONT_UNITS*PPEM/UNITS_PER_EM. ! ! - UNITS_PER_EM: The size of the EM square for the font face. ! ! - X_PPEM, Y_PPEM: The horizontal and vertical size of the EM square in ! pixels. These values are meaningful only after a character size has been ! set. ! ! - BBOX: A tuple (XMIN,XMAX,YMIN,YMAX) describing the maximum bounding box ! for all glyphs in the font ! ! - ASCENDER, DESCENDER: The vertical distance from the horizontal baseline ! to the highest and lowest "character" coordinate in a font face, ! respectively. (Unfortunately, just what "character" means in this context ! is defined differently for different fonts.) ! ! - HEIGHT: The default line spacing (baseline-to-baseline distance) for the ! font. ! ! - MAX_ADVANCE_WIDTH, MAX_ADVANCE_HEIGHT: The maximum horizontal and ! vertical cursor advance for all glyphs in the font. (Note that the latter ! is only defined for vertical fonts which currently aren't supported ! anyway.) ! ! - UNDERLINE_POSITION, UNDERLINE_THICKNESS: The vertical position, relative ! to the baseline, of the underline bar, and its vertical thickness. */ public extern ggi_get_font_info VIS; |