summaryrefslogtreecommitdiff
path: root/src/corelib/x11/fpg_xft_x11.pas
blob: 8d095e67c063bcdb5ca3cd5a1202a894d1c7f06a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
{
    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.

    Description:
      Xft interface functions
}

unit fpg_xft_x11;

{$mode objfpc}{$H+}
{$linklib Xft}

interface
uses
  Classes
  ,SysUtils
  ,X
  ,XLib
  ,Xutil
  ;

const
  {$IF Defined(DARWIN)}
    libXft = 'libXft.dylib';
    {$LINKLIB libXft}
    fclib = 'libfontconfig.dylib';
    {$LINKLIB libfontconfig}
  {$ELSE}
    libXft = 'libXft.so';
    fclib = 'fontconfig';
  {$IFEND}

  
type
  TPicture = longword;

  TXftDraw = record
               dummy : Pointer;
             end;
  PXftDraw = ^TXftDraw;

  TXftFont = record
               ascent   : integer;
               descent  : integer;
               height   : integer;
               max_advance_width : integer;
               ptr1     : Pointer;  // charset
               ptr2     : Pointer;  // pattern
             end;
  PXftFont = ^TXftFont;

  TXRenderColor = record
                    red   : word;
                    green : word;
                    blue  : word;
                    alpha : word;
                  end;

  TXftColor = record
                pixel : ptrint;
                color : TXRenderColor;
              end;
              
  TXGlyphInfo = packed record
                  width   : word;
                  height  : word;
                  x       : smallint;
                  y       : smallint;
                  xOff    : smallint;
                  yOff    : smallint;
                end;

  TFcPattern = record
    dummy : integer;
  end;

  PFcPattern = ^TFcPattern;
  PPFcPattern = ^PFcPattern;

  TFcFontSet = packed record
    nfont : integer;
    sfont : integer;
    fonts : PPFcPattern;
  end;
  PFcFontSet = ^TFcFontSet;

const
//  FC_FAMILY  : PChar = 'family';
//  FC_SIZE    : PChar = 'size';
//  FC_SCALABLE : PChar = 'scalable';

  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_VERTICAL_LAYOUT = 'verticallayout';//* Bool (false) */
  FC_AUTOHINT =	       'autohint';	//* Bool (false) */
  FC_GLOBAL_ADVANCE =  'globaladvance';	//* Bool (true) */
  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_MATRIX =          'matrix';
  FC_CHAR_WIDTH =      'charwidth';

  FC_WEIGHT_BOLD = 200;
  FC_SLANT_ITALIC = 100;
  FC_PROPORTIONAL = 0;
  FC_MONO = 100;


  FcTypeVoid         = 0;
  FcTypeInteger      = 1;
  FcTypeDouble       = 2;
  FcTypeString       = 3;
  FcTypeBool         = 4;
  FcTypeMatrix       = 5;
  FcTypeCharSet      = 6;
  FcTypeFTFace       = 7;
  FcTypeLangSet      = 8;



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 fclib;


//function FcFontList(config: PFcConfig; p:PFcPattern; os:PFcObjectSet): PFcFontSet;cdecl; external fclib name 'FcFontList';


implementation

end.