Browse Source

Adds initial Xft and fontconfig headers

git-svn-id: trunk@19879 -
sekelsenmat 13 years ago
parent
commit
4785b5637f
5 changed files with 419 additions and 8 deletions
  1. 2 0
      .gitattributes
  2. 6 1
      packages/x11/fpmake.pp
  3. 269 0
      packages/x11/src/fontconfig.pas
  4. 126 0
      packages/x11/src/xft.pas
  5. 16 7
      packages/x11/src/xrender.pp

+ 2 - 0
.gitattributes

@@ -6749,6 +6749,7 @@ packages/x11/Makefile svneol=native#text/plain
 packages/x11/Makefile.fpc svneol=native#text/plain
 packages/x11/fpmake.pp svneol=native#text/plain
 packages/x11/src/cursorfont.pp svneol=native#text/plain
+packages/x11/src/fontconfig.pas svneol=native#text/pascal
 packages/x11/src/keysym.pp svneol=native#text/plain
 packages/x11/src/randr.inc svneol=native#text/plain
 packages/x11/src/x.pp svneol=native#text/plain
@@ -6757,6 +6758,7 @@ packages/x11/src/xcms.pp svneol=native#text/plain
 packages/x11/src/xf86dga.pp svneol=native#text/plain
 packages/x11/src/xf86dga1.inc svneol=native#text/plain
 packages/x11/src/xf86vmode.pp svneol=native#text/plain
+packages/x11/src/xft.pas svneol=native#text/pascal
 packages/x11/src/xi.pp svneol=native#text/plain
 packages/x11/src/xinerama.pp svneol=native#text/plain
 packages/x11/src/xkb.pp svneol=native#text/plain

+ 6 - 1
packages/x11/fpmake.pp

@@ -93,7 +93,12 @@ begin
           AddUnit('xshm');
         end;
     T:=P.Targets.AddUnit('xv.pp');
-
+    T:=P.Targets.AddUnit('fontconfig.pas');
+    T.Dependencies.AddUnit('xlib');
+    T:=P.Targets.AddUnit('xft.pas');
+    T.Dependencies.AddUnit('xlib');
+    T.Dependencies.AddUnit('xrender');
+    T.Dependencies.AddUnit('fontconfig');
 
 {$ifndef ALLPACKAGES}
     Run;

+ 269 - 0
packages/x11/src/fontconfig.pas

