├── .gitignore ├── .mailmap ├── ChangeLog ├── Jamfile ├── Jamrules ├── Makefile ├── README ├── bin ├── .gitignore └── README ├── graph ├── Jamfile ├── allegro │ ├── gralleg.c │ ├── gralleg.h │ └── rules.mk ├── beos │ ├── Jamfile │ ├── grbeos.cpp │ ├── grbeos.h │ └── rules.mk ├── gblany.h ├── gblbgra.h ├── gblblit.c ├── gblblit.h ├── gblcolor.h ├── gblender.c ├── gblender.h ├── gblhbgr.h ├── gblhrgb.h ├── gblvbgr.h ├── gblvrgb.h ├── graph.h ├── grblit.c ├── grblit.h ├── grconfig.h ├── grdevice.c ├── grdevice.h ├── grevents.h ├── grfill.c ├── grfont.c ├── grfont.h ├── grinit.c ├── grobjs.c ├── grobjs.h ├── grswizzle.c ├── grswizzle.h ├── grtypes.h ├── mac │ ├── grmac.c │ └── grmac.h ├── migs.html ├── os2 │ ├── Jamfile │ ├── gros2pm.c │ ├── gros2pm.def │ ├── gros2pm.h │ └── rules.mk ├── rules.mk ├── win32 │ ├── Jamfile │ ├── grwin32.c │ ├── grwin32.h │ └── rules.mk ├── x11 │ ├── Jamfile │ ├── grx11.c │ ├── grx11.h │ └── rules.mk └── xtest.c ├── mac ├── Makefile ├── README ├── ascii2mpw.py ├── codewarrior │ ├── carbonprefix.h │ ├── ftlint.prj │ └── ftview.prj ├── ftlint_m.c ├── ftoldmac.c ├── ftoldmac.m68k_far.make.txt ├── ftoldmac.ppc_classic.make.txt ├── ftview_m.c ├── getargv.c ├── getargv.h └── resource.hqx ├── obj ├── .gitignore └── README ├── src ├── Jamfile ├── common.c ├── common.h ├── compos.c ├── ftbench.1 ├── ftbench.c ├── ftchkwd.c ├── ftcommon.c ├── ftcommon.h ├── ftdiff.1 ├── ftdiff.c ├── ftdump.1 ├── ftdump.c ├── ftgamma.1 ├── ftgamma.c ├── ftgrid.1 ├── ftgrid.c ├── ftinspect │ ├── .gitignore │ ├── engine │ │ ├── engine.cpp │ │ └── engine.hpp │ ├── ftinspect-build.sh │ ├── ftinspect-qt4 │ ├── ftinspect-qt4.pro │ ├── ftinspect-qt5 │ ├── ftinspect-qt5.pro │ ├── ftinspect.cpp │ ├── ftinspect.pro │ ├── maingui.cpp │ ├── maingui.hpp │ ├── rendering │ │ ├── glyphbitmap.cpp │ │ ├── glyphbitmap.hpp │ │ ├── glyphoutline.cpp │ │ ├── glyphoutline.hpp │ │ ├── glyphpointnumbers.cpp │ │ ├── glyphpointnumbers.hpp │ │ ├── glyphpoints.cpp │ │ ├── glyphpoints.hpp │ │ ├── grid.cpp │ │ └── grid.hpp │ └── widgets │ │ ├── qcomboboxx.cpp │ │ ├── qcomboboxx.hpp │ │ ├── qgraphicsviewx.cpp │ │ ├── qgraphicsviewx.hpp │ │ ├── qpushbuttonx.cpp │ │ ├── qpushbuttonx.hpp │ │ ├── qspinboxx.cpp │ │ └── qspinboxx.hpp ├── ftlint.1 ├── ftlint.c ├── ftmemchk.c ├── ftmulti.1 ├── ftmulti.c ├── ftpatchk.c ├── ftsbit.c ├── ftstring.1 ├── ftstring.c ├── fttimer.c ├── fttry.c ├── ftvalid.1 ├── ftvalid.c ├── ftview.1 ├── ftview.c ├── gbench.c ├── gbench.h ├── mlgetopt.c ├── mlgetopt.h ├── output.c ├── output.h ├── testname.c ├── ttdebug.1 └── ttdebug.c └── vms_make.com /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | cmake-build-debug -------------------------------------------------------------------------------- /.mailmap: -------------------------------------------------------------------------------- 1 | Alexei Podtelezhnikov (Алексей Подтележников) 2 | Behdad Esfahbod 3 | Bram Tassyns bram tassyns 4 | Bram Tassyns 5 | Suzuki, Toshiya (鈴木俊哉) 6 | Suzuki, Toshiya (鈴木俊哉) sssa 7 | Suzuki, Toshiya (鈴木俊哉) suzuki toshiya 8 | Suzuki, Toshiya (鈴木俊哉) sssa 9 | -------------------------------------------------------------------------------- /Jamfile: -------------------------------------------------------------------------------- 1 | # FreeType2 demos top Jamfile (c) 2001 David Turner 2 | # 3 | 4 | if $(FT2DEMO_TOP) != $(DOT) 5 | { 6 | SubDir FT2DEMO_TOP ; 7 | } 8 | 9 | # compile FreeType library here! 10 | # 11 | FT2_TOP ?= ../freetype2 ; 12 | 13 | SubInclude FT2_TOP ; 14 | 15 | FT2DEMO_SRC = [ FT2DEMO_SubDir src ] ; 16 | FT2DEMO_GRAPH = [ FT2DEMO_SubDir graph ] ; 17 | 18 | # Include Graph sub-system rules 19 | # 20 | SubInclude FT2DEMO_GRAPH ; 21 | 22 | # Include demos rules 23 | # 24 | SubInclude FT2DEMO_SRC ; 25 | 26 | 27 | # end of top Jamfile 28 | -------------------------------------------------------------------------------- /Jamrules: -------------------------------------------------------------------------------- 1 | # FreeType 2 Demos JamRules (c) 2001 David Turner 2 | # 3 | # This file contains the Jam rules needed to build the FreeType 2 Demos. 4 | # It is shared by all Jamfiles and is included only once in the build 5 | # process. 6 | # 7 | 8 | 9 | # Determine prefix of library file. We must use "libxxxxx" on Unix systems, 10 | # while all other simply use the real name. 11 | # 12 | if $(UNIX) 13 | { 14 | LIBPREFIX ?= lib ; 15 | } 16 | else 17 | { 18 | LIBPREFIX ?= "" ; 19 | } 20 | 21 | 22 | FT2_TOP ?= [ FDirName $(DOTDOT) freetype2 ] ; 23 | 24 | # FT2_INCLUDE contains the location of the public FreeType 2 header files 25 | # it is ../freetype2/include by default 26 | # 27 | FT2_INCLUDE ?= [ FDirName $(FT2_TOP) include ] ; 28 | 29 | 30 | # FT2_LIB contains the path to the FreeType 2 library object 31 | # 32 | FT2_LIB ?= [ FDirName $(FT2_TOP) objs $(LIBPREFIX)freetype$(SUFLIB) ] ; 33 | 34 | # X11_LINKLIBS is only used when compiling the X11 graphics back-end 35 | # this should be generated from a "configure" script on Unix 36 | # 37 | X11_LINKLIBS = -lX11 -L/usr/X11R6/lib ; 38 | 39 | 40 | # FT2DEMO_TOP contains the location of the FreeType demos directory. 41 | # 42 | FT2DEMO_TOP ?= $(DOT) ; 43 | 44 | 45 | # Define a new rule used to declare a sub directory of the Nirvana source 46 | # tree. 47 | # 48 | rule FT2DEMO_SubDir 49 | { 50 | if $(FT2DEMO_TOP) = $(DOT) 51 | { 52 | return [ FDirName $(<) ] ; 53 | } 54 | else 55 | { 56 | return [ FDirName $(FT2DEMO_TOP) $(<) ] ; 57 | } 58 | } 59 | 60 | # We also set ALL_LOCATE_TARGET in order to place all object and library 61 | # files in "objs". 62 | # 63 | ALL_LOCATE_TARGET ?= [ FT2DEMO_SubDir objs ] ; 64 | 65 | 66 | # end of Jamrules 67 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | This package contains example programs for the FreeType 2 library. 2 | 3 | 4 | WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING 5 | 6 | The Makefile and Jamfile contained in this directory assume that the 7 | FreeType 2 library sources are located in `../freetype2'. If you 8 | downloaded one of the stable FreeType 2 source packages from our 9 | server, you most probably have to rename its directory, for example: 10 | 11 | mv freetype-2.8 freetype2 on Unix 12 | rename freetype-2.8 freetype2 on Windows 13 | 14 | WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING 15 | 16 | 17 | First compile the FreeType 2 library, then say `make'. However, you 18 | must rename the directory of the FreeType 2 library to `freetype2' 19 | (or create a symlink) before doing this. 20 | 21 | Note that the demonstration programs include a tiny graphics 22 | sub-system that includes `drivers' to display Windows on Win32, X11, 23 | BeOS, Mac, and OS/2. The build system should automatically detect 24 | which driver to use based on the current platform. 25 | 26 | UNIX USERS 27 | ========== 28 | 29 | X11 issues 30 | ---------- 31 | 32 | When building the demos, the build system tries to detect your X11 33 | path by looking for the patterns `X11/bin', `X11R6/bin', and 34 | `X11R5/bin' in your current path (in this order). If no X11 path 35 | is found, some demo programs will not be able to display graphics 36 | and will fail. If you have X11 in an unusual place, use the 37 | X11_PATH make variable. More than one directory, if necessary, 38 | must be separated with spaces. Example: 39 | 40 | make X11_PATH="/usr/openwin /usr/local/X11R6" 41 | 42 | The build system then derives the X11_INCLUDE include file path 43 | from X11_PATH by appending `/include' to all path components. It 44 | also derives the X11_LIB library path from X11_PATH by appending 45 | `/lib64' and `/lib' to all components (in that order). You might 46 | override those variables similar to X11_PATH as arguments to 47 | `make'. 48 | 49 | If you don't have X11 at all, fix the definition of the EXES 50 | variable as described in the top-level Makefile. 51 | 52 | Recent versions of Mac OS X no longer deliver X11 by default; you 53 | have to install XQuartz, see 54 | 55 | https://support.apple.com/en-us/HT201341 56 | 57 | for more details. 58 | 59 | 60 | Using a different build directory 61 | --------------------------------- 62 | 63 | If the `configure' script of the FreeType 2 library is run from a 64 | separate build directory, it creates a dummy Makefile which sets 65 | some variables before including the top-level Makefile of the 66 | source directory. This dummy Makefile can also be used for the 67 | ft2demos package to be compiled in a different build directory: 68 | 69 | make FT2DEMOS=1 -f /path/to/freetype2/build-dir/Makefile 70 | 71 | If necessary, adapt the `TOP_DIR_2' variable to make it point to 72 | the ft2demos source directory. 73 | 74 | --- end of README --- 75 | -------------------------------------------------------------------------------- /bin/.gitignore: -------------------------------------------------------------------------------- 1 | ftbench 2 | ftchkwd 3 | ftdiff 4 | ftdump 5 | ftgamma 6 | ftgrid 7 | ftlint 8 | ftmemchk 9 | ftmulti 10 | ftpatchk 11 | ftstring 12 | fttimer 13 | ftvalid 14 | ftview 15 | testname 16 | ttdebug 17 | .libs 18 | -------------------------------------------------------------------------------- /bin/README: -------------------------------------------------------------------------------- 1 | This directory contains all executables for the FreeType demo programs 2 | -------------------------------------------------------------------------------- /graph/Jamfile: -------------------------------------------------------------------------------- 1 | # FreeType2 demo graph Jamfile (c) 2001 David Turner 2 | # 3 | 4 | SubDir FT2DEMO_TOP graph ; 5 | 6 | GRAPH_INCLUDE = $(FT2DEMO_GRAPH) ; 7 | GRAPH_LIB = $(LIBPREFIX)graph$(SUFLIB) ; 8 | 9 | graph_sources = grblit 10 | grobjs 11 | grfont 12 | grdevice 13 | grinit 14 | gblender 15 | gblblit 16 | grfill 17 | grswizzle 18 | ; 19 | 20 | if $(OS) = BEOS 21 | { 22 | DEVICE_DEFINE = -DDEVICE_BEOS ; 23 | } 24 | else if $(UNIX) 25 | { 26 | DEVICE_DEFINE = -DDEVICE_X11 ; 27 | } 28 | else if $(NT) 29 | { 30 | DEVICE_DEFINE = -DDEVICE_WIN32 ; 31 | } 32 | else if $(OS2) 33 | { 34 | DEVICE_DEFINE = -DDEVICE_OS2 ; 35 | } 36 | 37 | CCFLAGS on grinit$(SUFOBJ) = $(CCFLAGS) $(DEVICE_DEFINE) ; 38 | 39 | Library $(GRAPH_LIB) : $(graph_sources).c ; 40 | 41 | if $(OS) = BEOS 42 | { 43 | SubInclude FT2DEMO_TOP graph beos ; 44 | } 45 | else if $(UNIX) 46 | { 47 | SubInclude FT2DEMO_TOP graph x11 ; 48 | } 49 | else if $(NT) 50 | { 51 | SubInclude FT2DEMO_TOP graph win32 ; 52 | } 53 | else if $(OS2) 54 | { 55 | SubInclude FT2DEMO_TOP graph os2 ; 56 | } 57 | 58 | # end of graph Jamfile 59 | -------------------------------------------------------------------------------- /graph/allegro/gralleg.c: -------------------------------------------------------------------------------- 1 | /******************************************************************* 2 | * 3 | * ft2demos/graph/allegro/gralleg.c 4 | * 5 | * Allegro driver for MiGS (minimalist graphics subsystem). Allegro 6 | * (Allegro Low LEvel Gaming ROutines) is a library for sound, 7 | * graphics, timers, etc., and is available on 32-bit DOS, Windows, 8 | * UNIX (X11, DGA, DGA2), Linux (svgalib, framebuffer) and BeOS. 9 | * 10 | * http://liballeg.org/ 11 | * https://github.com/liballeg 12 | * 13 | ******************************************************************/ 14 | 15 | /* FT graphics subsystem */ 16 | #include "grobjs.h" 17 | #include "grdevice.h" 18 | 19 | /* Allegro header */ 20 | #include 21 | 22 | static void set_graypalette() 23 | { 24 | PALETTE pal; 25 | int i = 0; 26 | 27 | for(; i < 256; i++) { 28 | pal[i].r = i >> 2; 29 | pal[i].g = i >> 2; 30 | pal[i].b = i >> 2; 31 | } 32 | 33 | set_palette(pal); 34 | } 35 | 36 | static int almodes[] = { 37 | 32, 38 | 24, 39 | 16, 40 | 15, 41 | 8, 42 | 0 43 | }; 44 | 45 | static int gray[256]; 46 | 47 | static int init_device(void) 48 | { 49 | int* almode = almodes; 50 | 51 | if(allegro_init()) return -1; 52 | if(install_keyboard()) return -1; 53 | 54 | while(*almode) { 55 | set_color_depth(*almode); 56 | if(*almode == 8) set_graypalette(); 57 | if(set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) == 0) { 58 | int i = 0; 59 | for(; i < 256; i++) gray[i] = makecol(i, i, i); 60 | 61 | clear(screen); 62 | return 0; 63 | } 64 | almode++; 65 | } 66 | 67 | return -1; 68 | } 69 | 70 | static void done_device(void) 71 | { 72 | allegro_exit(); 73 | } 74 | 75 | static void alset_title(grSurface* surface, const char* title_string) 76 | { 77 | set_window_title(title_string); 78 | } 79 | 80 | static void alrefresh_rect(grSurface* surface, int x, int y, int width, int height) 81 | { 82 | unsigned char* bufptr = surface->bitmap.buffer; 83 | int cx = 0, cy = 0; 84 | 85 | switch(surface->bitmap.mode) { 86 | case gr_pixel_mode_mono: 87 | for(; cy < height; cy++) { 88 | for(cx = 0; cx < width; cx++) { 89 | putpixel(screen, cx + x, cy + y, (*bufptr++ ? gray[255] : gray[0])); 90 | } 91 | } 92 | break; 93 | 94 | case gr_pixel_mode_gray: 95 | for(; cy < height; cy++) { 96 | for(cx = 0; cx < width; cx++) { 97 | putpixel(screen, cx + x, cy + y, gray[*bufptr++]); 98 | } 99 | } 100 | break; 101 | 102 | default: 103 | break; 104 | } 105 | } 106 | 107 | static void aldone(grSurface* surface) 108 | { 109 | grDoneBitmap(&(surface->bitmap)); 110 | } 111 | 112 | static int key_translator[] = { 113 | KEY_F1, grKeyF1, 114 | KEY_F2, grKeyF2, 115 | KEY_F3, grKeyF3, 116 | KEY_F4, grKeyF4, 117 | KEY_F5, grKeyF5, 118 | KEY_F6, grKeyF6, 119 | KEY_F7, grKeyF7, 120 | KEY_F8, grKeyF8, 121 | KEY_F9, grKeyF9, 122 | KEY_F10, grKeyF10, 123 | KEY_F11, grKeyF11, 124 | KEY_F12, grKeyF12, 125 | KEY_LEFT, grKeyLeft, 126 | KEY_RIGHT, grKeyRight, 127 | KEY_UP, grKeyUp, 128 | KEY_DOWN, grKeyDown, 129 | KEY_INSERT, grKeyIns, 130 | KEY_DEL, grKeyDel, 131 | KEY_HOME, grKeyHome, 132 | KEY_END, grKeyEnd, 133 | KEY_PGUP, grKeyPageUp, 134 | KEY_PGDN, grKeyPageDown, 135 | KEY_ESC, grKeyEsc, 136 | KEY_TAB, grKeyTab, 137 | KEY_BACKSPACE, grKeyBackSpace, 138 | KEY_ENTER, grKeyReturn, 139 | 0, 0 140 | }; 141 | 142 | static int translateKey(int scancode) 143 | { 144 | int* trans = key_translator; 145 | 146 | while(*trans) { 147 | if(scancode == *trans++) { 148 | return *trans; 149 | } 150 | trans++; 151 | } 152 | 153 | return 0; 154 | } 155 | 156 | static int allisten_event(grSurface* surface, int event_mode, grEvent* event) 157 | { 158 | int ch = 0, ascii = 0, scancode = 0, shifts = 0; 159 | 160 | event->type = gr_event_key; 161 | 162 | while(1) { 163 | ch = readkey(); 164 | 165 | shifts = 0; 166 | 167 | if(key_shifts & KB_SHIFT_FLAG) shifts |= grKeyShift; 168 | if(key_shifts & KB_CTRL_FLAG) shifts |= grKeyCtrl; 169 | if(key_shifts & KB_ALT_FLAG) shifts |= grKeyAlt; 170 | 171 | ascii = ch & 0xFF; 172 | scancode = ch >> 8; 173 | 174 | if(ascii > 31 && ascii < 127) { 175 | event->key = ascii | shifts; 176 | return 1; 177 | } 178 | 179 | if( (ch = translateKey(scancode)) ) { 180 | event->key = ch | shifts; 181 | return 1; 182 | } 183 | } 184 | 185 | return 0; 186 | } 187 | 188 | static int init_surface(grSurface* surface, grBitmap* bitmap) 189 | { 190 | if(grNewBitmap(bitmap->mode, bitmap->grays, bitmap->width, bitmap->rows, bitmap)) return 0; 191 | 192 | surface->device = &gr_alleg_device; 193 | surface->bitmap = *bitmap; 194 | surface->refresh = 0; 195 | surface->owner = 0; 196 | surface->saturation = 0; 197 | surface->blit_mono = 0; 198 | 199 | surface->refresh_rect = alrefresh_rect; 200 | surface->set_title = alset_title; 201 | surface->listen_event = allisten_event; 202 | surface->done = aldone; 203 | 204 | return 1; 205 | } 206 | 207 | grDevice gr_alleg_device = 208 | { 209 | sizeof(grSurface), 210 | "Allegro", 211 | 212 | init_device, 213 | done_device, 214 | 215 | init_surface, 216 | 217 | 0, 218 | 0 219 | }; 220 | 221 | -------------------------------------------------------------------------------- /graph/allegro/gralleg.h: -------------------------------------------------------------------------------- 1 | #ifndef GRALLEG_H_ 2 | #define GRALLEG_H_ 3 | 4 | #include "grobjs.h" 5 | 6 | extern 7 | grDevice gr_alleg_device; 8 | 9 | #ifdef GR_INIT_BUILD 10 | static 11 | grDeviceChain gr_alleg_device_chain = 12 | { 13 | "Allegro", 14 | &gr_alleg_device, 15 | GR_INIT_DEVICE_CHAIN 16 | }; 17 | 18 | #undef GR_INIT_DEVICE_CHAIN 19 | #define GR_INIT_DEVICE_CHAIN &gr_alleg_device_chain 20 | 21 | #endif /* GR_INIT_BUILD */ 22 | 23 | #endif /* GRALLEG_H_ */ 24 | -------------------------------------------------------------------------------- /graph/allegro/rules.mk: -------------------------------------------------------------------------------- 1 | #************************************************************************** 2 | #* 3 | #* Allegro driver makefile 4 | #* 5 | #************************************************************************** 6 | 7 | # test for the `ALLEGRO' environment variable. This is non-optimal. 8 | # 9 | ifdef ALLEGRO 10 | 11 | # directory of Allegro driver 12 | # 13 | GR_ALLEG := $(GRAPH)/allegro 14 | 15 | # add Allegro driver to lib objects 16 | # 17 | GRAPH_OBJS += $(OBJ_DIR_2)/gralleg.$O 18 | 19 | # add Allegro driver to list of devices 20 | # 21 | DEVICES += ALLEGRO 22 | 23 | # our compilation rule 24 | # 25 | $(OBJ_DIR_2)/gralleg.$O : $(GR_ALLEG)/gralleg.c $(GR_ALLEG)/gralleg.h 26 | $(CC) $(CFLAGS) $(GRAPH_INCLUDES:%=$I%) \ 27 | $I$(subst /,$(COMPILER_SEP),$(GR_ALLEG)) \ 28 | $T$(subst /,$(COMPILER_SEP),$@ $<) 29 | 30 | # we need to link with Allegro 31 | # 32 | GRAPH_LINK += -lalleg 33 | 34 | endif # test ALLEGRO 35 | 36 | # EOF 37 | -------------------------------------------------------------------------------- /graph/beos/Jamfile: -------------------------------------------------------------------------------- 1 | # FreeType2 demos graph/beos Jamfile (c) 2002 David Turner 2 | # 3 | 4 | SubDir FT2DEMO_TOP graph beos ; 5 | 6 | SubDirHdrs $(GRAPH_INCLUDE) ; 7 | 8 | GRAPH_LINKLIBS = -lbe -lstdc++.r4 ; 9 | 10 | Library $(GRAPH_LIB) : grbeos.cpp ; 11 | 12 | # end of graph/beos Jamfile 13 | -------------------------------------------------------------------------------- /graph/beos/grbeos.h: -------------------------------------------------------------------------------- 1 | #ifndef GRBEOS_H_ 2 | #define GRBEOS_H_ 3 | 4 | #include "grobjs.h" 5 | 6 | extern 7 | grDevice gr_beos_device; 8 | 9 | #ifdef GR_INIT_BUILD 10 | static 11 | grDeviceChain gr_beos_device_chain = 12 | { 13 | "beos", 14 | &gr_beos_device, 15 | GR_INIT_DEVICE_CHAIN 16 | }; 17 | 18 | #undef GR_INIT_DEVICE_CHAIN 19 | #define GR_INIT_DEVICE_CHAIN &gr_beos_device_chain 20 | 21 | #endif /* GR_INIT_BUILD */ 22 | 23 | #endif /* GRBEOS_H_ */ 24 | 25 | -------------------------------------------------------------------------------- /graph/beos/rules.mk: -------------------------------------------------------------------------------- 1 | #************************************************************************** 2 | #* 3 | #* BeOS specific rules file, used to compile the BeOS graphics driver 4 | #* to the graphics subsystem 5 | #* 6 | #************************************************************************** 7 | 8 | ifeq ($(PLATFORM),beos) 9 | 10 | # directory of the BeOS graphics driver 11 | # 12 | GR_BEOS := $(GRAPH)/beos 13 | 14 | # add the BeOS driver object file to the graphics library `graph.a' 15 | # 16 | GRAPH_OBJS += $(OBJ_DIR_2)/grbeos.$(O) 17 | 18 | DEVICES += BEOS 19 | DEVICE_INCLUDES += $(GR_BEOS) 20 | 21 | # the rule used to compile the graphics driver 22 | # 23 | $(OBJ_DIR_2)/grbeos.$(O): $(GR_BEOS)/grbeos.cpp $(GR_BEOS)/grbeos.h 24 | ifneq ($(LIBTOOL),) 25 | $(LIBTOOL) --mode=compile $(CC) -static $(CFLAGS) \ 26 | $(GRAPH_INCLUDES:%=$I%) \ 27 | $I$(subst /,$(COMPILER_SEP),$(GR_BEOS)) \ 28 | $(X11_INCLUDE:%=$I%) \ 29 | $T$(subst /,$(COMPILER_SEP),$@ $<) 30 | else 31 | $(CC) $(CFLAGS) $(GRAPH_INCLUDES:%=$I%) \ 32 | $I$(subst /,$(COMPILER_SEP),$(GR_BEOS)) \ 33 | $(X11_INCLUDE:%=$I%) \ 34 | $T$(subst /,$(COMPILER_SEP),$@ $<) 35 | endif 36 | 37 | # Now update GRAPH_LINK according to the compiler used on BeOS 38 | GRAPH_LINK += -lbe -lstdc++.r4 39 | 40 | endif 41 | 42 | # EOF 43 | -------------------------------------------------------------------------------- /graph/gblany.h: -------------------------------------------------------------------------------- 1 | /* check that all macros are correctly set 2 | */ 3 | #ifndef GDST_INCR 4 | #error "GDST_INCR not defined" 5 | #endif 6 | 7 | #ifndef GDST_TYPE 8 | #error "GDST_TYPE not defined" 9 | #endif 10 | 11 | #ifndef GDST_READ 12 | #error "GDST_READ not defined" 13 | #endif 14 | 15 | #ifdef GBLENDER_STORE_BYTES 16 | # ifndef GDST_STOREB 17 | # error "GDST_STOREB not defined" 18 | # endif 19 | #else 20 | # ifndef GDST_STOREP 21 | # error "GDST_STOREP not defined" 22 | # endif 23 | #endif /* !STORE_BYTES */ 24 | 25 | #ifndef GDST_STOREC 26 | #error "GDST_STOREC not defined" 27 | #endif 28 | 29 | #ifndef GDST_COPY 30 | #error "GDST_COPY not defined" 31 | #endif 32 | 33 | #ifndef GDST_COPY_VAR 34 | #error "GDST_COPY_VAR not defined" 35 | #endif 36 | 37 | #undef GCONCAT 38 | #undef GCONCATX 39 | #define GCONCAT(x,y) GCONCATX(x,y) 40 | #define GCONCATX(x,y) x ## y 41 | 42 | 43 | static void 44 | GCONCAT( _gblender_blit_gray8_, GDST_TYPE )( GBlenderBlit blit, 45 | GBlenderPixel color ) 46 | { 47 | GBlender blender = blit->blender; 48 | unsigned int r = (color >> 16) & 255; 49 | unsigned int g = (color >> 8) & 255; 50 | unsigned int b = (color) & 255; 51 | 52 | GDST_COPY_VAR 53 | 54 | #include "gblcolor.h" 55 | } 56 | 57 | 58 | static void 59 | GCONCAT( _gblender_blit_hrgb_, GDST_TYPE )( GBlenderBlit blit, 60 | GBlenderPixel color ) 61 | { 62 | GBlender blender = blit->blender; 63 | unsigned int r = (color >> 16) & 255; 64 | unsigned int g = (color >> 8) & 255; 65 | unsigned int b = (color) & 255; 66 | 67 | GDST_COPY_VAR 68 | 69 | #include "gblhrgb.h" 70 | } 71 | 72 | 73 | static void 74 | GCONCAT( _gblender_blit_hbgr_, GDST_TYPE )( GBlenderBlit blit, 75 | GBlenderPixel color ) 76 | { 77 | GBlender blender = blit->blender; 78 | unsigned int r = (color >> 16) & 255; 79 | unsigned int g = (color >> 8) & 255; 80 | unsigned int b = (color) & 255; 81 | 82 | GDST_COPY_VAR 83 | 84 | #include "gblhbgr.h" 85 | } 86 | 87 | 88 | static void 89 | GCONCAT( _gblender_blit_vrgb_, GDST_TYPE )( GBlenderBlit blit, 90 | GBlenderPixel color ) 91 | { 92 | GBlender blender = blit->blender; 93 | unsigned int r = (color >> 16) & 255; 94 | unsigned int g = (color >> 8) & 255; 95 | unsigned int b = (color) & 255; 96 | 97 | GDST_COPY_VAR 98 | 99 | #include "gblvrgb.h" 100 | } 101 | 102 | 103 | static void 104 | GCONCAT( _gblender_blit_vbgr_, GDST_TYPE )( GBlenderBlit blit, 105 | GBlenderPixel color ) 106 | { 107 | GBlender blender = blit->blender; 108 | unsigned int r = (color >> 16) & 255; 109 | unsigned int g = (color >> 8) & 255; 110 | unsigned int b = (color) & 255; 111 | 112 | GDST_COPY_VAR 113 | 114 | #include "gblvbgr.h" 115 | } 116 | 117 | 118 | static void 119 | GCONCAT( _gblender_blit_bgra_, GDST_TYPE )( GBlenderBlit blit, 120 | GBlenderPixel color ) 121 | { 122 | GBlender blender = blit->blender; 123 | 124 | (void)color; /* unused */ 125 | 126 | #include "gblbgra.h" 127 | } 128 | 129 | 130 | /* unset the macros, to prevent accidental re-use 131 | */ 132 | 133 | #undef GCONCATX 134 | #undef GCONCAT 135 | #undef GDST_TYPE 136 | #undef GDST_INCR 137 | #undef GDST_READ 138 | #undef GDST_COPY 139 | #undef GDST_STOREB 140 | #undef GDST_STOREP 141 | #undef GDST_STOREC 142 | #undef GDST_COPY_VAR 143 | 144 | /* EOF */ 145 | -------------------------------------------------------------------------------- /graph/gblbgra.h: -------------------------------------------------------------------------------- 1 | 2 | int h = blit->height; 3 | const unsigned char* src_line = blit->src_line; 4 | unsigned char* dst_line = blit->dst_line; 5 | 6 | gblender_use_channels( blender, 0 ); 7 | 8 | do 9 | { 10 | const unsigned char* src = src_line + blit->src_x * 4; 11 | unsigned char* dst = dst_line + blit->dst_x * GDST_INCR; 12 | int w = blit->width; 13 | 14 | do 15 | { 16 | unsigned int a = GBLENDER_SHADE_INDEX(src[3]); 17 | unsigned int ra = src[3]; 18 | 19 | unsigned int b = src[0]; 20 | unsigned int g = src[1]; 21 | unsigned int r = src[2]; 22 | 23 | 24 | if ( a == 0 ) 25 | { 26 | /* nothing */ 27 | } 28 | else if ( a == 255 ) 29 | { 30 | dst[0] = (unsigned char)r; 31 | dst[1] = (unsigned char)g; 32 | dst[2] = (unsigned char)b; 33 | } 34 | else 35 | { 36 | unsigned int ba = 255 - ra; 37 | unsigned int br = dst[0]; 38 | unsigned int bb = dst[1]; 39 | unsigned int bg = dst[2]; 40 | 41 | 42 | dst[0] = (unsigned char)(br * ba / 255 + r); 43 | dst[1] = (unsigned char)(bg * ba / 255 + g); 44 | dst[2] = (unsigned char)(bb * ba / 255 + b); 45 | } 46 | 47 | src += 4; 48 | dst += GDST_INCR; 49 | 50 | } while ( --w > 0 ); 51 | 52 | src_line += blit->src_pitch; 53 | dst_line += blit->dst_pitch; 54 | 55 | } while ( --h > 0 ); 56 | 57 | -------------------------------------------------------------------------------- /graph/gblblit.h: -------------------------------------------------------------------------------- 1 | #ifndef GBLBLIT_H_ 2 | #define GBLBLIT_H_ 3 | 4 | #include "gblender.h" 5 | 6 | /* 7 | * blitting interface 8 | * 9 | */ 10 | 11 | typedef enum 12 | { 13 | GBLENDER_SOURCE_GRAY8 = 0, 14 | GBLENDER_SOURCE_HRGB, 15 | GBLENDER_SOURCE_HBGR, 16 | GBLENDER_SOURCE_VRGB, 17 | GBLENDER_SOURCE_VBGR, 18 | GBLENDER_SOURCE_BGRA, 19 | 20 | GBLENDER_SOURCE_MAX 21 | 22 | } GBlenderSourceFormat; 23 | 24 | 25 | typedef enum 26 | { 27 | GBLENDER_TARGET_GRAY8 = 0, 28 | GBLENDER_TARGET_RGB32, 29 | GBLENDER_TARGET_RGB24, 30 | GBLENDER_TARGET_RGB565, 31 | GBLENDER_TARGET_BGR565, 32 | 33 | GBLENDER_TARGET_MAX 34 | 35 | } GBlenderTargetFormat; 36 | 37 | typedef struct GBlenderBlitRec_* GBlenderBlit; 38 | 39 | typedef void (*GBlenderBlitFunc)( GBlenderBlit blit, 40 | GBlenderPixel color ); 41 | 42 | typedef struct GBlenderBlitRec_ 43 | { 44 | int width; 45 | int height; 46 | const unsigned char* src_line; 47 | int src_pitch; 48 | int src_x; 49 | int src_y; 50 | unsigned char* dst_line; 51 | int dst_pitch; 52 | int dst_x; 53 | int dst_y; 54 | GBlenderSourceFormat src_format; 55 | GBlenderTargetFormat dst_format; 56 | 57 | GBlender blender; 58 | GBlenderBlitFunc blit_func; 59 | 60 | } GBlenderBlitRec; 61 | 62 | 63 | 64 | GBLENDER_API( int ) 65 | gblender_blit_init( GBlenderBlit blit, 66 | GBlender blender, 67 | int dst_x, 68 | int dst_y, 69 | GBlenderSourceFormat src_format, 70 | const unsigned char* src_buffer, 71 | int src_pitch, 72 | int src_width, 73 | int src_height, 74 | GBlenderTargetFormat dst_format, 75 | unsigned char* dst_buffer, 76 | int dst_pitch, 77 | int dst_width, 78 | int dst_height ); 79 | 80 | #define gblender_blit_run(b,color) (b)->blit_func( (b), (color) ) 81 | 82 | 83 | #endif /* GBLBLIT_H_ */ 84 | -------------------------------------------------------------------------------- /graph/gblcolor.h: -------------------------------------------------------------------------------- 1 | 2 | GBLENDER_VARS; 3 | 4 | int h = blit->height; 5 | const unsigned char* src_line = blit->src_line; 6 | unsigned char* dst_line = blit->dst_line; 7 | 8 | gblender_use_channels( blender, 0 ); 9 | 10 | GBLENDER_VARS_SET(blender,color); 11 | 12 | /* make compiler happy */ 13 | (void)(r); 14 | (void)(g); 15 | (void)(b); 16 | 17 | do 18 | { 19 | const unsigned char* src = src_line + (blit->src_x); 20 | unsigned char* dst = dst_line + blit->dst_x*GDST_INCR; 21 | int w = blit->width; 22 | 23 | do 24 | { 25 | int a = GBLENDER_SHADE_INDEX(src[0]); 26 | 27 | if ( a == 0 ) 28 | { 29 | /* nothing */ 30 | } 31 | else if ( a == GBLENDER_SHADE_COUNT-1 ) 32 | { 33 | GDST_COPY(dst); 34 | } 35 | else 36 | { 37 | GBlenderPixel back; 38 | 39 | GDST_READ(dst,back); 40 | 41 | GBLENDER_LOOKUP( blender, back ); 42 | 43 | #ifdef GBLENDER_STORE_BYTES 44 | GDST_STOREB(dst,_gcells,a); 45 | #else 46 | GDST_STOREP(dst,_gcells,a); 47 | #endif 48 | } 49 | 50 | src += 1; 51 | dst += GDST_INCR; 52 | } 53 | while (--w > 0); 54 | 55 | src_line += blit->src_pitch; 56 | dst_line += blit->dst_pitch; 57 | } 58 | while (--h > 0); 59 | 60 | GBLENDER_CLOSE(blender); 61 | -------------------------------------------------------------------------------- /graph/gblhbgr.h: -------------------------------------------------------------------------------- 1 | 2 | GBLENDER_CHANNEL_VARS; 3 | 4 | int h = blit->height; 5 | const unsigned char* src_line = blit->src_line; 6 | unsigned char* dst_line = blit->dst_line; 7 | 8 | gblender_use_channels( blender, 1 ); 9 | 10 | GBLENDER_CHANNEL_VARS_SET(blender,r,g,b); 11 | 12 | do 13 | { 14 | const unsigned char* src = src_line + blit->src_x*3; 15 | unsigned char* dst = dst_line + blit->dst_x*GDST_INCR; 16 | int w = blit->width; 17 | 18 | do 19 | { 20 | unsigned int ab = GBLENDER_SHADE_INDEX(src[0]); 21 | unsigned int ag = GBLENDER_SHADE_INDEX(src[1]); 22 | unsigned int ar = GBLENDER_SHADE_INDEX(src[2]); 23 | unsigned int aa = (ar << 16) | (ag << 8) | ab; 24 | 25 | if ( aa == 0 ) 26 | { 27 | /* nothing */ 28 | } 29 | else if ( aa == (((GBLENDER_SHADE_COUNT-1) << 16) | 30 | ((GBLENDER_SHADE_COUNT-1) << 8) | 31 | (GBLENDER_SHADE_COUNT-1) ) ) 32 | { 33 | GDST_COPY(dst); 34 | } 35 | else 36 | { 37 | GBlenderPixel back; 38 | int pix_r, pix_g, pix_b; 39 | 40 | GDST_READ(dst,back); 41 | 42 | { 43 | unsigned int back_r = (back >> 16) & 255; 44 | 45 | GBLENDER_LOOKUP_R( blender, back_r ); 46 | 47 | pix_r = _grcells[ar]; 48 | } 49 | 50 | { 51 | unsigned int back_g = (back >> 8) & 255; 52 | 53 | GBLENDER_LOOKUP_G( blender, back_g ); 54 | 55 | pix_g = _ggcells[ag]; 56 | } 57 | 58 | { 59 | unsigned int back_b = (back) & 255; 60 | 61 | GBLENDER_LOOKUP_B( blender, back_b ); 62 | 63 | pix_b = _gbcells[ab]; 64 | } 65 | 66 | GDST_STOREC(dst,pix_r,pix_g,pix_b); 67 | } 68 | 69 | src += 3; 70 | dst += GDST_INCR; 71 | } 72 | while (--w > 0); 73 | 74 | src_line += blit->src_pitch; 75 | dst_line += blit->dst_pitch; 76 | } 77 | while (--h > 0); 78 | 79 | GBLENDER_CHANNEL_CLOSE(blender); 80 | -------------------------------------------------------------------------------- /graph/gblhrgb.h: -------------------------------------------------------------------------------- 1 | 2 | GBLENDER_CHANNEL_VARS; 3 | 4 | int h = blit->height; 5 | const unsigned char* src_line = blit->src_line; 6 | unsigned char* dst_line = blit->dst_line; 7 | 8 | gblender_use_channels( blender, 1 ); 9 | 10 | GBLENDER_CHANNEL_VARS_SET(blender,r,g,b); 11 | 12 | do 13 | { 14 | const unsigned char* src = src_line + blit->src_x*3; 15 | unsigned char* dst = dst_line + blit->dst_x*GDST_INCR; 16 | int w = blit->width; 17 | 18 | do 19 | { 20 | unsigned int ar = GBLENDER_SHADE_INDEX(src[0]); 21 | unsigned int ag = GBLENDER_SHADE_INDEX(src[1]); 22 | unsigned int ab = GBLENDER_SHADE_INDEX(src[2]); 23 | unsigned int aa = (ar << 16) | (ag << 8) | ab; 24 | 25 | if ( aa == 0 ) 26 | { 27 | /* nothing */ 28 | } 29 | else if ( aa == (((GBLENDER_SHADE_COUNT-1) << 16) | 30 | ((GBLENDER_SHADE_COUNT-1) << 8) | 31 | (GBLENDER_SHADE_COUNT-1) ) ) 32 | { 33 | GDST_COPY(dst); 34 | } 35 | else 36 | { 37 | GBlenderPixel back; 38 | int pix_r, pix_g, pix_b; 39 | 40 | GDST_READ(dst,back); 41 | 42 | { 43 | unsigned int back_r = (back >> 16) & 255; 44 | 45 | GBLENDER_LOOKUP_R( blender, back_r ); 46 | 47 | pix_r = _grcells[ar]; 48 | } 49 | 50 | { 51 | unsigned int back_g = (back >> 8) & 255; 52 | 53 | GBLENDER_LOOKUP_G( blender, back_g ); 54 | 55 | pix_g = _ggcells[ag]; 56 | } 57 | 58 | { 59 | unsigned int back_b = (back) & 255; 60 | 61 | GBLENDER_LOOKUP_B( blender, back_b ); 62 | 63 | pix_b = _gbcells[ab]; 64 | } 65 | 66 | GDST_STOREC(dst,pix_r,pix_g,pix_b); 67 | } 68 | 69 | src += 3; 70 | dst += GDST_INCR; 71 | } 72 | while (--w > 0); 73 | 74 | src_line += blit->src_pitch; 75 | dst_line += blit->dst_pitch; 76 | } 77 | while (--h > 0); 78 | 79 | GBLENDER_CHANNEL_CLOSE(blender); 80 | -------------------------------------------------------------------------------- /graph/gblvbgr.h: -------------------------------------------------------------------------------- 1 | 2 | GBLENDER_CHANNEL_VARS; 3 | 4 | int h = blit->height; 5 | const unsigned char* src_line = blit->src_line; 6 | int src_pitch = blit->src_pitch; 7 | unsigned char* dst_line = blit->dst_line; 8 | 9 | gblender_use_channels( blender, 1 ); 10 | 11 | GBLENDER_CHANNEL_VARS_SET(blender,r,g,b); 12 | 13 | do 14 | { 15 | const unsigned char* src = src_line + blit->src_x; 16 | unsigned char* dst = dst_line + blit->dst_x*GDST_INCR; 17 | int w = blit->width; 18 | 19 | do 20 | { 21 | unsigned int ab = GBLENDER_SHADE_INDEX(src[0]); 22 | unsigned int ag = GBLENDER_SHADE_INDEX(src[src_pitch]); 23 | unsigned int ar = GBLENDER_SHADE_INDEX(src[src_pitch << 1]); 24 | GBlenderPixel aa = ((GBlenderPixel)ar << 16) | (ag << 8) | ab; 25 | 26 | if ( aa == 0 ) 27 | { 28 | /* nothing */ 29 | } 30 | else if ( aa == (((GBLENDER_SHADE_COUNT-1) << 16) | 31 | ((GBLENDER_SHADE_COUNT-1) << 8) | 32 | (GBLENDER_SHADE_COUNT-1) ) ) 33 | { 34 | GDST_COPY(dst); 35 | } 36 | else 37 | { 38 | GBlenderPixel back; 39 | int pix_r, pix_g, pix_b; 40 | 41 | GDST_READ(dst,back); 42 | 43 | { 44 | unsigned int back_r = (back >> 16) & 255; 45 | 46 | GBLENDER_LOOKUP_R( blender, back_r ); 47 | 48 | pix_r = _grcells[ar]; 49 | } 50 | 51 | { 52 | unsigned int back_g = (back >> 8) & 255; 53 | 54 | GBLENDER_LOOKUP_G( blender, back_g ); 55 | 56 | pix_g = _ggcells[ag]; 57 | } 58 | 59 | { 60 | unsigned int back_b = (back) & 255; 61 | 62 | GBLENDER_LOOKUP_B( blender, back_b ); 63 | 64 | pix_b = _gbcells[ab]; 65 | } 66 | 67 | GDST_STOREC(dst,pix_r,pix_g,pix_b); 68 | } 69 | 70 | src += 1; 71 | dst += GDST_INCR; 72 | } 73 | while (--w > 0); 74 | 75 | src_line += blit->src_pitch*3; 76 | dst_line += blit->dst_pitch; 77 | } 78 | while (--h > 0); 79 | 80 | GBLENDER_CHANNEL_CLOSE(blender); 81 | -------------------------------------------------------------------------------- /graph/gblvrgb.h: -------------------------------------------------------------------------------- 1 | 2 | GBLENDER_CHANNEL_VARS; 3 | 4 | int h = blit->height; 5 | const unsigned char* src_line = blit->src_line; 6 | int src_pitch = blit->src_pitch; 7 | unsigned char* dst_line = blit->dst_line; 8 | 9 | gblender_use_channels( blender, 1 ); 10 | 11 | GBLENDER_CHANNEL_VARS_SET(blender,r,g,b); 12 | 13 | do 14 | { 15 | const unsigned char* src = src_line + blit->src_x; 16 | unsigned char* dst = dst_line + blit->dst_x*GDST_INCR; 17 | int w = blit->width; 18 | 19 | do 20 | { 21 | unsigned int ar = GBLENDER_SHADE_INDEX(src[0]); 22 | unsigned int ag = GBLENDER_SHADE_INDEX(src[src_pitch]); 23 | unsigned int ab = GBLENDER_SHADE_INDEX(src[src_pitch << 1]); 24 | GBlenderPixel aa = ((GBlenderPixel)ar << 16) | (ag << 8) | ab; 25 | 26 | if ( aa == 0 ) 27 | { 28 | /* nothing */ 29 | } 30 | else if ( aa == (((GBLENDER_SHADE_COUNT-1) << 16) | 31 | ((GBLENDER_SHADE_COUNT-1) << 8) | 32 | (GBLENDER_SHADE_COUNT-1) ) ) 33 | { 34 | GDST_COPY(dst); 35 | } 36 | else 37 | { 38 | GBlenderPixel back; 39 | int pix_r, pix_g, pix_b; 40 | 41 | GDST_READ(dst,back); 42 | 43 | { 44 | unsigned int back_r = (back >> 16) & 255; 45 | 46 | GBLENDER_LOOKUP_R( blender, back_r ); 47 | 48 | pix_r = _grcells[ar]; 49 | } 50 | 51 | { 52 | unsigned int back_g = (back >> 8) & 255; 53 | 54 | GBLENDER_LOOKUP_G( blender, back_g ); 55 | 56 | pix_g = _ggcells[ag]; 57 | } 58 | 59 | { 60 | unsigned int back_b = (back) & 255; 61 | 62 | GBLENDER_LOOKUP_B( blender, back_b ); 63 | 64 | pix_b = _gbcells[ab]; 65 | } 66 | 67 | GDST_STOREC(dst,pix_r,pix_g,pix_b); 68 | } 69 | 70 | src += 1; 71 | dst += GDST_INCR; 72 | } 73 | while (--w > 0); 74 | 75 | src_line += blit->src_pitch*3; 76 | dst_line += blit->dst_pitch; 77 | } 78 | while (--h > 0); 79 | 80 | GBLENDER_CHANNEL_CLOSE(blender); 81 | -------------------------------------------------------------------------------- /graph/grblit.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* */ 3 | /* The FreeType project -- a free and portable quality TrueType renderer. */ 4 | /* */ 5 | /* Copyright 1996-1999 by */ 6 | /* D. Turner, R.Wilhelm, and W. Lemberg */ 7 | /* */ 8 | /* blitter.h: Support for blitting of bitmaps with various depth. */ 9 | /* */ 10 | /****************************************************************************/ 11 | 12 | #ifndef GRBLIT_H_ 13 | #define GRBLIT_H_ 14 | 15 | #include "grobjs.h" 16 | 17 | int grBlitMono( grBitmap* target, 18 | grBitmap* source, 19 | int x_offset, 20 | int y_offset, 21 | grColor color ); 22 | 23 | 24 | #endif /* GRBLIT_H_ */ 25 | 26 | 27 | /* End */ 28 | -------------------------------------------------------------------------------- /graph/grconfig.h: -------------------------------------------------------------------------------- 1 | #ifndef GRCONFIG_H_ 2 | #define GRCONFIG_H_ 3 | 4 | #define GR_MAX_SATURATIONS 8 5 | #define GR_MAX_CONVERSIONS 16 6 | 7 | #define GR_MAX_DEVICES 8 8 | 9 | #endif /* GRCONFIG_H_ */ 10 | -------------------------------------------------------------------------------- /graph/grdevice.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * 3 | * grdevice.h 4 | * 5 | * Graphics device interface 6 | * 7 | * Copyright 1999 - The FreeType Development Team - www.freetype.org 8 | * 9 | * 10 | ***************************************************************************/ 11 | 12 | #ifndef GRDEVICE_H_ 13 | #define GRDEVICE_H_ 14 | 15 | #include "graph.h" 16 | 17 | 18 | /******************************************************************** 19 | * 20 | * 21 | * grDeviceInitFunc 22 | * 23 | * 24 | * Simple device initialiser function 25 | * 26 | * 27 | * error code. 0 means success 28 | * 29 | ********************************************************************/ 30 | 31 | typedef int (*grDeviceInitFunc)( void ); 32 | 33 | 34 | /******************************************************************** 35 | * 36 | * 37 | * grDeviceDoneFunc 38 | * 39 | * 40 | * Simple device finaliser function 41 | * 42 | * 43 | * error code. 0 means success 44 | * 45 | ********************************************************************/ 46 | 47 | typedef void (*grDeviceDoneFunc)( void ); 48 | 49 | 50 | /******************************************************************** 51 | * 52 | * 53 | * grDeviceInitSurfaceFunc 54 | * 55 | * 56 | * initializes a new surface for the device. This may be a window 57 | * or a video screen, depending on the device. 58 | * 59 | * 60 | * surface :: handle to target surface 61 | * 62 | * 63 | * bitmap :: handle to bitmap descriptor 64 | * 65 | ********************************************************************/ 66 | 67 | typedef int (*grDeviceInitSurfaceFunc)( grSurface* surface, 68 | grBitmap* bitmap ); 69 | 70 | 71 | /******************************************************************** 72 | * 73 | * 74 | * grDevice 75 | * 76 | * 77 | * Simple device interface structure 78 | * 79 | * 80 | * surface_objsize :: size in bytes of a single surface object for 81 | * this device. 82 | * 83 | * device_name :: name of device, e.g. "x11", "os2pm", "directx" etc.. 84 | * init :: device initialisation routine 85 | * done :: device finalisation 86 | * new_surface :: function used to create a new surface (screen or 87 | * window) from the device 88 | * 89 | * num_pixel_modes :: the number of pixel modes supported by this 90 | * device. This value _must_ be set to -1 91 | * default, unless the device provides a 92 | * static set of pixel modes (fullscreen). 93 | * 94 | * pixel_modes :: an array of pixel modes supported by this 95 | * device 96 | * 97 | * 98 | * the fields "num_pixel_modes" and "pixel_modes" must be 99 | * set by the "init" function. 100 | * 101 | * This allows windowed devices to "discover" at run-time the 102 | * available pixel modes they can provide depending on the 103 | * current screen depth. 104 | * 105 | ********************************************************************/ 106 | 107 | struct grDevice_ 108 | { 109 | unsigned int surface_objsize; 110 | const char* device_name; /* name of device */ 111 | 112 | grDeviceInitFunc init; 113 | grDeviceDoneFunc done; 114 | 115 | grDeviceInitSurfaceFunc init_surface; 116 | 117 | int num_pixel_modes; 118 | grPixelMode* pixel_modes; 119 | }; 120 | 121 | 122 | extern grDevice* gr_devices[]; 123 | extern grDeviceChain gr_device_chain[]; 124 | extern int gr_num_devices; 125 | extern int gr_max_devices; 126 | 127 | 128 | extern void 129 | gr_swizzle_rgb24( unsigned char* read_buff, 130 | int read_pitch, 131 | unsigned char* write_buff, 132 | int write_pitch, 133 | int width, 134 | int height ); 135 | 136 | #endif /* GRDEVICE_H_ */ 137 | -------------------------------------------------------------------------------- /graph/grevents.h: -------------------------------------------------------------------------------- 1 | #ifndef GREVENTS_H_ 2 | #define GREVENTS_H_ 3 | 4 | 5 | #define gr_event_none 0 6 | #define gr_event_wait 1 7 | #define gr_event_poll 2 8 | #define gr_event_flush 3 9 | 10 | #define gr_mouse_down 0x04 11 | #define gr_mouse_move 0x08 12 | #define gr_mouse_up 0x10 13 | #define gr_mouse_drag 0x20 14 | 15 | #define gr_key_down 0x40 16 | #define gr_key_up 0x80 17 | 18 | 19 | #define gr_event_mouse 0x3C 20 | #define gr_event_key 0xC0 21 | 22 | #define gr_event_type ( gr_event_mouse | gr_event_key ) 23 | 24 | 25 | typedef enum grKey_ 26 | { 27 | grKeyNone = 0, 28 | 29 | grKeySpace = ' ', 30 | grKey0 = '0', 31 | grKey1 = '1', 32 | grKey2 = '2', 33 | grKey3 = '3', 34 | grKey4 = '4', 35 | grKey5 = '5', 36 | grKey6 = '6', 37 | grKey7 = '7', 38 | grKey8 = '8', 39 | grKey9 = '9', 40 | 41 | grKeyPlus = '+', 42 | grKeyLess = '-', 43 | grKeyEqual = '=', 44 | grKeyMult = '*', 45 | grKeyDollar = '$', 46 | grKeySmaller = '<', 47 | grKeyGreater = '>', 48 | grKeyQuestion = '?', 49 | grKeyComma = ',', 50 | grKeyDot = '.', 51 | grKeySemiColon = ';', 52 | grKeyColon = ':', 53 | grKeyDiv = '/', 54 | grKeyExclam = '!', 55 | grKeyPercent = '%', 56 | grKeyLeftParen = '(', 57 | grKeyRightParen = ')', 58 | grKeyAt = '@', 59 | 60 | grKey_A = 'A', 61 | grKey_B = 'B', 62 | grKey_C = 'C', 63 | grKey_D = 'D', 64 | grKey_E = 'E', 65 | grKey_F = 'F', 66 | grKey_G = 'G', 67 | grKey_H = 'H', 68 | grKey_I = 'I', 69 | grKey_J = 'J', 70 | grKey_K = 'K', 71 | grKey_L = 'L', 72 | grKey_M = 'M', 73 | grKey_N = 'N', 74 | grKey_O = 'O', 75 | grKey_P = 'P', 76 | grKey_Q = 'Q', 77 | grKey_R = 'R', 78 | grKey_S = 'S', 79 | grKey_T = 'T', 80 | grKey_U = 'U', 81 | grKey_V = 'V', 82 | grKey_W = 'W', 83 | grKey_X = 'X', 84 | grKey_Y = 'Y', 85 | grKey_Z = 'Z', 86 | 87 | grKeyLeftB = '[', 88 | grKeyBackSlash = '\\', 89 | grKeyRightB = ']', 90 | grKeyCircumflex = '^', 91 | grKeyUnder = '_', 92 | grKeyBackTick = '`', 93 | 94 | grKey_a = 'a', 95 | grKey_b = 'b', 96 | grKey_c = 'c', 97 | grKey_d = 'd', 98 | grKey_e = 'e', 99 | grKey_f = 'f', 100 | grKey_g = 'g', 101 | grKey_h = 'h', 102 | grKey_i = 'i', 103 | grKey_j = 'j', 104 | grKey_k = 'k', 105 | grKey_l = 'l', 106 | grKey_m = 'm', 107 | grKey_n = 'n', 108 | grKey_o = 'o', 109 | grKey_p = 'p', 110 | grKey_q = 'q', 111 | grKey_r = 'r', 112 | grKey_s = 's', 113 | grKey_t = 't', 114 | grKey_u = 'u', 115 | grKey_v = 'v', 116 | grKey_w = 'w', 117 | grKey_x = 'x', 118 | grKey_y = 'y', 119 | grKey_z = 'z', 120 | 121 | grKeyBackSpace = 0x100, 122 | grKeyTab, 123 | grKeyReturn, 124 | grKeyEsc, 125 | 126 | grKeyIns, 127 | grKeyDel, 128 | grKeyHome, 129 | grKeyEnd, 130 | grKeyPageUp, 131 | grKeyPageDown, 132 | 133 | grKeyF1, 134 | grKeyF2, 135 | grKeyF3, 136 | grKeyF4, 137 | grKeyF5, 138 | grKeyF6, 139 | grKeyF7, 140 | grKeyF8, 141 | grKeyF9, 142 | grKeyF10, 143 | grKeyF11, 144 | grKeyF12, 145 | 146 | grKeyLeft, 147 | grKeyRight, 148 | grKeyUp, 149 | grKeyDown, 150 | 151 | grKeyForceShort = 0x7FFF, /* this forces the grKey to be stored */ 152 | /* on at least one short */ 153 | grKeyMax 154 | 155 | } grKey; 156 | 157 | 158 | #define grKEY( c ) ( (grKey)( c ) ) 159 | /* masks - to be used as enums they would have to be included */ 160 | /* in the grKey enum */ 161 | #define grKeyAlt ( (grKey)0x8000 ) 162 | #define grKeyCtrl ( (grKey)0x4000 ) 163 | #define grKeyShift ( (grKey)0x2000 ) 164 | 165 | #define grKeyModifiers ( (grKey)0xE000 ) 166 | 167 | 168 | typedef struct grEvent_ 169 | { 170 | int type; 171 | grKey key; 172 | int x, y; 173 | 174 | } grEvent; 175 | 176 | 177 | #endif /* GREVENTS_H_ */ 178 | -------------------------------------------------------------------------------- /graph/grfill.c: -------------------------------------------------------------------------------- 1 | #include "graph.h" 2 | #include 3 | #include 4 | 5 | static void 6 | gr_fill_hline_mono( unsigned char* line, 7 | int x, 8 | int width, 9 | grColor color ) 10 | { 11 | int c1 = (x >> 3); 12 | int lmask = 0xFF >> (x & 7); 13 | int c2 = ((x+width-1) >> 3); 14 | int rmask = 0x7F8 >> ((x+width-1) & 7); 15 | 16 | if ( color.value != 0 ) 17 | { 18 | if ( c1 == c2 ) 19 | line[c1] = (unsigned char)( line[c1] | (lmask & rmask)); 20 | else 21 | { 22 | line[c1] = (unsigned char)(line[c1] | lmask); 23 | for ( ++c1; c1 < c2; c1++ ) 24 | line[c1] = 0xFF; 25 | line[c2] = (unsigned char)(line[c2] | rmask); 26 | } 27 | } 28 | else 29 | { 30 | if ( c1 == c2 ) 31 | line[c1] = (unsigned char)( line[c1] & ~(lmask & rmask) ); 32 | else 33 | { 34 | line[c1] = (unsigned char)(line[c1] & ~lmask); 35 | for (++c1; c1 < c2; c1++) 36 | line[c1] = 0; 37 | line[c2] = (unsigned char)(line[c2] & ~rmask); 38 | } 39 | } 40 | } 41 | 42 | static void 43 | gr_fill_hline_4( unsigned char* line, 44 | int x, 45 | int width, 46 | grColor color ) 47 | { 48 | int col = color.value | (color.value << 4); 49 | 50 | line += (x >> 1); 51 | if ( x & 1 ) 52 | { 53 | line[0] = (unsigned char)((line[0] & 0xF0) | (col & 0x0F)); 54 | line++; 55 | width--; 56 | } 57 | 58 | for ( ; width >= 2; width -= 2 ) 59 | { 60 | line[0] = (unsigned char)col; 61 | line++; 62 | } 63 | 64 | if ( width > 0 ) 65 | line[0] = (unsigned char)((line[0] & 0x0F) | (col & 0xF0)); 66 | } 67 | 68 | static void 69 | gr_fill_hline_8( unsigned char* line, 70 | int x, 71 | int width, 72 | grColor color ) 73 | { 74 | memset( line+x, color.value, (unsigned int)width ); 75 | } 76 | 77 | static void 78 | gr_fill_hline_16( unsigned char* _line, 79 | int x, 80 | int width, 81 | grColor color ) 82 | { 83 | unsigned short* line = (unsigned short*)_line + x; 84 | 85 | for ( ; width > 0; width-- ) 86 | *line++ = (unsigned short)color.value; 87 | } 88 | 89 | static void 90 | gr_fill_hline_24( unsigned char* line, 91 | int x, 92 | int width, 93 | grColor color ) 94 | { 95 | int r = color.chroma[0]; 96 | int g = color.chroma[1]; 97 | int b = color.chroma[2]; 98 | 99 | line += 3*x; 100 | 101 | if (r == g && g == b) 102 | memset( line, r, (unsigned int)(width*3) ); 103 | else 104 | { 105 | for ( ; width > 0; width--, line += 3 ) 106 | { 107 | line[0] = (unsigned char)r; 108 | line[1] = (unsigned char)g; 109 | line[2] = (unsigned char)b; 110 | } 111 | } 112 | } 113 | 114 | static void 115 | gr_fill_hline_32( unsigned char* line, 116 | int x, 117 | int width, 118 | grColor color ) 119 | { 120 | line += 4*x; 121 | 122 | /* clearly slow */ 123 | for (; width > 0; width--, line += 4) 124 | { 125 | line[0] = color.chroma[0]; 126 | line[1] = color.chroma[1]; 127 | line[2] = color.chroma[2]; 128 | line[3] = color.chroma[3]; 129 | } 130 | } 131 | 132 | 133 | typedef void (*grFillHLineFunc)( unsigned char* line, 134 | int x, 135 | int width, 136 | grColor color ); 137 | 138 | static const grFillHLineFunc gr_fill_hline_funcs[gr_pixel_mode_max] = 139 | { 140 | NULL, 141 | gr_fill_hline_mono, 142 | gr_fill_hline_4, 143 | gr_fill_hline_8, 144 | gr_fill_hline_8, 145 | gr_fill_hline_16, 146 | gr_fill_hline_16, 147 | gr_fill_hline_24, 148 | gr_fill_hline_32, 149 | NULL, 150 | NULL, 151 | NULL, 152 | NULL 153 | }; 154 | 155 | extern void 156 | grFillHLine( grBitmap* target, 157 | int x, 158 | int y, 159 | int width, 160 | grColor color ) 161 | { 162 | int delta; 163 | unsigned char* line; 164 | grFillHLineFunc hline_func = gr_fill_hline_funcs[target->mode]; 165 | 166 | if ( x < 0 ) 167 | { 168 | width += x; 169 | x = 0; 170 | } 171 | delta = x + width - target->width; 172 | if ( delta > 0 ) 173 | width -= x; 174 | 175 | if ( y < 0 || y >= target->rows || width < 0 || hline_func == NULL ) 176 | return; 177 | 178 | line = target->buffer + y*target->pitch; 179 | if ( target->pitch < 0 ) 180 | line -= target->pitch*(target->rows-1); 181 | 182 | hline_func( line, x, width, color ); 183 | } 184 | 185 | extern void 186 | grFillVLine( grBitmap* target, 187 | int x, 188 | int y, 189 | int height, 190 | grColor color ) 191 | { 192 | int delta; 193 | unsigned char* line; 194 | grFillHLineFunc hline_func; 195 | 196 | if ( x < 0 || x >= target->width ) 197 | return; 198 | 199 | if ( y < 0 ) 200 | { 201 | height += y; 202 | y = 0; 203 | } 204 | delta = y + height - target->rows; 205 | if ( delta > 0 ) 206 | height -= delta; 207 | 208 | if ( height <= 0 ) 209 | return; 210 | 211 | hline_func = gr_fill_hline_funcs[ target->mode ]; 212 | if ( hline_func ) 213 | { 214 | line = target->buffer + y*target->pitch; 215 | if ( target->pitch < 0 ) 216 | line -= target->pitch*(target->rows-1); 217 | 218 | for ( ; height > 0; height--, line += target->pitch ) 219 | hline_func( line, x, 1, color ); 220 | } 221 | } 222 | 223 | extern void 224 | grFillRect( grBitmap* target, 225 | int x, 226 | int y, 227 | int width, 228 | int height, 229 | grColor color ) 230 | { 231 | int delta; 232 | unsigned char* line; 233 | grFillHLineFunc hline_func; 234 | 235 | if ( x < 0 ) 236 | { 237 | width -= x; 238 | x = 0; 239 | } 240 | delta = x + width - target->width; 241 | if ( delta > 0 ) 242 | width -= delta; 243 | 244 | if ( y < 0 ) 245 | { 246 | height += y; 247 | y = 0; 248 | } 249 | delta = y + height - target->rows; 250 | if ( delta > 0 ) 251 | height -= delta; 252 | 253 | if ( width <= 0 || height <= 0 ) 254 | return; 255 | 256 | hline_func = gr_fill_hline_funcs[ target->mode ]; 257 | if ( hline_func ) 258 | { 259 | line = target->buffer + y*target->pitch; 260 | if ( target->pitch < 0 ) 261 | line -= target->pitch*(target->rows-1); 262 | 263 | for ( ; height > 0; height--, line += target->pitch ) 264 | hline_func( line, x, width, color ); 265 | } 266 | } 267 | -------------------------------------------------------------------------------- /graph/grfont.h: -------------------------------------------------------------------------------- 1 | /* grfont.h */ 2 | 3 | #ifndef GRFONT_H_ 4 | #define GRFONT_H_ 5 | 6 | #include "graph.h" 7 | 8 | extern const unsigned char font_8x8[]; 9 | 10 | 11 | void 12 | grGotobitmap( grBitmap* bitmap ); 13 | 14 | void 15 | grSetMargin( int right, 16 | int top ); 17 | 18 | void 19 | grSetPixelMargin( int right, 20 | int top ); 21 | 22 | void 23 | grSetLineHeight( int height ); 24 | 25 | void 26 | grGotoxy ( int x, 27 | int y ); 28 | 29 | 30 | void 31 | grWrite( const char* string ); 32 | 33 | void 34 | grWriteln( const char* string ); 35 | 36 | void 37 | grLn( void ); 38 | 39 | #endif /* GRFONT_H_ */ 40 | 41 | 42 | /* eof */ 43 | -------------------------------------------------------------------------------- /graph/grinit.c: -------------------------------------------------------------------------------- 1 | #include "grobjs.h" 2 | #include "grdevice.h" 3 | #include 4 | 5 | #define GR_INIT_DEVICE_CHAIN ((grDeviceChain*)0) 6 | #define GR_INIT_BUILD 7 | 8 | #ifdef DEVICE_X11 9 | #ifndef VMS 10 | #include "x11/grx11.h" 11 | #else 12 | #include "grx11.h" 13 | #endif 14 | #endif 15 | 16 | #ifdef DEVICE_OS2_PM 17 | #include "os2/gros2pm.h" 18 | #endif 19 | 20 | #ifdef DEVICE_WIN32 21 | #include "win32/grwin32.h" 22 | #endif 23 | 24 | #ifdef macintosh 25 | #include "mac/grmac.h" 26 | #endif 27 | 28 | #ifdef DEVICE_ALLEGRO 29 | #include "allegro/gralleg.h" 30 | #endif 31 | 32 | #ifdef DEVICE_BEOS 33 | #include "beos/grbeos.h" 34 | #endif 35 | 36 | 37 | /********************************************************************** 38 | * 39 | * 40 | * grInitDevices 41 | * 42 | * 43 | * This function is in charge of initialising all system-specific 44 | * devices. A device is responsible for creating and managing one 45 | * or more "surfaces". A surface is either a window or a screen, 46 | * depending on the system. 47 | * 48 | * 49 | * a pointer to the first element of a device chain. The chain can 50 | * be parsed to find the available devices on the current system 51 | * 52 | * 53 | * If a device cannot be initialised correctly, it is not part of 54 | * the device chain returned by this function. For example, if an 55 | * X11 device was compiled in the library, it will be part of 56 | * the returned device chain only if a connection to the display 57 | * could be established 58 | * 59 | * If no driver could be initialised, this function returns NULL. 60 | * 61 | **********************************************************************/ 62 | 63 | extern 64 | grDeviceChain* grInitDevices( void ) 65 | { 66 | grDeviceChain* chain = GR_INIT_DEVICE_CHAIN; 67 | grDeviceChain* cur = gr_device_chain; 68 | 69 | 70 | while (chain) 71 | { 72 | /* initialize the device */ 73 | grDevice* device; 74 | 75 | device = chain->device; 76 | if ( device->init() == 0 && 77 | gr_num_devices < GR_MAX_DEVICES ) 78 | 79 | { 80 | /* successful device initialisation - add it to our chain */ 81 | cur->next = 0; 82 | cur->device = device; 83 | cur->name = device->device_name; 84 | 85 | if (cur > gr_device_chain) 86 | cur[-1].next = cur; 87 | 88 | cur++; 89 | gr_num_devices++; 90 | } 91 | chain = chain->next; 92 | } 93 | 94 | return (gr_num_devices > 0 ? gr_device_chain : 0 ); 95 | } 96 | 97 | 98 | extern 99 | void grDoneDevices( void ) 100 | { 101 | int i; 102 | grDeviceChain* chain = gr_device_chain; 103 | 104 | 105 | for ( i = 0; i < gr_num_devices; i++ ) 106 | { 107 | chain->device->done(); 108 | 109 | chain->next = 0; 110 | chain->device = 0; 111 | chain->name = 0; 112 | 113 | chain++; 114 | } 115 | 116 | gr_num_devices = 0; 117 | } 118 | -------------------------------------------------------------------------------- /graph/grobjs.c: -------------------------------------------------------------------------------- 1 | #include "grobjs.h" 2 | #include 3 | #include 4 | 5 | int grError = 0; 6 | 7 | 8 | /* values must be in 0..255 range */ 9 | grColor 10 | grFindColor( grBitmap* target, 11 | int red, 12 | int green, 13 | int blue, 14 | int alpha ) 15 | { 16 | grColor color; 17 | 18 | color.value = 0; 19 | 20 | switch (target->mode) 21 | { 22 | case gr_pixel_mode_mono: 23 | if ( (red|green|blue) ) 24 | color.value = 1; 25 | break; 26 | 27 | case gr_pixel_mode_gray: 28 | color.value = (3*red + 6*green + blue)/10; 29 | break; 30 | 31 | case gr_pixel_mode_rgb565: 32 | color.value = ((red & 0xF8) << 8) | ((green & 0xFC) << 3) | ((blue & 0xF8) >> 3); 33 | break; 34 | 35 | case gr_pixel_mode_rgb24: 36 | color.chroma[0] = (unsigned char)red; 37 | color.chroma[1] = (unsigned char)green; 38 | color.chroma[2] = (unsigned char)blue; 39 | break; 40 | 41 | case gr_pixel_mode_rgb32: 42 | color.chroma[0] = (unsigned char)red; 43 | color.chroma[1] = (unsigned char)green; 44 | color.chroma[2] = (unsigned char)blue; 45 | color.chroma[3] = (unsigned char)alpha; 46 | break; 47 | 48 | default: 49 | ; 50 | } 51 | return color; 52 | } 53 | 54 | 55 | /******************************************************************** 56 | * 57 | * 58 | * grAlloc 59 | * 60 | * 61 | * Simple memory allocation. The returned block is always zero-ed 62 | * 63 | * 64 | * size :: size in bytes of the requested block 65 | * 66 | * 67 | * the memory block address. 0 in case of error 68 | * 69 | ********************************************************************/ 70 | 71 | unsigned char* 72 | grAlloc( unsigned long size ) 73 | { 74 | unsigned char* p; 75 | 76 | p = (unsigned char*)malloc(size); 77 | if (!p && size > 0) 78 | { 79 | grError = gr_err_memory; 80 | } 81 | 82 | if (p) 83 | memset( p, 0, size ); 84 | 85 | return p; 86 | } 87 | 88 | 89 | /******************************************************************** 90 | * 91 | * 92 | * grFree 93 | * 94 | * 95 | * Simple memory release 96 | * 97 | * 98 | * block :: target block 99 | * 100 | ********************************************************************/ 101 | 102 | void grFree( const void* block ) 103 | { 104 | if (block) 105 | free( (void *)block ); 106 | } 107 | 108 | 109 | 110 | static 111 | int check_mode( grPixelMode pixel_mode, 112 | int num_grays ) 113 | { 114 | if ( pixel_mode <= gr_pixel_mode_none || 115 | pixel_mode >= gr_pixel_mode_max ) 116 | goto Fail; 117 | 118 | if ( pixel_mode != gr_pixel_mode_gray || 119 | ( num_grays >= 2 && num_grays <= 256 ) ) 120 | return 0; 121 | 122 | Fail: 123 | grError = gr_err_bad_argument; 124 | return grError; 125 | } 126 | 127 | 128 | /********************************************************************** 129 | * 130 | * 131 | * grNewBitmap 132 | * 133 | * 134 | * creates a new bitmap 135 | * 136 | * 137 | * pixel_mode :: the target surface's pixel_mode 138 | * num_grays :: number of grays levels for PAL8 pixel mode 139 | * width :: width in pixels 140 | * height :: height in pixels 141 | * 142 | * 143 | * bit :: descriptor of the new bitmap 144 | * 145 | * 146 | * Error code. 0 means success. 147 | * 148 | **********************************************************************/ 149 | 150 | extern int grNewBitmap( grPixelMode pixel_mode, 151 | int num_grays, 152 | int width, 153 | int height, 154 | grBitmap *bit ) 155 | { 156 | int pitch; 157 | 158 | /* check mode */ 159 | if (check_mode(pixel_mode,num_grays)) 160 | goto Fail; 161 | 162 | /* check dimensions */ 163 | if (width < 0 || height < 0) 164 | { 165 | grError = gr_err_bad_argument; 166 | goto Fail; 167 | } 168 | 169 | bit->width = width; 170 | bit->rows = height; 171 | bit->mode = pixel_mode; 172 | bit->grays = num_grays; 173 | 174 | pitch = width; 175 | 176 | switch (pixel_mode) 177 | { 178 | case gr_pixel_mode_mono : pitch = (width+7) >> 3; break; 179 | case gr_pixel_mode_pal4 : pitch = (width+3) >> 2; break; 180 | 181 | case gr_pixel_mode_pal8 : 182 | case gr_pixel_mode_gray : pitch = width; break; 183 | 184 | case gr_pixel_mode_rgb555: 185 | case gr_pixel_mode_rgb565: pitch = width*2; break; 186 | 187 | case gr_pixel_mode_rgb24 : pitch = width*3; break; 188 | 189 | case gr_pixel_mode_rgb32 : pitch = width*4; break; 190 | 191 | default: 192 | grError = gr_err_bad_target_depth; 193 | return 0; 194 | } 195 | 196 | bit->pitch = pitch; 197 | bit->buffer = grAlloc( (unsigned long)( bit->pitch * bit->rows ) ); 198 | if (!bit->buffer) goto Fail; 199 | 200 | return 0; 201 | 202 | Fail: 203 | return grError; 204 | } 205 | 206 | /********************************************************************** 207 | * 208 | * 209 | * grDoneBitmap 210 | * 211 | * 212 | * destroys a bitmap 213 | * 214 | * 215 | * bitmap :: handle to bitmap descriptor 216 | * 217 | * 218 | * This function does NOT release the bitmap descriptor, only 219 | * the pixel buffer. 220 | * 221 | **********************************************************************/ 222 | 223 | extern void grDoneBitmap( grBitmap* bit ) 224 | { 225 | grFree( bit->buffer ); 226 | bit->buffer = 0; 227 | } 228 | 229 | 230 | 231 | -------------------------------------------------------------------------------- /graph/grobjs.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * 3 | * grobjs.h 4 | * 5 | * basic object classes definitions 6 | * 7 | * Copyright 1999 - The FreeType Development Team - www.freetype.org 8 | * 9 | * 10 | * 11 | * 12 | ***************************************************************************/ 13 | 14 | #ifndef GROBJS_H_ 15 | #define GROBJS_H_ 16 | 17 | #include "graph.h" 18 | #include "grconfig.h" 19 | #include "grtypes.h" 20 | 21 | 22 | typedef struct grBiColor_ 23 | { 24 | grColor foreground; 25 | grColor background; 26 | 27 | int num_levels; 28 | int max_levels; 29 | grColor* levels; 30 | 31 | } grBiColor; 32 | 33 | 34 | 35 | /********************************************************************** 36 | * 37 | * Technical note : explaining how the blitter works. 38 | * 39 | * The blitter is used to "draw" a given source bitmap into 40 | * a given target bitmap. 41 | * 42 | * The function called 'compute_clips' is used to compute clipping 43 | * constraints. These lead us to compute two areas : 44 | * 45 | * - the read area : is the rectangle, within the source bitmap, 46 | * which will be effectively "drawn" in the 47 | * target bitmap. 48 | * 49 | * - the write area : is the rectangle, within the target bitmap, 50 | * which will effectively "receive" the pixels 51 | * from the read area 52 | * 53 | * Note that both areas have the same dimensions, but are 54 | * located in distinct surfaces. 55 | * 56 | * These areas are computed by 'compute_clips' which is called 57 | * by each blitting function. 58 | * 59 | * Note that we use the Y-downwards convention within the blitter 60 | * 61 | **********************************************************************/ 62 | 63 | typedef struct grBlitter_ 64 | { 65 | int width; /* width in pixels of the areas */ 66 | int height; /* height in pixels of the areas */ 67 | 68 | int xread; /* x position of start point in read area */ 69 | int yread; /* y position of start point in read area */ 70 | 71 | int xwrite; /* x position of start point in write area */ 72 | int ywrite; /* y position of start point in write area */ 73 | 74 | int right_clip; /* amount of right clip */ 75 | 76 | unsigned char* read; /* top left corner of read area in source map */ 77 | unsigned char* write; /* top left corner of write area in target map */ 78 | 79 | int read_line; /* byte increment to go down one row in read area */ 80 | int write_line; /* byte increment to go down one row in write area */ 81 | 82 | grBitmap source; /* source bitmap descriptor */ 83 | grBitmap target; /* target bitmap descriptor */ 84 | 85 | } grBlitter; 86 | 87 | 88 | 89 | typedef void (*grBlitterFunc)( grBlitter* blitter, 90 | grColor color ); 91 | 92 | typedef void (*grSetTitleFunc)( grSurface* surface, 93 | const char* title_string ); 94 | 95 | typedef void (*grRefreshRectFunc)( grSurface* surface, 96 | int x, 97 | int y, 98 | int width, 99 | int height ); 100 | 101 | typedef void (*grDoneSurfaceFunc)( grSurface* surface ); 102 | 103 | typedef int (*grListenEventFunc)( grSurface* surface, 104 | int event_mode, 105 | grEvent *event ); 106 | 107 | 108 | 109 | struct grSurface_ 110 | { 111 | grDevice* device; 112 | grBitmap bitmap; 113 | grBool refresh; 114 | grBool owner; 115 | 116 | const byte* saturation; /* used for gray surfaces only */ 117 | grBlitterFunc blit_mono; /* 0 by default, set by grBlit.. */ 118 | 119 | grRefreshRectFunc refresh_rect; 120 | grSetTitleFunc set_title; 121 | grListenEventFunc listen_event; 122 | grDoneSurfaceFunc done; 123 | }; 124 | 125 | 126 | 127 | /******************************************************************** 128 | * 129 | * 130 | * grAlloc 131 | * 132 | * 133 | * Simple memory allocation. The returned block is always zero-ed 134 | * 135 | * 136 | * size :: size in bytes of the requested block 137 | * 138 | * 139 | * the memory block address. 0 in case of error 140 | * 141 | ********************************************************************/ 142 | 143 | extern unsigned char* 144 | grAlloc( unsigned long size ); 145 | 146 | 147 | /******************************************************************** 148 | * 149 | * 150 | * grFree 151 | * 152 | * 153 | * Simple memory release 154 | * 155 | * 156 | * block :: target block 157 | * 158 | ********************************************************************/ 159 | 160 | extern void grFree( const void* block ); 161 | 162 | 163 | #endif /* GROBJS_H_ */ 164 | -------------------------------------------------------------------------------- /graph/grswizzle.h: -------------------------------------------------------------------------------- 1 | #ifndef GRSWIZZLE_H_ 2 | #define GRSWIZZLE_H_ 3 | 4 | void 5 | gr_swizzle_rect_rgb24( unsigned char* read_buff, 6 | int read_pitch, 7 | unsigned char* write_buff, 8 | int write_pitch, 9 | int buff_width, 10 | int buff_height, 11 | int x, 12 | int y, 13 | int width, 14 | int height ); 15 | 16 | void 17 | gr_swizzle_rect_rgb565( unsigned char* read_buff, 18 | int read_pitch, 19 | unsigned char* write_buff, 20 | int write_pitch, 21 | int buff_width, 22 | int buff_height, 23 | int x, 24 | int y, 25 | int width, 26 | int height ); 27 | 28 | void 29 | gr_swizzle_rect_xrgb32( unsigned char* read_buff, 30 | int read_pitch, 31 | unsigned char* write_buff, 32 | int write_pitch, 33 | int buff_width, 34 | int buff_height, 35 | int x, 36 | int y, 37 | int width, 38 | int height ); 39 | 40 | #endif /* GRSWIZZLE_H_ */ 41 | -------------------------------------------------------------------------------- /graph/grtypes.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * 3 | * grtypes.h 4 | * 5 | * basic type definitions 6 | * 7 | * Copyright 1999 - The FreeType Development Team - www.freetype.org 8 | * 9 | * 10 | * 11 | * 12 | ***************************************************************************/ 13 | 14 | #ifndef GRTYPES_H_ 15 | #define GRTYPES_H_ 16 | 17 | typedef unsigned char byte; 18 | 19 | #if 0 20 | typedef signed char uchar; 21 | 22 | typedef unsigned long ulong; 23 | typedef unsigned short ushort; 24 | typedef unsigned int uint; 25 | #endif 26 | 27 | typedef struct grDimension_ 28 | { 29 | int x; 30 | int y; 31 | 32 | } grDimension; 33 | 34 | #define gr_err_ok 0 35 | #define gr_err_memory -1 36 | #define gr_err_bad_argument -2 37 | #define gr_err_bad_target_depth -3 38 | #define gr_err_bad_source_depth -4 39 | #define gr_err_saturation_overflow -5 40 | #define gr_err_conversion_overflow -6 41 | #define gr_err_invalid_device -7 42 | 43 | 44 | #ifdef GR_MAKE_OPTION_SINGLE_OBJECT 45 | #define GR_LOCAL_DECL static 46 | #define GR_LOCAL_FUNC static 47 | #else 48 | #define GR_LOCAL_DECL extern 49 | #define GR_LOCAL_FUNC /* void */ 50 | #endif 51 | 52 | #endif /* GRTYPES_H_ */ 53 | -------------------------------------------------------------------------------- /graph/mac/grmac.h: -------------------------------------------------------------------------------- 1 | #ifndef GRMAC_H_ 2 | #define GRMAC_H_ 3 | 4 | #include "grobjs.h" 5 | 6 | extern 7 | grDevice gr_mac_device; 8 | 9 | #ifdef GR_INIT_BUILD 10 | static 11 | grDeviceChain gr_mac_device_chain = 12 | { 13 | "mac", 14 | &gr_mac_device, 15 | GR_INIT_DEVICE_CHAIN 16 | }; 17 | 18 | #undef GR_INIT_DEVICE_CHAIN 19 | #define GR_INIT_DEVICE_CHAIN &gr_mac_device_chain 20 | 21 | #endif /* GR_INIT_BUILD */ 22 | 23 | #endif /* GRMAC_H_ */ 24 | -------------------------------------------------------------------------------- /graph/os2/Jamfile: -------------------------------------------------------------------------------- 1 | # FreeType2 demos graph/os2 Jamfile (c) 2001 David Turner 2 | # 3 | 4 | SubDir FT2DEMO_TOP graph os2 ; 5 | 6 | SubDirHdrs $(GRAPH_INCLUDE) ; 7 | 8 | GROS2_PATH = [ FT2_SubDir graph os2 ]; 9 | GRAPH_LINKLIBS = $(GROS2_PATH)gros2pm.def ; 10 | 11 | Library $(GRAPH_LIB) : grxos2.c ; 12 | 13 | # end of graph/os2 Jamfile 14 | -------------------------------------------------------------------------------- /graph/os2/gros2pm.def: -------------------------------------------------------------------------------- 1 | NAME WINDOWCOMPAT 2 | 3 | DESCRIPTION 'FreeType Graphics' 4 | HEAPSIZE 8192 5 | STACKSIZE 40888 6 | -------------------------------------------------------------------------------- /graph/os2/gros2pm.h: -------------------------------------------------------------------------------- 1 | #ifndef GROS2PM_H_ 2 | #define GROS2PM_H_ 3 | 4 | #include "grobjs.h" 5 | 6 | extern 7 | grDevice gr_os2pm_device; 8 | 9 | #ifdef GR_INIT_BUILD 10 | static 11 | grDeviceChain gr_os2pm_device_chain = 12 | { 13 | "os2pm", 14 | &gr_os2pm_device, 15 | GR_INIT_DEVICE_CHAIN 16 | }; 17 | 18 | #undef GR_INIT_DEVICE_CHAIN 19 | #define GR_INIT_DEVICE_CHAIN &gr_os2pm_device_chain 20 | 21 | #endif /* GR_INIT_BUILD */ 22 | 23 | #endif /* GROS2PM_H_ */ 24 | -------------------------------------------------------------------------------- /graph/os2/rules.mk: -------------------------------------------------------------------------------- 1 | #************************************************************************** 2 | #* 3 | #* OS/2 specific rules file, used to compile the OS/2 graphics driver 4 | #* to the graphics subsystem 5 | #* 6 | #************************************************************************** 7 | 8 | ifeq ($(PLATFORM),os2) 9 | 10 | GR_OS2 := $(GRAPH)/os2 11 | 12 | # the GRAPH_LINK is expanded each time an executable is linked with the 13 | # graphics library. 14 | # 15 | GRAPH_LINK += $(subst /,$(COMPILER_SEP),$(GR_OS2)/gros2pm.def) 16 | 17 | # add the OS/2 driver object file to the graphics library `graph.a' 18 | # 19 | GRAPH_OBJS += $(OBJ_DIR_2)/gros2pm.$O 20 | 21 | DEVICES += OS2_PM 22 | 23 | # the rule used to compile the graphics driver 24 | # 25 | $(OBJ_DIR_2)/gros2pm.$O: $(GR_OS2)/gros2pm.c $(GR_OS2)/gros2pm.h 26 | $(CC) $(CFLAGS) $(GRAPH_INCLUDES:%=$I%) \ 27 | $I$(subst /,$(COMPILER_SEP),$(GR_OS2)) \ 28 | $T$(subst /,$(COMPILER_SEP),$@ $<) 29 | 30 | endif 31 | 32 | # EOF 33 | -------------------------------------------------------------------------------- /graph/rules.mk: -------------------------------------------------------------------------------- 1 | #************************************************************************** 2 | #* 3 | #* FreeType demo utilities sub-Makefile 4 | #* 5 | #* This Makefile is to be included by `../Makefile'. Its 6 | #* purpose is to compile MiGS (the Minimalist Graphics Subsystem). 7 | #* 8 | #* It is written for GNU Make. Other make utilities are not 9 | #* supported! 10 | #* 11 | #************************************************************************** 12 | 13 | 14 | GRAPH_INCLUDES := $(subst /,$(COMPILER_SEP),$(TOP_DIR_2)/graph) 15 | GRAPH_LIB := $(OBJ_DIR_2)/graph.$(SA) 16 | 17 | GRAPH := $(TOP_DIR_2)/graph 18 | 19 | GRAPH_H := $(GRAPH)/gblany.h \ 20 | $(GRAPH)/gblbgra.h \ 21 | $(GRAPH)/gblblit.h \ 22 | $(GRAPH)/gblcolor.h \ 23 | $(GRAPH)/gblhbgr.h \ 24 | $(GRAPH)/gblhrgb.h \ 25 | $(GRAPH)/gblvbgr.h \ 26 | $(GRAPH)/gblvrgb.h \ 27 | $(GRAPH)/gblender.h \ 28 | $(GRAPH)/graph.h \ 29 | $(GRAPH)/grblit.h \ 30 | $(GRAPH)/grconfig.h \ 31 | $(GRAPH)/grdevice.h \ 32 | $(GRAPH)/grevents.h \ 33 | $(GRAPH)/grfont.h \ 34 | $(GRAPH)/grobjs.h \ 35 | $(GRAPH)/grswizzle.h \ 36 | $(GRAPH)/grtypes.h 37 | 38 | 39 | GRAPH_OBJS := $(OBJ_DIR_2)/gblblit.$(O) \ 40 | $(OBJ_DIR_2)/gblender.$(O) \ 41 | $(OBJ_DIR_2)/grblit.$(O) \ 42 | $(OBJ_DIR_2)/grdevice.$(O) \ 43 | $(OBJ_DIR_2)/grfill.$(O) \ 44 | $(OBJ_DIR_2)/grfont.$(O) \ 45 | $(OBJ_DIR_2)/grinit.$(O) \ 46 | $(OBJ_DIR_2)/grobjs.$(O) \ 47 | $(OBJ_DIR_2)/grswizzle.$(O) 48 | 49 | 50 | 51 | # Default value for COMPILE_GRAPH_LIB; 52 | # this value can be modified by the system-specific graphics drivers. 53 | # 54 | ifneq ($(LIBTOOL),) 55 | COMPILE_GRAPH_LIB = $(LIBTOOL) --mode=link $(CCraw) -static \ 56 | -o $(subst /,$(COMPILER_SEP),$@ $(GRAPH_OBJS)) 57 | else 58 | COMPILE_GRAPH_LIB = ar -r $(subst /,$(COMPILER_SEP),$@ $(GRAPH_OBJS)) 59 | endif 60 | 61 | 62 | # Add the rules used to detect and compile graphics driver depending 63 | # on the current platform. 64 | # 65 | include $(wildcard $(TOP_DIR_2)/graph/*/rules.mk) 66 | 67 | 68 | ######################################################################### 69 | # 70 | # Build the `graph' library from its objects. This should be changed 71 | # in the future in order to support more systems. Probably something 72 | # like a `config/' hierarchy with a system-specific rules file 73 | # to indicate how to make a library file, but for now, I'll stick to 74 | # unix, Win32, and OS/2-gcc. 75 | # 76 | # 77 | $(GRAPH_LIB): $(GRAPH_OBJS) 78 | $(COMPILE_GRAPH_LIB) 79 | 80 | 81 | # pattern rule for normal sources 82 | # 83 | $(OBJ_DIR_2)/%.$(O): $(GRAPH)/%.c $(GRAPH_H) 84 | ifneq ($(LIBTOOL),) 85 | $(LIBTOOL) --mode=compile $(CC) -static $(CFLAGS) \ 86 | $(GRAPH_INCLUDES:%=$I%) $T$@ $< 87 | else 88 | $(CC) $(CFLAGS) $(GRAPH_INCLUDES:%=$I%) $T$@ $< 89 | endif 90 | 91 | 92 | # a special rule is used for 'grinit.o' as it needs the definition 93 | # of some macros like "-DDEVICE_X11" or "-DDEVICE_OS2_PM" 94 | # 95 | $(OBJ_DIR_2)/grinit.$(O): $(GRAPH)/grinit.c $(GRAPH_H) 96 | ifneq ($(LIBTOOL),) 97 | $(LIBTOOL) --mode=compile $(CC) -static \ 98 | $(CFLAGS) $(GRAPH_INCLUDES:%=$I%) \ 99 | $(DEVICES:%=$DDEVICE_%) $T$(subst /,$(COMPILER_SEP),$@ $<) 100 | else 101 | $(CC) $(CFLAGS) $(GRAPH_INCLUDES:%=$I%) \ 102 | $(DEVICES:%=$DDEVICE_%) $T$(subst /,$(COMPILER_SEP),$@ $<) 103 | endif 104 | 105 | 106 | # EOF 107 | -------------------------------------------------------------------------------- /graph/win32/Jamfile: -------------------------------------------------------------------------------- 1 | # FreeType2 demos graph/win32 Jamfile (c) 2001 David Turner 2 | # 3 | 4 | SubDir FT2DEMO_TOP graph win32 ; 5 | 6 | SubDirHdrs $(GRAPH_INCLUDE) ; 7 | 8 | if $(JAM_TOOLSET) = MINGW 9 | { 10 | GRAPH_LINKLIBS = "-luser32 -lgdi32" ; 11 | } 12 | else 13 | { 14 | GRAPH_LINKLIBS = user32.lib gdi32.lib ; 15 | } 16 | 17 | Library $(GRAPH_LIB) : grwin32.c ; 18 | 19 | # end of graph/win32 Jamfile 20 | -------------------------------------------------------------------------------- /graph/win32/grwin32.h: -------------------------------------------------------------------------------- 1 | /******************************************************************* 2 | * 3 | * grwin32.h graphics driver for Win32 platform (header) 4 | * 5 | * This is the driver for displaying inside a window under Win32, 6 | * used by the graphics utility of the FreeType test suite. 7 | * 8 | * Written by Antoine Leca. 9 | * Copyright 1999-2000, 2001, 2002 by Antoine Leca, David Turner 10 | * David Turner, Robert Wilhelm, and Werner Lemberg. 11 | * 12 | * Borrowing liberally from the other FreeType drivers. 13 | * 14 | * This file is part of the FreeType project, and may only be used 15 | * modified and distributed under the terms of the FreeType project 16 | * license, LICENSE.TXT. By continuing to use, modify or distribute 17 | * this file you indicate that you have read the license and 18 | * understand and accept it fully. 19 | * 20 | ******************************************************************/ 21 | 22 | #ifndef GRWIN32_H_ 23 | #define GRWIN32_H_ 24 | 25 | #include "grobjs.h" 26 | 27 | extern 28 | grDevice gr_win32_device; 29 | 30 | #ifdef GR_INIT_BUILD 31 | static 32 | grDeviceChain gr_win32_device_chain = 33 | { 34 | "win32", 35 | &gr_win32_device, 36 | GR_INIT_DEVICE_CHAIN 37 | }; 38 | 39 | #undef GR_INIT_DEVICE_CHAIN 40 | #define GR_INIT_DEVICE_CHAIN &gr_win32_device_chain 41 | 42 | #endif /* GR_INIT_BUILD */ 43 | 44 | #endif /* GRWIN32_H_ */ 45 | -------------------------------------------------------------------------------- /graph/win32/rules.mk: -------------------------------------------------------------------------------- 1 | #************************************************************************** 2 | #* 3 | #* Win32 specific rules file, used to compile the Win32 graphics driver 4 | #* to the graphics subsystem 5 | #* 6 | #************************************************************************** 7 | 8 | ifeq ($(PLATFORM),win32) 9 | 10 | # directory of the Win32 graphics driver 11 | # 12 | GR_WIN32 := $(GRAPH)/win32 13 | 14 | # add the Win32 driver object file to the graphics library `graph.lib' 15 | # 16 | GRAPH_OBJS += $(OBJ_DIR_2)/grwin32.$O 17 | 18 | DEVICES += WIN32 19 | 20 | # the rule used to compile the graphics driver 21 | # 22 | $(OBJ_DIR_2)/grwin32.$O: $(GR_WIN32)/grwin32.c $(GR_WIN32)/grwin32.h 23 | $(CC) $(CFLAGS) $(GRAPH_INCLUDES:%=$I%) \ 24 | $I$(subst /,$(COMPILER_SEP),$(GR_WIN32)) \ 25 | $T$(subst /,$(COMPILER_SEP),$@ $<) 26 | 27 | # now update COMPILE_GRAPH_LIB according to the compiler used on Win32 28 | # 29 | ifeq ($(firstword $(CC)),gcc) # test for GCC 30 | GRAPH_LINK += -luser32 -lgdi32 31 | endif 32 | 33 | ifeq ($(findstring $(CC),cl icl), $(CC)) # test for Visual C++ & Intel C++ 34 | COMPILE_GRAPH_LIB = lib /nologo /out:$(subst /,$(COMPILER_SEP),$(GRAPH_LIB) $(GRAPH_OBJS)) 35 | LINK = cl /nologo /MD /Fe$(subst /,$(COMPILER_SEP),$@ $< $(FTLIB)) 36 | GRAPH_LINK += user32.lib gdi32.lib 37 | endif 38 | 39 | ifeq ($(CC),lcc) # test for LCC-Win32 40 | COMPILE_GRAPH_LIB = lcclib /out:$(subst /,$(COMPILER_SEP),$(GRAPH_LIB) $(GRAPH_OBJS)) 41 | LINK = lcclnk -o $(subst /,$(COMPILER_SEP),$@ $< $(FTLIB)) 42 | GRAPH_LINK += user32.lib gdi32.lib 43 | endif 44 | 45 | ifeq ($(CC),bcc32) # test for Borland C++ 46 | COMPILE_GRAPH_LIB = tlib /u $(subst /,$(COMPILER_SEP),$(GRAPH_LIB) $(GRAPH_OBJS:%=+%)) 47 | LINK = bcc32 -e$(subst /,$(COMPILER_SEP),$@ $< $(FTLIB)) 48 | endif 49 | endif 50 | 51 | # EOF 52 | -------------------------------------------------------------------------------- /graph/x11/Jamfile: -------------------------------------------------------------------------------- 1 | # FreeType2 demos graph/x11 Jamfile (c) 2001 David Turner 2 | # 3 | 4 | SubDir FT2DEMO_TOP graph x11 ; 5 | 6 | SubDirHdrs $(GRAPH_INCLUDE) ; 7 | 8 | GRAPH_LINKLIBS = -lX11 -L/usr/X11R6/lib ; 9 | 10 | Library $(GRAPH_LIB) : grx11.c ; 11 | 12 | # end of graph/x11 Jamfile 13 | -------------------------------------------------------------------------------- /graph/x11/grx11.h: -------------------------------------------------------------------------------- 1 | /******************************************************************* 2 | * 3 | * grx11.h graphics driver for X11 (header) 4 | * 5 | * This is the driver for displaying inside a window under X11, 6 | * used by the graphics utility of the FreeType test suite. 7 | * 8 | * Copyright 1999-2000, 2001, 2002 by Antoine Leca, David Turner 9 | * David Turner, Robert Wilhelm, and Werner Lemberg. 10 | * 11 | * This file is part of the FreeType project, and may only be used 12 | * modified and distributed under the terms of the FreeType project 13 | * license, LICENSE.TXT. By continuing to use, modify or distribute 14 | * this file you indicate that you have read the license and 15 | * understand and accept it fully. 16 | * 17 | ******************************************************************/ 18 | 19 | #ifndef GRX11_H_ 20 | #define GRX11_H_ 21 | 22 | #ifdef __cplusplus 23 | #define class c_class 24 | #endif 25 | 26 | #include "grobjs.h" 27 | #include "grdevice.h" 28 | 29 | extern 30 | grDevice gr_x11_device; 31 | 32 | #ifdef GR_INIT_BUILD 33 | static 34 | grDeviceChain gr_x11_device_chain = 35 | { 36 | "x11", 37 | &gr_x11_device, 38 | GR_INIT_DEVICE_CHAIN 39 | }; 40 | 41 | #undef GR_INIT_DEVICE_CHAIN 42 | #define GR_INIT_DEVICE_CHAIN &gr_x11_device_chain 43 | 44 | #endif /* GR_INIT_BUILD */ 45 | 46 | #endif /* GRX11_H_ */ 47 | -------------------------------------------------------------------------------- /graph/x11/rules.mk: -------------------------------------------------------------------------------- 1 | #************************************************************************** 2 | #* 3 | #* X11-specific rules files, used to compile the X11 graphics driver 4 | #* when supported by the current platform 5 | #* 6 | #************************************************************************** 7 | 8 | 9 | ######################################################################### 10 | # 11 | # Try to detect an X11 setup. 12 | # 13 | # We try to detect the following directories (in that order) in the current 14 | # path: 15 | # 16 | # X11 (usually a symlink to the current release) 17 | # X11R6 18 | # X11R5 19 | # 20 | # If no success, we directly check the directories 21 | # 22 | # /usr 23 | # /usr/X11R6 24 | # /usr/local/X11R6 25 | # 26 | # whether they contain `include/X11/Xlib.h'. Note that the Makefile 27 | # silently assumes that they will also contain `lib/X11/libX11.(a|so)'. 28 | # 29 | # If the variable X11_PATH is set (to specify unusual locations of X11), no 30 | # other directory is searched. More than one directory must be separated 31 | # with spaces. Example: 32 | # 33 | # make X11_PATH="/usr/openwin /usr/local/X11R6" 34 | # 35 | FT_PATH := $(subst ;, ,$(subst :, ,$(subst $(SEP),/,$(PATH)))) 36 | 37 | ifndef X11_PATH 38 | ifneq ($(findstring X11/bin,$(FT_PATH)),) 39 | xversion := X11 40 | else 41 | ifneq ($(findstring X11R6/bin,$(FT_PATH)),) 42 | xversion := X11R6 43 | else 44 | ifneq ($(findstring X11R5/bin,$(FT_PATH)),) 45 | xversion := X11R5 46 | endif 47 | endif 48 | endif 49 | 50 | ifdef xversion 51 | X11_PATH := $(filter %$(xversion)/bin,$(FT_PATH)) 52 | X11_PATH := $(X11_PATH:%/bin=%) 53 | else 54 | X11_DIRS := /usr /usr/X11R6 /usr/local/X11R6 55 | X11_XLIB := include/X11/Xlib.h 56 | X11_PATH := $(foreach dir,$(X11_DIRS),$(wildcard $(dir)/$(X11_XLIB))) 57 | X11_PATH := $(X11_PATH:%/$(X11_XLIB)=%) 58 | endif 59 | endif 60 | 61 | 62 | ########################################################################## 63 | # 64 | # Update some variables to compile the X11 graphics module. Note that 65 | # X11 is available on Unix, or on OS/2. However, it only compiles with 66 | # gcc on the latter platform, which is why it is safe to use the flags 67 | # `-L' and `-l' in GRAPH_LINK. 68 | # 69 | ifneq ($(X11_PATH),) 70 | 71 | X11_INCLUDE := $(subst /,$(COMPILER_SEP),$(X11_PATH:%=%/include)) 72 | X11_LIB := $(subst /,$(COMPILER_SEP),$(X11_PATH:%=%/lib64) \ 73 | $(X11_PATH:%=%/lib)) 74 | 75 | # The GRAPH_LINK variable is expanded each time an executable is linked 76 | # against the graphics library. 77 | # 78 | ifeq ($(PLATFORM),unix) 79 | GRAPH_LINK += $(X11_LIB:%=-R%) 80 | endif 81 | GRAPH_LINK += $(X11_LIB:%=-L%) -lX11 82 | 83 | # Solaris needs a -lsocket in GRAPH_LINK. 84 | # 85 | UNAME := $(shell uname) 86 | ifneq ($(findstring $(UNAME),SunOS Solaris),) 87 | GRAPH_LINK += -lsocket 88 | endif 89 | 90 | 91 | # Add the X11 driver object file to the graphics library. 92 | # 93 | GRAPH_OBJS += $(OBJ_DIR_2)/grx11.$(O) 94 | 95 | GR_X11 := $(GRAPH)/x11 96 | 97 | DEVICES += X11 98 | 99 | # the rule used to compile the X11 driver 100 | # 101 | $(OBJ_DIR_2)/grx11.$(O): $(GR_X11)/grx11.c $(GR_X11)/grx11.h 102 | ifneq ($(LIBTOOL),) 103 | $(LIBTOOL) --mode=compile $(CC) -static $(CFLAGS) \ 104 | $(GRAPH_INCLUDES:%=$I%) \ 105 | $I$(subst /,$(COMPILER_SEP),$(GR_X11)) \ 106 | $(X11_INCLUDE:%=$I%) \ 107 | $T$(subst /,$(COMPILER_SEP),$@ $<) 108 | else 109 | $(CC) $(CFLAGS) $(GRAPH_INCLUDES:%=$I%) \ 110 | $I$(subst /,$(COMPILER_SEP),$(GR_X11)) \ 111 | $(X11_INCLUDE:%=$I%) \ 112 | $T$(subst /,$(COMPILER_SEP),$@ $<) 113 | endif 114 | endif 115 | 116 | # EOF 117 | -------------------------------------------------------------------------------- /graph/xtest.c: -------------------------------------------------------------------------------- 1 | #include "graph.h" 2 | #include "grfont.h" /* dispara^itra bientot */ 3 | #include 4 | 5 | 6 | static 7 | void Panic( const char* message ) 8 | { 9 | fprintf( stderr, "PANIC: %s\n", message ); 10 | exit(1); 11 | } 12 | 13 | 14 | typedef struct grKeyName 15 | { 16 | grKey key; 17 | const char* name; 18 | 19 | } grKeyName; 20 | 21 | 22 | static 23 | const grKeyName key_names[] = 24 | { 25 | { grKeyF1, "F1" }, 26 | { grKeyF2, "F2" }, 27 | { grKeyF3, "F3" }, 28 | { grKeyF4, "F4" }, 29 | { grKeyF5, "F5" }, 30 | { grKeyF6, "F6" }, 31 | { grKeyF7, "F7" }, 32 | { grKeyF8, "F8" }, 33 | { grKeyF9, "F9" }, 34 | { grKeyF10, "F10" }, 35 | { grKeyF11, "F11" }, 36 | { grKeyF12, "F12" }, 37 | { grKeyEsc, "Esc" }, 38 | { grKeyHome, "Home" }, 39 | { grKeyEnd, "End" }, 40 | 41 | { grKeyPageUp, "Page_Up" }, 42 | { grKeyPageDown, "Page_Down" }, 43 | { grKeyLeft, "Left" }, 44 | { grKeyRight, "Right" }, 45 | { grKeyUp, "Up" }, 46 | { grKeyDown, "Down" }, 47 | { grKeyBackSpace, "BackSpace" }, 48 | { grKeyReturn, "Return" } 49 | }; 50 | 51 | int main( void ) 52 | { 53 | grSurface* surface; 54 | int n; 55 | 56 | grInit(); 57 | surface = grNewScreenSurface( 0, gr_pixel_mode_gray, 320, 400, 128 ); 58 | if (!surface) 59 | Panic("Could not create window\n" ); 60 | else 61 | { 62 | grColor color; 63 | grEvent event; 64 | const char* string; 65 | int x; 66 | 67 | grSetSurfaceRefresh( surface, 1 ); 68 | grSetTitle(surface,"X11 driver demonstration" ); 69 | 70 | for ( x = -10; x < 10; x++ ) 71 | { 72 | for ( n = 0; n < 128; n++ ) 73 | { 74 | color.value = (n*3) & 127; 75 | grWriteCellChar( surface, 76 | x + ((n % 60) << 3), 77 | 80 + (x+10)*8*3 + ((n/60) << 3), n, color ); 78 | } 79 | 80 | } 81 | color.value = 64; 82 | grWriteCellString( surface, 0, 0, "just an example", color ); 83 | 84 | do 85 | { 86 | grListenSurface( surface, 0, &event); 87 | 88 | /* return if ESC was pressed */ 89 | if ( event.key == grKeyEsc ) 90 | return 0; 91 | 92 | /* otherwise, display key string */ 93 | color.value = (color.value + 8) & 127; 94 | { 95 | int count = sizeof(key_names)/sizeof(key_names[0]); 96 | grKeyName* name = (grKeyName*)key_names; 97 | grKeyName* limit = name + count; 98 | const char* kname = 0; 99 | char kname_temp[16]; 100 | 101 | while (name < limit) 102 | { 103 | if ( name->key == event.key ) 104 | { 105 | kname = (const char*)name->name; 106 | break; 107 | } 108 | name++; 109 | } 110 | 111 | if (!kname) 112 | { 113 | sprintf( kname_temp, "char '%c'", (char)event.key ); 114 | kname = kname_temp; 115 | } 116 | 117 | grWriteCellString( surface, 30, 30, kname, color ); 118 | grRefreshSurface(surface); 119 | } 120 | } while (1); 121 | } 122 | 123 | return 0; 124 | } 125 | 126 | -------------------------------------------------------------------------------- /mac/Makefile: -------------------------------------------------------------------------------- 1 | ################################################################## 2 | # 3 | # Makefile for MacOS X to build MacOS-specific API test program, 4 | # Also targets to setup vanilla source for MPW are included. 5 | # This should be executed in this directory, as 6 | # "cd ft2demos ; make -C mac". 7 | # 8 | # most part is taken from ft2demos/Makefile, for UNIX platform. 9 | # 10 | 11 | all: exes 12 | 13 | empty := 14 | space := $(empty) $(empty) 15 | 16 | TOP_DIR ?= ../../freetype2 17 | OBJ_DIR ?= $(TOP_DIR)/objs 18 | TOP_DIR_2 ?= .. 19 | OBJ_DIR_2 ?= $(TOP_DIR_2)/obj 20 | TOP_DIR_2_MAC ?= $(TOP_DIR_2)/mac 21 | 22 | ifndef CONFIG_MK 23 | PROJECT := freetype 24 | CONFIG_MK := $(TOP_DIR)/config.mk 25 | endif 26 | 27 | ifeq ($(wildcard $(CONFIG_MK)),) 28 | no_config_mk := 1 29 | endif 30 | 31 | ifdef no_config_mk 32 | exes: 33 | @echo Please compile the library before the demo programs! 34 | clean distclean: 35 | @echo "I need \`$(subst /,$(SEP),$(TOP_DIR)/config.mk)' to do that!" 36 | else 37 | include $(CONFIG_MK) 38 | have_makefile := $(strip $(wildcard Makefile)) 39 | TOP_DIR := $(shell cd $(TOP_DIR); pwd) 40 | TOP_DIR_2 := $(shell cd $(TOP_DIR_2); pwd) 41 | ifneq ($(have_makefile),) 42 | BIN_DIR_2 ?= $(TOP_DIR_2)/bin 43 | OBJ_DIR_2 ?= $(TOP_DIR_2)/obj 44 | else 45 | BIN_DIR_2 ?= .. 46 | OBJ_DIR_2 ?= .. 47 | endif 48 | 49 | GRAPH_DIR := $(TOP_DIR_2)/graph 50 | include $(GRAPH_DIR)/rules.mk 51 | 52 | ifeq ($(TOP_DIR),..) 53 | SRC_DIR := src 54 | else 55 | SRC_DIR := $(TOP_DIR_2)/src 56 | endif 57 | 58 | FT_INCLUDES := $(OBJ_BUILD) $(BUILD_DIR) $(TOP_DIR)/include $(SRC_DIR) 59 | INCLUDES := $(subst /,$(COMPILER_SEP),$(FT_INCLUDES)) 60 | COMPILE = $(CC) $(CFLAGS) $(INCLUDES:%=$I%) 61 | FTLIB := $(LIB_DIR)/$(LIBRARY).$A 62 | ifeq ($(PLATFORM),unix) 63 | MATH := -lm 64 | endif 65 | ifeq ($(PLATFORM),unixdev) 66 | MATH := -lm 67 | endif 68 | LINK_ITEMS = $T$(subst /,$(COMPILER_SEP),$@ $<) 69 | 70 | CC = $(CCraw) 71 | LINK_CMD = $(subst /,$(SEP),$(OBJ_BUILD)/libtool) \ 72 | --mode=link $(CC) \ 73 | $(subst /,$(COMPILER_SEP),$(LDFLAGS)) 74 | ifeq ($(findstring CoreServices,$(LDFLAGS)),) 75 | LINK_LIBS = $(subst /,$(COMPILER_SEP),$(FTLIB) $(EFENCE)) $(MATH) \ 76 | -Xlinker -framework -Xlinker CoreServices \ 77 | -Xlinker -framework -Xlinker ApplicationServices 78 | else 79 | LINK_LIBS = $(subst /,$(COMPILER_SEP),$(FTLIB) $(EFENCE)) $(MATH) 80 | endif 81 | LINK_COMMON = $(LINK_CMD) \ 82 | $(LINK_ITEMS) $(subst /,$(COMPILER_SEP),$(COMMON_OBJ)) \ 83 | $(LINK_LIBS) 84 | 85 | .PHONY: exes clean distclean 86 | 87 | E := 88 | EXES := ftoldmac 89 | exes: $(EXES:%=$(BIN_DIR_2)/%$E) 90 | 91 | $(BIN_DIR_2)/ftoldmac$E: $(OBJ_DIR_2)/ftoldmac.$(SO) $(FTLIB) $(COMMON_OBJ) 92 | $(LINK_COMMON) 93 | 94 | $(OBJ_DIR_2)/ftoldmac.$(SO): $(TOP_DIR_2_MAC)/ftoldmac.c 95 | $(COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<) $DFT2_BUILD_LIBRARY 96 | 97 | COMMON_OBJ := $(OBJ_DIR_2)/common.$(SO) 98 | $(COMMON_OBJ): $(SRC_DIR)/common.c 99 | $(COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<) $DFT2_BUILD_LIBRARY 100 | 101 | ################################################################ 102 | # Targets to setup MPW 103 | # 104 | 105 | clean: 106 | rm -f \ 107 | $(TOP_DIR_2)/ftoldmac.*.make \ 108 | $(OBJ_DIR_2)/*.NJ \ 109 | $(OBJ_DIR_2)/*.makeout \ 110 | $(OBJ_DIR_2)/*.o $(OBJ_DIR_2)/*.exe 111 | 112 | makefiles: 113 | python $(TOP_DIR_2_MAC)/ascii2mpw.py \ 114 | > $(TOP_DIR_2)/ftoldmac.m68k_far.make \ 115 | < $(TOP_DIR_2_MAC)/ftoldmac.m68k_far.make.txt 116 | python $(TOP_DIR_2_MAC)/ascii2mpw.py \ 117 | > $(TOP_DIR_2)/ftoldmac.ppc_classic.make \ 118 | < $(TOP_DIR_2_MAC)/ftoldmac.ppc_classic.make.txt 119 | find $(TOP_DIR_2) -name '*.make' | \ 120 | xargs /Developer/Tools/SetFile -a l -c "MPS " -t TEXT 121 | 122 | resource: 123 | find $(SRC_DIR) $(TOP_DIR_2_MAC) -name '*.[ch]' | \ 124 | xargs /Developer/Tools/SetFile -a l -c "MPS " -t TEXT 125 | endif 126 | -------------------------------------------------------------------------------- /mac/README: -------------------------------------------------------------------------------- 1 | This folder contains supporting code and CodeWarrior Pro 4 project 2 | files to build the FreeType demo programs ftlint and ftview for MacOS. 3 | 4 | Building 5 | To build these apps, you'll first need to build the FreeType library 6 | (see config/mac). Be sure to unpack the resource.hqx file; it contains 7 | two resource files that are needed for ftlint and ftview. The 8 | applications get built in the demos/bin folder. 9 | 10 | Notes 11 | Since the Mac doesn't have the notion of argc/argv, we'll emulate 12 | this: each file dropped onto the application will be translated 13 | to a command line argument. Both ftlint and ftview take a ppem 14 | value as their first command line argument: for the Mac version 15 | this has been hard-coded into the source. Also: the additional 16 | options for ftview cannot be set. 17 | 18 | Appendix 19 | Makefile, ftoldmac.m68k_far.make.txt, ftoldmac.ppc_classic.make.txt 20 | and ftoldmac.c are for commandline program "ftoldmac" to test MacOS 21 | specific API, written by suzuki toshiya. On MacOS X, you can build 22 | ftoldmac by "make -C mac" in the top directory of ft2demos. Also 23 | you can generate MPW makefiles by "make -C mac makefiles", in MacOS 24 | X commandline. 25 | 26 | Have fun with FreeType on the Mac! 27 | 28 | Just van Rossum, 29 | 30 | DISCLAIMER: this subdirectory is *not* being maintained by the 31 | FreeType team, but by Just van Rossum. It's being released under 32 | the same terms as FreeType (see LICENSE.TXT). 33 | -------------------------------------------------------------------------------- /mac/ascii2mpw.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import sys 3 | import string 4 | 5 | if len( sys.argv ) == 1 : 6 | for asc_line in sys.stdin.readlines(): 7 | mpw_line = string.replace(asc_line, "\\xA5", "\245") 8 | mpw_line = string.replace(mpw_line, "\\xB6", "\266") 9 | mpw_line = string.replace(mpw_line, "\\xC4", "\304") 10 | mpw_line = string.replace(mpw_line, "\\xC5", "\305") 11 | mpw_line = string.replace(mpw_line, "\\xFF", "\377") 12 | mpw_line = string.replace(mpw_line, "\n", "\r") 13 | mpw_line = string.replace(mpw_line, "\\n", "\n") 14 | sys.stdout.write(mpw_line) 15 | elif sys.argv[1] == "-r" : 16 | for mpw_line in sys.stdin.readlines(): 17 | asc_line = string.replace(mpw_line, "\n", "\\n") 18 | asc_line = string.replace(asc_line, "\r", "\n") 19 | asc_line = string.replace(asc_line, "\245", "\\xA5") 20 | asc_line = string.replace(asc_line, "\266", "\\xB6") 21 | asc_line = string.replace(asc_line, "\304", "\\xC4") 22 | asc_line = string.replace(asc_line, "\305", "\\xC5") 23 | asc_line = string.replace(asc_line, "\377", "\\xFF") 24 | sys.stdout.write(asc_line) 25 | -------------------------------------------------------------------------------- /mac/codewarrior/carbonprefix.h: -------------------------------------------------------------------------------- 1 | #define USING_CARBON 2 | 3 | #include "ftoption.h" -------------------------------------------------------------------------------- /mac/codewarrior/ftlint.prj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/source-foundry/freetype2-demos/9ad98da32f687356655ddfc51a874cee48b83cec/mac/codewarrior/ftlint.prj -------------------------------------------------------------------------------- /mac/codewarrior/ftview.prj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/source-foundry/freetype2-demos/9ad98da32f687356655ddfc51a874cee48b83cec/mac/codewarrior/ftview.prj -------------------------------------------------------------------------------- /mac/ftlint_m.c: -------------------------------------------------------------------------------- 1 | /* minimal Mac wrapper for the ftlint.c program */ 2 | 3 | 4 | int original_main( int argc, char** argv ); 5 | 6 | /* We rename the original main() program to original_main, 7 | so we can provide a wrapper around it */ 8 | #define main original_main 9 | #include "ftlint.c" 10 | #undef main 11 | 12 | 13 | #define PPEM "24" /* hard-code the ppem size */ 14 | 15 | 16 | #include 17 | #include "getargv.h" 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | static void 24 | init_toolbox() 25 | { 26 | InitGraf(&qd.thePort); 27 | InitFonts(); 28 | InitWindows(); 29 | TEInit(); 30 | InitDialogs((long)0); 31 | InitMenus(); 32 | InitCursor(); 33 | SIOUXSettings.asktosaveonclose = 0; 34 | } 35 | 36 | int main() 37 | { 38 | int argc, i; 39 | char** argv; 40 | 41 | init_toolbox(); 42 | 43 | /* put paths of all files dropped onto the app into argv */ 44 | argc = FTMac_GetArgv(&argv); 45 | if (argc < 2) 46 | { 47 | printf("Please drop one or more font files onto the app (but quit first!)\n"); 48 | exit(1); 49 | } 50 | /* move argv[1:] to argv[2:] and fill in the ppem arg */ 51 | for (i = argc; i > 1; i--) 52 | { 53 | argv[i] = argv[i-1]; 54 | } 55 | argc++; 56 | argv[1] = PPEM; 57 | /* call the original main() program */ 58 | original_main(argc, argv); 59 | } 60 | -------------------------------------------------------------------------------- /mac/ftoldmac.m68k_far.make.txt: -------------------------------------------------------------------------------- 1 | # File: ftoldmac.m68k_far.make 2 | # Target: ftoldmac.m68k_far 3 | # Created: Wednesday, November 23, 2005 04:21:20 PM 4 | 5 | 6 | MAKEFILE = ftoldmac.m68k_far.make 7 | \xA5MondoBuild\xA5 = {MAKEFILE} # Make blank to avoid rebuilds when makefile is modified 8 | 9 | FT2Dir = ::freetype2: 10 | ObjDir = :obj: 11 | Includes = \xB6 12 | -i "{FT2Dir}include:" \xB6 13 | -i "{FT2Dir}src:" \xB6 14 | -i :src: \xB6 15 | -i "{FT2Dir}include:freetype:config:" 16 | 17 | Sym-68K = -sym off 18 | 19 | COptions = \xB6 20 | -d HAVE_FSSPEC=1 \xB6 21 | -d HAVE_FSREF=0 \xB6 22 | -d HAVE_QUICKDRAW_TOOLBOX=1 \xB6 23 | -d HAVE_QUICKDRAW_CARBON=0 \xB6 24 | -d HAVE_ATS=0 \xB6 25 | -d FT2_BUILD_LIBRARY \xB6 26 | -d FT_CONFIG_CONFIG_H="" \xB6 27 | -d FT_CONFIG_MODULES_H="" \xB6 28 | {Includes} {Sym-68K} -model far -includes unix 29 | 30 | 31 | ### Source Files ### 32 | 33 | SrcFiles = \xB6 34 | :mac:ftoldmac.c \xB6 35 | :src:common.c 36 | 37 | 38 | ### Object Files ### 39 | 40 | ObjFiles-68K = \xB6 41 | "{ObjDir}ftoldmac.c.o" \xB6 42 | "{ObjDir}common.c.o" 43 | 44 | 45 | ### Libraries ### 46 | 47 | LibFiles-68K = \xB6 48 | "{FT2Dir}FreeType.m68k_far.o" \xB6 49 | "{Libraries}Stubs.o" \xB6 50 | "{Libraries}MathLib.far.o" \xB6 51 | "{CLibraries}StdCLib.far.o" \xB6 52 | "{Libraries}MacRuntime.o" \xB6 53 | "{Libraries}IntEnv.far.o" \xB6 54 | "{Libraries}ToolLibs.far.o" \xB6 55 | "{Libraries}Interface.o" 56 | 57 | 58 | ### Default Rules ### 59 | 60 | .c.o \xC4 .c {\xA5MondoBuild\xA5} 61 | {C} {depDir}{default}.c -o {targDir}{default}.c.o {COptions} 62 | 63 | 64 | ### Build Rules ### 65 | 66 | ftoldmac.m68k_far \xC4\xC4 {ObjFiles-68K} {LibFiles-68K} {\xA5MondoBuild\xA5} 67 | ILink \xB6 68 | -o {Targ} \xB6 69 | {ObjFiles-68K} \xB6 70 | {LibFiles-68K} \xB6 71 | {Sym-68K} \xB6 72 | -mf -d \xB6 73 | -t 'MPST' \xB6 74 | -c 'MPS ' \xB6 75 | -model far \xB6 76 | -state rewrite \xB6 77 | -compact -pad 0 \xB6 78 | -br on 79 | If "{Sym-68K}" =~ /-sym \xC5[nNuU]\xC5/ 80 | ILinkToSYM {Targ}.NJ -mf -sym 3.2 -c 'sade' 81 | End 82 | 83 | 84 | 85 | ### Required Dependencies ### 86 | 87 | "{ObjDir}ftoldmac.c.o" \xC4 :mac:ftoldmac.c 88 | "{ObjDir}common.c.o" \xC4 :src:common.c 89 | 90 | 91 | ### Optional Dependencies ### 92 | ### Build this target to generate "include file" dependencies. ### 93 | 94 | Dependencies \xC4 $OutOfDate 95 | MakeDepend \xB6 96 | -append {MAKEFILE} \xB6 97 | -ignore "{CIncludes}" \xB6 98 | -objdir "{ObjDir}" \xB6 99 | -objext .o \xB6 100 | {Includes} \xB6 101 | {SrcFiles} 102 | 103 | 104 | -------------------------------------------------------------------------------- /mac/ftoldmac.ppc_classic.make.txt: -------------------------------------------------------------------------------- 1 | # File: ftoldmac.ppc_classic.make 2 | # Target: ftoldmac.ppc_classic 3 | # Created: Thursday, November 24, 2005 10:02:30 AM 4 | 5 | 6 | MAKEFILE = ftoldmac.ppc_classic.make 7 | \xA5MondoBuild\xA5 = {MAKEFILE} # Make blank to avoid rebuilds when makefile is modified 8 | 9 | FT2Dir = ::freetype2: 10 | ObjDir = :obj: 11 | Includes = \xB6 12 | -i "{FT2Dir}include:" \xB6 13 | -i "{FT2Dir}src:" \xB6 14 | -i :src: \xB6 15 | -i "{FT2Dir}include:freetype:config:" 16 | 17 | Sym-PPC = -sym off 18 | 19 | PPCCOptions = \xB6 20 | -d HAVE_FSSPEC=1 \xB6 21 | -d HAVE_FSREF=0 \xB6 22 | -d HAVE_QUICKDRAW_TOOLBOX=1 \xB6 23 | -d HAVE_QUICKDRAW_CARBON=0 \xB6 24 | -d HAVE_ATS=0 \xB6 25 | -d FT2_BUILD_LIBRARY \xB6 26 | -d FT_CONFIG_CONFIG_H="" \xB6 27 | -d FT_CONFIG_MODULES_H="" \xB6 28 | {Includes} {Sym-PPC} -includes unix -ansi strict 29 | 30 | 31 | ### Source Files ### 32 | 33 | SrcFiles = \xB6 34 | :mac:ftoldmac.c \xB6 35 | :src:common.c 36 | 37 | 38 | ### Object Files ### 39 | 40 | ObjFiles-PPC = \xB6 41 | "{ObjDir}common.c.x" \xB6 42 | "{ObjDir}ftoldmac.c.x" 43 | 44 | 45 | ### Libraries ### 46 | 47 | LibFiles-PPC = \xB6 48 | "{FT2Dir}FreeType.ppc_classic.o" \xB6 49 | "{SharedLibraries}InterfaceLib" \xB6 50 | "{SharedLibraries}StdCLib" \xB6 51 | "{SharedLibraries}MathLib" \xB6 52 | "{PPCLibraries}StdCRuntime.o" \xB6 53 | "{PPCLibraries}PPCCRuntime.o" \xB6 54 | "{PPCLibraries}PPCToolLibs.o" 55 | 56 | 57 | ### Default Rules ### 58 | 59 | .c.x \xC4 .c {\xA5MondoBuild\xA5} 60 | {PPCC} {depDir}{default}.c -o {targDir}{default}.c.x {PPCCOptions} 61 | 62 | 63 | ### Build Rules ### 64 | 65 | ftoldmac.ppc_classic \xC4\xC4 {ObjFiles-PPC} {LibFiles-PPC} {\xA5MondoBuild\xA5} 66 | PPCLink \xB6 67 | -o {Targ} \xB6 68 | {ObjFiles-PPC} \xB6 69 | {LibFiles-PPC} \xB6 70 | {Sym-PPC} \xB6 71 | -mf -d \xB6 72 | -t 'MPST' \xB6 73 | -c 'MPS ' 74 | 75 | 76 | 77 | ### Required Dependencies ### 78 | 79 | "{ObjDir}common.c.x" \xC4 :src:common.c 80 | "{ObjDir}ftoldmac.c.x" \xC4 :mac:ftoldmac.c 81 | 82 | 83 | ### Optional Dependencies ### 84 | ### Build this target to generate "include file" dependencies. ### 85 | 86 | Dependencies \xC4 $OutOfDate 87 | MakeDepend \xB6 88 | -append {MAKEFILE} \xB6 89 | -ignore "{CIncludes}" \xB6 90 | -objdir "{ObjDir}" \xB6 91 | -objext .x \xB6 92 | {Includes} \xB6 93 | {SrcFiles} 94 | 95 | 96 | -------------------------------------------------------------------------------- /mac/ftview_m.c: -------------------------------------------------------------------------------- 1 | /* minimal Mac wrapper for the ftview.c program */ 2 | 3 | 4 | int original_main( int argc, char** argv ); 5 | 6 | /* We rename the original main() program to original_main, 7 | so we can provide a wrapper around it */ 8 | #define main original_main 9 | #include "ftview.c" 10 | #undef main 11 | 12 | 13 | #define PPEM "24" /* hard-code the ppem size */ 14 | 15 | 16 | #include 17 | #include "getargv.h" 18 | #ifndef USING_CARBON 19 | #include 20 | #include 21 | #include 22 | #include 23 | #else 24 | #include 25 | #endif 26 | 27 | static void 28 | init_toolbox() 29 | { 30 | #ifndef USING_CARBON 31 | InitGraf(&qd.thePort); 32 | InitFonts(); 33 | InitWindows(); 34 | TEInit(); 35 | InitDialogs((long)0); 36 | InitMenus(); 37 | InitCursor(); 38 | #endif 39 | 40 | SIOUXSettings.asktosaveonclose = 0; 41 | } 42 | 43 | int main() 44 | { 45 | int argc, i; 46 | char** argv; 47 | 48 | init_toolbox(); 49 | 50 | /* put paths of all files dropped onto the app into argv */ 51 | argc = FTMac_GetArgv(&argv); 52 | if (argc < 2) 53 | { 54 | printf("Please drop one or more font files onto the app (but quit first!)\n"); 55 | exit(1); 56 | } 57 | /* move argv[1:] to argv[2:] and fill in the ppem arg */ 58 | for (i = argc; i > 1; i--) 59 | { 60 | argv[i] = argv[i-1]; 61 | } 62 | argc++; 63 | argv[1] = PPEM; 64 | /* call the original main() program */ 65 | original_main(argc, argv); 66 | } 67 | -------------------------------------------------------------------------------- /mac/getargv.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | FTMac_GetArgv 4 | 5 | 6 | argc/argv emulation for the Mac. Converts files dropped 7 | onto the application to full paths, and stuff them into 8 | argv. 9 | 10 | 11 | pargv :: a pointer to an argv array. The array doesn't need to 12 | exist before calling this function. 13 | 14 | 15 | The number of files dropped onto the app (ie. argc) 16 | */ 17 | 18 | int FTMac_GetArgv(char ***pargv); 19 | 20 | -------------------------------------------------------------------------------- /mac/resource.hqx: -------------------------------------------------------------------------------- 1 | (This file must be converted with BinHex 4.0) :$(*PFfpeFQ0P,R0TG!"6594%8dP8)3%!!!!(9!!!!4kE)90*9#%!!J!!"e4b6'& e!J!!!!!@!!!0!!YQG'aTER3ZFR0bB`EK@D!!4J`+!!!!J!!!!!!'k52Z%qJ*KJ! !!!!!!!!!!!!!!!!!!!!!!!'I!!!!!2rrrrpbFh*M8P0&4!%!Y0lZjl6HlcS!!!' C!!!!!!!!!4N!!!!!Pl)!!!!!!!!!!&+E%3!)(#ae#1,@kQ-l3-r1rA-h'clY+LM H9q+m@S[Fj'KEDPD(PRRlbr3)Nck4+9)bfh$4M895H*J+"lDRd-a-6hUrB81a2k& e%)&b(ZXdrYBdI[ZdE)8F9('8dr066MF[CQTkaA%3fiT"m8l2P`!e0ENhlY2j"FL II%YbGc@ph91S4%8'Z5Xc+&ScAr+%DY2QlM5MEm[C1mhS@lHGdf@4$r)jQ+1c[Yf b16K0FP*c0Q[Vq(0e9lNT3"NeFC`c!fd61PVU13*GNpUBBBEDYdiZ2hX`9eAR44H ,BIaH('A$McIF3lH!AZ"TPCcBbG(bCcBTR0P-J9(CPq!SQh,26%f1,GX[-,2KJYL bC2[mR3Fc+V#JQ6c,1D9*!!!0!!YQG(CTCAFZFR0bB`EK@D!!4J`+!!!!J!!!!!! 'k52ZdTd*KJ!!!!!!!!!!!!!!!!!!!"B!!!!!!!!!!2rrrrpbFh*M8P0&4!%!Y0l Zjl@I*fJ!!!R0!!!!!!!!"88!!!!!G63!!!!!!!!!!0H8#eLdNFH9qjfA8IjfVYc V+,IcSPG[%r1Mef"PGRNH2bHC[@GR+aYdP+r9fR9b,hXDfQaLU$)NfG$H6Ma3l!J rb@q#cPhiF`e!5[$!i!F%P!CrjdRIiQ1U8#HUXAqC0ZNE+"#Gi-UPXm`GcPR6d1+ %j@UFd,+C*c(%&qq,LAI(q@TjQmA%0I,iR)F[aK-IRb@fBHY@VQVKj@[iNHP`l[3 r8D8HchTk%V!p1-QjjcVRES%ZEfC'F$,CbRNT829k%*Nh)ZZjkNHPN6Xb0E*fCNE %"EqJB#rq4EhN$`f-A&)XrIQFJU,$rTe68(6*#1FZS5%%1XqmqPYTB@9aET+h5Bi bPCcIjpGGAFkd#f@Z5RE'80"GFffLmqlRVPl4EB0*UP`qXXLr!m[jJH2TNIjAr2f IrFkCEHB6KGq6aiSXMc-8@6-H+E)pHUM)r[#")XH$G%A1p2X+rr[h&!(hlLTHZ(Y (NH[1E8AJl9Z+&frG915qH814jdDD)QrDGF9,ekmTAVjf9C([kK9&rLZA&DpF[U3 SF1QLiY@,&a4"&miVAMYr6[(kZE1+0mkH843mFeVajZP6LVG1R9381RP#i6TaA2( fm@1+`XH1+SSF2D*ijmKKaEZ($bQ#$ae8[(I`J+,SJIf+prI[8hb`EkqLf0ipLZ* lGLXqh,e,%E)V94'DZP04BZF1a8FlYLXqhVj0mFQfVBU5@lFS2Yfb@I(CjNf+ccG Y9(baFB2Lb`hV&DA@Ve0mY@kYS[6D0BSbDeBVbUjHTIKke8T&f-S9L[!9baAPPLp 6P&qf9&&Kk4*&a5@,&Hl&La59&Le84#aFS+LmB,kLb[ajLQrQc998R6Y(8@h1E%A Nl&Q+U&Nc&Gr16&&mPc*$8Ah'G%@0kG-80DG09G5D1N94HdUbi[[NbBSkNbFTITJ d89&hiJ6&Ma2'+hiD2dlamlLaLRTMabMUMaQYL"ip5Y&Je%K&`j%M&$%MKLXD$4q Qm!`EUQJmG)LLbC!!`BUQJ`FTQJdDU2KPi!$&V`2k+f,lpe2meUq[`YZhMb+Z6fp &mpkp&,rhkUR`pHbKL1r4AC(3[CZL4EHZLTCGZbJ5Zh4@r0'jNk*9Tik+eKdl+2l Xd&l4TRdla9rYfLVqETZNq#I*)ZNI3pZr$Hhq-V4[BqM`Tk&MDd1R9SE1IaLk*"U kYM4dDf(SRQ$S%@rSk62dqYh3ZlQK6jbKVpI3lcG$reM$J&m0!hma$'TQ'0c8-+5 *B@KM`c#2BAJM`iJB`mL'KP%0$+1M$@2U'mE@-iclf6$q*m1%(`d6kaSQr@#BA-H 3!2bpB8TY`p4DKQNe$G0V''C80k4mCjMjV@&@P'&fT'&10F2FUSCjhaMQ9c%XU'a B''&B9-Q`f'eB8Y'`Y)*K@AR$mR+'&H''P@''99mE9TFeV#PM@&[DX1iV`rT5KJe I'MCqBGMdZ@(cCiBYRaUfPM4Xqm5`r@2$MSm-1dXB8N-0Zd)-Zcmdl#PZf&[-X%p IX-ihl2lh$3H+'JkqCcJ8E$MmVZ()1iDM43c(#KZ1[fdii6+F,'3ipCEKp*Z'-`8 0Cpm`R([GF2ie`i8J`m9A$CF+'#krBVL5hh!eRq(DbiEV,aR5mKTZj$(Fc'fipD, KGU$K6Ll$h4F-p`)-prd0k6N0$h)B(QBh2-TQb-KUH*c&m-62k-[r[hh!IlZ6J*4 "Cl2AG8i+iL9VZFJ+9Cfc`Xqf#L(2YJbPBQ*E*$M[ET+HEdHHRVQHVdQ+2EYI(ZH e4%$+`06F8BPHMmrPmm6(YA"@,IRF2SqRCU[Q(PGiZ+YjJeK23S,Rrjhb!!!"!!! !!3!!!!!!!!!!(MX0)#!J)#!J)#"'9&p(E(P`D&p0CA4bD@0c+L"YCA4b$A*PFfp eFQ0PFbjcDA4jFe0jFe0jFe0jFfjcC#PdFh-#)&0*9%46593K!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!YD"h%3!!"e3!!!%HGA4XD@jPAe4bB@jcCQpbE5JJ*QGXHA" S,6jbEfpd,QpeG'aTEQ8X$5!J)#!J)#!J)#!J)#!J)#!J)#!J)#!J)#!J)#!J)#C QB@0P,6jdHA"P-5jQEfjdAfeKG(*TH#!T1`d0)#!J)#!J)#"'9&p2GA4XD@jPAdG PG&p$3Qpi+#!QC`!!!3!!!!%!!!!!!!!!!"i!!!!!!!!!!!!F!"lrrf$Z: -------------------------------------------------------------------------------- /obj/.gitignore: -------------------------------------------------------------------------------- 1 | graph.a 2 | *.lo 3 | *.o 4 | -------------------------------------------------------------------------------- /obj/README: -------------------------------------------------------------------------------- 1 | This directory contains all the object files generated for the demonstration programs 2 | -------------------------------------------------------------------------------- /src/Jamfile: -------------------------------------------------------------------------------- 1 | # FreeType 2 src Jamfile (c) 2001, 2003, 2004, 2005, 2007 David Turner 2 | # 3 | 4 | SubDir FT2DEMO_TOP src ; 5 | 6 | SubDirHdrs $(FT2_INCLUDE) ; 7 | SubDirHdrs [ FT2DEMO_SubDir src ] ; 8 | SubDirHdrs [ FT2DEMO_SubDir graph ] ; 9 | 10 | COMMON_LIB = $(LIBPREFIX)ft2common$(SUFLIB) ; 11 | 12 | Library $(COMMON_LIB) : ftcommon.c common.c ; 13 | 14 | 15 | if $(UNIX) 16 | { 17 | CCDEFS += UNIX ; 18 | LINKLIBS += -lm ; 19 | } 20 | 21 | PROGRAMS = ftbench ftlint ftdump fttimer ftchkwd ftvalid ftpatchk ; 22 | GRAPHIC_PROGRAMS = ftview ftmulti ftstring ftgamma ftgrid ftdiff ; 23 | { 24 | local t ; 25 | 26 | for t in $(PROGRAMS) $(GRAPHIC_PROGRAMS) 27 | { 28 | Main $(t) : $(t).c ; 29 | LinkLibraries $(t) : $(COMMON_LIB) $(FT2_LIB) ; 30 | } 31 | 32 | for t in $(GRAPHIC_PROGRAMS) 33 | { 34 | LINKLIBS on $(t)$(SUFEXE) = $(LINKLIBS) $(GRAPH_LINKLIBS) ; 35 | LinkLibraries $(t) : $(GRAPH_LIB) ; 36 | } 37 | } 38 | 39 | 40 | # Compile bytecode debugger when needed. Define the environment 41 | # variable FT2_DEBUG_TT to enable this one before calling "jam" 42 | # 43 | if $(FT2_DEBUG_TT) 44 | { 45 | if $(UNIX) { DEFINES += UNIX ; } 46 | SubDirHdrs $(FT2_INCLUDE)/../src/truetype ; 47 | 48 | LinkLibraries ttdebug : $(FT2_LIB) ; 49 | Main ttdebug : ttdebug.c ; 50 | } 51 | 52 | Main gbench : gbench.c ; 53 | 54 | 55 | # end of src Jamfile 56 | -------------------------------------------------------------------------------- /src/common.c: -------------------------------------------------------------------------------- 1 | /* some utility functions */ 2 | 3 | #include "common.h" 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | char* 11 | ft_basename( const char* name ) 12 | { 13 | const char* base; 14 | const char* current; 15 | char c; 16 | 17 | base = name; 18 | current = name; 19 | 20 | c = *current; 21 | 22 | while ( c ) 23 | { 24 | #ifndef macintosh 25 | if ( c == '/' || c == '\\' ) 26 | #else 27 | if ( c == ':' ) 28 | #endif 29 | base = current + 1; 30 | 31 | current++; 32 | c = *current; 33 | } 34 | 35 | return (char*)base; 36 | } 37 | 38 | 39 | void 40 | Panic( const char* fmt, 41 | ... ) 42 | { 43 | va_list ap; 44 | 45 | 46 | va_start( ap, fmt ); 47 | vprintf( fmt, ap ); 48 | va_end( ap ); 49 | 50 | exit( 1 ); 51 | } 52 | 53 | 54 | extern int 55 | utf8_next( const char** pcursor, 56 | const char* end ) 57 | { 58 | const unsigned char* p = (const unsigned char*)*pcursor; 59 | int ch; 60 | 61 | 62 | if ( (const char*)p >= end ) /* end of stream */ 63 | return -1; 64 | 65 | ch = *p++; 66 | if ( ch >= 0x80 ) 67 | { 68 | int len; 69 | 70 | 71 | if ( ch < 0xc0 ) /* malformed data */ 72 | goto BAD_DATA; 73 | else if ( ch < 0xe0 ) 74 | { 75 | len = 1; 76 | ch &= 0x1f; 77 | } 78 | else if ( ch < 0xf0 ) 79 | { 80 | len = 2; 81 | ch &= 0x0f; 82 | } 83 | else 84 | { 85 | len = 3; 86 | ch &= 0x07; 87 | } 88 | 89 | while ( len > 0 ) 90 | { 91 | if ( (const char*)p >= end || ( p[0] & 0xc0 ) != 0x80 ) 92 | goto BAD_DATA; 93 | 94 | ch = ( ch << 6 ) | ( p[0] & 0x3f ); 95 | p += 1; 96 | len -= 1; 97 | } 98 | } 99 | 100 | *pcursor = (const char*)p; 101 | 102 | return ch; 103 | 104 | BAD_DATA: 105 | return -1; 106 | } 107 | 108 | 109 | /* End */ 110 | -------------------------------------------------------------------------------- /src/common.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMON_H_ 2 | #define COMMON_H_ 3 | 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | extern char* 10 | ft_basename( const char* name ); 11 | 12 | /* print a message and exit */ 13 | extern void 14 | Panic( const char* fmt, 15 | ... ); 16 | 17 | /* 18 | * Read the next UTF-8 code from `*pcursor' and 19 | * returns its value. `end' is the limit of the 20 | * input string. 21 | * 22 | * Return -1 if the end of the input string is 23 | * reached, or in case of malformed data. 24 | */ 25 | extern int 26 | utf8_next( const char** pcursor, 27 | const char* end ); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif /* COMMON_H_ */ 34 | 35 | 36 | /* End */ 37 | -------------------------------------------------------------------------------- /src/compos.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* */ 3 | /* The FreeType project -- a free and portable quality TrueType renderer. */ 4 | /* */ 5 | /* Copyright 1996-1998, 2001, 2003, 2013 by */ 6 | /* D. Turner, R.Wilhelm, and W. Lemberg */ 7 | /* */ 8 | /* compos: this is a very simple program used to test the flag */ 9 | /* FT_LOAD_NO_RECURSE */ 10 | /* */ 11 | /* NOTE: This is just a test program that is used to show off and */ 12 | /* debug the current engine. */ 13 | /* */ 14 | /****************************************************************************/ 15 | 16 | #define FT2_BUILD_LIBRARY 17 | 18 | #include 19 | #include FT_FREETYPE_H 20 | #include FT_INTERNAL_GLYPH_LOADER_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | 27 | #define gettext( x ) ( x ) 28 | 29 | FT_Error error; 30 | 31 | FT_Library library; 32 | FT_Face face; 33 | FT_Size size; 34 | FT_GlyphSlot slot; 35 | 36 | unsigned int num_glyphs; 37 | int ptsize; 38 | 39 | int Fail; 40 | int Num; 41 | 42 | 43 | 44 | static void Usage( char* name ) 45 | { 46 | printf( "compos: test FT_LOAD_NO_RECURSE load flag - www.freetype.org\n" ); 47 | printf( "------------------------------------------------------------\n" ); 48 | printf( "\n" ); 49 | printf( "Usage: %s fontname[.ttf|.ttc] [fontname2..]\n", name ); 50 | printf( "\n" ); 51 | 52 | exit( 1 ); 53 | } 54 | 55 | 56 | static void Panic( const char* message ) 57 | { 58 | fprintf( stderr, "%s\n error code = 0x%04x\n", message, error ); 59 | exit(1); 60 | } 61 | 62 | 63 | int main( int argc, char** argv ) 64 | { 65 | int i, file_index; 66 | unsigned int id; 67 | char filename[1024 + 4]; 68 | char alt_filename[1024 + 4]; 69 | char* execname; 70 | char* fname; 71 | 72 | 73 | execname = argv[0]; 74 | 75 | if ( argc < 2 ) 76 | Usage( execname ); 77 | 78 | error = FT_Init_FreeType( &library ); 79 | if (error) Panic( "Could not create library object" ); 80 | 81 | /* Now check all files */ 82 | for ( file_index = 1; file_index < argc; file_index++ ) 83 | { 84 | fname = argv[file_index]; 85 | i = strlen( fname ); 86 | while ( i > 0 && fname[i] != '\\' && fname[i] != '/' ) 87 | { 88 | if ( fname[i] == '.' ) 89 | i = 0; 90 | i--; 91 | } 92 | 93 | filename[1024] = '\0'; 94 | alt_filename[1024] = '\0'; 95 | 96 | strncpy( filename, fname, 1024 ); 97 | strncpy( alt_filename, fname, 1024 ); 98 | 99 | #ifndef macintosh 100 | if ( i >= 0 ) 101 | { 102 | strncpy( filename + strlen( filename ), ".ttf", 4 ); 103 | strncpy( alt_filename + strlen( alt_filename ), ".ttc", 4 ); 104 | } 105 | #endif 106 | i = strlen( filename ); 107 | fname = filename; 108 | 109 | while ( i >= 0 ) 110 | #ifndef macintosh 111 | if ( filename[i] == '/' || filename[i] == '\\' ) 112 | #else 113 | if ( filename[i] == ':' ) 114 | #endif 115 | { 116 | fname = filename + i + 1; 117 | i = -1; 118 | } 119 | else 120 | i--; 121 | 122 | printf( "%s:\n", fname ); 123 | 124 | /* Load face */ 125 | error = FT_New_Face( library, filename, 0, &face ); 126 | if (error) 127 | { 128 | if (error == FT_Err_Invalid_File_Format) 129 | printf( "unknown format\n" ); 130 | else 131 | printf( "could not find/open file (error: %d)\n", error ); 132 | continue; 133 | } 134 | 135 | num_glyphs = face->num_glyphs; 136 | slot = face->glyph; 137 | 138 | Fail = 0; 139 | { 140 | for ( id = 0; id < num_glyphs; id++ ) 141 | { 142 | int has_scale; 143 | 144 | error = FT_Load_Glyph( face, id, FT_LOAD_NO_RECURSE ); 145 | if ( !error && slot->format == FT_GLYPH_FORMAT_COMPOSITE ) 146 | { 147 | unsigned int n; 148 | FT_SubGlyph subg = slot->subglyphs; 149 | 150 | printf( "%4d:", id ); 151 | for ( n = 0; n < slot->num_subglyphs; n++, subg++ ) 152 | { 153 | has_scale = subg->flags & ( 154 | FT_SUBGLYPH_FLAG_SCALE | 155 | FT_SUBGLYPH_FLAG_XY_SCALE | 156 | FT_SUBGLYPH_FLAG_2X2 ); 157 | 158 | printf( " [%d%c", 159 | subg->index, 160 | subg->flags & FT_SUBGLYPH_FLAG_USE_MY_METRICS ? '*' : ' ' ); 161 | 162 | if ( subg->arg1|subg->arg2 ) 163 | { 164 | if ( subg->flags & FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES ) 165 | printf( "(%d,%d)", subg->arg1, subg->arg2 ); 166 | else 167 | printf( "<%d,%d>", subg->arg1, subg->arg2 ); 168 | } 169 | 170 | if (has_scale) 171 | printf( "-{%0.3f %0.3f %0.3f %0.3f}", 172 | subg->transform.xx/65536.0, 173 | subg->transform.xy/65536.0, 174 | subg->transform.yx/65536.0, 175 | subg->transform.yy/65536.0 ); 176 | printf( "]" ); 177 | } 178 | printf( " adv=%ld lsb=%ld\n", 179 | slot->metrics.horiAdvance, 180 | slot->metrics.horiBearingX ); 181 | } 182 | } 183 | } 184 | 185 | FT_Done_Face( face ); 186 | } 187 | 188 | FT_Done_FreeType(library); 189 | exit( 0 ); /* for safety reasons */ 190 | 191 | return 0; /* never reached */ 192 | } 193 | 194 | 195 | /* End */ 196 | -------------------------------------------------------------------------------- /src/ftbench.1: -------------------------------------------------------------------------------- 1 | '\" t 2 | .TH FTVIEW 1 "May 2017" "Freetype 2.8" 3 | . 4 | . 5 | .SH NAME 6 | . 7 | ftbench \- benchmark some common FreeType paths 8 | . 9 | . 10 | .SH SYNOPSIS 11 | . 12 | .B ftbench 13 | .RI [ options ] 14 | .I fontname 15 | . 16 | . 17 | .SH DESCRIPTION 18 | . 19 | The 20 | .B ftbench 21 | tool measures performance of some common FreeType operations. 22 | . 23 | .PP 24 | This program is part of the FreeType demos package. 25 | . 26 | . 27 | .SH OPTIONS 28 | . 29 | .TP 30 | .B \-C 31 | Compare with cached version if available. 32 | . 33 | .TP 34 | .BI \-c \ n 35 | Use at most 36 | .I n 37 | iterations for each test (0 means time limited). 38 | . 39 | .TP 40 | .BI \-f \ l 41 | Use 42 | .B hexadecimal 43 | (not decimal) number 44 | .I l 45 | as load flags (see the 46 | .RB ` FT_LOAD_XXX ' 47 | macros in the FreeType reference). 48 | . 49 | .TP 50 | .BI "\-H " name 51 | Using CFF hinting engine 52 | .IR name . 53 | Available versions are depending on compilation options of FreeType; 54 | call 55 | .B ftbench 56 | without an argument to get the actual list. 57 | . 58 | .TP 59 | .BI "\-I " ver 60 | Using TT interpreter version 61 | .IR ver . 62 | Available versions are depending on compilation options of FreeType; 63 | call 64 | .B ftbench 65 | without an argument to get the actual list. 66 | . 67 | .TP 68 | .BI \-i \ idx 69 | Start with glyph index 70 | .I idx 71 | (default is 0, which means to process all glyphs). 72 | . 73 | .TP 74 | .BI \-m \ m 75 | Set maximum cache size to 76 | .I M 77 | KiByte (default is 1024). 78 | . 79 | .TP 80 | .B \-p 81 | Preload font file in memory (this is, testing 82 | .B FT_New_Memory_Face 83 | instead of 84 | .BR FT_New_Face ). 85 | . 86 | .TP 87 | .BI \-r \ n 88 | Set render mode to 89 | .IR n : 90 | . 91 | .RS 92 | .TS 93 | tab (@); 94 | rB l. 95 | 0@normal 96 | 1@light 97 | 2@mono 98 | 3@horizontal LCD 99 | 4@vertical LCD 100 | .TE 101 | .RE 102 | . 103 | .IP 104 | (default is 0). 105 | This corresponds to the values of the 106 | .RB ` FT_RENDER_MODE_XXX ' 107 | flags. 108 | . 109 | .TP 110 | .BI \-s \ s 111 | Use 112 | .I s 113 | ppem as face size (default is 10ppem). 114 | If set to zero, don't call 115 | .BR FT_Set_Pixel_Sizes . 116 | Use value\ 0 with option 117 | .RB ` "-f\ 1" ' 118 | or something similar to load the glyphs unscaled, 119 | otherwise errors will show up. 120 | . 121 | .TP 122 | .BI \-t \ t 123 | Use at most 124 | .I t 125 | seconds per test (default is 2). 126 | . 127 | .TP 128 | .BI \-b \ tests 129 | Perform chosen tests: 130 | . 131 | .RS 132 | .TS 133 | tab (@); 134 | rB l. 135 | a@load glyphs (FT_Load_Glyph) 136 | b@load advance widths (FT_Get_Advances) 137 | c@render glyphs (FT_Render_Glyph) 138 | d@load glyphs (FT_Get_Glyph) 139 | e@get glyph cboxes (FT_Glyph_Get_CBox) 140 | f@get glyph indices (FT_Get_Char_Index) 141 | g@iterate CMap (FT_Get_{First,Next}_Char) 142 | h@open a new face (FT_New_Face or FT_New_Memory_Face) 143 | i@embolden glyphs (FT_GlyphSlot_Embolden) 144 | j@get glyph bboxes (FT_Outline_Get_BBox) 145 | .TE 146 | .RE 147 | . 148 | .IP 149 | (default is 150 | .BR abcdefghij , 151 | this is, all tests). 152 | . 153 | .IP 154 | The number of used glyphs per test (within a single iteration) is given by 155 | option 156 | .BR \-i . 157 | . 158 | .TP 159 | .B \-v 160 | Show version. 161 | . 162 | .\" eof 163 | -------------------------------------------------------------------------------- /src/ftchkwd.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* */ 3 | /* The FreeType project -- a free and portable quality font engine */ 4 | /* */ 5 | /* Copyright 2003, 2011, 2013 by */ 6 | /* D. Turner, R.Wilhelm, and W. Lemberg */ 7 | /* */ 8 | /* ftchkwd */ 9 | /* */ 10 | /* NOTE: This is just a test program that is used to show off and */ 11 | /* debug the current engine. */ 12 | /* */ 13 | /****************************************************************************/ 14 | 15 | #include 16 | #include FT_FREETYPE_H 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | 23 | FT_Error error; 24 | 25 | 26 | static void 27 | Usage( char* name ) 28 | { 29 | printf( "ftchkwd: test fixed font width -- part of the FreeType project\n" ); 30 | printf( "---------------------------------------------------------------------\n" ); 31 | printf( "\n" ); 32 | printf( "Usage: %s fontname[.ttf|.ttc] [fontname2..]\n", name ); 33 | printf( "\n" ); 34 | 35 | exit( 1 ); 36 | } 37 | 38 | 39 | static void 40 | Panic( const char* message ) 41 | { 42 | fprintf( stderr, "%s\n error code = 0x%04x\n", message, error ); 43 | exit(1); 44 | } 45 | 46 | 47 | static const char* 48 | file_basename( const char* pathname ) 49 | { 50 | const char* base = pathname; 51 | const char* p = pathname; 52 | 53 | 54 | while ( *p ) 55 | { 56 | if ( *p == '/' || *p == '\\' ) 57 | base = p + 1; 58 | 59 | p++; 60 | } 61 | 62 | return base; 63 | } 64 | 65 | 66 | static void 67 | check_face( FT_Face face, 68 | const char* filepathname, 69 | int idx ) 70 | { 71 | int face_has_fixed_flag = FT_IS_FIXED_WIDTH(face); 72 | int face_max_advance = face->max_advance_width; 73 | int num_proportional = 0; 74 | int n; 75 | 76 | FT_UNUSED( idx ); 77 | 78 | 79 | printf( "%15s : %20s : ", 80 | file_basename( filepathname ), 81 | face->family_name ? face->family_name : "UNKNOWN FAMILY" ); 82 | 83 | for ( n = 0; n < face->num_glyphs; n++ ) 84 | { 85 | /* load the glyph outline */ 86 | error = FT_Load_Glyph( face, n, FT_LOAD_NO_SCALE ); 87 | if ( error ) 88 | continue; 89 | 90 | if ( face->glyph->metrics.horiAdvance != face_max_advance ) 91 | num_proportional++; 92 | } 93 | 94 | if ( num_proportional > 0 ) 95 | { 96 | if ( face_has_fixed_flag ) 97 | printf( "KO! Tagged as fixed, but has %d `proportional' glyphs", 98 | num_proportional ); 99 | else 100 | printf( "OK (proportional)" ); 101 | } 102 | else 103 | { 104 | if ( face_has_fixed_flag ) 105 | printf( "OK (fixed-width)" ); 106 | else 107 | printf( "KO! Tagged as proportional but has fixed width" ); 108 | } 109 | printf( "\n" ); 110 | } 111 | 112 | 113 | int 114 | main( int argc, 115 | char** argv ) 116 | { 117 | FT_Face face; 118 | FT_Library library; 119 | 120 | int i, file_index; 121 | char filename[1024 + 4]; 122 | char alt_filename[1024 + 4]; 123 | char* execname; 124 | char* fname; 125 | 126 | 127 | execname = argv[0]; 128 | 129 | if ( argc < 2 ) 130 | Usage( execname ); 131 | 132 | error = FT_Init_FreeType( &library ); 133 | if ( error ) 134 | Panic( "Could not create library object" ); 135 | 136 | /* Now check all files */ 137 | for ( file_index = 1; file_index < argc; file_index++ ) 138 | { 139 | fname = argv[file_index]; 140 | 141 | /* try to open the file with no extra extension first */ 142 | error = FT_New_Face( library, fname, 0, &face ); 143 | if ( !error ) 144 | goto Success; 145 | 146 | if ( error == FT_Err_Unknown_File_Format ) 147 | { 148 | fprintf( stderr, "%s: unknown format\n", fname ); 149 | continue; 150 | } 151 | 152 | /* Ok, we could not load the file. Try to add an extension to */ 153 | /* its name if possible. */ 154 | 155 | i = strlen( fname ); 156 | while ( i > 0 && fname[i] != '\\' && fname[i] != '/' ) 157 | { 158 | if ( fname[i] == '.' ) 159 | i = 0; 160 | i--; 161 | } 162 | 163 | filename[1024] = '\0'; 164 | alt_filename[1024] = '\0'; 165 | 166 | strncpy( filename, fname, 1024 ); 167 | strncpy( alt_filename, fname, 1024 ); 168 | 169 | #ifndef macintosh 170 | if ( i >= 0 ) 171 | { 172 | strncpy( filename + strlen( filename ), ".ttf", 4 ); 173 | strncpy( alt_filename + strlen( alt_filename ), ".ttc", 4 ); 174 | } 175 | #endif 176 | 177 | /* Load face */ 178 | error = FT_New_Face( library, filename, 0, &face ); 179 | if ( error ) 180 | { 181 | if ( error == FT_Err_Unknown_File_Format ) 182 | printf( "unknown format\n" ); 183 | else 184 | printf( "could not find/open file (error: %d)\n", error ); 185 | continue; 186 | } 187 | 188 | Success: 189 | check_face( face, fname, face->face_index ); 190 | 191 | FT_Done_Face( face ); 192 | } 193 | 194 | FT_Done_FreeType( library ); 195 | exit( 0 ); /* for safety reasons */ 196 | 197 | return 0; /* never reached */ 198 | } 199 | 200 | 201 | /* End */ 202 | -------------------------------------------------------------------------------- /src/ftdiff.1: -------------------------------------------------------------------------------- 1 | .TH FTDIFF 1 "May 2017" "FreeType 2.8" 2 | . 3 | . 4 | .SH NAME 5 | . 6 | ftdiff \- compare font hinting modes 7 | . 8 | . 9 | .SH SYNOPSIS 10 | . 11 | .B ftdiff 12 | .RI [ options ] 13 | .IR font \ .\|.\|. 14 | . 15 | . 16 | .SH DESCRIPTION 17 | . 18 | .B ftdiff 19 | displays text in three columns, using the font or fonts given on the command 20 | line, and applies different FreeType hinting modes to each column. 21 | . 22 | .TP 23 | .B font 24 | The font file(s) to display. 25 | For Type\ 1 font files, 26 | .B ftdiff 27 | also tries to attach the corresponding metrics file (with extension `.afm' 28 | or `.pfm'). 29 | . 30 | .PP 31 | This program is part of the FreeType demos package. 32 | . 33 | . 34 | .SH OPTIONS 35 | . 36 | .TP 37 | .BI \-w \ w 38 | Set the window width to 39 | .I w 40 | pixels (default: 640px). 41 | . 42 | .TP 43 | .BI \-h \ h 44 | Set the window height to 45 | .I h 46 | pixels (default: 480px). 47 | . 48 | .TP 49 | .BI \-r \ r 50 | Use resolution 51 | .I r 52 | dpi (default: 72dpi). 53 | . 54 | .TP 55 | .BI \-s \ s 56 | Set character size to 57 | .I s 58 | points (default: 16pt). 59 | . 60 | .TP 61 | .BI \-f \ textfile 62 | Change displayed text, using text in 63 | .I textfile 64 | (in UTF-8 encoding). 65 | . 66 | .TP 67 | .B \-v 68 | Show version. 69 | . 70 | .\" eof 71 | -------------------------------------------------------------------------------- /src/ftdump.1: -------------------------------------------------------------------------------- 1 | .TH FTDUMP 1 "May 2017" "FreeType 2.8" 2 | . 3 | . 4 | .SH NAME 5 | . 6 | ftdump \- simple font dumper 7 | . 8 | . 9 | .SH SYNOPSIS 10 | . 11 | .B ftdump 12 | .RI [ options ] 13 | .I fontname 14 | . 15 | . 16 | .SH DESCRIPTION 17 | . 18 | .B ftdump 19 | lists information about a font file that is relevant for FreeType. 20 | . 21 | .PP 22 | This program is part of the FreeType demos package. 23 | . 24 | . 25 | .SH OPTIONS 26 | . 27 | .TP 28 | .B \-n 29 | Print SFNT name tables. 30 | . 31 | .TP 32 | .B \-p 33 | Print TrueType programs. 34 | . 35 | .TP 36 | .B \-t 37 | Print SFNT table list. 38 | . 39 | .TP 40 | .B \-u 41 | Emit UTF-8. 42 | . 43 | .TP 44 | .B \-V 45 | Be verbose. 46 | . 47 | .TP 48 | .B \-v 49 | Show version. 50 | . 51 | .\" eof 52 | -------------------------------------------------------------------------------- /src/ftgamma.1: -------------------------------------------------------------------------------- 1 | .TH FTGAMMA 1 "May 2017" "FreeType 2.8" 2 | . 3 | . 4 | .SH NAME 5 | . 6 | ftgamma \- screen gamma calibration helper 7 | . 8 | . 9 | .SH SYNOPSIS 10 | . 11 | .B ftgamma 12 | . 13 | . 14 | .SH DESCRIPTION 15 | . 16 | The 17 | .B ftgamma 18 | demo program opens a window showing series of gray stripes filled with 19 | solid color and checkered pattern of pixels. Your monitor's gamma value 20 | roughly corresponds to the horizontal position where the solid and checkered 21 | stripes are equally bright when seen from some distance. Three brightness 22 | targets are explored: 33%, 50%, and 67%. If the input-output curve of your 23 | monitor does not follow ideal power law relationship, you might observe 24 | slightly different gamma values at different brightness levels. It is also 25 | possible to examine gamma values for basic colors. 26 | . 27 | .PP 28 | Two alternative patterns relevant to font rendering are also provided, 29 | where slightly slanted lines are rendered using grayscale and subpixel 30 | anti-aliasing. In the grayscale case, the correct gamma helps to achieve 31 | uniform perceived thickness of the lines. The gamma value that corresponds 32 | to vanishing moiré pattern is ideal for anti-aliased font rendering. 33 | In the subpixel case, the correct gamma removes color fringes that remain 34 | even after LCD filtering. 35 | . 36 | .PP 37 | This program does not have any options. 38 | . 39 | .PP 40 | This program is part of the FreeType demos package. 41 | . 42 | .\" eof 43 | -------------------------------------------------------------------------------- /src/ftgrid.1: -------------------------------------------------------------------------------- 1 | .TH FTGRID 1 "May 2017" "Freetype 2.8" 2 | . 3 | . 4 | .SH NAME 5 | . 6 | ftgrid \- simple glyph grid viewer 7 | . 8 | . 9 | .SH SYNOPSIS 10 | . 11 | .B ftgrid 12 | .RI [ options ] 13 | .I pt font .\|.\|. 14 | . 15 | . 16 | .SH DESCRIPTION 17 | . 18 | .B ftgrid 19 | displays the glyphs of a font as outlines right before the conversion 20 | from outlines to pixels take place. 21 | It also displays the resulting bitmap. 22 | It is possible to interactively change hinting and rendering options, 23 | thus visualizing the applied distortions to the outlines. 24 | . 25 | .TP 26 | .B pt 27 | The point size for the given resolution. 28 | If resolution is 72dpi, this directly gives the ppem value (pixels per EM). 29 | . 30 | .TP 31 | .B font 32 | The font file(s) to display. 33 | For Type 1 font files, 34 | .B ftgrid 35 | also tries to attach the corresponding metrics file (with extension `.afm' 36 | or `.pfm'). 37 | . 38 | .PP 39 | This program is part of the FreeType demos package. 40 | . 41 | . 42 | .SH OPTIONS 43 | . 44 | .TP 45 | .BI \-w \ w 46 | Set the window width to 47 | .I w 48 | pixels (default: 640px). 49 | . 50 | .TP 51 | .BI \-h \ h 52 | Set the window height to 53 | .I h 54 | pixels (default: 480px). 55 | . 56 | .TP 57 | .BI \-r \ r 58 | Use resolution 59 | .I r 60 | dpi (default: 72dpi). 61 | . 62 | .TP 63 | .BI \-f \ index 64 | Specify first index to display (default: 0). 65 | . 66 | .TP 67 | .BI "\-d\ \(dq" "axis1\ axis2\ .\|.\|." \(dq 68 | For Multiple Master or GX fonts, specify design coordinates for each axis at 69 | start-up. 70 | If this option is given, no named instances are shown. 71 | Ignored for all other font formats. 72 | . 73 | .TP 74 | .B \-v 75 | Show version. 76 | . 77 | .\" eof 78 | -------------------------------------------------------------------------------- /src/ftinspect/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | ftinspect 3 | *.o 4 | moc_*.cpp 5 | moc_*.h 6 | .qmake.stash 7 | -------------------------------------------------------------------------------- /src/ftinspect/engine/engine.hpp: -------------------------------------------------------------------------------- 1 | // engine.hpp 2 | 3 | // Copyright (C) 2016-2017 by Werner Lemberg. 4 | 5 | 6 | #pragma once 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | #include FT_FREETYPE_H 13 | #include FT_OUTLINE_H 14 | #include FT_CACHE_H 15 | 16 | 17 | // This structure maps the (font, face, instance) index triplet to abstract 18 | // IDs (generated by a running number stored in MainGUI's `faceCounter' 19 | // member). 20 | // 21 | // Qt's `QMap' class needs an implementation of the `<' operator. 22 | 23 | struct FaceID 24 | { 25 | int fontIndex; 26 | long faceIndex; 27 | int namedInstanceIndex; 28 | 29 | FaceID(); 30 | FaceID(int fontIndex, 31 | long faceIndex, 32 | int namedInstanceIndex); 33 | bool operator<(const FaceID& other) const; 34 | }; 35 | 36 | 37 | class MainGUI; 38 | 39 | // FreeType specific data. 40 | 41 | class Engine 42 | { 43 | public: 44 | Engine(MainGUI*); 45 | ~Engine(); 46 | 47 | const QString& currentFamilyName(); 48 | const QString& currentStyleName(); 49 | QString glyphName(int glyphIndex); 50 | long numberOfFaces(int fontIndex); 51 | int numberOfNamedInstances(int fontIndex, 52 | long faceIndex); 53 | int loadFont(int fontIndex, 54 | long faceIndex, 55 | int namedInstanceIndex); // return number of glyphs 56 | FT_Outline* loadOutline(int glyphIndex); 57 | void removeFont(int fontIndex); 58 | void setCFFHintingMode(int mode); 59 | void setTTInterpreterVersion(int version); 60 | void update(); 61 | 62 | friend class MainGUI; 63 | friend FT_Error faceRequester(FTC_FaceID, 64 | FT_Library, 65 | FT_Pointer, 66 | FT_Face*); 67 | 68 | // XXX cover all available modules 69 | enum FontType 70 | { 71 | FontType_CFF, 72 | FontType_TrueType, 73 | FontType_Other 74 | }; 75 | 76 | private: 77 | MainGUI* gui; 78 | 79 | int faceCounter; // a running number used to initialize `faceIDMap' 80 | QMap faceIDMap; 81 | 82 | QString curFamilyName; 83 | QString curStyleName; 84 | 85 | FT_Library library; 86 | FTC_Manager cacheManager; 87 | FTC_ImageCache imageCache; 88 | FTC_SBitCache sbitsCache; 89 | 90 | FTC_ScalerRec scaler; 91 | FT_Size ftSize; 92 | 93 | int cffHintingEngineDefault; 94 | int cffHintingEngineOther; 95 | 96 | int ttInterpreterVersionDefault; 97 | int ttInterpreterVersionOther; 98 | int ttInterpreterVersionOther1; 99 | 100 | int fontType; 101 | 102 | int haveWarping; 103 | 104 | double pointSize; 105 | double pixelSize; 106 | unsigned int dpi; 107 | 108 | bool doHinting; 109 | bool doAutoHinting; 110 | bool doHorizontalHinting; 111 | bool doVerticalHinting; 112 | bool doBlueZoneHinting; 113 | bool showSegments; 114 | bool doWarping; 115 | 116 | double gamma; 117 | 118 | unsigned long loadFlags; 119 | }; 120 | 121 | 122 | // end of engine.hpp 123 | -------------------------------------------------------------------------------- /src/ftinspect/ftinspect-build.sh: -------------------------------------------------------------------------------- 1 | export TRASH_OFF=YES 2 | 3 | make clean 4 | qmake ftinspect-qt4.pro 5 | make 6 | 7 | make clean 8 | qmake-qt5 -spec linux-clang ftinspect-qt5.pro 9 | make 10 | -------------------------------------------------------------------------------- /src/ftinspect/ftinspect-qt4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/source-foundry/freetype2-demos/9ad98da32f687356655ddfc51a874cee48b83cec/src/ftinspect/ftinspect-qt4 -------------------------------------------------------------------------------- /src/ftinspect/ftinspect-qt4.pro: -------------------------------------------------------------------------------- 1 | # ftinspect.pro 2 | 3 | QMAKE_CXXFLAGS += -isystem ../../../freetype2.compiled \ 4 | -isystem ../../../freetype2/include 5 | 6 | # To avoid conflicts with the FreeType version compiled into or used by Qt, 7 | # we use the static library. 8 | # 9 | # You should adapt this to your setup. 10 | unix|macx { 11 | LIBS += ../../../freetype2.compiled/libfreetype.a 12 | 13 | CONFIG += link_pkgconfig 14 | PKGCONFIG += libpng harfbuzz zlib bzip2 15 | } 16 | win32 { 17 | LIBS += ../../../freetyp2.compiled/freetype28.lib 18 | LIBS += -lpng -lharfbuzz -lz -lbz2 -lm 19 | } 20 | 21 | CONFIG += qt debug 22 | 23 | # we need access to internal FreeType header files 24 | DEFINES += FT2_BUILD_LIBRARY 25 | 26 | SOURCES += \ 27 | engine/engine.cpp \ 28 | rendering/glyphbitmap.cpp \ 29 | rendering/glyphoutline.cpp \ 30 | rendering/glyphpointnumbers.cpp \ 31 | rendering/glyphpoints.cpp \ 32 | rendering/grid.cpp \ 33 | widgets/qcomboboxx.cpp \ 34 | widgets/qgraphicsviewx.cpp \ 35 | widgets/qpushbuttonx.cpp \ 36 | widgets/qspinboxx.cpp \ 37 | ftinspect.cpp \ 38 | maingui.cpp 39 | 40 | HEADERS += \ 41 | engine/engine.hpp \ 42 | rendering/glyphbitmap.hpp \ 43 | rendering/glyphoutline.hpp \ 44 | rendering/glyphpointnumbers.hpp \ 45 | rendering/glyphpoints.hpp \ 46 | rendering/grid.hpp \ 47 | widgets/qcomboboxx.hpp \ 48 | widgets/qgraphicsviewx.hpp \ 49 | widgets/qpushbuttonx.hpp \ 50 | widgets/qspinboxx.hpp \ 51 | maingui.hpp 52 | 53 | TARGET = ftinspect-qt4 54 | 55 | QT += widgets 56 | 57 | 58 | # end of ftinpect.pro 59 | -------------------------------------------------------------------------------- /src/ftinspect/ftinspect-qt5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/source-foundry/freetype2-demos/9ad98da32f687356655ddfc51a874cee48b83cec/src/ftinspect/ftinspect-qt5 -------------------------------------------------------------------------------- /src/ftinspect/ftinspect-qt5.pro: -------------------------------------------------------------------------------- 1 | # ftinspect.pro 2 | 3 | QMAKE_CXXFLAGS += -isystem ../../../freetype2.compiled \ 4 | -isystem ../../../freetype2/include 5 | 6 | # To avoid conflicts with the FreeType version compiled into or used by Qt, 7 | # we use the static library. 8 | # 9 | # You should adapt this to your setup. 10 | unix|macx { 11 | LIBS += ../../../freetype2.compiled/libfreetype.a 12 | 13 | CONFIG += link_pkgconfig 14 | PKGCONFIG += libpng harfbuzz zlib bzip2 15 | } 16 | win32 { 17 | LIBS += ../../../freetyp2.compiled/freetype28.lib 18 | LIBS += -lpng -lharfbuzz -lz -lbz2 -lm 19 | } 20 | 21 | CONFIG += qt debug 22 | 23 | # we need access to internal FreeType header files 24 | DEFINES += FT2_BUILD_LIBRARY 25 | 26 | SOURCES += \ 27 | engine/engine.cpp \ 28 | rendering/glyphbitmap.cpp \ 29 | rendering/glyphoutline.cpp \ 30 | rendering/glyphpointnumbers.cpp \ 31 | rendering/glyphpoints.cpp \ 32 | rendering/grid.cpp \ 33 | widgets/qcomboboxx.cpp \ 34 | widgets/qgraphicsviewx.cpp \ 35 | widgets/qpushbuttonx.cpp \ 36 | widgets/qspinboxx.cpp \ 37 | ftinspect.cpp \ 38 | maingui.cpp 39 | 40 | HEADERS += \ 41 | engine/engine.hpp \ 42 | rendering/glyphbitmap.hpp \ 43 | rendering/glyphoutline.hpp \ 44 | rendering/glyphpointnumbers.hpp \ 45 | rendering/glyphpoints.hpp \ 46 | rendering/grid.hpp \ 47 | widgets/qcomboboxx.hpp \ 48 | widgets/qgraphicsviewx.hpp \ 49 | widgets/qpushbuttonx.hpp \ 50 | widgets/qspinboxx.hpp \ 51 | maingui.hpp 52 | 53 | TARGET = ftinspect-qt5 54 | 55 | QT += widgets 56 | 57 | 58 | # end of ftinpect.pro 59 | -------------------------------------------------------------------------------- /src/ftinspect/ftinspect.cpp: -------------------------------------------------------------------------------- 1 | // ftinspect.cpp 2 | 3 | // Copyright (C) 2016-2017 by Werner Lemberg. 4 | 5 | 6 | #include "maingui.hpp" 7 | #include "engine/engine.hpp" 8 | 9 | #include 10 | 11 | #define VERSION "X.Y.Z" 12 | 13 | 14 | int 15 | main(int argc, 16 | char** argv) 17 | { 18 | QApplication app(argc, argv); 19 | app.setApplicationName("ftinspect"); 20 | app.setApplicationVersion(VERSION); 21 | app.setOrganizationName("FreeType"); 22 | app.setOrganizationDomain("freetype.org"); 23 | 24 | MainGUI gui; 25 | Engine engine(&gui); 26 | 27 | gui.update(&engine); 28 | gui.setDefaults(); 29 | 30 | gui.show(); 31 | 32 | return app.exec(); 33 | } 34 | 35 | 36 | // end of ftinspect.cpp 37 | -------------------------------------------------------------------------------- /src/ftinspect/ftinspect.pro: -------------------------------------------------------------------------------- 1 | # ftinspect.pro 2 | 3 | QMAKE_CXXFLAGS += -isystem ../../../freetype2/include 4 | 5 | # To avoid conflicts with the FreeType version compiled into or used by Qt, 6 | # we use the static library. 7 | # 8 | # You should adapt this to your setup. 9 | unix|macx { 10 | LIBS += ../../../freetype2/objs/.libs/libfreetype.a 11 | 12 | CONFIG += link_pkgconfig 13 | PKGCONFIG += libpng harfbuzz zlib bzip2 14 | } 15 | win32 { 16 | LIBS += ../../../freetyp2/objs/vc2010/freetype271.lib 17 | LIBS += -lpng -lharfbuzz -lz -lbz2 -lm 18 | } 19 | 20 | CONFIG += qt debug 21 | 22 | # we need access to internal FreeType header files 23 | DEFINES += FT2_BUILD_LIBRARY 24 | 25 | SOURCES += \ 26 | engine/engine.cpp \ 27 | rendering/glyphbitmap.cpp \ 28 | rendering/glyphoutline.cpp \ 29 | rendering/glyphpointnumbers.cpp \ 30 | rendering/glyphpoints.cpp \ 31 | rendering/grid.cpp \ 32 | widgets/qcomboboxx.cpp \ 33 | widgets/qgraphicsviewx.cpp \ 34 | widgets/qpushbuttonx.cpp \ 35 | widgets/qspinboxx.cpp \ 36 | ftinspect.cpp \ 37 | maingui.cpp 38 | 39 | HEADERS += \ 40 | engine/engine.hpp \ 41 | rendering/glyphbitmap.hpp \ 42 | rendering/glyphoutline.hpp \ 43 | rendering/glyphpointnumbers.hpp \ 44 | rendering/glyphpoints.hpp \ 45 | rendering/grid.hpp \ 46 | widgets/qcomboboxx.hpp \ 47 | widgets/qgraphicsviewx.hpp \ 48 | widgets/qpushbuttonx.hpp \ 49 | widgets/qspinboxx.hpp \ 50 | maingui.hpp 51 | 52 | TARGET = ftinspect 53 | 54 | QT += widgets 55 | 56 | 57 | # end of ftinpect.pro 58 | -------------------------------------------------------------------------------- /src/ftinspect/maingui.hpp: -------------------------------------------------------------------------------- 1 | // maingui.hpp 2 | 3 | // Copyright (C) 2016-2017 by Werner Lemberg. 4 | 5 | 6 | #pragma once 7 | 8 | #include "engine/engine.hpp" 9 | #include "rendering/glyphbitmap.hpp" 10 | #include "rendering/glyphoutline.hpp" 11 | #include "rendering/glyphpointnumbers.hpp" 12 | #include "rendering/glyphpoints.hpp" 13 | #include "widgets/qcomboboxx.hpp" 14 | #include "widgets/qgraphicsviewx.hpp" 15 | #include "widgets/qpushbuttonx.hpp" 16 | #include "widgets/qspinboxx.hpp" 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | #include 46 | #include FT_LCD_FILTER_H 47 | 48 | 49 | class MainGUI 50 | : public QMainWindow 51 | { 52 | Q_OBJECT 53 | 54 | public: 55 | MainGUI(); 56 | ~MainGUI(); 57 | 58 | void setDefaults(); 59 | void update(Engine*); 60 | 61 | friend class Engine; 62 | friend FT_Error faceRequester(FTC_FaceID, 63 | FT_Library, 64 | FT_Pointer, 65 | FT_Face*); 66 | 67 | protected: 68 | void closeEvent(QCloseEvent*); 69 | 70 | private slots: 71 | void about(); 72 | void aboutQt(); 73 | void adjustGlyphIndex(int); 74 | void checkAntiAliasing(); 75 | void checkAutoHinting(); 76 | void checkCurrentFaceIndex(); 77 | void checkCurrentFontIndex(); 78 | void checkCurrentNamedInstanceIndex(); 79 | void checkHinting(); 80 | void checkHintingMode(); 81 | void checkLcdFilter(); 82 | void checkShowPoints(); 83 | void checkUnits(); 84 | void closeFont(); 85 | void drawGlyph(); 86 | void loadFonts(); 87 | void nextFace(); 88 | void nextFont(); 89 | void nextNamedInstance(); 90 | void previousFace(); 91 | void previousFont(); 92 | void previousNamedInstance(); 93 | void watchCurrentFont(); 94 | void zoom(); 95 | 96 | private: 97 | Engine* engine; 98 | 99 | QStringList fontList; 100 | int currentFontIndex; 101 | 102 | long currentNumberOfFaces; 103 | long currentFaceIndex; 104 | 105 | int currentNumberOfNamedInstances; 106 | int currentNamedInstanceIndex; 107 | 108 | int currentNumberOfGlyphs; 109 | int currentGlyphIndex; 110 | 111 | int currentCFFHintingMode; 112 | int currentTTInterpreterVersion; 113 | 114 | // layout related stuff 115 | GlyphOutline *currentGlyphOutlineItem; 116 | GlyphPoints *currentGlyphPointsItem; 117 | GlyphPointNumbers *currentGlyphPointNumbersItem; 118 | GlyphBitmap *currentGlyphBitmapItem; 119 | 120 | QAction *aboutAct; 121 | QAction *aboutQtAct; 122 | QAction *closeFontAct; 123 | QAction *exitAct; 124 | QAction *loadFontsAct; 125 | 126 | QCheckBox *autoHintingCheckBox; 127 | QCheckBox *blueZoneHintingCheckBox; 128 | QCheckBox *hintingCheckBox; 129 | QCheckBox *horizontalHintingCheckBox; 130 | QCheckBox *segmentDrawingCheckBox; 131 | QCheckBox *showBitmapCheckBox; 132 | QCheckBox *showOutlinesCheckBox; 133 | QCheckBox *showPointNumbersCheckBox; 134 | QCheckBox *showPointsCheckBox; 135 | QCheckBox *verticalHintingCheckBox; 136 | QCheckBox *warpingCheckBox; 137 | 138 | QComboBoxx *antiAliasingComboBoxx; 139 | QComboBoxx *hintingModeComboBoxx; 140 | QComboBox *lcdFilterComboBox; 141 | QComboBox *unitsComboBox; 142 | 143 | QDoubleSpinBox *sizeDoubleSpinBox; 144 | 145 | QFileSystemWatcher *fontWatcher; 146 | 147 | QGraphicsScene *glyphScene; 148 | QGraphicsViewx *glyphView; 149 | 150 | QGridLayout *fontLayout; 151 | QGridLayout *infoRightLayout; 152 | 153 | QHash hintingModesTrueTypeHash; 154 | QHash hintingModesCFFHash; 155 | QHash lcdFilterHash; 156 | 157 | QHBoxLayout *antiAliasingLayout; 158 | QHBoxLayout *blueZoneHintingLayout; 159 | QHBoxLayout *ftinspectLayout; 160 | QHBoxLayout *gammaLayout; 161 | QHBoxLayout *hintingModeLayout; 162 | QHBoxLayout *horizontalHintingLayout; 163 | QHBoxLayout *infoLeftLayout; 164 | QHBoxLayout *lcdFilterLayout; 165 | QHBoxLayout *navigationLayout; 166 | QHBoxLayout *pointNumbersLayout; 167 | QHBoxLayout *segmentDrawingLayout; 168 | QHBoxLayout *sizeLayout; 169 | QHBoxLayout *verticalHintingLayout; 170 | QHBoxLayout *warpingLayout; 171 | 172 | QLabel *antiAliasingLabel; 173 | QLabel *dpiLabel; 174 | QLabel *fontFilenameLabel; 175 | QLabel *fontNameLabel; 176 | QLabel *gammaLabel; 177 | QLabel *glyphIndexLabel; 178 | QLabel *glyphNameLabel; 179 | QLabel *hintingModeLabel; 180 | QLabel *lcdFilterLabel; 181 | QLabel *sizeLabel; 182 | QLabel *zoomLabel; 183 | 184 | QList hintingModesAlwaysDisabled; 185 | 186 | QLocale *locale; 187 | 188 | QMenu *menuFile; 189 | QMenu *menuHelp; 190 | 191 | QPen axisPen; 192 | QPen blueZonePen; 193 | QPen gridPen; 194 | QPen offPen; 195 | QPen onPen; 196 | QPen outlinePen; 197 | QPen segmentPen; 198 | 199 | QPushButton *nextFaceButton; 200 | QPushButton *nextFontButton; 201 | QPushButton *nextNamedInstanceButton; 202 | QPushButton *previousFaceButton; 203 | QPushButton *previousFontButton; 204 | QPushButton *previousNamedInstanceButton; 205 | 206 | QPushButtonx *toEndButtonx; 207 | QPushButtonx *toM1000Buttonx; 208 | QPushButtonx *toM100Buttonx; 209 | QPushButtonx *toM10Buttonx; 210 | QPushButtonx *toM1Buttonx; 211 | QPushButtonx *toP1000Buttonx; 212 | QPushButtonx *toP100Buttonx; 213 | QPushButtonx *toP10Buttonx; 214 | QPushButtonx *toP1Buttonx; 215 | QPushButtonx *toStartButtonx; 216 | 217 | QSignalMapper *glyphNavigationMapper; 218 | 219 | QSlider *gammaSlider; 220 | 221 | QSpinBox *dpiSpinBox; 222 | QSpinBoxx *zoomSpinBox; 223 | 224 | QTabWidget *tabWidget; 225 | 226 | QTimer *timer; 227 | 228 | QVBoxLayout *generalTabLayout; 229 | QVBoxLayout *leftLayout; 230 | QVBoxLayout *rightLayout; 231 | 232 | QVector grayColorTable; 233 | QVector monoColorTable; 234 | 235 | QWidget *ftinspectWidget; 236 | QWidget *generalTabWidget; 237 | QWidget *leftWidget; 238 | QWidget *rightWidget; 239 | QWidget *mmgxTabWidget; 240 | 241 | enum AntiAliasing 242 | { 243 | AntiAliasing_None, 244 | AntiAliasing_Normal, 245 | AntiAliasing_Light, 246 | AntiAliasing_LCD, 247 | AntiAliasing_LCD_BGR, 248 | AntiAliasing_LCD_Vertical, 249 | AntiAliasing_LCD_Vertical_BGR 250 | }; 251 | enum HintingMode 252 | { 253 | HintingMode_TrueType_v35, 254 | HintingMode_TrueType_v38, 255 | HintingMode_TrueType_v40, 256 | HintingMode_CFF_FreeType, 257 | HintingMode_CFF_Adobe 258 | }; 259 | enum LCDFilter 260 | { 261 | LCDFilter_Default, 262 | LCDFilter_Light, 263 | LCDFilter_None, 264 | LCDFilter_Legacy 265 | }; 266 | enum Units 267 | { 268 | Units_px, 269 | Units_pt 270 | }; 271 | 272 | void createActions(); 273 | void createConnections(); 274 | void createLayout(); 275 | void createMenus(); 276 | void clearStatusBar(); 277 | void createStatusBar(); 278 | void readSettings(); 279 | void setGraphicsDefaults(); 280 | void showFont(); 281 | void writeSettings(); 282 | }; 283 | 284 | 285 | // end of maingui.hpp 286 | -------------------------------------------------------------------------------- /src/ftinspect/rendering/glyphbitmap.cpp: -------------------------------------------------------------------------------- 1 | // glyphbitmap.cpp 2 | 3 | // Copyright (C) 2016-2017 by Werner Lemberg. 4 | 5 | 6 | #include "glyphbitmap.hpp" 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | 13 | GlyphBitmap::GlyphBitmap(FT_Outline* outline, 14 | FT_Library lib, 15 | FT_Pixel_Mode pxlMode, 16 | const QVector& monoColorTbl, 17 | const QVector& grayColorTbl) 18 | : library(lib), 19 | pixelMode(pxlMode), 20 | monoColorTable(monoColorTbl), 21 | grayColorTable(grayColorTbl) 22 | { 23 | // make a copy of the outline since we are going to manipulate it 24 | FT_Outline_New(library, 25 | static_cast(outline->n_points), 26 | outline->n_contours, 27 | &transformed); 28 | FT_Outline_Copy(outline, &transformed); 29 | 30 | FT_BBox cbox; 31 | FT_Outline_Get_CBox(outline, &cbox); 32 | 33 | cbox.xMin &= ~63; 34 | cbox.yMin &= ~63; 35 | cbox.xMax = (cbox.xMax + 63) & ~63; 36 | cbox.yMax = (cbox.yMax + 63) & ~63; 37 | 38 | // we shift the outline to the origin for rendering later on 39 | FT_Outline_Translate(&transformed, -cbox.xMin, -cbox.yMin); 40 | 41 | bRect.setCoords(cbox.xMin / 64, -cbox.yMax / 64, 42 | cbox.xMax / 64, -cbox.yMin / 64); 43 | } 44 | 45 | 46 | GlyphBitmap::~GlyphBitmap() 47 | { 48 | FT_Outline_Done(library, &transformed); 49 | } 50 | 51 | QRectF 52 | GlyphBitmap::boundingRect() const 53 | { 54 | return bRect; 55 | } 56 | 57 | 58 | void 59 | GlyphBitmap::paint(QPainter* painter, 60 | const QStyleOptionGraphicsItem* option, 61 | QWidget*) 62 | { 63 | FT_Bitmap bitmap; 64 | 65 | int height = static_cast(ceil(bRect.height())); 66 | int width = static_cast(ceil(bRect.width())); 67 | QImage::Format format = QImage::Format_Indexed8; 68 | 69 | // XXX cover LCD and color 70 | if (pixelMode == FT_PIXEL_MODE_MONO) 71 | format = QImage::Format_Mono; 72 | 73 | QImage image(QSize(width, height), format); 74 | 75 | if (pixelMode == FT_PIXEL_MODE_MONO) 76 | image.setColorTable(monoColorTable); 77 | else 78 | image.setColorTable(grayColorTable); 79 | 80 | image.fill(0); 81 | 82 | bitmap.rows = static_cast(height); 83 | bitmap.width = static_cast(width); 84 | bitmap.buffer = image.bits(); 85 | bitmap.pitch = image.bytesPerLine(); 86 | bitmap.pixel_mode = pixelMode; 87 | 88 | FT_Error error = FT_Outline_Get_Bitmap(library, 89 | &transformed, 90 | &bitmap); 91 | if (error) 92 | { 93 | // XXX error handling 94 | return; 95 | } 96 | 97 | // `drawImage' doesn't work as expected: 98 | // the larger the zoom, the more the pixel rectangle positions 99 | // deviate from the grid lines 100 | #if 0 101 | painter->drawImage(QPoint(bRect.left(), bRect.top()), 102 | image.convertToFormat( 103 | QImage::Format_ARGB32_Premultiplied)); 104 | #else 105 | const qreal lod = option->levelOfDetailFromTransform( 106 | painter->worldTransform()); 107 | 108 | painter->setPen(Qt::NoPen); 109 | 110 | for (int x = 0; x < image.width(); x++) 111 | for (int y = 0; y < image.height(); y++) 112 | { 113 | // be careful not to lose the alpha channel 114 | QRgb p = image.pixel(x, y); 115 | painter->fillRect(QRectF(x + bRect.left() - 1 / lod / 2, 116 | y + bRect.top() - 1 / lod / 2, 117 | 1 + 1 / lod, 118 | 1 + 1 / lod), 119 | QColor(qRed(p), 120 | qGreen(p), 121 | qBlue(p), 122 | qAlpha(p))); 123 | } 124 | #endif 125 | } 126 | 127 | 128 | // end of glyphbitmap.cpp 129 | -------------------------------------------------------------------------------- /src/ftinspect/rendering/glyphbitmap.hpp: -------------------------------------------------------------------------------- 1 | // glyphbitmap.hpp 2 | 3 | // Copyright (C) 2016-2017 by Werner Lemberg. 4 | 5 | 6 | #pragma once 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | #include FT_FREETYPE_H 13 | #include FT_OUTLINE_H 14 | 15 | 16 | class GlyphBitmap 17 | : public QGraphicsItem 18 | { 19 | public: 20 | GlyphBitmap(FT_Outline* outline, 21 | FT_Library library, 22 | FT_Pixel_Mode pixelMode, 23 | const QVector& monoColorTable, 24 | const QVector& grayColorTable); 25 | ~GlyphBitmap(); 26 | QRectF boundingRect() const; 27 | void paint(QPainter* painter, 28 | const QStyleOptionGraphicsItem* option, 29 | QWidget* widget); 30 | 31 | private: 32 | FT_Outline transformed; 33 | FT_Library library; 34 | unsigned char pixelMode; 35 | const QVector& monoColorTable; 36 | const QVector& grayColorTable; 37 | QRectF bRect; 38 | }; 39 | 40 | 41 | // end of glyphbitmap.hpp 42 | -------------------------------------------------------------------------------- /src/ftinspect/rendering/glyphoutline.cpp: -------------------------------------------------------------------------------- 1 | // glyphoutline.cpp 2 | 3 | // Copyright (C) 2016=2017 by Werner Lemberg. 4 | 5 | 6 | #include "glyphoutline.hpp" 7 | 8 | #include 9 | 10 | 11 | extern "C" { 12 | 13 | // vertical font coordinates are bottom-up, 14 | // while Qt uses top-down 15 | 16 | static int 17 | moveTo(const FT_Vector* to, 18 | void* user) 19 | { 20 | QPainterPath* path = static_cast(user); 21 | 22 | path->moveTo(qreal(to->x) / 64, 23 | -qreal(to->y) / 64); 24 | 25 | return 0; 26 | } 27 | 28 | 29 | static int 30 | lineTo(const FT_Vector* to, 31 | void* user) 32 | { 33 | QPainterPath* path = static_cast(user); 34 | 35 | path->lineTo(qreal(to->x) / 64, 36 | -qreal(to->y) / 64); 37 | 38 | return 0; 39 | } 40 | 41 | 42 | static int 43 | conicTo(const FT_Vector* control, 44 | const FT_Vector* to, 45 | void* user) 46 | { 47 | QPainterPath* path = static_cast(user); 48 | 49 | path->quadTo(qreal(control->x) / 64, 50 | -qreal(control->y) / 64, 51 | qreal(to->x) / 64, 52 | -qreal(to->y) / 64); 53 | 54 | return 0; 55 | } 56 | 57 | 58 | static int 59 | cubicTo(const FT_Vector* control1, 60 | const FT_Vector* control2, 61 | const FT_Vector* to, 62 | void* user) 63 | { 64 | QPainterPath* path = static_cast(user); 65 | 66 | path->cubicTo(qreal(control1->x) / 64, 67 | -qreal(control1->y) / 64, 68 | qreal(control2->x) / 64, 69 | -qreal(control2->y) / 64, 70 | qreal(to->x) / 64, 71 | -qreal(to->y) / 64); 72 | 73 | return 0; 74 | } 75 | 76 | 77 | static FT_Outline_Funcs outlineFuncs = 78 | { 79 | moveTo, 80 | lineTo, 81 | conicTo, 82 | cubicTo, 83 | 0, // no shift 84 | 0 // no delta 85 | }; 86 | 87 | } // extern "C" 88 | 89 | 90 | GlyphOutline::GlyphOutline(const QPen& outlineP, 91 | FT_Outline* outln) 92 | : outlinePen(outlineP), 93 | outline(outln) 94 | { 95 | FT_BBox cbox; 96 | 97 | qreal halfPenWidth = outlinePen.widthF(); 98 | 99 | FT_Outline_Get_CBox(outline, &cbox); 100 | 101 | bRect.setCoords(qreal(cbox.xMin) / 64 - halfPenWidth, 102 | -qreal(cbox.yMax) / 64 - halfPenWidth, 103 | qreal(cbox.xMax) / 64 + halfPenWidth, 104 | -qreal(cbox.yMin) / 64 + halfPenWidth); 105 | } 106 | 107 | 108 | QRectF 109 | GlyphOutline::boundingRect() const 110 | { 111 | return bRect; 112 | } 113 | 114 | 115 | void 116 | GlyphOutline::paint(QPainter* painter, 117 | const QStyleOptionGraphicsItem*, 118 | QWidget*) 119 | { 120 | painter->setPen(outlinePen); 121 | 122 | QPainterPath path; 123 | FT_Outline_Decompose(outline, &outlineFuncs, &path); 124 | 125 | painter->drawPath(path); 126 | } 127 | 128 | 129 | // end of glyphoutline.cpp 130 | -------------------------------------------------------------------------------- /src/ftinspect/rendering/glyphoutline.hpp: -------------------------------------------------------------------------------- 1 | // glyphoutline.hpp 2 | 3 | // Copyright (C) 2016-2017 by Werner Lemberg. 4 | 5 | 6 | #pragma once 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | #include FT_FREETYPE_H 13 | #include FT_OUTLINE_H 14 | 15 | 16 | class GlyphOutline 17 | : public QGraphicsItem 18 | { 19 | public: 20 | GlyphOutline(const QPen& pen, 21 | FT_Outline* outline); 22 | QRectF boundingRect() const; 23 | void paint(QPainter* painter, 24 | const QStyleOptionGraphicsItem* option, 25 | QWidget* widget); 26 | 27 | private: 28 | QPen outlinePen; 29 | FT_Outline* outline; 30 | QRectF bRect; 31 | }; 32 | 33 | 34 | // end of glyphoutline.hpp 35 | -------------------------------------------------------------------------------- /src/ftinspect/rendering/glyphpointnumbers.cpp: -------------------------------------------------------------------------------- 1 | // glyphpointnumbers.cpp 2 | 3 | // Copyright (C) 2016-2017 by Werner Lemberg. 4 | 5 | 6 | #include "glyphpointnumbers.hpp" 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | 13 | GlyphPointNumbers::GlyphPointNumbers(const QPen& onP, 14 | const QPen& offP, 15 | FT_Outline* outln) 16 | : onPen(onP), 17 | offPen(offP), 18 | outline(outln) 19 | { 20 | FT_BBox cbox; 21 | 22 | FT_Outline_Get_CBox(outline, &cbox); 23 | 24 | // XXX fix bRect size 25 | bRect.setCoords(qreal(cbox.xMin) / 64, 26 | -qreal(cbox.yMax) / 64, 27 | qreal(cbox.xMax) / 64, 28 | -qreal(cbox.yMin) / 64); 29 | } 30 | 31 | 32 | QRectF 33 | GlyphPointNumbers::boundingRect() const 34 | { 35 | return bRect; 36 | } 37 | 38 | 39 | void 40 | GlyphPointNumbers::paint(QPainter* painter, 41 | const QStyleOptionGraphicsItem* option, 42 | QWidget*) 43 | { 44 | const qreal lod = option->levelOfDetailFromTransform( 45 | painter->worldTransform()); 46 | 47 | // don't draw point numbers if magnification is too small 48 | if (lod >= 10) 49 | { 50 | QFont font = painter->font(); 51 | 52 | // the following doesn't work correctly with scaling; 53 | // it seems that Qt doesn't allow arbitrarily small font sizes 54 | // that get magnified later on 55 | #if 0 56 | // we want the same text size regardless of the scaling 57 | font.setPointSizeF(font.pointSizeF() / lod); 58 | painter->setFont(font); 59 | #else 60 | font.setPointSizeF(font.pointSizeF() * 3 / 4); 61 | painter->setFont(font); 62 | 63 | QBrush onBrush(onPen.color()); 64 | QBrush offBrush(offPen.color()); 65 | 66 | painter->scale(1 / lod, 1 / lod); 67 | #endif 68 | 69 | FT_Vector* points = outline->points; 70 | FT_Short* contours = outline->contours; 71 | char* tags = outline->tags; 72 | 73 | QVector2D octants[8] = { QVector2D(1, 0), 74 | QVector2D(0.707f, -0.707f), 75 | QVector2D(0, -1), 76 | QVector2D(-0.707f, -0.707f), 77 | QVector2D(-1, 0), 78 | QVector2D(-0.707f, 0.707f), 79 | QVector2D(0, 1), 80 | QVector2D(0.707f, 0.707f) }; 81 | 82 | 83 | short ptIdx = 0; 84 | for (int contIdx = 0; contIdx < outline->n_contours; contIdx++ ) 85 | { 86 | for (;;) 87 | { 88 | short prevIdx, nextIdx; 89 | 90 | // find previous and next point in outline 91 | if (contIdx == 0) 92 | { 93 | if (contours[contIdx] == 0) 94 | { 95 | prevIdx = 0; 96 | nextIdx = 0; 97 | } 98 | else 99 | { 100 | prevIdx = ptIdx > 0 ? ptIdx - 1 101 | : contours[contIdx]; 102 | nextIdx = ptIdx < contours[contIdx] ? ptIdx + 1 103 | : 0; 104 | } 105 | } 106 | else 107 | { 108 | prevIdx = ptIdx > (contours[contIdx - 1] + 1) ? ptIdx - 1 109 | : contours[contIdx]; 110 | nextIdx = ptIdx < contours[contIdx] ? ptIdx + 1 111 | : contours[contIdx - 1] + 1; 112 | } 113 | 114 | // get vectors to previous and next point and normalize them; 115 | QVector2D in(static_cast(points[prevIdx].x 116 | - points[ptIdx].x) / 64, 117 | -static_cast(points[prevIdx].y 118 | - points[ptIdx].y) / 64); 119 | QVector2D out(static_cast(points[nextIdx].x 120 | - points[ptIdx].x) / 64, 121 | -static_cast(points[nextIdx].y 122 | - points[ptIdx].y) / 64); 123 | 124 | in = in.normalized(); 125 | out = out.normalized(); 126 | 127 | QVector2D middle = in + out; 128 | // check whether vector is very small, using a threshold of 1/8px 129 | if (qAbs(middle.x()) < 1.0f / 8 130 | && qAbs(middle.y()) < 1.0f / 8) 131 | { 132 | // in case of vectors in almost exactly opposite directions, 133 | // use a vector orthogonal to them 134 | middle.setX(out.y()); 135 | middle.setY(-out.x()); 136 | 137 | if (qAbs(middle.x()) < 1.0f / 8 138 | && qAbs(middle.y()) < 1.0f / 8) 139 | { 140 | // use direction based on point index for the offset 141 | // if we still don't have a good value 142 | middle = octants[ptIdx % 8]; 143 | } 144 | } 145 | 146 | // normalize `middle' vector (which is never zero), 147 | // then multiply by 8 to get some distance between 148 | // the point and the number 149 | middle = middle.normalized() * 8; 150 | 151 | // we now position the point number in the opposite 152 | // direction of the `middle' vector, 153 | QString number = QString::number(ptIdx); 154 | 155 | #if 0 156 | // this fails, see comment above 157 | int size = 10000; 158 | qreal x = qreal(points[ptIdx].x) / 64 - middle.x() / lod; 159 | qreal y = -qreal(points[ptIdx].y) / 64 - middle.y() / lod; 160 | QPointF corner(x, y); 161 | int flags = middle.x() > 0 ? Qt::AlignRight 162 | : Qt::AlignLeft; 163 | if (flags == Qt::AlignRight) 164 | corner.rx() -= size; 165 | QRectF posRect(corner, QSizeF(size, size)); 166 | 167 | if (tags[ptIdx] & FT_CURVE_TAG_ON) 168 | painter->setPen(onPen); 169 | else 170 | painter->setPen(offPen); 171 | 172 | painter->drawText(posRect, flags, number); 173 | #else 174 | // convert text string to a path object 175 | QPainterPath path; 176 | path.addText(QPointF(0, 0), font, number); 177 | QRectF ctrlPtRect = path.controlPointRect(); 178 | 179 | qreal x = static_cast(points[ptIdx].x) / 64 * lod 180 | - static_cast(middle.x()); 181 | qreal y = -static_cast(points[ptIdx].y) / 64 * lod 182 | - static_cast(middle.y()); 183 | 184 | qreal heuristicOffset = 2; 185 | if (middle.x() > 0) 186 | path.translate(x - ctrlPtRect.width() - heuristicOffset, 187 | y + ctrlPtRect.height() / 2); 188 | else 189 | path.translate(x, 190 | y + ctrlPtRect.height() / 2); 191 | 192 | painter->fillPath(path, 193 | tags[ptIdx] & FT_CURVE_TAG_ON ? onBrush 194 | : offBrush); 195 | #endif 196 | 197 | ptIdx++; 198 | if (ptIdx > contours[contIdx]) 199 | break; 200 | } 201 | } 202 | } 203 | } 204 | 205 | 206 | // end of glyphpointnumbers.cpp 207 | -------------------------------------------------------------------------------- /src/ftinspect/rendering/glyphpointnumbers.hpp: -------------------------------------------------------------------------------- 1 | // glyphpointnumbers.hpp 2 | 3 | // Copyright (C) 2016-2017 by Werner Lemberg. 4 | 5 | 6 | #pragma once 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | #include FT_FREETYPE_H 13 | #include FT_OUTLINE_H 14 | 15 | 16 | class GlyphPointNumbers 17 | : public QGraphicsItem 18 | { 19 | public: 20 | GlyphPointNumbers(const QPen& onPen, 21 | const QPen& offPen, 22 | FT_Outline* outline); 23 | QRectF boundingRect() const; 24 | void paint(QPainter* painter, 25 | const QStyleOptionGraphicsItem* option, 26 | QWidget* widget); 27 | 28 | private: 29 | QPen onPen; 30 | QPen offPen; 31 | FT_Outline* outline; 32 | QRectF bRect; 33 | }; 34 | 35 | 36 | // end of glyphpointnumbers.hpp 37 | -------------------------------------------------------------------------------- /src/ftinspect/rendering/glyphpoints.cpp: -------------------------------------------------------------------------------- 1 | // glyphpoints.cpp 2 | 3 | // Copyright (C) 2016-2017 by Werner Lemberg. 4 | 5 | 6 | #include "glyphpoints.hpp" 7 | 8 | #include 9 | #include 10 | 11 | 12 | GlyphPoints::GlyphPoints(const QPen& onP, 13 | const QPen& offP, 14 | FT_Outline* outln) 15 | : onPen(onP), 16 | offPen(offP), 17 | outline(outln) 18 | { 19 | FT_BBox cbox; 20 | 21 | qreal halfPenWidth = qMax(onPen.widthF(), offPen.widthF()) / 2; 22 | 23 | FT_Outline_Get_CBox(outline, &cbox); 24 | 25 | bRect.setCoords(qreal(cbox.xMin) / 64 - halfPenWidth, 26 | -qreal(cbox.yMax) / 64 - halfPenWidth, 27 | qreal(cbox.xMax) / 64 + halfPenWidth, 28 | -qreal(cbox.yMin) / 64 + halfPenWidth); 29 | } 30 | 31 | 32 | QRectF 33 | GlyphPoints::boundingRect() const 34 | { 35 | return bRect; 36 | } 37 | 38 | 39 | void 40 | GlyphPoints::paint(QPainter* painter, 41 | const QStyleOptionGraphicsItem* option, 42 | QWidget*) 43 | { 44 | const qreal lod = option->levelOfDetailFromTransform( 45 | painter->worldTransform()); 46 | 47 | // don't draw points if magnification is too small 48 | if (lod >= 5) 49 | { 50 | // we want the same dot size regardless of the scaling; 51 | // for good optical results, the pen widths should be uneven integers 52 | 53 | // interestingly, using `drawPoint' doesn't work as expected: 54 | // the larger the zoom, the more horizontally stretched the dot appears 55 | #if 0 56 | qreal origOnPenWidth = onPen.widthF(); 57 | qreal origOffPenWidth = offPen.widthF(); 58 | 59 | onPen.setWidthF(origOnPenWidth / lod); 60 | offPen.setWidthF(origOffPenWidth / lod); 61 | 62 | for (int i = 0; i < outline->n_points; i++) 63 | { 64 | if (outline->tags[i] & FT_CURVE_TAG_ON) 65 | painter->setPen(onPen); 66 | else 67 | painter->setPen(offPen); 68 | 69 | painter->drawPoint(QPointF(qreal(outline->points[i].x) / 64, 70 | -qreal(outline->points[i].y) / 64)); 71 | } 72 | 73 | onPen.setWidthF(origOnPenWidth); 74 | offPen.setWidthF(origOffPenWidth); 75 | #else 76 | QBrush onBrush(onPen.color()); 77 | QBrush offBrush(offPen.color()); 78 | 79 | painter->setPen(Qt::NoPen); 80 | 81 | qreal onRadius = onPen.widthF() / lod; 82 | qreal offRadius = offPen.widthF() / lod; 83 | 84 | for (int i = 0; i < outline->n_points; i++) 85 | { 86 | if (outline->tags[i] & FT_CURVE_TAG_ON) 87 | { 88 | painter->setBrush(onBrush); 89 | painter->drawEllipse(QPointF(qreal(outline->points[i].x) / 64, 90 | -qreal(outline->points[i].y) / 64), 91 | onRadius, 92 | onRadius); 93 | } 94 | else 95 | { 96 | painter->setBrush(offBrush); 97 | painter->drawEllipse(QPointF(qreal(outline->points[i].x) / 64, 98 | -qreal(outline->points[i].y) / 64), 99 | offRadius, 100 | offRadius); 101 | } 102 | } 103 | #endif 104 | } 105 | } 106 | 107 | 108 | // end of glyphpoints.cpp 109 | -------------------------------------------------------------------------------- /src/ftinspect/rendering/glyphpoints.hpp: -------------------------------------------------------------------------------- 1 | // glyphpoints.hpp 2 | 3 | // Copyright (C) 2016-2017 by Werner Lemberg. 4 | 5 | 6 | #pragma once 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | #include FT_FREETYPE_H 13 | #include FT_OUTLINE_H 14 | 15 | 16 | class GlyphPoints 17 | : public QGraphicsItem 18 | { 19 | public: 20 | GlyphPoints(const QPen& onPen, 21 | const QPen& offPen, 22 | FT_Outline* outline); 23 | QRectF boundingRect() const; 24 | void paint(QPainter* painter, 25 | const QStyleOptionGraphicsItem* option, 26 | QWidget* widget); 27 | 28 | private: 29 | QPen onPen; 30 | QPen offPen; 31 | FT_Outline* outline; 32 | QRectF bRect; 33 | }; 34 | 35 | 36 | // end of glyphpoints.hpp 37 | -------------------------------------------------------------------------------- /src/ftinspect/rendering/grid.cpp: -------------------------------------------------------------------------------- 1 | // grid.cpp 2 | 3 | // Copyright (C) 2016-2017 by Werner Lemberg. 4 | 5 | 6 | #include "grid.hpp" 7 | 8 | #include 9 | #include 10 | 11 | 12 | Grid::Grid(const QPen& gridP, 13 | const QPen& axisP) 14 | : gridPen(gridP), 15 | axisPen(axisP) 16 | { 17 | // empty 18 | } 19 | 20 | 21 | QRectF 22 | Grid::boundingRect() const 23 | { 24 | // XXX fix size 25 | 26 | // no need to take care of pen width 27 | return QRectF(-100, -100, 28 | 200, 200); 29 | } 30 | 31 | 32 | // XXX call this in a `myQDraphicsView::drawBackground' derived method 33 | // to always fill the complete viewport 34 | 35 | void 36 | Grid::paint(QPainter* painter, 37 | const QStyleOptionGraphicsItem* option, 38 | QWidget*) 39 | { 40 | const qreal lod = option->levelOfDetailFromTransform( 41 | painter->worldTransform()); 42 | 43 | painter->setPen(gridPen); 44 | 45 | // don't mark pixel center with a cross if magnification is too small 46 | if (lod > 20) 47 | { 48 | int halfLength = 1; 49 | 50 | // cf. QSpinBoxx 51 | if (lod > 640) 52 | halfLength = 6; 53 | else if (lod > 320) 54 | halfLength = 5; 55 | else if (lod > 160) 56 | halfLength = 4; 57 | else if (lod > 80) 58 | halfLength = 3; 59 | else if (lod > 40) 60 | halfLength = 2; 61 | 62 | for (qreal x = -100; x < 100; x++) 63 | for (qreal y = -100; y < 100; y++) 64 | { 65 | painter->drawLine(QLineF(x + 0.5, y + 0.5 - halfLength / lod, 66 | x + 0.5, y + 0.5 + halfLength / lod)); 67 | painter->drawLine(QLineF(x + 0.5 - halfLength / lod, y + 0.5, 68 | x + 0.5 + halfLength / lod, y + 0.5)); 69 | } 70 | } 71 | 72 | // don't draw grid if magnification is too small 73 | if (lod >= 5) 74 | { 75 | // XXX fix size 76 | for (int x = -100; x <= 100; x++) 77 | painter->drawLine(x, -100, 78 | x, 100); 79 | for (int y = -100; y <= 100; y++) 80 | painter->drawLine(-100, y, 81 | 100, y); 82 | } 83 | 84 | painter->setPen(axisPen); 85 | 86 | painter->drawLine(0, -100, 87 | 0, 100); 88 | painter->drawLine(-100, 0, 89 | 100, 0); 90 | } 91 | 92 | 93 | // end of grid.cpp 94 | -------------------------------------------------------------------------------- /src/ftinspect/rendering/grid.hpp: -------------------------------------------------------------------------------- 1 | // grid.hpp 2 | 3 | // Copyright (C) 2016-2017 by Werner Lemberg. 4 | 5 | 6 | #pragma once 7 | 8 | #include 9 | #include 10 | 11 | 12 | class Grid 13 | : public QGraphicsItem 14 | { 15 | public: 16 | Grid(const QPen& gridPen, 17 | const QPen& axisPen); 18 | QRectF boundingRect() const; 19 | void paint(QPainter* painter, 20 | const QStyleOptionGraphicsItem* option, 21 | QWidget* widget); 22 | 23 | private: 24 | QPen gridPen; 25 | QPen axisPen; 26 | }; 27 | 28 | 29 | // end of grid.hpp 30 | -------------------------------------------------------------------------------- /src/ftinspect/widgets/qcomboboxx.cpp: -------------------------------------------------------------------------------- 1 | // qcomboboxx.cpp 2 | 3 | // Copyright (C) 2016-2017 by Werner Lemberg. 4 | 5 | 6 | #include "qcomboboxx.hpp" 7 | 8 | #include 9 | 10 | 11 | void 12 | QComboBoxx::setItemEnabled(int index, 13 | bool enable) 14 | { 15 | const QStandardItemModel* itemModel = 16 | qobject_cast(model()); 17 | QStandardItem* item = itemModel->item(index); 18 | 19 | if (enable) 20 | { 21 | item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); 22 | item->setData(QVariant(), 23 | Qt::TextColorRole); 24 | } 25 | else 26 | { 27 | item->setFlags(item->flags() 28 | & ~(Qt::ItemIsSelectable | Qt::ItemIsEnabled)); 29 | // clear item data in order to use default color; 30 | // this visually greys out the item 31 | item->setData(palette().color(QPalette::Disabled, QPalette::Text), 32 | Qt::TextColorRole); 33 | } 34 | } 35 | 36 | 37 | // end of qcomboboxx.cpp 38 | -------------------------------------------------------------------------------- /src/ftinspect/widgets/qcomboboxx.hpp: -------------------------------------------------------------------------------- 1 | // qcomboboxx.hpp 2 | 3 | // Copyright (C) 2016-2017 by Werner Lemberg. 4 | 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | 11 | // we want to grey out items in a combo box; 12 | // since Qt doesn't provide a function for this we derive a class 13 | class QComboBoxx 14 | : public QComboBox 15 | { 16 | Q_OBJECT 17 | 18 | public: 19 | void setItemEnabled(int index, 20 | bool enable); 21 | }; 22 | 23 | 24 | // end of qcomboboxx.hpp 25 | -------------------------------------------------------------------------------- /src/ftinspect/widgets/qgraphicsviewx.cpp: -------------------------------------------------------------------------------- 1 | // qgraphicsviewx.hpp 2 | 3 | // Copyright (C) 2016-2017 by Werner Lemberg. 4 | 5 | 6 | #include "qgraphicsviewx.hpp" 7 | 8 | #include 9 | 10 | 11 | QGraphicsViewx::QGraphicsViewx() 12 | : lastBottomLeftPointInitialized(false) 13 | { 14 | // empty 15 | } 16 | 17 | 18 | void 19 | QGraphicsViewx::scrollContentsBy(int dx, 20 | int dy) 21 | { 22 | QGraphicsView::scrollContentsBy(dx, dy); 23 | lastBottomLeftPoint = viewport()->rect().bottomLeft(); 24 | } 25 | 26 | 27 | void 28 | QGraphicsViewx::resizeEvent(QResizeEvent* event) 29 | { 30 | QGraphicsView::resizeEvent(event); 31 | 32 | // XXX I don't know how to properly initialize this value, 33 | // thus the hack with the boolean 34 | if (!lastBottomLeftPointInitialized) 35 | { 36 | lastBottomLeftPoint = viewport()->rect().bottomLeft(); 37 | lastBottomLeftPointInitialized = true; 38 | } 39 | 40 | QPointF currentBottomLeftPoint = viewport()->rect().bottomLeft(); 41 | int verticalPosition = verticalScrollBar()->value(); 42 | verticalScrollBar()->setValue(static_cast( 43 | verticalPosition 44 | - (currentBottomLeftPoint.y() 45 | - lastBottomLeftPoint.y()))); 46 | } 47 | 48 | 49 | // end of qgraphicsviewx.cpp 50 | -------------------------------------------------------------------------------- /src/ftinspect/widgets/qgraphicsviewx.hpp: -------------------------------------------------------------------------------- 1 | // qgraphicsviewx.hpp 2 | 3 | // Copyright (C) 2016-2017 by Werner Lemberg. 4 | 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | 11 | // we want to anchor the view at the bottom left corner 12 | // while the windows gets resized 13 | class QGraphicsViewx 14 | : public QGraphicsView 15 | { 16 | Q_OBJECT 17 | 18 | public: 19 | QGraphicsViewx(); 20 | 21 | protected: 22 | void resizeEvent(QResizeEvent* event); 23 | void scrollContentsBy(int dx, 24 | int dy); 25 | 26 | private: 27 | QPointF lastBottomLeftPoint; 28 | bool lastBottomLeftPointInitialized; 29 | }; 30 | 31 | 32 | // end of qgraphicsviewx.hpp 33 | -------------------------------------------------------------------------------- /src/ftinspect/widgets/qpushbuttonx.cpp: -------------------------------------------------------------------------------- 1 | // qpushbuttonx.cpp 2 | 3 | // Copyright (C) 2016-2017 by Werner Lemberg. 4 | 5 | 6 | #include "qpushbuttonx.hpp" 7 | 8 | #include 9 | 10 | 11 | // code derived from Qt 4.8.7, function `QPushButton::sizeHint', 12 | // file `src/gui/widgets/qpushbutton.cpp' 13 | 14 | QPushButtonx::QPushButtonx(const QString &text, 15 | QWidget *parent) 16 | : QPushButton(text, parent) 17 | { 18 | QStyleOptionButton opt; 19 | opt.initFrom(this); 20 | QString s(this->text()); 21 | QFontMetrics fm = fontMetrics(); 22 | QSize sz = fm.size(Qt::TextShowMnemonic, s); 23 | opt.rect.setSize(sz); 24 | 25 | sz = style()->sizeFromContents(QStyle::CT_PushButton, 26 | &opt, 27 | sz, 28 | this); 29 | setFixedWidth(sz.width()); 30 | } 31 | 32 | 33 | // end of qpushbuttonx.cpp 34 | -------------------------------------------------------------------------------- /src/ftinspect/widgets/qpushbuttonx.hpp: -------------------------------------------------------------------------------- 1 | // qpushbuttonx.hpp 2 | 3 | // Copyright (C) 2016-2017 by Werner Lemberg. 4 | 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | 11 | // we want buttons that are horizontally as small as possible 12 | class QPushButtonx 13 | : public QPushButton 14 | { 15 | Q_OBJECT 16 | 17 | public: 18 | QPushButtonx(const QString& text, 19 | QWidget* = 0); 20 | virtual ~QPushButtonx(){} 21 | }; 22 | 23 | 24 | // end of qpushbuttonx.hpp 25 | -------------------------------------------------------------------------------- /src/ftinspect/widgets/qspinboxx.cpp: -------------------------------------------------------------------------------- 1 | // qspinboxx.cpp 2 | 3 | // Copyright (C) 2016-2017 by Werner Lemberg. 4 | 5 | 6 | #include "qspinboxx.hpp" 7 | 8 | 9 | // we want to mark the center of a pixel square with a single dot or a small 10 | // cross; starting with a certain magnification we thus only use even values 11 | // so that we can do that symmetrically 12 | 13 | int 14 | QSpinBoxx::valueFromText(const QString& text) const 15 | { 16 | int val = QSpinBox::valueFromText(text); 17 | 18 | if (val > 640) 19 | val = val - (val % 64); 20 | else if (val > 320) 21 | val = val - (val % 32); 22 | else if (val > 160) 23 | val = val - (val % 16); 24 | else if (val > 80) 25 | val = val - (val % 8); 26 | else if (val > 40) 27 | val = val - (val % 4); 28 | else if (val > 20) 29 | val = val - (val % 2); 30 | 31 | return val; 32 | } 33 | 34 | 35 | void 36 | QSpinBoxx::stepBy(int steps) 37 | { 38 | int val = value(); 39 | 40 | if (steps > 0) 41 | { 42 | for (int i = 0; i < steps; i++) 43 | { 44 | if (val >= 640) 45 | val = val + 64; 46 | else if (val >= 320) 47 | val = val + 32; 48 | else if (val >= 160) 49 | val = val + 16; 50 | else if (val >= 80) 51 | val = val + 8; 52 | else if (val >= 40) 53 | val = val + 4; 54 | else if (val >= 20) 55 | val = val + 2; 56 | else 57 | val++; 58 | } 59 | } 60 | else if (steps < 0) 61 | { 62 | for (int i = 0; i < -steps; i++) 63 | { 64 | if (val > 640) 65 | val = val - 64; 66 | else if (val > 320) 67 | val = val - 32; 68 | else if (val > 160) 69 | val = val - 16; 70 | else if (val > 80) 71 | val = val - 8; 72 | else if (val > 40) 73 | val = val - 4; 74 | else if (val > 20) 75 | val = val - 2; 76 | else 77 | val--; 78 | } 79 | } 80 | 81 | setValue(val); 82 | } 83 | 84 | 85 | // end of qspinboxx.cpp 86 | -------------------------------------------------------------------------------- /src/ftinspect/widgets/qspinboxx.hpp: -------------------------------------------------------------------------------- 1 | // qspinboxx.hpp 2 | 3 | // Copyright (C) 2016-2017 by Werner Lemberg. 4 | 5 | 6 | #pragma once 7 | 8 | #include 9 | #include 10 | 11 | 12 | // we want to have our own `stepBy' function for the zoom spin box 13 | class QSpinBoxx 14 | : public QSpinBox 15 | { 16 | Q_OBJECT 17 | 18 | public: 19 | void stepBy(int val); 20 | int valueFromText(const QString& text) const; 21 | }; 22 | 23 | 24 | // qspinboxx.hpp 25 | -------------------------------------------------------------------------------- /src/ftlint.1: -------------------------------------------------------------------------------- 1 | .TH FTLINT 1 "May 2017" "Freetype 2.8" 2 | . 3 | . 4 | .SH NAME 5 | . 6 | ftlint \- simple font tester 7 | . 8 | . 9 | .SH SYNOPSIS 10 | . 11 | .B ftlint 12 | .I ppem 13 | .IR fontname [ .ttf | .ttc "] .\|.\|." 14 | . 15 | . 16 | .SH DESCRIPTION 17 | . 18 | .B ftlint 19 | opens the given font(s), loads and renders all glyphs at the given ppem 20 | value, and reports failing glyphs if there are less than ten fails, or the 21 | number of fails only if there are more fails. 22 | . 23 | .PP 24 | This program does not have any options. 25 | It is part of the FreeType demos package. 26 | . 27 | .\" eof 28 | -------------------------------------------------------------------------------- /src/ftlint.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* */ 3 | /* The FreeType project -- a free and portable quality font engine */ 4 | /* */ 5 | /* Copyright 1996-1998, 2001, 2013 by */ 6 | /* D. Turner, R.Wilhelm, and W. Lemberg */ 7 | /* */ 8 | /* ftlint: a simple font tester. This program tries to load all the */ 9 | /* glyphs of a given font. */ 10 | /* */ 11 | /* NOTE: This is just a test program that is used to show off and */ 12 | /* debug the current engine. */ 13 | /* */ 14 | /****************************************************************************/ 15 | 16 | #include 17 | #include FT_FREETYPE_H 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | 24 | #define xxTEST_PSNAMES 25 | 26 | 27 | static FT_Error error; 28 | 29 | static FT_Library library; 30 | static FT_Face face; 31 | 32 | static unsigned int num_glyphs; 33 | static int ptsize; 34 | 35 | static int Fail; 36 | 37 | 38 | static void 39 | Usage( char* name ) 40 | { 41 | printf( "ftlint: simple font tester -- part of the FreeType project\n" ); 42 | printf( "----------------------------------------------------------\n" ); 43 | printf( "\n" ); 44 | printf( "Usage: %s ppem fontname[.ttf|.ttc] [fontname2..]\n", name ); 45 | printf( "\n" ); 46 | 47 | exit( 1 ); 48 | } 49 | 50 | 51 | static void 52 | Panic( const char* message ) 53 | { 54 | fprintf( stderr, "%s\n error code = 0x%04x\n", message, error ); 55 | exit(1); 56 | } 57 | 58 | 59 | int 60 | main( int argc, 61 | char** argv ) 62 | { 63 | int i, file_index; 64 | unsigned int id; 65 | char filename[1024 + 4]; 66 | char alt_filename[1024 + 4]; 67 | char* execname; 68 | char* fname; 69 | 70 | 71 | execname = argv[0]; 72 | 73 | if ( argc < 3 ) 74 | Usage( execname ); 75 | 76 | if ( sscanf( argv[1], "%d", &ptsize ) != 1 ) 77 | Usage( execname ); 78 | 79 | error = FT_Init_FreeType( &library ); 80 | if (error) Panic( "Could not create library object" ); 81 | 82 | /* Now check all files */ 83 | for ( file_index = 2; file_index < argc; file_index++ ) 84 | { 85 | fname = argv[file_index]; 86 | 87 | /* try to open the file with no extra extension first */ 88 | error = FT_New_Face( library, fname, 0, &face ); 89 | if (!error) 90 | { 91 | printf( "%s: ", fname ); 92 | goto Success; 93 | } 94 | 95 | 96 | if ( error == FT_Err_Unknown_File_Format ) 97 | { 98 | printf( "unknown format\n" ); 99 | continue; 100 | } 101 | 102 | /* ok, we could not load the file, try to add an extension to */ 103 | /* its name if possible.. */ 104 | 105 | i = (int)strlen( fname ); 106 | while ( i > 0 && fname[i] != '\\' && fname[i] != '/' ) 107 | { 108 | if ( fname[i] == '.' ) 109 | i = 0; 110 | i--; 111 | } 112 | 113 | filename[1024] = '\0'; 114 | alt_filename[1024] = '\0'; 115 | 116 | strncpy( filename, fname, 1024 ); 117 | strncpy( alt_filename, fname, 1024 ); 118 | 119 | #ifndef macintosh 120 | if ( i >= 0 ) 121 | { 122 | strncpy( filename + strlen( filename ), ".ttf", 4 ); 123 | strncpy( alt_filename + strlen( alt_filename ), ".ttc", 4 ); 124 | } 125 | #endif 126 | i = (int)strlen( filename ); 127 | fname = filename; 128 | 129 | while ( i >= 0 ) 130 | #ifndef macintosh 131 | if ( filename[i] == '/' || filename[i] == '\\' ) 132 | #else 133 | if ( filename[i] == ':' ) 134 | #endif 135 | { 136 | fname = filename + i + 1; 137 | i = -1; 138 | } 139 | else 140 | i--; 141 | 142 | printf( "%s: ", fname ); 143 | 144 | /* Load face */ 145 | error = FT_New_Face( library, filename, 0, &face ); 146 | if (error) 147 | { 148 | if (error == FT_Err_Unknown_File_Format) 149 | printf( "unknown format\n" ); 150 | else 151 | printf( "could not find/open file (error: %d)\n", error ); 152 | continue; 153 | } 154 | if (error) Panic( "Could not open file" ); 155 | 156 | Success: 157 | num_glyphs = (unsigned int)face->num_glyphs; 158 | 159 | #ifdef TEST_PSNAMES 160 | { 161 | const char* ps_name = FT_Get_Postscript_Name( face ); 162 | 163 | printf( "[%s] ", ps_name ? ps_name : "." ); 164 | } 165 | #endif 166 | 167 | error = FT_Set_Char_Size( face, ptsize << 6, ptsize << 6, 72, 72 ); 168 | if (error) Panic( "Could not set character size" ); 169 | 170 | Fail = 0; 171 | { 172 | for ( id = 0; id < num_glyphs; id++ ) 173 | { 174 | error = FT_Load_Glyph( face, id, FT_LOAD_DEFAULT ); 175 | if (error) 176 | { 177 | if ( Fail < 10 ) 178 | printf( "glyph %4u: 0x%04x\n" , id, error ); 179 | Fail++; 180 | } 181 | } 182 | } 183 | 184 | if ( Fail == 0 ) 185 | printf( "OK.\n" ); 186 | else 187 | if ( Fail == 1 ) 188 | printf( "1 fail.\n" ); 189 | else 190 | printf( "%d fails.\n", Fail ); 191 | 192 | FT_Done_Face( face ); 193 | } 194 | 195 | FT_Done_FreeType(library); 196 | exit( 0 ); /* for safety reasons */ 197 | 198 | /* return 0; */ /* never reached */ 199 | } 200 | 201 | 202 | /* End */ 203 | -------------------------------------------------------------------------------- /src/ftmulti.1: -------------------------------------------------------------------------------- 1 | .TH FTMULTI 1 "May 2017" "Freetype 2.8" 2 | . 3 | . 4 | .SH NAME 5 | . 6 | ftmulti \- multiple masters font viewer 7 | . 8 | . 9 | .SH SYNOPSIS 10 | . 11 | .B ftmulti 12 | .RI [ options ] 13 | .I pt 14 | .IR fontname \ .\|.\|. 15 | . 16 | . 17 | .SH DESCRIPTION 18 | . 19 | .B ftmulti 20 | is an interactive viewer for multiple masters and GX fonts. 21 | . 22 | .TP 23 | .B pt 24 | The point size for the given resolution. 25 | If resolution is 72dpi, this directly gives the ppem value (pixels per EM). 26 | . 27 | .TP 28 | .B font 29 | The font file(s) to display. 30 | . 31 | .PP 32 | This program is part of the FreeType demos package. 33 | . 34 | . 35 | .SH OPTIONS 36 | . 37 | .TP 38 | .BI \-w \ w 39 | Set the window width to 40 | .I w 41 | pixels (default: 640px). 42 | . 43 | .TP 44 | .BI \-h \ h 45 | Set the window height to 46 | .I h 47 | pixels (default: 480px). 48 | . 49 | .TP 50 | .BI \-e \ encoding 51 | Specify encoding tag (default: no encoding). 52 | Common values: 53 | .B unic 54 | (Unicode), 55 | .B symb 56 | (symbol), 57 | .B ADOB 58 | (Adobe standard), 59 | .B ADBC 60 | (Adobe custom). 61 | . 62 | .TP 63 | .BI \-r \ r 64 | Use resolution 65 | .I r 66 | dpi (default: 72 dpi). 67 | . 68 | .TP 69 | .BI \-f \ index 70 | Specify first glyph index to display. 71 | . 72 | .TP 73 | .BI "\-d\ \(dq" "axis1\ axis2\ .\|.\|." \(dq 74 | Specify the design coordinates for each Multiple Master axis at start-up. 75 | . 76 | .TP 77 | .B \-v 78 | Show version. 79 | . 80 | .\" eof 81 | -------------------------------------------------------------------------------- /src/ftpatchk.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* */ 3 | /* The FreeType project -- a free and portable quality TrueType renderer. */ 4 | /* */ 5 | /* Copyright 2007 by */ 6 | /* D. Turner, R.Wilhelm, and W. Lemberg */ 7 | /* */ 8 | /* */ 9 | /* FTpatchk - a simple program that tests whether patented hinting is */ 10 | /* necessary. */ 11 | /* */ 12 | /****************************************************************************/ 13 | 14 | 15 | #include 16 | #include 17 | 18 | #include 19 | #include FT_FREETYPE_H 20 | 21 | 22 | int 23 | main( int argc, 24 | char* argv[] ) 25 | { 26 | FT_Error error; 27 | FT_Library library; 28 | 29 | 30 | error = FT_Init_FreeType( &library ); 31 | if ( error ) 32 | { 33 | fprintf( stderr, "could not create FreeType instance\n" ); 34 | exit( 1 ); 35 | } 36 | 37 | for ( ; argc > 1; argc--, argv++ ) 38 | { 39 | FT_Face face; 40 | 41 | 42 | error = FT_New_Face( library, argv[1], 0, &face ); 43 | if ( error ) 44 | { 45 | fprintf( stderr, "could not open as a valid font: `%s'\n", argv[1] ); 46 | continue; 47 | } 48 | printf( "%-50s %s\n", argv[1], 49 | FT_Face_CheckTrueTypePatents( face ) 50 | ? "uses patented opcodes" 51 | : "doesn't use patented opcodes" ); 52 | } 53 | 54 | exit( 0 ); 55 | return 0; 56 | } 57 | 58 | 59 | /* End */ 60 | -------------------------------------------------------------------------------- /src/ftstring.1: -------------------------------------------------------------------------------- 1 | .TH FTSTRING 1 "May 2017" "Freetype 2.8" 2 | . 3 | . 4 | .SH NAME 5 | . 6 | ftstring \- string viewer 7 | . 8 | . 9 | .SH SYNOPSIS 10 | . 11 | .B ftstring 12 | .RI [ options ] 13 | .I pt font .\|.\|. 14 | . 15 | . 16 | .SH DESCRIPTION 17 | . 18 | .B ftstring 19 | displays a text string with the given font, allowing to change 20 | various rendering and display options interactively. 21 | . 22 | .TP 23 | .B pt 24 | The point size for the given resolution. 25 | If resolution is 72dpi, this directly gives the ppem value (pixels per EM). 26 | . 27 | .TP 28 | .B font 29 | The font file(s) to display. 30 | For Type 1 font files, 31 | .B ftstring 32 | also tries to attach the corresponding metrics file (with extension `.afm' 33 | or `.pfm'). 34 | . 35 | .PP 36 | This program is part of the FreeType demos package. 37 | . 38 | . 39 | .SH OPTIONS 40 | . 41 | .TP 42 | .BI \-w \ w 43 | Set the window width to 44 | .I w 45 | pixels (default: 640px). 46 | . 47 | .TP 48 | .BI \-h \ h 49 | Set the window height to 50 | .I h 51 | pixels (default: 480px). 52 | . 53 | .TP 54 | .BI \-r \ r 55 | Use resolution 56 | .I r 57 | dpi (default: 72dpi). 58 | . 59 | .TP 60 | .BI \-e \ enc 61 | Specify encoding tag (default: no encoding). 62 | Common values: 63 | .B unic 64 | (Unicode), 65 | .B symb 66 | (symbol), 67 | .B ADOB 68 | (Adobe standard), 69 | .B ADBC 70 | (Adobe custom). 71 | . 72 | .TP 73 | .BI \-m \ text 74 | Use 75 | .I text 76 | for rendering. 77 | . 78 | .TP 79 | .B \-v 80 | Show version. 81 | . 82 | .\" eof 83 | -------------------------------------------------------------------------------- /src/fttry.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* */ 3 | /* The FreeType project -- a free and portable quality TrueType renderer. */ 4 | /* */ 5 | /* Copyright 1996-1998, 2001, 2013 by */ 6 | /* D. Turner, R.Wilhelm, and W. Lemberg */ 7 | /* */ 8 | /* ftlint: a simple TrueType instruction tester. */ 9 | /* */ 10 | /* NOTE: This is just a test program that is used to show off and */ 11 | /* debug the current engine. */ 12 | /* */ 13 | /****************************************************************************/ 14 | 15 | 16 | #include 17 | #include FT_FREETYPE_H 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | 24 | #define DUMP_NAME 25 | 26 | #define gettext( x ) ( x ) 27 | 28 | 29 | FT_Error error; 30 | 31 | FT_Library library; 32 | FT_Face face; 33 | 34 | unsigned int num_glyphs; 35 | int ptsize; 36 | 37 | int Fail; 38 | int Num; 39 | 40 | 41 | static void 42 | Usage( char* name ) 43 | { 44 | printf( "fttry: simple TrueType instruction tester -- part of the FreeType project\n" ); 45 | printf( "--------------------------------------------------------------------------\n" ); 46 | printf( "\n" ); 47 | printf( "Usage: %s ppem glyph fontname [fontname2..]\n\n", name ); 48 | printf( " or %s -u glyph fontname [fontname2..]\n", name ); 49 | printf( " to load an unscaled glyph\n\n" ); 50 | 51 | exit( 1 ); 52 | } 53 | 54 | 55 | static void 56 | Panic( const char* message ) 57 | { 58 | fprintf( stderr, 59 | "%s\n error code = 0x%04x\n", message, error ); 60 | exit( 1 ); 61 | } 62 | 63 | 64 | int 65 | main( int argc, 66 | char** argv ) 67 | { 68 | int i, file_index, glyph_index; 69 | char filename[1024 + 4]; 70 | char alt_filename[1024 + 4]; 71 | char* execname; 72 | char* fname; 73 | int load_unscaled = 0; 74 | 75 | 76 | execname = argv[0]; 77 | 78 | if ( argc < 3 ) 79 | Usage( execname ); 80 | 81 | if ( argv[1][0] == '-' && 82 | argv[1][1] == 'u' ) 83 | load_unscaled = 1; 84 | else 85 | { 86 | if ( sscanf( argv[1], "%d", &ptsize ) != 1 ) 87 | Usage( execname ); 88 | } 89 | argc--; 90 | argv++; 91 | 92 | if ( sscanf( argv[1], "%d", &glyph_index ) != 1 ) 93 | Usage( execname ); 94 | 95 | error = FT_Init_FreeType( &library ); 96 | if ( error ) 97 | Panic( "Could not create library object" ); 98 | 99 | /* Now check all files */ 100 | for ( file_index = 2; file_index < argc; file_index++ ) 101 | { 102 | fname = argv[file_index]; 103 | i = strlen( fname ); 104 | while ( i > 0 && fname[i] != '\\' && fname[i] != '/' ) 105 | { 106 | if ( fname[i] == '.' ) 107 | i = 0; 108 | i--; 109 | } 110 | 111 | filename[1024] = '\0'; 112 | alt_filename[1024] = '\0'; 113 | 114 | strncpy( filename, fname, 1024 ); 115 | strncpy( alt_filename, fname, 1024 ); 116 | 117 | if ( i >= 0 ) 118 | { 119 | strncpy( filename + strlen( filename ), ".ttf", 4 ); 120 | strncpy( alt_filename + strlen( alt_filename ), ".ttc", 4 ); 121 | } 122 | 123 | i = strlen( filename ); 124 | fname = filename; 125 | 126 | while ( i >= 0 ) 127 | if ( filename[i] == '/' || filename[i] == '\\' ) 128 | { 129 | fname = filename + i + 1; 130 | i = -1; 131 | } 132 | else 133 | i--; 134 | 135 | printf( "%s: ", fname ); 136 | 137 | /* Load face */ 138 | error = FT_New_Face( library, filename, 0, &face ); 139 | if ( error ) 140 | Panic( "Could not create face object" ); 141 | 142 | num_glyphs = face->num_glyphs; 143 | 144 | error = FT_Set_Char_Size( face, ptsize << 6, 0, 0, 0 ); 145 | if ( error ) 146 | Panic( "Could not set character size" ); 147 | 148 | #ifdef DUMP_NAME 149 | { 150 | char name[1024]; 151 | 152 | error = FT_Get_Glyph_Name( face, glyph_index, name, 1024 ); 153 | if ( error ) 154 | printf( "no glyph name available\n" ); 155 | else 156 | printf( "glyph name = '%s'\n", name ); 157 | } 158 | 159 | #endif 160 | 161 | error = FT_Load_Glyph( face, 162 | glyph_index, 163 | load_unscaled ? FT_LOAD_NO_SCALE 164 | : FT_LOAD_DEFAULT ); 165 | if ( error == 0 ) 166 | printf( "OK.\n" ); 167 | else 168 | printf( "Fail with error 0x%04x\n", error ); 169 | 170 | FT_Done_Face( face ); 171 | } 172 | 173 | FT_Done_FreeType(library); 174 | exit( 0 ); /* for safety reasons */ 175 | 176 | return 0; /* never reached */ 177 | } 178 | 179 | 180 | /* End */ 181 | -------------------------------------------------------------------------------- /src/ftvalid.1: -------------------------------------------------------------------------------- 1 | .TH FTVALID 1 "May 2017" "FreeType 2.8" 2 | . 3 | . 4 | .SH NAME 5 | . 6 | ftvalid \- font layout table validator 7 | . 8 | . 9 | .SH SYNOPSIS 10 | . 11 | .B ftvalid 12 | .RI [ options ] 13 | .I fontfile 14 | . 15 | . 16 | .SH DESCRIPTION 17 | . 18 | .B ftvalid 19 | is an OpenType layout table validator. 20 | . 21 | .PP 22 | This program is part of the FreeType demos package. 23 | . 24 | . 25 | .SH OPTIONS 26 | . 27 | .TP 28 | .BI \-f \ index 29 | Select font index (default: 0). 30 | . 31 | .TP 32 | .BI \-t \ validator 33 | Select validator. 34 | Available validators are 35 | .BR ot , 36 | .BR gx , 37 | and 38 | .BR ckern . 39 | . 40 | .IP 41 | Note that the availability of validators depends on 42 | compile-time options of FreeType (this is, whether the modules 43 | `otvalid' and `gxvalid' are compiled into the library). 44 | . 45 | .TP 46 | .BI \-T \ tbls 47 | [ot, gx] Select sfnt table name tags to be validated. 48 | Use `:' to separate tags. 49 | . 50 | .IP 51 | Supported tables in ot validator are 52 | .BR BASE , 53 | .BR GDEF , 54 | .BR GPOS , 55 | .BR GSUB , 56 | .BR JSTF , 57 | and 58 | .BR MATH . 59 | . 60 | .IP 61 | Supported tables in gx validator are 62 | .BR feat , 63 | .BR mort , 64 | .BR morx , 65 | .BR bsln , 66 | .BR just , 67 | .BR kern , 68 | .BR opbd , 69 | .BR trak , 70 | .BR prop , 71 | and 72 | .BR lcar . 73 | . 74 | .IP 75 | Example: 76 | .B \-T \(dqfeat:morx\(dq 77 | . 78 | .TP 79 | .BI \-T \ dialect 80 | [ckern] Select classic kern dialect for validation. 81 | Use `:' to separate dialect names. 82 | If more than one dialect is specified, all dialects are accepted when 83 | validating. 84 | . 85 | .IP 86 | Supported dialects in ckern validator are 87 | .B ms 88 | and 89 | .BR apple . 90 | . 91 | .TP 92 | .BI \-l 93 | List the layout-related SFNT tables available in the font file. 94 | The selected validator (with option 95 | .BR \-t ) 96 | affects the list. 97 | . 98 | .IP 99 | ckern is applicable to `kern' table only. 100 | Option 101 | .B \-L 102 | lists dialects supported in ckern validator only if `kern' table is 103 | available in the font file. 104 | . 105 | .TP 106 | .BI \-V \ level 107 | Validation level. 108 | Possible values are 109 | .B 0 110 | (default), 111 | .B 1 112 | (tight), and 113 | .B 2 114 | (paranoid). 115 | . 116 | .TP 117 | .B \-v 118 | Show version. 119 | . 120 | . 121 | .SH ENVIRONMENT VARIABLES 122 | . 123 | .TP 124 | .B FT2_DEBUG 125 | You can specify 126 | .RI ` component : level ' 127 | pairs for tracing. 128 | .I level 129 | must be in the range [1,7]. 130 | . 131 | .IP 132 | Available components for ot validator are 133 | .BR otvmodule , 134 | .BR otvcommon , 135 | .BR otvbase , 136 | .BR otvgdef , 137 | .BR otvgpos , 138 | .BR otvgsub , 139 | and 140 | .BR otvjstf . 141 | . 142 | .IP 143 | Available components for gx validator are 144 | .BR gxvmodule , 145 | .BR gxvcommon , 146 | .BR gxvfeat , 147 | .BR gxvmort , 148 | .BR gxvmorx , 149 | .BR gxvbsln , 150 | .BR gxvjust , 151 | .BR gxvkern , 152 | .BR gxvopbd , 153 | .BR gxvtrak , 154 | .BR gxvprop , 155 | and 156 | .BR gxvlcar . 157 | .IP 158 | Available component for ckern validator is 159 | .B gxvkern 160 | only. 161 | . 162 | .IP 163 | Example: 164 | .B FT2_DEBUG=\(dqotvcommon:5 gxvkern:7\(dq 165 | . 166 | .IP 167 | .B FT2_DEBUG 168 | only works if tracing support is compiled into FreeType. 169 | . 170 | .\" eof 171 | -------------------------------------------------------------------------------- /src/ftview.1: -------------------------------------------------------------------------------- 1 | .TH FTVIEW 1 "May 2017" "FreeType 2.8" 2 | . 3 | . 4 | .SH NAME 5 | . 6 | ftview \- simple glyph viewer 7 | . 8 | . 9 | .SH SYNOPSIS 10 | . 11 | .B ftview 12 | .RI [ options ] 13 | .I pt font 14 | . 15 | . 16 | .SH DESCRIPTION 17 | . 18 | .B ftview 19 | displays all glyphs of a font, allowing changes of various rendering 20 | and hinting parameters interactively. 21 | . 22 | .TP 23 | .B pt 24 | The point size for the given resolution. 25 | If resolution is 72dpi, this directly gives the ppem value (pixels per EM). 26 | . 27 | .TP 28 | .B font 29 | The font file(s) to display. 30 | For Type 1 font files, ftview also tries to attach the corresponding metrics 31 | file (with extension `.afm' or `.pfm'). 32 | . 33 | .PP 34 | This program is part of the FreeType demos package. 35 | . 36 | . 37 | .SH OPTIONS 38 | . 39 | .TP 40 | .BI \-w \ w 41 | Set the window width to 42 | .I w 43 | pixels (default: 640px). 44 | . 45 | .TP 46 | .BI \-h \ h 47 | Set the window height to 48 | .I h 49 | pixels (default: 480px). 50 | . 51 | .TP 52 | .BI \-r \ r 53 | Use resolution 54 | .I r 55 | dpi (default: 72dpi). 56 | . 57 | .TP 58 | .BI \-f \ index 59 | Specify first index to display (default: 0). 60 | . 61 | .TP 62 | .BI \-e \ enc 63 | Specify encoding tag (default: no encoding). 64 | Common values: 65 | .B unic 66 | (Unicode), 67 | .B symb 68 | (symbol), 69 | .B ADOB 70 | (Adobe standard), 71 | .B ADBC 72 | (Adobe custom). 73 | . 74 | .TP 75 | .BI \-m \ text 76 | Use 77 | .I text 78 | for rendering. 79 | . 80 | .TP 81 | .BI \-l \ mode 82 | Set start-up rendering mode (0 <= 83 | .I mode 84 | <= 5). 85 | . 86 | .TP 87 | .B \-p 88 | Preload file in memory to simulate memory-mapping. 89 | . 90 | .TP 91 | .B \-v 92 | Show version. 93 | . 94 | .\" eof 95 | -------------------------------------------------------------------------------- /src/gbench.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* */ 3 | /* The FreeType project -- a free and portable quality font engine */ 4 | /* */ 5 | /* Copyright 2006 by */ 6 | /* D. Turner, R.Wilhelm, and W. Lemberg */ 7 | /* */ 8 | /* */ 9 | /* gbench is a small program used to benchmark a new algorithm */ 10 | /* performing gamma-corrected alpha-blending. */ 11 | /* */ 12 | /****************************************************************************/ 13 | 14 | 15 | #ifndef GBENCH_H_ 16 | #define GBENCH_H_ 17 | 18 | typedef enum 19 | { 20 | GBITMAP_FORMAT_NONE = 0, 21 | GBITMAP_FORMAT_RGB24, 22 | GBITMAP_FORMAT_GRAY, 23 | GBITMAP_FORMAT_RGB, 24 | GBITMAP_FORMAT_BGR, 25 | GBITMAP_FORMAT_RGBV, 26 | GBITMAP_FORMAT_BGRV, 27 | 28 | GBITMAP_FORMAT_MAX 29 | 30 | } GBitmapFormat; 31 | 32 | 33 | typedef struct GBitmapRec_ 34 | { 35 | int width; 36 | int height; 37 | int pitch; 38 | unsigned char* buffer; 39 | GBitmapFormat format; 40 | 41 | } GBitmapRec, *GBitmap; 42 | 43 | 44 | typedef struct GBlitterRec_* GBlitter; 45 | 46 | typedef void (*GBlitterFunc)( GBlitter blitter, 47 | int color ); 48 | 49 | typedef struct GBlitterRec_ 50 | { 51 | int width; 52 | int height; 53 | 54 | int src_x; 55 | unsigned char* src_line; 56 | int src_incr; 57 | 58 | int dst_x; 59 | unsigned char* dst_line; 60 | int dst_incr; 61 | 62 | GBlitterFunc blit; 63 | 64 | } GBlitterRec; 65 | 66 | 67 | extern void 68 | ggamma_set( double gamma ); 69 | 70 | extern int 71 | gblitter_init_rgb24( GBlitter blitter, 72 | GBitmap src, 73 | int dst_x, 74 | int dst_y, 75 | int dst_width, 76 | int dst_height, 77 | void* dst_buffer, 78 | int dst_pitch ); 79 | 80 | #define gblitter_blit(b,c) (b)->blit( (b), (c) ) 81 | 82 | 83 | #endif /* GBENCH_H_ */ 84 | 85 | 86 | /* End */ 87 | -------------------------------------------------------------------------------- /src/mlgetopt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a cheap replacement for getopt() because that routine is not 3 | * available on some platforms and behaves differently on other platforms. 4 | * This code was written from scratch without looking at any other 5 | * implementation. 6 | * 7 | * This code is hereby expressly placed in the public domain. 8 | * mleisher@crl.nmsu.edu (Mark Leisher) 9 | * 10 October 1997 10 | * 11 | * Last update 2009-03-11. 12 | */ 13 | 14 | #include "mlgetopt.h" 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #ifdef __STDC__ 22 | #define CONST const 23 | #else 24 | #define CONST 25 | #endif 26 | 27 | /* 28 | * Externals visible to programs. 29 | */ 30 | 31 | int opterr = 1; 32 | int optind = 1; 33 | char* optarg; 34 | 35 | /* 36 | * Internal variables that are used to detect when the global values 37 | * need to be reset. 38 | */ 39 | 40 | static int cmdac; 41 | static CONST char* cmdname; 42 | static char* CONST* cmdav; 43 | 44 | int 45 | #ifdef __STDC__ 46 | getopt( int ac, char* const* av, const char* pat ) 47 | #else 48 | getopt( ac, av, pat ) 49 | int ac; 50 | char** av; 51 | char* pat; 52 | #endif 53 | { 54 | int opt; 55 | CONST char* p; 56 | CONST char* pp; 57 | 58 | /* 59 | * If there is no pattern, indicate the parsing is done. 60 | */ 61 | if ( pat == 0 || *pat == 0 ) 62 | return -1; 63 | 64 | /* 65 | * Always reset the option argument to NULL. 66 | */ 67 | optarg = 0; 68 | 69 | /* 70 | * If the number of arguments or argument list do not match the last 71 | * values seen, reset the internal pointers and the globals. 72 | */ 73 | if ( ac != cmdac || av != cmdav ) 74 | { 75 | optind = 1; 76 | cmdac = ac; 77 | cmdav = av; 78 | 79 | /* 80 | * Determine the command name in case it is needed for warning 81 | * messages. 82 | */ 83 | for ( cmdname = 0, p = av[0]; *p; p++ ) 84 | { 85 | if ( *p == '/' || *p == '\\' ) 86 | cmdname = p; 87 | } 88 | /* 89 | * Skip the path separator if the name was assigned. 90 | */ 91 | if ( cmdname ) 92 | cmdname++; 93 | else 94 | cmdname = av[0]; 95 | } 96 | 97 | /* 98 | * If the next index is greater than or equal to the number of 99 | * arguments, then the command line is done. 100 | */ 101 | if ( optind >= ac ) 102 | return -1; 103 | 104 | /* 105 | * Test the next argument for one of three cases: 106 | * 1. The next argument does not have an initial '-'. 107 | * 2. The next argument is '-'. 108 | * 3. The next argument is '--'. 109 | * 110 | * In either of these cases, command line processing is done. 111 | */ 112 | if ( av[optind][0] != '-' || 113 | strcmp( av[optind], "-" ) == 0 || 114 | strcmp( av[optind], "--" ) == 0 ) 115 | return -1; 116 | 117 | /* 118 | * Point at the next command line argument and increment the 119 | * command line index. 120 | */ 121 | p = av[optind++]; 122 | 123 | /* 124 | * Look for the first character of the command line option. 125 | */ 126 | for ( opt = *(p + 1), pp = pat; *pp && *pp != opt; pp++ ) 127 | ; 128 | 129 | /* 130 | * If nothing in the pattern was recognized, then issue a warning 131 | * and return a '?'. 132 | */ 133 | if ( *pp == 0 ) 134 | { 135 | if ( opterr ) 136 | fprintf( stderr, "%s: invalid option -- %c\n", cmdname, opt ); 137 | return '?'; 138 | } 139 | 140 | /* 141 | * If the option expects an argument, get it. 142 | */ 143 | if ( *(pp + 1) == ':' && (optarg = av[optind]) == 0 ) 144 | { 145 | /* 146 | * If the option argument is NULL, issue a warning and return a '?'. 147 | */ 148 | if ( opterr ) 149 | fprintf( stderr, "%s: option requires an argument -- %c\n", 150 | cmdname, opt ); 151 | opt = '?'; 152 | } 153 | else if ( optarg ) 154 | /* 155 | * Increment the option index past the argument. 156 | */ 157 | optind++; 158 | 159 | /* 160 | * Return the option character. 161 | */ 162 | return opt; 163 | } 164 | 165 | 166 | /* End */ 167 | -------------------------------------------------------------------------------- /src/mlgetopt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a cheap replacement for getopt() because that routine is not 3 | * available on some platforms and behaves differently on other platforms. 4 | * 5 | * This code is hereby expressly placed in the public domain. 6 | * mleisher@crl.nmsu.edu (Mark Leisher) 7 | * 10 October 1997 8 | */ 9 | 10 | #ifndef MLGETOPT_H_ 11 | #define MLGETOPT_H_ 12 | 13 | #ifdef VMS 14 | #define getopt local_getopt 15 | #define optind local_optind 16 | #define opterr local_opterr 17 | #endif 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | extern int opterr; 24 | extern int optind; 25 | extern char* optarg; 26 | 27 | extern int getopt( 28 | #ifdef __STDC__ 29 | int argc, 30 | char* const* argv, 31 | const char* pattern 32 | #endif 33 | ); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | #endif /* MLGETOPT_H_ */ 40 | 41 | 42 | /* End */ 43 | -------------------------------------------------------------------------------- /src/output.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* */ 3 | /* The FreeType project -- a free and portable quality TrueType renderer. */ 4 | /* */ 5 | /* Copyright 2015 by */ 6 | /* D. Turner, R.Wilhelm, and W. Lemberg */ 7 | /* */ 8 | /* */ 9 | /* output.h - string output routines for the FreeType demo programs. */ 10 | /* */ 11 | /****************************************************************************/ 12 | 13 | 14 | #ifndef OUTPUT_H_ 15 | #define OUTPUT_H_ 16 | 17 | 18 | #include 19 | #include FT_FREETYPE_H 20 | 21 | 22 | void 23 | put_ascii_string( char* out, 24 | FT_Byte* string, 25 | FT_UInt string_len, 26 | FT_UInt indent ); 27 | 28 | FT_UInt 29 | put_ascii_string_size( FT_Byte* string, 30 | FT_UInt string_len, 31 | FT_UInt indent ); 32 | 33 | void 34 | put_ascii( FT_Byte* string, 35 | FT_UInt string_len, 36 | FT_UInt indent ); 37 | 38 | 39 | void 40 | put_unicode_be16_string( char* out, 41 | FT_Byte* string, 42 | FT_UInt string_len, 43 | FT_UInt indent, 44 | FT_Int as_utf8 ); 45 | 46 | FT_UInt 47 | put_unicode_be16_string_size( FT_Byte* string, 48 | FT_UInt string_len, 49 | FT_UInt indent, 50 | FT_Int as_utf8 ); 51 | 52 | void 53 | put_unicode_be16( FT_Byte* string, 54 | FT_UInt string_len, 55 | FT_UInt indent, 56 | FT_Int as_utf8 ); 57 | 58 | 59 | #endif /* OUTPUT_H_ */ 60 | 61 | /* End */ 62 | -------------------------------------------------------------------------------- /src/testname.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | #include FT_FREETYPE_H 7 | 8 | 9 | int main( int argc, 10 | char* argv[] ) 11 | { 12 | FT_Library font_library; 13 | FT_Face font_face; 14 | FT_Bitmap bitmap; 15 | FT_GlyphSlot cur_glyph; 16 | FT_Glyph_Metrics glyph_metrics; 17 | 18 | int glyph_ind; 19 | int num_chars; 20 | char char_name[256]; 21 | 22 | 23 | if (argc != 2) 24 | exit( 1 ); 25 | if ( FT_Init_FreeType( &font_library ) ) 26 | exit( 1 ); 27 | if ( FT_New_Face( font_library, argv[1], 0 , &font_face ) ) 28 | exit( 1 ); 29 | if ( FT_Set_Char_Size( font_face , 0 , 768 , 300 , 300 ) ) 30 | exit( 1 ); 31 | 32 | num_chars = (int)font_face->num_glyphs; 33 | FT_Set_Transform( font_face , NULL , NULL ); 34 | 35 | for ( glyph_ind = 0 ; glyph_ind < num_chars; glyph_ind++ ) 36 | { 37 | if ( FT_Load_Glyph( font_face, glyph_ind, FT_LOAD_DEFAULT ) ) 38 | exit( 1 ); 39 | cur_glyph = font_face->glyph; 40 | if ( cur_glyph->format != FT_GLYPH_FORMAT_BITMAP ) 41 | if ( FT_Render_Glyph( font_face->glyph, FT_RENDER_MODE_MONO ) ) 42 | exit( 1 ); 43 | if ( FT_Get_Glyph_Name( font_face, glyph_ind, char_name, 16 ) ) 44 | exit( 1 ); 45 | 46 | bitmap = cur_glyph->bitmap; 47 | glyph_metrics = cur_glyph->metrics; 48 | 49 | printf( "Glyph %d name %s %ld %ld %ld %d %d\n", 50 | glyph_ind, 51 | char_name, 52 | glyph_metrics.horiBearingX / 64, 53 | glyph_metrics.horiBearingY / 64, 54 | glyph_metrics.horiAdvance / 64, 55 | bitmap.width , bitmap.rows ); 56 | } 57 | 58 | return 0; 59 | } 60 | 61 | 62 | /* END */ 63 | -------------------------------------------------------------------------------- /src/ttdebug.1: -------------------------------------------------------------------------------- 1 | .TH TTDEBUG 1 "May 2017" "FreeType 2.8" 2 | . 3 | . 4 | .SH NAME 5 | . 6 | ttdebug \- a TrueType bytecode debugger 7 | . 8 | . 9 | .SH SYNOPSIS 10 | . 11 | .B ttdebug 12 | .RI [ options ] 13 | .I index size font 14 | . 15 | . 16 | .SH DESCRIPTION 17 | . 18 | .B ttdebug 19 | is an interactive TrueType bytecode debugger working in a terminal. 20 | Its spartanic interface faintly resembles debuggers like 21 | .BR gdb . 22 | . 23 | .PP 24 | For the specified 25 | .IR font , 26 | a glyph with the given 27 | .I index 28 | and 29 | .I size 30 | is loaded, making it possible to trace the bytecode execution step by step. 31 | . 32 | .PP 33 | This program is part of the FreeType demos package. 34 | . 35 | . 36 | .SH OPTIONS 37 | . 38 | .TP 39 | .BI "\-I " ver 40 | Use TrueType interpreter version 41 | .IR ver . 42 | Available versions are depending on compilation options of FreeType; 43 | call 44 | .B ttdebug 45 | without an argument to get the actual list. 46 | . 47 | .TP 48 | .B \-v 49 | Show version. 50 | . 51 | .\" eof 52 | --------------------------------------------------------------------------------