summaryrefslogtreecommitdiff
path: root/src/corelib/x11/x11_xft.pas
blob: 805797cd229800cc1fde909d7d004ed6d9eda015 (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
{
    fpGFX  -  Free Pascal Graphics Library
    Copyright (C) 2006-2007 by Graeme Geldenhuys
      member of the fpGFX development team.

    Xft interface functions

    See the file COPYING.fpGFX, included in this distribution,
    for details about the copyright.

    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.

 **********************************************************************}


unit x11_xft;

{$mode objfpc}{$H+}

{$linklib Xft}

interface
uses
  Classes
  ,SysUtils
  ,X
  ,XLib
  ,Xutil
  ;
  
  
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';

  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;
procedure XftDrawChange(xftd : PXftDraw; win : TXID); cdecl;
procedure XftDrawDestroy(draw : PXftDraw); cdecl;

function XftDrawPicture(draw : PXftDraw) : TPicture; cdecl;

function XftFontOpenName(display : PXDisplay; scr : integer; par3 : PChar) : PXftFont; cdecl;
procedure XftFontClose(display : PXDisplay; fnt : PXftFont); cdecl;

procedure XftDrawStringUtf8(draw : PXftDraw; var col : TXftColor; fnt : PXftFont; x,y : integer; txt : PChar; len : integer); cdecl;
procedure XftDrawString8(draw : PXftDraw; var col : TXftColor; fnt : PXftFont; x,y : integer; txt : PChar; len : integer); cdecl;
procedure XftDrawString16(draw : PXftDraw; var col : TXftColor; fnt : PXftFont; x,y : integer; txt : PChar; len : integer); cdecl;

procedure XftTextExtentsUtf8(display : PXDisplay; fnt : PXftFont; txt : PChar; len : integer; var extents : TXGlyphInfo); cdecl;
procedure XftTextExtents8(display : PXDisplay; fnt : PXftFont; txt : PChar; len : integer; var extents : TXGlyphInfo); cdecl;
procedure XftTextExtents16(display : PXDisplay; fnt : PXftFont; txt : PChar; len : integer; var extents : TXGlyphInfo); cdecl;

//function XftGlyphExists(display : PXDisplay; fnt : PXftFont; ch : integer) : longbool; cdecl;

//procedure XftDrawSetClipRectangles(draw : PXftDraw; xorigin, yorigin : integer; rect : PXRectangle; rnum : integer); cdecl;

procedure XftDrawSetClip(draw : PXftDraw; rg : TRegion); cdecl;

function XftListFonts(display : PXDisplay; screen : integer; params : array of const) : PFcFontSet; cdecl;
function XftNameUnparse(pat : PFcPattern; dest : PChar; destlen : integer) : boolean; cdecl;
procedure FcFontSetDestroy(fsp : PFcFontSet); cdecl;



implementation


function XftDrawCreate(display : PXDisplay; win : TXID; vis : PVisual; colorm : longint) : PXftDraw; cdecl; external;
procedure XftDrawChange(xftd : PXftDraw; win : TXID); cdecl; external;
procedure XftDrawDestroy(draw : PXftDraw); cdecl; external;

function XftDrawPicture(draw : PXftDraw) : TPicture; cdecl; external;

function XftFontOpenName(display : PXDisplay; scr : integer; par3 : PChar) : PXftFont; cdecl; external;
procedure XftFontClose(display : PXDisplay; fnt : PXftFont); cdecl; external;

procedure XftDrawStringUtf8(draw : PXftDraw; var col : TXftColor; fnt : PXftFont; x,y : integer; txt : PChar; len : integer); cdecl; external;
procedure XftDrawString8(draw : PXftDraw; var col : TXftColor; fnt : PXftFont; x,y : integer; txt : PChar; len : integer); cdecl; external;
procedure XftDrawString16(draw : PXftDraw; var col : TXftColor; fnt : PXftFont; x,y : integer; txt : PChar; len : integer); cdecl; external;

procedure XftTextExtentsUtf8(display : PXDisplay; fnt : PXftFont; txt : PChar; len : integer; var extents : TXGlyphInfo); cdecl; external;
procedure XftTextExtents8(display : PXDisplay; fnt : PXftFont; txt : PChar; len : integer; var extents : TXGlyphInfo); cdecl; external;
procedure XftTextExtents16(display : PXDisplay; fnt : PXftFont; txt : PChar; len : integer; var extents : TXGlyphInfo); cdecl; external;

//function XftGlyphExists(display : PXDisplay; fnt : PXftFont; ch : integer) : longbool; cdecl; external;

//procedure XftDrawSetClipRectangles(draw : PXftDraw; xorigin, yorigin : integer; rect : PXRectangle; rnum : integer); cdecl; external;

procedure XftDrawSetClip(draw : PXftDraw; rg : TRegion); cdecl; external;

function XftListFonts(display : PXDisplay; screen : integer; params : array of const) : PFcFontSet; cdecl; external;
function XftNameUnparse(pat : PFcPattern; dest : PChar; destlen : integer) : boolean; cdecl; external;
procedure FcFontSetDestroy(fsp : PFcFontSet); cdecl; external;

end.