FreeType 1.31.1
This commit is contained in:
1
test/arch/unix/.cvsignore
Normal file
1
test/arch/unix/.cvsignore
Normal file
@@ -0,0 +1 @@
|
||||
Makefile
|
||||
170
test/arch/unix/Makefile.in
Normal file
170
test/arch/unix/Makefile.in
Normal file
@@ -0,0 +1,170 @@
|
||||
# This file is part of the FreeType project.
|
||||
#
|
||||
# test/arch/unix/Makefile.in
|
||||
|
||||
ARCH = arch/unix
|
||||
|
||||
top_builddir=..
|
||||
|
||||
VPATH = @srcdir@/../..
|
||||
srcdir = @srcdir@/../..
|
||||
|
||||
RM = @RM@
|
||||
RMF = @RM@ -f
|
||||
RMDIR = @RMDIR@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
|
||||
CC = @CC@
|
||||
CPP = @CPP@
|
||||
|
||||
LIBTOOL = $(top_builddir)/libtool
|
||||
MKINSTALLDIRS = $(srcdir)/../mkinstalldirs
|
||||
|
||||
include $(top_builddir)/MakeSub
|
||||
|
||||
FT_LIBDIR = $(srcdir)/../lib
|
||||
INCDIRS = -I. -I$(srcdir) -I$(top_builddir) \
|
||||
-I$(FT_LIBDIR) -I$(FT_LIBDIR)/extend
|
||||
|
||||
CFLAGS = @CFLAGS@ @X_CFLAGS@ @XX_CFLAGS@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
FT_CFLAGS = $(INCDIRS) $(CFLAGS) $(CPPFLAGS) -DX11 -DLOCALEDIR='"@LOCALEDIR@"'
|
||||
|
||||
FT_LIBS = @X_LIBS@ @X_PRE_LIBS@ @X_EXTRA_LIBS@ @LIBS@
|
||||
|
||||
SRC = $(srcdir)/arabic.c \
|
||||
$(srcdir)/common.c \
|
||||
$(srcdir)/ftdump.c \
|
||||
$(srcdir)/fterror.c \
|
||||
$(srcdir)/ftlint.c \
|
||||
$(srcdir)/ftmetric.c \
|
||||
$(srcdir)/ftsbit.c \
|
||||
$(srcdir)/ftstring.c \
|
||||
$(srcdir)/ftstrpnm.c \
|
||||
$(srcdir)/fttimer.c \
|
||||
$(srcdir)/ftview.c \
|
||||
$(srcdir)/ftzoom.c \
|
||||
$(srcdir)/ftstrtto.c \
|
||||
$(srcdir)/gmain.c \
|
||||
$(srcdir)/$(ARCH)/gwin_x11.c
|
||||
|
||||
DISPOBJS = common.o gmain.o display.o gwin_x11.o blitter.o
|
||||
|
||||
PROGRAMS = ftview fttimer ftlint ftdump ftzoom ftsbit \
|
||||
ftstring ftstrpnm fterror ftmetric ftstrtto
|
||||
|
||||
# set this variable to nil if you don't need to use Electric-Fence
|
||||
EFENCE =
|
||||
#EFENCE = -lefence
|
||||
|
||||
|
||||
# variables used to compile either with libtool or not
|
||||
#
|
||||
PROCESS = $(LIBTOOL) --mode=link $(CC) $(FT_CFLAGS)
|
||||
#PROCESS = $(CC) $(FT_CFLAGS)
|
||||
|
||||
LIBTTF = $(top_builddir)/lib/libttf.la
|
||||
#LIBTTF =$(top_builddir)/lib/libttf.a
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(FT_CFLAGS) $<
|
||||
|
||||
|
||||
all: $(PROGRAMS)
|
||||
|
||||
|
||||
gwin_x11.o: $(srcdir)/$(ARCH)/gwin_x11.c
|
||||
$(CC) -c $(FT_CFLAGS) $(srcdir)/$(ARCH)/gwin_x11.c
|
||||
|
||||
ftzoom: ftzoom.o $(DISPOBJS) $(LIBTTF)
|
||||
$(PROCESS) -o ftzoom ftzoom.o $(DISPOBJS) \
|
||||
$(EFENCE) $(LIBTTF) $(FT_LIBS) -lX11
|
||||
|
||||
fttimer: fttimer.o $(DISPOBJS) $(LIBTTF)
|
||||
$(PROCESS) -o fttimer fttimer.o $(DISPOBJS) \
|
||||
$(EFENCE) $(LIBTTF) $(FT_LIBS) -lX11
|
||||
|
||||
ftview: ftview.o $(DISPOBJS) $(LIBTTF)
|
||||
$(PROCESS) -o ftview ftview.o $(DISPOBJS) \
|
||||
$(EFENCE) $(LIBTTF) $(FT_LIBS) -lX11
|
||||
|
||||
ftlint: ftlint.o common.o $(LIBTTF)
|
||||
$(PROCESS) -o ftlint ftlint.o common.o \
|
||||
$(EFENCE) $(LIBTTF) $(FT_LIBS)
|
||||
|
||||
ftdump: ftdump.o common.o $(LIBTTF)
|
||||
$(PROCESS) -o ftdump ftdump.o common.o \
|
||||
$(EFENCE) $(LIBTTF) $(FT_LIBS)
|
||||
|
||||
ftmetric: ftmetric.o common.o $(LIBTTF)
|
||||
$(PROCESS) -o ftmetric ftmetric.o common.o \
|
||||
$(EFENCE) $(LIBTTF) $(FT_LIBS)
|
||||
|
||||
ftsbit: ftsbit.o common.o $(LIBTTF)
|
||||
$(PROCESS) -o ftsbit ftsbit.o common.o \
|
||||
$(EFENCE) $(LIBTTF)
|
||||
|
||||
ftstring: ftstring.o $(DISPOBJS) $(LIBTTF)
|
||||
$(PROCESS) -o ftstring ftstring.o $(DISPOBJS) \
|
||||
$(EFENCE) $(LIBTTF) $(FT_LIBS) -lX11
|
||||
|
||||
# ftstrpnm does not need any extra libraries
|
||||
ftstrpnm: ftstrpnm.o common.o $(LIBTTF)
|
||||
$(PROCESS) -o ftstrpnm ftstrpnm.o common.o \
|
||||
$(EFENCE) $(LIBTTF)
|
||||
|
||||
fterror: fterror.o common.o $(LIBTTF)
|
||||
$(PROCESS) -o fterror fterror.o common.o \
|
||||
$(EFENCE) $(LIBTTF) $(FT_LIBS)
|
||||
|
||||
ftstrtto: ftstrtto.o $(DISPOBJS) arabic.o $(LIBTTF)
|
||||
$(PROCESS) -o ftstrtto ftstrtto.o $(DISPOBJS) arabic.o \
|
||||
$(EFENCE) $(LIBTTF) $(FT_LIBS) -lX11
|
||||
|
||||
|
||||
install: $(PROGRAMS)
|
||||
$(MKINSTALLDIRS) $(bindir)
|
||||
for P in $(PROGRAMS) ; do \
|
||||
$(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$P $(bindir)/$$P ; \
|
||||
done
|
||||
|
||||
uninstall:
|
||||
-for P in $(PROGRAMS) ; do \
|
||||
$(LIBTOOL) --mode=uninstall $(RM) $(bindir)/$$P ; \
|
||||
done
|
||||
|
||||
clean: do_clean
|
||||
|
||||
distclean: do_clean
|
||||
-$(RMF) $(PROGRAMS)
|
||||
-$(RMF) *~ *.orig core *.core
|
||||
-$(RMF) config.cache config.log config.status
|
||||
-$(RMF) $(ARCH)/Makefile
|
||||
-$(RMF) .libs/*
|
||||
-$(RMDIR) .libs
|
||||
|
||||
do_clean:
|
||||
-$(RMF) *.o
|
||||
|
||||
depend:
|
||||
(echo '/^#.* PUT NO STUFF BELOW/,$$d' ; echo w ; echo q) | \
|
||||
ed - $(ARCH)/Makefile
|
||||
echo '# Dependencies generated by make depend: PUT NO STUFF BELOW' \
|
||||
>> $(ARCH)/Makefile
|
||||
for file in $(SRC) ; do \
|
||||
$(CPP) $(CPPFLAGS) $(INCDIRS) $$file | \
|
||||
sed -n -e 's|^# [1-9][0-9]* "\([^/].*\.h\)".*|\1|p' \
|
||||
-e 's|^# [1-9][0-9]* "\($(srcdir)/.*\.h\)".*|\1|p' | \
|
||||
sed -e 's|/\./|.|g' -e "s/^/`basename $$file .c`.o: /" ; \
|
||||
done | \
|
||||
sort -u | \
|
||||
awk '{ if (LINE == 1) \
|
||||
{ line = last = $$1 } \
|
||||
else if ($$1 != last) \
|
||||
{ print line ; line = last = $$1 } \
|
||||
line = line " " $$2 } \
|
||||
END { print line }' >> $(ARCH)/Makefile
|
||||
|
||||
# Dependencies generated by make depend: PUT NO STUFF BELOW
|
||||
451
test/arch/unix/gwin_x11.c
Normal file
451
test/arch/unix/gwin_x11.c
Normal file
@@ -0,0 +1,451 @@
|
||||
/*******************************************************************
|
||||
*
|
||||
* gwin_x11.c graphics utility X-Window driver. 1.0
|
||||
*
|
||||
* This is the driver for windowed display under X11, used by the
|
||||
* graphics utility of the FreeType test suite.
|
||||
*
|
||||
* Copyright 1996-1999 by
|
||||
* David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
*
|
||||
* This file is part of the FreeType project, and may only be used
|
||||
* modified and distributed under the terms of the FreeType project
|
||||
* license, LICENSE.TXT. By continuing to use, modify or distribute
|
||||
* this file you indicate that you have read the license and
|
||||
* understand and accept it fully.
|
||||
*
|
||||
******************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/cursorfont.h>
|
||||
|
||||
#include "common.h" /* for Panic() */
|
||||
#include "freetype.h"
|
||||
|
||||
#include "gdriver.h"
|
||||
#include "gevents.h"
|
||||
#include "gmain.h"
|
||||
|
||||
|
||||
/* Translator added to ease changes to control keys */
|
||||
|
||||
typedef struct _Translator
|
||||
{
|
||||
char key;
|
||||
GEvent event_class;
|
||||
int event_info;
|
||||
} Translator;
|
||||
|
||||
#define NUM_Translators 20
|
||||
|
||||
static const Translator trans[NUM_Translators] =
|
||||
{
|
||||
{ (char)27, event_Quit, 0 },
|
||||
{ 'q', event_Quit, 0 },
|
||||
|
||||
{ 'x', event_Rotate_Glyph, -1 },
|
||||
{ 'c', event_Rotate_Glyph, 1 },
|
||||
{ 'v', event_Rotate_Glyph, -16 },
|
||||
{ 'b', event_Rotate_Glyph, 16 },
|
||||
|
||||
{ '{', event_Change_Glyph, -10000 },
|
||||
{ '}', event_Change_Glyph, 10000 },
|
||||
{ '(', event_Change_Glyph, -1000 },
|
||||
{ ')', event_Change_Glyph, 1000 },
|
||||
{ '9', event_Change_Glyph, -100 },
|
||||
{ '0', event_Change_Glyph, 100 },
|
||||
{ 'i', event_Change_Glyph, -10 },
|
||||
{ 'o', event_Change_Glyph, 10 },
|
||||
{ 'k', event_Change_Glyph, -1 },
|
||||
{ 'l', event_Change_Glyph, 1 },
|
||||
|
||||
{ '+', event_Scale_Glyph, 10 },
|
||||
{ '-', event_Scale_Glyph, -10 },
|
||||
{ 'u', event_Scale_Glyph, 1 },
|
||||
{ 'j', event_Scale_Glyph, -1 }
|
||||
};
|
||||
|
||||
/* End of translators addition. See Get_Event() below */
|
||||
|
||||
extern char Header[]; /* defined in the test programs */
|
||||
|
||||
static Window win;
|
||||
static GC gcblack;
|
||||
static XColor color[5];
|
||||
|
||||
Display* display;
|
||||
static char* displayname = "";
|
||||
|
||||
static XImage* image;
|
||||
|
||||
static Visual* visual;
|
||||
static Colormap colormap;
|
||||
static int depth;
|
||||
static Bool gray;
|
||||
|
||||
static Cursor idle;
|
||||
static Cursor busy;
|
||||
|
||||
static int win_origin_x, win_origin_y,
|
||||
win_width, win_height;
|
||||
static int image_width, image_height;
|
||||
|
||||
long vioBufOfs;
|
||||
|
||||
|
||||
|
||||
/* restore acreen to its original state */
|
||||
|
||||
int Driver_Restore_Mode( void )
|
||||
{
|
||||
XUnmapWindow( display, win );
|
||||
XCloseDisplay( display );
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
|
||||
/* set graphics mode */
|
||||
|
||||
void x11init( void )
|
||||
{
|
||||
int screen_num, i;
|
||||
XTextProperty xtp;
|
||||
XSizeHints xsh;
|
||||
XSetWindowAttributes xswa;
|
||||
|
||||
#if 1
|
||||
unsigned short colors[5] = { 0, 16, 32, 48, 63 }; /* gamma = 1.0 */
|
||||
#else
|
||||
unsigned short colors[5] = { 0, 34, 46, 55, 63 }; /* gamma = 2.2 */
|
||||
#endif
|
||||
|
||||
|
||||
XrmInitialize();
|
||||
|
||||
if( !( display = XOpenDisplay( displayname ) ) )
|
||||
Panic( "ERROR: cannot open display\n" );
|
||||
|
||||
screen_num = DefaultScreen ( display );
|
||||
colormap = DefaultColormap( display, screen_num );
|
||||
depth = DefaultDepth ( display, screen_num );
|
||||
visual = DefaultVisual ( display, screen_num );
|
||||
|
||||
idle = XCreateFontCursor( display, XC_left_ptr );
|
||||
busy = XCreateFontCursor( display, XC_watch );
|
||||
|
||||
if ( gray )
|
||||
{
|
||||
int count;
|
||||
XPixmapFormatValues* formats;
|
||||
|
||||
|
||||
formats = XListPixmapFormats( display, &count );
|
||||
vio_ScanLineWidth = 0;
|
||||
|
||||
while ( count > 0 )
|
||||
{
|
||||
--count;
|
||||
if ( formats[count].depth == depth )
|
||||
{
|
||||
int bits;
|
||||
|
||||
bits = win_width * formats[count].bits_per_pixel;
|
||||
if ( bits % formats[count].scanline_pad )
|
||||
{
|
||||
bits -= bits % formats[count].scanline_pad;
|
||||
bits += formats[count].scanline_pad;
|
||||
}
|
||||
|
||||
vio_ScanLineWidth = bits / 8;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( !vio_ScanLineWidth )
|
||||
Panic( "ERROR: the display doesn't offer a suitable pixmap format\n" );
|
||||
|
||||
XFree( formats );
|
||||
}
|
||||
|
||||
Vio = (char*)malloc( win_height * vio_ScanLineWidth );
|
||||
|
||||
if ( !Vio )
|
||||
Panic( "ERROR: cannot malloc display memory\n" );
|
||||
|
||||
xswa.border_pixel = BlackPixel( display, screen_num );
|
||||
xswa.background_pixel = WhitePixel( display, screen_num );
|
||||
xswa.cursor = busy;
|
||||
|
||||
xswa.event_mask = KeyPressMask | ExposureMask;
|
||||
|
||||
win = XCreateWindow( display,
|
||||
RootWindow( display, screen_num ),
|
||||
win_origin_x,
|
||||
win_origin_y,
|
||||
win_width,
|
||||
win_height,
|
||||
10,
|
||||
depth,
|
||||
InputOutput,
|
||||
visual,
|
||||
CWBackPixel | CWBorderPixel | CWEventMask | CWCursor,
|
||||
&xswa );
|
||||
|
||||
XMapWindow( display, win );
|
||||
|
||||
gcblack = XCreateGC( display, RootWindow( display, screen_num ),
|
||||
0L, NULL );
|
||||
XSetForeground( display, gcblack, BlackPixel( display, screen_num ) );
|
||||
XSetBackground( display, gcblack, WhitePixel( display, screen_num ) );
|
||||
|
||||
/* allocate colors */
|
||||
|
||||
if ( gray )
|
||||
for ( i = 0; i < 5; i++ )
|
||||
{
|
||||
gray_palette[i] = i;
|
||||
|
||||
color[i].red =
|
||||
color[i].green =
|
||||
color[i].blue = 65535 - ( colors[i] * 65535 ) / 63;
|
||||
|
||||
if ( !XAllocColor( display, colormap, &color[i] ) )
|
||||
Panic( "ERROR: cannot allocate Color\n" );
|
||||
}
|
||||
|
||||
image = XCreateImage( display,
|
||||
visual,
|
||||
gray ? depth : 1,
|
||||
gray ? ZPixmap : XYBitmap,
|
||||
0,
|
||||
(char*)Vio,
|
||||
win_width,
|
||||
win_height,
|
||||
8,
|
||||
0 );
|
||||
if ( !image )
|
||||
Panic( "ERROR: cannot create image\n" );
|
||||
|
||||
if ( !gray )
|
||||
{
|
||||
image->byte_order = MSBFirst;
|
||||
image->bitmap_bit_order = MSBFirst;
|
||||
}
|
||||
|
||||
/* make window manager happy :-) */
|
||||
xtp.value = (unsigned char*)"FreeType";
|
||||
xtp.encoding = 31;
|
||||
xtp.format = 8;
|
||||
xtp.nitems = strlen( (char*)xtp.value );
|
||||
|
||||
xsh.x = win_origin_x;
|
||||
xsh.y = win_origin_y;
|
||||
|
||||
xsh.width = win_width;
|
||||
xsh.height = win_height;
|
||||
xsh.flags = (PPosition | PSize);
|
||||
xsh.flags = 0;
|
||||
|
||||
XSetWMProperties( display, win, &xtp, &xtp, NULL, 0, &xsh, NULL, NULL );
|
||||
}
|
||||
|
||||
|
||||
int Driver_Set_Graphics( int mode )
|
||||
{
|
||||
if ( mode == Graphics_Mode_Gray )
|
||||
{
|
||||
gray = 1;
|
||||
vio_ScanLineWidth = 320;
|
||||
|
||||
win_origin_x = 0;
|
||||
win_origin_y = 0;
|
||||
win_width = 320;
|
||||
win_height = 200;
|
||||
}
|
||||
else if ( mode == Graphics_Mode_Mono )
|
||||
{
|
||||
gray = 0;
|
||||
vio_ScanLineWidth = 80;
|
||||
|
||||
win_origin_x = 0;
|
||||
win_origin_y = 0;
|
||||
win_width = 640;
|
||||
win_height = 450;
|
||||
}
|
||||
else
|
||||
Panic( "ERROR: mode %d not supported\n", mode );
|
||||
|
||||
vio_Width = win_width;
|
||||
vio_Height = win_height;
|
||||
|
||||
x11init();
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
|
||||
void Put_Image( int x, int y, int w, int h )
|
||||
{
|
||||
XPutImage( display, win, gcblack, image, x, y, x, y, w, h );
|
||||
}
|
||||
|
||||
|
||||
int Driver_Display_Bitmap( char* buffer, int line, int col )
|
||||
{
|
||||
int z, y, used_col;
|
||||
char* target;
|
||||
|
||||
|
||||
XClearWindow( display, win );
|
||||
|
||||
/* this displays the Header string in the window title */
|
||||
XStoreName( display, win, Header );
|
||||
|
||||
if ( line > win_height )
|
||||
line = win_height;
|
||||
|
||||
if ( !gray )
|
||||
{
|
||||
if ( col > vio_ScanLineWidth )
|
||||
used_col = vio_ScanLineWidth;
|
||||
else
|
||||
used_col = col;
|
||||
|
||||
target = Vio + ( line - 1 ) * vio_ScanLineWidth;
|
||||
|
||||
for ( y = 0; y < line; y++ )
|
||||
{
|
||||
memcpy( (char*)target, buffer, used_col );
|
||||
target -= vio_ScanLineWidth;
|
||||
buffer += col;
|
||||
}
|
||||
|
||||
Put_Image( 0, 0, used_col * 8, line );
|
||||
image_width = used_col * 8;
|
||||
image_height = line;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( col > win_width )
|
||||
used_col = win_width;
|
||||
else
|
||||
used_col = col;
|
||||
|
||||
for ( y = line - 1; y >= 0; y-- )
|
||||
{
|
||||
char* bufp;
|
||||
|
||||
|
||||
bufp = buffer;
|
||||
|
||||
for ( z = 0; z < used_col; z++ )
|
||||
{
|
||||
int c;
|
||||
|
||||
|
||||
c = *bufp++;
|
||||
|
||||
if ( c < 0 || c >= 5 ) /* security check */
|
||||
{
|
||||
/* Message( "weird grayshade: %d\n", c ); */
|
||||
c = 0;
|
||||
}
|
||||
XPutPixel( image, z, y, color[c].pixel );
|
||||
}
|
||||
|
||||
buffer += col;
|
||||
}
|
||||
|
||||
Put_Image( 0, 0, used_col, line );
|
||||
image_width = used_col;
|
||||
image_height = line;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* This function maps X keystrokes into GEvents. Note that */
|
||||
/* currently only keystrokes events exit this function. */
|
||||
|
||||
void Get_Event( TEvent* event )
|
||||
{
|
||||
static char key_buffer[10];
|
||||
static int key_cursor = 0;
|
||||
static int key_number = 0;
|
||||
static XEvent x_event;
|
||||
KeySym key;
|
||||
|
||||
int i, bool_exit;
|
||||
char c;
|
||||
|
||||
XComposeStatus compose;
|
||||
|
||||
|
||||
bool_exit = key_cursor < key_number;
|
||||
|
||||
XDefineCursor( display, win, idle );
|
||||
|
||||
while ( !bool_exit )
|
||||
{
|
||||
XNextEvent( display, &x_event );
|
||||
|
||||
switch ( x_event.type )
|
||||
{
|
||||
case KeyPress:
|
||||
key_number = XLookupString( &x_event.xkey,
|
||||
key_buffer,
|
||||
sizeof ( key_buffer ),
|
||||
&key,
|
||||
&compose );
|
||||
key_cursor = 0;
|
||||
|
||||
if ( key_number > 0 )
|
||||
bool_exit = 1;
|
||||
break;
|
||||
|
||||
case MappingNotify:
|
||||
XRefreshKeyboardMapping( &x_event.xmapping );
|
||||
break;
|
||||
|
||||
case Expose:
|
||||
#if 0
|
||||
Put_Image( x_event.xexpose.x,
|
||||
x_event.xexpose.y,
|
||||
x_event.xexpose.width,
|
||||
x_event.xexpose.height );
|
||||
#else
|
||||
/* we always redraw the whole image */
|
||||
Put_Image( 0, 0, image_width, image_height );
|
||||
#endif
|
||||
break;
|
||||
|
||||
/* You should add more cases to handle mouse events, etc. */
|
||||
}
|
||||
}
|
||||
|
||||
XDefineCursor( display, win, busy );
|
||||
XFlush ( display );
|
||||
|
||||
c = key_buffer[key_cursor++];
|
||||
|
||||
for ( i = 0; i < NUM_Translators; i++ )
|
||||
{
|
||||
if ( c == trans[i].key )
|
||||
{
|
||||
event->what = trans[i].event_class;
|
||||
event->info = trans[i].event_info;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
event->what = event_Keyboard;
|
||||
event->info = (int)c;
|
||||
}
|
||||
|
||||
|
||||
/* End */
|
||||
Reference in New Issue
Block a user