@@ -0,0 +1,269 @@
+{*
+ * fontconfig/fontconfig/fontconfig.h
+ *
+ * Copyright © 2001 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *}
+unit fontconfig;
+
+{$mode objfpc}{$H+}
+{$packrecords c}
+
+interface
+
+uses
+  Classes, SysUtils, X, XLib, Xutil, ctypes;
+
+const
+  {$IF Defined(DARWIN)}
+    fclib = 'libfontconfig.dylib';
+    {$LINKLIB libfontconfig}
+  {$ELSE}
+    fclib = 'libfontconfig.so';
+  {$IFEND}
+
+//#define FcPublic
+
+type
+  FcChar8 = cuchar;
+  PFcChar8 = ^FcChar8;
+  FcChar16 = cushort;
+  FcChar32 = cuint;
+  FcBool = cint;
+
+const
+{*
+ * Current Fontconfig version number.  This same number
+ * must appear in the fontconfig configure.in file. Yes,
+ * it'a a pain to synchronize version numbers like this.
+ *}
+
+  FC_MAJOR	= 2;
+  FC_MINOR	= 8;
+  FC_REVISION = 0;
+
+  FC_VERSION = ((FC_MAJOR * 10000) + (FC_MINOR * 100) + (FC_REVISION));
+
+{*
+ * Current font cache file format version
+ * This is appended to the cache files so that multiple
+ * versions of the library will peacefully coexist
+ *
+ * Change this value whenever the disk format for the cache file
+ * changes in any non-compatible way.  Try to avoid such changes as
+ * it means multiple copies of the font information.
+ *}
+
+  FC_CACHE_VERSION   = '3';
+
+  FcTrue	=	1;
+  FcFalse	=	0;
+
+const
+  FC_FAMILY =          'family';	//* String */
+  FC_STYLE =           'style';		//* String */
+  FC_SLANT =           'slant';		//* Int */
+  FC_WEIGHT =	       'weight';	//* Int */
+  FC_SIZE =	           'size';      //* Double */
+  FC_ASPECT =	       'aspect';	//* Double */
+  FC_PIXEL_SIZE =      'pixelsize';     //* Double */
+  FC_SPACING =	       'spacing';	//* Int */
+  FC_FOUNDRY =	       'foundry';	//* String */
+  FC_ANTIALIAS =       'antialias';	//* Bool (depends) */
+  FC_HINTING =	       'hinting';	//* Bool (true) */
+  FC_HINT_STYLE	=      'hintstyle';	//* Int */
+  FC_VERTICAL_LAYOUT = 'verticallayout';//* Bool (false) */
+  FC_AUTOHINT =	       'autohint';	//* Bool (false) */
+  FC_GLOBAL_ADVANCE =  'globaladvance';	//* Bool (true) */
+  FC_WIDTH=	       'width';		//* Int */
+  FC_FILE =	       'file';		//* String */
+  FC_INDEX =	       'index';		//* Int */
+  FC_FT_FACE =	       'ftface';	//* FT_Face */
+  FC_RASTERIZER =      'rasterizer';	//* String */
+  FC_OUTLINE =	       'outline';	//* Bool */
+  FC_SCALABLE =	       'scalable';	//* Bool */
+  FC_SCALE =	       'scale';		//* double */
+  FC_DPI =             'dpi';		//* double */
+  FC_RGBA =            'rgba';		//* Int */
+  FC_MINSPACE =	       'minspace';	//* Bool use minimum line spacing */
+  FC_SOURCE =	       'source';	//* String (X11, freetype) */
+  FC_CHARSET =	       'charset';	//* CharSet */
+  FC_LANG =            'lang';		//* String RFC 3066 langs */
+  FC_FONTVERSION =     'fontversion';	//* Int from 'head' table */
+  FC_FULLNAME =	       'fullname';	//* String */
+  FC_FAMILYLANG =      'familylang';	//* String RFC 3066 langs */
+  FC_STYLELANG =       'stylelang';	//* String RFC 3066 langs */
+  FC_FULLNAMELANG =    'fullnamelang';	//* String RFC 3066 langs */
+  FC_CAPABILITY =      'capability';	//* String */
+  FC_FONTFORMAT =      'fontformat';	//* String */
+  FC_EMBOLDEN =	       'embolden';	//* Bool - true if emboldening needed*/
+  FC_EMBEDDED_BITMAP = 'embeddedbitmap';//* Bool - true to enable embedded bitmaps */
+  FC_DECORATIVE =      'decorative';	//* Bool - true if style is a decorative variant */
+  FC_LCD_FILTER =      'lcdfilter';	//* Int */
+
+  //FC_CACHE_SUFFIX		    ".cache-"FC_CACHE_VERSION
+  //FC_DIR_CACHE_FILE	    "fonts.cache-"FC_CACHE_VERSION
+  //FC_USER_CACHE_FILE	    ".fonts.cache-"FC_CACHE_VERSION
+
+  // Adjust outline rasterizer */
+  FC_CHAR_WIDTH =      'charwidth'; // Int */
+  FC_CHAR_HEIGHT =      'charheight'; // Int */
+  FC_MATRIX =          'matrix';    //* FcMatrix */
+
+  FC_WEIGHT_THIN = 0;
+  FC_WEIGHT_EXTRALIGHT =    40;
+  FC_WEIGHT_ULTRALIGHT =    FC_WEIGHT_EXTRALIGHT;
+  FC_WEIGHT_LIGHT =	    50;
+  FC_WEIGHT_BOOK =	    75;
+  FC_WEIGHT_REGULAR =	    80;
+  FC_WEIGHT_NORMAL =	    FC_WEIGHT_REGULAR;
+  FC_WEIGHT_MEDIUM =	    100;
+  FC_WEIGHT_DEMIBOLD =	    180;
+  FC_WEIGHT_SEMIBOLD =	    FC_WEIGHT_DEMIBOLD;
+  FC_WEIGHT_BOLD = 200;
+  FC_WEIGHT_EXTRABOLD =	    205;
+  FC_WEIGHT_ULTRABOLD =	    FC_WEIGHT_EXTRABOLD;
+  FC_WEIGHT_BLACK =	    210;
+  FC_WEIGHT_HEAVY =	    FC_WEIGHT_BLACK;
+  FC_WEIGHT_EXTRABLACK =    215;
+  FC_WEIGHT_ULTRABLACK =    FC_WEIGHT_EXTRABLACK;
+
+  FC_SLANT_ROMAN =	    0;
+  FC_SLANT_ITALIC =	    100;
+  FC_SLANT_OBLIQUE =	    110;
+
+  FC_WIDTH_ULTRACONDENSED =    50;
+  FC_WIDTH_EXTRACONDENSED =    63;
+  FC_WIDTH_CONDENSED =	    75;
+  FC_WIDTH_SEMICONDENSED =    87;
+  FC_WIDTH_NORMAL =	    100;
+  FC_WIDTH_SEMIEXPANDED =   113;
+  FC_WIDTH_EXPANDED =	    125;
+  FC_WIDTH_EXTRAEXPANDED =  150;
+  FC_WIDTH_ULTRAEXPANDED =  200;
+
+  FC_PROPORTIONAL =	    0;
+  FC_DUAL =		    90;
+  FC_MONO = 100;
+  FC_CHARCELL =	    110;
+
+  //* sub-pixel order */
+  FC_RGBA_UNKNOWN =	    0;
+  FC_RGBA_RGB =	    1;
+  FC_RGBA_BGR =	    2;
+  FC_RGBA_VRGB =	    3;
+  FC_RGBA_VBGR =	    4;
+  FC_RGBA_NONE =	    5;
+
+  // hinting style */
+  FC_HINT_NONE =        0;
+  FC_HINT_SLIGHT =      1;
+  FC_HINT_MEDIUM =      2;
+  FC_HINT_FULL =        3;
+
+  // LCD filter */
+  FC_LCD_NONE =	    0;
+  FC_LCD_DEFAULT =	    1;
+  FC_LCD_LIGHT =	    2;
+  FC_LCD_LEGACY =	    3;
+
+type
+  TFcType = Byte; // In C was a enum
+
+const
+  FcTypeVoid         = 0;
+  FcTypeInteger      = 1;
+  FcTypeDouble       = 2;
+  FcTypeString       = 3;
+  FcTypeBool         = 4;
+  FcTypeMatrix       = 5;
+  FcTypeCharSet      = 6;
+  FcTypeFTFace       = 7;
+  FcTypeLangSet      = 8;
+
+type
+  TFcMatrix = record
+    xx, xy, yx, yy: double;
+  end;
+
+//#define FcMatrixInit(m)	((m)->xx = (m)->yy = 1, \
+//			 (m)->xy = (m)->yx = 0)
+
+{*
+ * A data structure to represent the available glyphs in a font.
+ * This is represented as a sparse boolean btree.
+ *}
+
+  TFcCharSet = record
+    dummy : integer;
+  end;
+  PFcCharSet = ^TFcCharSet;
+
+  TFcObjectType = record
+    object_: PChar;
+    type_: TFcType;
+  end;
+
+  TFcConstant = record
+    name: PFcChar8;
+    object_: PChar;
+    value: cint;
+  end;
+
+  TFcResult = (
+    FcResultMatch, FcResultNoMatch, FcResultTypeMismatch, FcResultNoId,
+    FcResultOutOfMemory);
+
+  TFcPattern = record
+    dummy : integer;
+  end;
+
+  PFcPattern = ^TFcPattern;
+  PPFcPattern = ^PFcPattern;
+
+  TFcLangSet = record
+    dummy : integer;
+  end;
+
+  TFcValue = record
+    type_: TFcType;
+    (*union {
+	const FcChar8	*s;
+	int		i;
+	FcBool		b;
+	double		d;
+	const FcMatrix	*m;
+	const FcCharSet	*c;
+	void		*f;
+	const FcLangSet	*l;
+    } u;*)
+  end;
+
+  TFcFontSet = packed record
+    nfont : integer;
+    sfont : integer;
+    fonts : PPFcPattern;
+  end;
+  PFcFontSet = ^TFcFontSet;
+
+implementation
+
+end.
+

+ 126 - 0
packages/x11/src/xft.pas

@@ -0,0 +1,126 @@
+{ Original C header:
+ * include/X11/Xft/Xft.h.  Generated from Xft.h.in by configure.  */
+/*
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *}
+{
+    Initial Pascal headers obtained from:
+    fpGUI  -  Free Pascal GUI Toolkit
+
+    Copyright (C) 2006 - 2010 See the file AUTHORS.txt, included in this
+    distribution, for details of the copyright.
+
+    See the file COPYING.modifiedLGPL, included in this distribution,
+    for details about redistributing fpGUI.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+    Headers extended and modified by Felipe Monteiro de Carvalho in 2011
+
+    Description:
+      Xft interface functions
+}
+unit xft;
+
+{$mode objfpc}{$H+}
+{$packrecords c}
+
+interface
+
+uses
+  Classes, SysUtils, X, XLib, Xutil, ctypes, fontconfig, xrender;
+
+//#include FT_FREETYPE_H
+//#include <fontconfig/fontconfig.h>
+//#include <X11/extensions/Xrender.h>
+
+const
+  {$IF Defined(DARWIN)}
+    libXft = 'libXft.dylib';
+    {$linklib Xft}
+  {$ELSE}
+    libXft = 'libXft.so';
+  {$IFEND}
+
+{* Current Xft version number, set from version in the Xft configure.ac file. *}
+  XFT_MAJOR = 2;
+  XFT_MINOR = 2;
+  XFT_REVISION = 0;
+
+  XFT_VERSION = ((XFT_MAJOR * 10000) + (XFT_MINOR * 100) + (XFT_REVISION));
+  XftVersion = XFT_VERSION;
+
+  XFT_CORE = 'core';
+  XFT_RENDER	=	'render';
+  XFT_XLFD	=	'xlfd';
+  XFT_MAX_GLYPH_MEMORY ='maxglyphmemory';
+  XFT_MAX_UNREF_FONTS =	'maxunreffonts';
+  
+type
+// extern FT_Library	_XftFTlibrary;
+
+  TXftFontInfo = record end;
+
+  TPicture = longword;
+
+  TXftDraw = record end;
+  PXftDraw = ^TXftDraw;
+
+  TXftFont = record
+   ascent   : cint;
+   descent  : cint;
+   height   : cint;
+   max_advance_width : cint;
+   ptr1     : PFcCharSet;
+   ptr2     : PFcPattern;
+  end;
+  PXftFont = ^TXftFont;
+
+  TXftColor = record
+    pixel : culong;
+    color : TXRenderColor;
+  end;
+              
+function  XftDrawCreate(display : PXDisplay; win : TXID; vis : PVisual; colorm : longint) : PXftDraw; cdecl; external libXft;
+procedure XftDrawChange(xftd : PXftDraw; win : TXID); cdecl; external libXft;
+procedure XftDrawDestroy(draw : PXftDraw); cdecl; external libXft;
+function  XftDrawPicture(draw : PXftDraw) : TPicture; cdecl; external libXft;
+function  XftFontOpenName(display : PXDisplay; scr : integer; par3 : PChar) : PXftFont; cdecl; external libXft;
+procedure XftFontClose(display : PXDisplay; fnt : PXftFont); cdecl; external libXft;
+procedure XftDrawStringUtf8(draw : PXftDraw; var col : TXftColor; fnt : PXftFont; x,y : integer; txt : PChar; len : integer); cdecl; external libXft;
+procedure XftDrawString8(draw : PXftDraw; var col : TXftColor; fnt : PXftFont; x,y : integer; txt : PChar; len : integer); cdecl; external libXft;
+procedure XftDrawString16(draw : PXftDraw; var col : TXftColor; fnt : PXftFont; x,y : integer; txt : PChar; len : integer); cdecl; external libXft;
+procedure XftTextExtentsUtf8(display : PXDisplay; fnt : PXftFont; txt : PChar; len : integer; var extents : TXGlyphInfo); cdecl; external libXft;
+procedure XftTextExtents8(display : PXDisplay; fnt : PXftFont; txt : PChar; len : integer; var extents : TXGlyphInfo); cdecl; external libXft;
+procedure XftTextExtents16(display : PXDisplay; fnt : PXftFont; txt : PChar; len : integer; var extents : TXGlyphInfo); cdecl; external libXft;
+//function XftGlyphExists(display : PXDisplay; fnt : PXftFont; ch : integer) : longbool; cdecl; external libXft;
+//procedure XftDrawSetClipRectangles(draw : PXftDraw; xorigin, yorigin : integer; rect : PXRectangle; rnum : integer); cdecl; external libXft;
+procedure XftDrawSetClip(draw : PXftDraw; rg : TRegion); cdecl; external libXft;
+function  XftListFonts(display : PXDisplay; screen : integer; params : array of const) : PFcFontSet; cdecl; external libXft;
+function  XftNameUnparse(pat : PFcPattern; dest : PChar; destlen : integer) : boolean; cdecl; external libXft;
+procedure FcFontSetDestroy(fsp : PFcFontSet); cdecl; external libXft;
+
+implementation
+
+end.
+

+ 16 - 7
packages/x11/src/xrender.pp

@@ -1,7 +1,9 @@
 unit xrender;
+
 interface
+
 uses
-  x,xlib;
+  x, xlib, ctypes;
 
 {$ifndef os2}
   {$LinkLib c}
@@ -133,6 +135,13 @@ type
         colormap : TColormap;
      end;
 
+   TXRenderColor = record
+     red   : cushort;
+     green : cushort;
+     blue  : cushort;
+     alpha : cushort;
+   end;
+
 const
    PictFormatID = 1 shl 0;
    PictFormatType = 1 shl 1;
@@ -198,12 +207,12 @@ type
 
    PXGlyphInfo = ^TXGlyphInfo;
    TXGlyphInfo = record
-        width : word;
-        height : word;
-        x : smallint;
-        y : smallint;
-        xOff : smallint;
-        yOff : smallint;
+        width : cushort;
+        height : cushort;
+        x : cshort;
+        y : cshort;
+        xOff : cshort;
+        yOff : cshort;
      end;
 
 function XRenderQueryExtension(dpy:PDisplay; event_basep:Plongint; error_basep:Plongint):TBoolResult;cdecl;external libX11;