Karsten Hopp 4c462a
To: vim_dev@googlegroups.com
Karsten Hopp 4c462a
Subject: Patch 7.4.393
Karsten Hopp 4c462a
Fcc: outbox
Karsten Hopp 4c462a
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 4c462a
Mime-Version: 1.0
Karsten Hopp 4c462a
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 4c462a
Content-Transfer-Encoding: 8bit
Karsten Hopp 4c462a
------------
Karsten Hopp 4c462a
Karsten Hopp 4c462a
Patch 7.4.393
Karsten Hopp 4c462a
Problem:    Text drawing on newer MS-Windows systems is suboptimal.  Some
Karsten Hopp 4c462a
	    multi-byte characters are not displayed, even though the same font
Karsten Hopp 4c462a
	    in Notepad can display them. (Srinath Avadhanula)
Karsten Hopp 4c462a
Solution:   Add the 'renderoptions' option to enable Direct-X drawing. (Taro
Karsten Hopp 4c462a
	    Muraoka)
Karsten Hopp 4c462a
Files:	    runtime/doc/eval.txt, runtime/doc/options.txt,
Karsten Hopp 4c462a
	    runtime/doc/various.txt, src/Make_cyg.mak, src/Make_ming.mak,
Karsten Hopp 4c462a
	    src/Make_mvc.mak, src/eval.c, src/gui_dwrite.cpp,
Karsten Hopp 4c462a
	    src/gui_dwrite.h, src/gui_w32.c, src/gui_w48.c, src/option.c,
Karsten Hopp 4c462a
	    src/option.h, src/version.c, src/vim.h, src/proto/gui_w32.pro
Karsten Hopp 4c462a
Karsten Hopp 4c462a
Karsten Hopp 4c462a
*** ../vim-7.4.392/runtime/doc/eval.txt	2014-06-25 18:15:18.442838249 +0200
Karsten Hopp 4c462a
--- runtime/doc/eval.txt	2014-08-06 14:35:24.871243363 +0200
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 6606,6611 ****
Karsten Hopp 4c462a
--- 6622,6628 ----
Karsten Hopp 4c462a
  dialog_gui		Compiled with GUI dialog support.
Karsten Hopp 4c462a
  diff			Compiled with |vimdiff| and 'diff' support.
Karsten Hopp 4c462a
  digraphs		Compiled with support for digraphs.
Karsten Hopp 4c462a
+ directx			Compiled with support for Direct-X and 'renderoptions'.
Karsten Hopp 4c462a
  dnd			Compiled with support for the "~ register |quote_~|.
Karsten Hopp 4c462a
  dos16			16 bits DOS version of Vim.
Karsten Hopp 4c462a
  dos32			32 bits DOS (DJGPP) version of Vim.
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 6744,6750 ****
Karsten Hopp 4c462a
  writebackup		Compiled with 'writebackup' default on.
Karsten Hopp 4c462a
  xfontset		Compiled with X fontset support |xfontset|.
Karsten Hopp 4c462a
  xim			Compiled with X input method support |xim|.
Karsten Hopp 4c462a
! xpm_w32			Compiled with pixmap support for Win32.
Karsten Hopp 4c462a
  xsmp			Compiled with X session management support.
Karsten Hopp 4c462a
  xsmp_interact		Compiled with interactive X session management support.
Karsten Hopp 4c462a
  xterm_clipboard		Compiled with support for xterm clipboard.
Karsten Hopp 4c462a
--- 6761,6769 ----
Karsten Hopp 4c462a
  writebackup		Compiled with 'writebackup' default on.
Karsten Hopp 4c462a
  xfontset		Compiled with X fontset support |xfontset|.
Karsten Hopp 4c462a
  xim			Compiled with X input method support |xim|.
Karsten Hopp 4c462a
! xpm			Compiled with pixmap support.
Karsten Hopp 4c462a
! xpm_w32			Compiled with pixmap support for Win32. (Only for
Karsten Hopp 4c462a
! 			backward compatibility. Use "xpm" instead.)
Karsten Hopp 4c462a
  xsmp			Compiled with X session management support.
Karsten Hopp 4c462a
  xsmp_interact		Compiled with interactive X session management support.
Karsten Hopp 4c462a
  xterm_clipboard		Compiled with support for xterm clipboard.
Karsten Hopp 4c462a
*** ../vim-7.4.392/runtime/doc/options.txt	2014-07-02 19:59:35.446375136 +0200
Karsten Hopp 4c462a
--- runtime/doc/options.txt	2014-08-06 14:36:59.591242682 +0200
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 5647,5652 ****
Karsten Hopp 4c462a
--- 5650,5726 ----
Karsten Hopp 4c462a
  	this option at the default "on".  Only switch it off when working with
Karsten Hopp 4c462a
  	old Vi scripts.
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
+                                                *'renderoptions'* *'rop'*
Karsten Hopp 4c462a
+ 'renderoptions' 'rop'	string  (default: empty)
Karsten Hopp 4c462a
+ 			global
Karsten Hopp 4c462a
+ 			{not in Vi}
Karsten Hopp 4c462a
+ 			{only available when compiled with GUI and DIRECTX on
Karsten Hopp 4c462a
+ 			MS-Windows}
Karsten Hopp 4c462a
+ 	Select a text renderer and set its options.  The options depend on the
Karsten Hopp 4c462a
+ 	renderer.
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ 	Syntax: >
Karsten Hopp 4c462a
+ 		set rop=type:{renderer}(,{name}:{value})*
Karsten Hopp 4c462a
+ <
Karsten Hopp 4c462a
+ 	Currently, only one optional renderer is available.
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ 	render	behavior    ~
Karsten Hopp 4c462a
+ 	directx	Vim will draw text using DirectX (DirectWrite).  It makes
Karsten Hopp 4c462a
+ 		drawn glyphs more beautiful than default GDI.
Karsten Hopp 4c462a
+ 		It requires 'encoding' is "utf-8", and only works on
Karsten Hopp 4c462a
+ 		MS-Windows Vista or newer version.
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ 		Options:
Karsten Hopp 4c462a
+ 		  name	    meaning		type	value       ~
Karsten Hopp 4c462a
+ 		  gamma	    gamma		float	1.0 - 2.2 (maybe)
Karsten Hopp 4c462a
+ 		  contrast  enhancedContrast	float	(unknown)
Karsten Hopp 4c462a
+ 		  level	    clearTypeLevel	float	(unknown)
Karsten Hopp 4c462a
+ 		  geom	    pixelGeometry	int	0 - 2 (see below)
Karsten Hopp 4c462a
+ 		  renmode   renderingMode	int	0 - 6 (see below)
Karsten Hopp 4c462a
+ 		  taamode   textAntialiasMode	int	0 - 3 (see below)
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ 		See this URL for detail:
Karsten Hopp 4c462a
+ 		  http://msdn.microsoft.com/en-us/library/dd368190.aspx
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ 		For geom: structure of a device pixel.
Karsten Hopp 4c462a
+ 		  0 - DWRITE_PIXEL_GEOMETRY_FLAT
Karsten Hopp 4c462a
+ 		  1 - DWRITE_PIXEL_GEOMETRY_RGB
Karsten Hopp 4c462a
+ 		  2 - DWRITE_PIXEL_GEOMETRY_BGR
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ 		See this URL for detail:
Karsten Hopp 4c462a
+ 		  http://msdn.microsoft.com/en-us/library/dd368114.aspx
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ 		For renmode: method of rendering glyphs.
Karsten Hopp 4c462a
+ 		  0 - DWRITE_RENDERING_MODE_DEFAULT
Karsten Hopp 4c462a
+ 		  1 - DWRITE_RENDERING_MODE_ALIASED
Karsten Hopp 4c462a
+ 		  2 - DWRITE_RENDERING_MODE_GDI_CLASSIC
Karsten Hopp 4c462a
+ 		  3 - DWRITE_RENDERING_MODE_GDI_NATURAL
Karsten Hopp 4c462a
+ 		  4 - DWRITE_RENDERING_MODE_NATURAL
Karsten Hopp 4c462a
+ 		  5 - DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC
Karsten Hopp 4c462a
+ 		  6 - DWRITE_RENDERING_MODE_OUTLINE
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ 		See this URL for detail:
Karsten Hopp 4c462a
+ 		  http://msdn.microsoft.com/en-us/library/dd368118.aspx
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ 		For taamode: antialiasing mode used for drawing text.
Karsten Hopp 4c462a
+ 		  0 - D2D1_TEXT_ANTIALIAS_MODE_DEFAULT
Karsten Hopp 4c462a
+ 		  1 - D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE
Karsten Hopp 4c462a
+ 		  2 - D2D1_TEXT_ANTIALIAS_MODE_GRAYSCALE
Karsten Hopp 4c462a
+ 		  3 - D2D1_TEXT_ANTIALIAS_MODE_ALIASED
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ 		See this URL for detail:
Karsten Hopp 4c462a
+ 		  http://msdn.microsoft.com/en-us/library/dd368170.aspx
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ 		Example: >
Karsten Hopp 4c462a
+ 		  set encoding=utf-8
Karsten Hopp 4c462a
+ 		  set gfn=Ricty_Diminished:h12:cSHIFTJIS
Karsten Hopp 4c462a
+ 		  set rop=type:directx
Karsten Hopp 4c462a
+ <
Karsten Hopp 4c462a
+ 		If select a raster font (Courier, Terminal or FixedSys) to
Karsten Hopp 4c462a
+ 		'guifont', it fallbacks to be drawn by GDI automatically.
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ 	Other render types are currently not supported.
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
  						*'report'*
Karsten Hopp 4c462a
  'report'		number	(default 2)
Karsten Hopp 4c462a
  			global
Karsten Hopp 4c462a
*** ../vim-7.4.392/runtime/doc/various.txt	2013-08-10 13:25:06.000000000 +0200
Karsten Hopp 4c462a
--- runtime/doc/various.txt	2014-08-06 14:37:28.843242472 +0200
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 320,325 ****
Karsten Hopp 4c462a
--- 337,343 ----
Karsten Hopp 4c462a
  N  *+dialog_con_gui*	Support for |:confirm| with GUI and console dialog.
Karsten Hopp 4c462a
  N  *+diff*		|vimdiff| and 'diff'
Karsten Hopp 4c462a
  N  *+digraphs*		|digraphs| *E196*
Karsten Hopp 4c462a
+ m  *+directx*		Win32 GUI only: DirectX and |'renderoptions'|
Karsten Hopp 4c462a
     *+dnd*		Support for DnD into the "~ register |quote_~|.
Karsten Hopp 4c462a
  B  *+emacs_tags*	|emacs-tags| files
Karsten Hopp 4c462a
  N  *+eval*		expression evaluation |eval.txt|
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 426,431 ****
Karsten Hopp 4c462a
--- 445,451 ----
Karsten Hopp 4c462a
  m  *+writebackup*	|'writebackup'| is default on
Karsten Hopp 4c462a
  m  *+xim*		X input method |xim|
Karsten Hopp 4c462a
     *+xfontset*		X fontset support |xfontset|
Karsten Hopp 4c462a
+    *+xpm*		pixmap support
Karsten Hopp 4c462a
  m  *+xpm_w32*		Win32 GUI only: pixmap support |w32-xpm-support|
Karsten Hopp 4c462a
     *+xsmp*		XSMP (X session management) support
Karsten Hopp 4c462a
     *+xsmp_interact*	interactive XSMP (X session management) support
Karsten Hopp 4c462a
*** ../vim-7.4.392/src/Make_cyg.mak	2013-12-11 15:06:36.000000000 +0100
Karsten Hopp 4c462a
--- src/Make_cyg.mak	2014-08-06 14:21:57.455249166 +0200
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 8,13 ****
Karsten Hopp 4c462a
--- 8,14 ----
Karsten Hopp 4c462a
  # Cygwin application use the Makefile (just like on Unix).
Karsten Hopp 4c462a
  #
Karsten Hopp 4c462a
  # GUI		no or yes: set to yes if you want the GUI version (yes)
Karsten Hopp 4c462a
+ # DIRECTX	no or yes: set to yes if you want use DirectWrite (no)
Karsten Hopp 4c462a
  # PERL		define to path to Perl dir to get Perl support (not defined)
Karsten Hopp 4c462a
  #   PERL_VER	  define to version of Perl being used (56)
Karsten Hopp 4c462a
  #   DYNAMIC_PERL  no or yes: set to yes to load the Perl DLL dynamically (yes)
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 88,93 ****
Karsten Hopp 4c462a
--- 89,98 ----
Karsten Hopp 4c462a
  ARCH = i386
Karsten Hopp 4c462a
  endif
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
+ ifndef DIRECTX
Karsten Hopp 4c462a
+ DIRECTX = no
Karsten Hopp 4c462a
+ endif
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
  ifndef WINVER
Karsten Hopp 4c462a
  WINVER = 0x0500
Karsten Hopp 4c462a
  endif
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 470,475 ****
Karsten Hopp 4c462a
--- 475,489 ----
Karsten Hopp 4c462a
  endif
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
  ##############################
Karsten Hopp 4c462a
+ ifeq (yes, $(DIRECTX))
Karsten Hopp 4c462a
+ # Only allow DIRECTX for a GUI build.
Karsten Hopp 4c462a
+ DEFINES += -DFEAT_DIRECTX -DDYNAMIC_DIRECTX
Karsten Hopp 4c462a
+ EXTRA_OBJS += $(OUTDIR)/gui_dwrite.o
Karsten Hopp 4c462a
+ EXTRA_LIBS += -ld2d1 -ldwrite
Karsten Hopp 4c462a
+ USE_STDCPLUS = yes
Karsten Hopp 4c462a
+ endif
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ ##############################
Karsten Hopp 4c462a
  ifdef XPM
Karsten Hopp 4c462a
  # Only allow XPM for a GUI build.
Karsten Hopp 4c462a
  DEFINES += -DFEAT_XPM_W32
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 495,505 ****
Karsten Hopp 4c462a
  DEFINES += -DFEAT_OLE
Karsten Hopp 4c462a
  EXTRA_OBJS += $(OUTDIR)/if_ole.o
Karsten Hopp 4c462a
  EXTRA_LIBS += -loleaut32
Karsten Hopp 4c462a
! ifeq (yes, $(STATIC_STDCPLUS))
Karsten Hopp 4c462a
! EXTRA_LIBS += -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic
Karsten Hopp 4c462a
! else
Karsten Hopp 4c462a
! EXTRA_LIBS += -lstdc++
Karsten Hopp 4c462a
! endif
Karsten Hopp 4c462a
  endif
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
  ##############################
Karsten Hopp 4c462a
--- 509,515 ----
Karsten Hopp 4c462a
  DEFINES += -DFEAT_OLE
Karsten Hopp 4c462a
  EXTRA_OBJS += $(OUTDIR)/if_ole.o
Karsten Hopp 4c462a
  EXTRA_LIBS += -loleaut32
Karsten Hopp 4c462a
! USE_STDCPLUS = yes
Karsten Hopp 4c462a
  endif
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
  ##############################
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 513,518 ****
Karsten Hopp 4c462a
--- 523,537 ----
Karsten Hopp 4c462a
  DIRSLASH = \\
Karsten Hopp 4c462a
  endif
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
+ ##############################
Karsten Hopp 4c462a
+ ifeq (yes, $(USE_STDCPLUS))
Karsten Hopp 4c462a
+ ifeq (yes, $(STATIC_STDCPLUS))
Karsten Hopp 4c462a
+ EXTRA_LIBS += -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic
Karsten Hopp 4c462a
+ else
Karsten Hopp 4c462a
+ EXTRA_LIBS += -lstdc++
Karsten Hopp 4c462a
+ endif
Karsten Hopp 4c462a
+ endif
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
  #>>>>> end of choices
Karsten Hopp 4c462a
  ###########################################################################
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 643,648 ****
Karsten Hopp 4c462a
--- 662,670 ----
Karsten Hopp 4c462a
  $(OUTDIR)/gui_w32.o:	gui_w32.c gui_w48.c $(INCL)
Karsten Hopp 4c462a
  	$(CC) -c $(CFLAGS) gui_w32.c -o $(OUTDIR)/gui_w32.o
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
+ $(OUTDIR)/gui_dwrite.o:	gui_dwrite.cpp $(INCL) gui_dwrite.h
Karsten Hopp 4c462a
+ 	$(CC) -c $(CFLAGS) gui_dwrite.cpp -o $(OUTDIR)/gui_dwrite.o
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
  $(OUTDIR)/if_cscope.o:	if_cscope.c $(INCL) if_cscope.h
Karsten Hopp 4c462a
  	$(CC) -c $(CFLAGS) if_cscope.c -o $(OUTDIR)/if_cscope.o
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
*** ../vim-7.4.392/src/Make_ming.mak	2014-01-06 15:44:59.000000000 +0100
Karsten Hopp 4c462a
--- src/Make_ming.mak	2014-08-06 14:21:57.455249166 +0200
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 31,36 ****
Karsten Hopp 4c462a
--- 31,38 ----
Karsten Hopp 4c462a
  OPTIMIZE=MAXSPEED
Karsten Hopp 4c462a
  # set to yes to make gvim, no for vim
Karsten Hopp 4c462a
  GUI=yes
Karsten Hopp 4c462a
+ # set to yes if you want to use DirectWrite (DirectX)
Karsten Hopp 4c462a
+ DIRECTX=no
Karsten Hopp 4c462a
  # FEATURES=[TINY | SMALL  | NORMAL | BIG | HUGE]
Karsten Hopp 4c462a
  # Set to TINY to make minimal version (few features).
Karsten Hopp 4c462a
  FEATURES=BIG
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 456,461 ****
Karsten Hopp 4c462a
--- 458,471 ----
Karsten Hopp 4c462a
  endif
Karsten Hopp 4c462a
  endif
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
+ # DirectWrite (DirectX)
Karsten Hopp 4c462a
+ ifeq ($(DIRECTX),yes)
Karsten Hopp 4c462a
+ # Only allow DirectWrite for a GUI build.
Karsten Hopp 4c462a
+ ifeq (yes, $(GUI))
Karsten Hopp 4c462a
+ DEFINES += -DFEAT_DIRECTX -DDYNAMIC_DIRECTX
Karsten Hopp 4c462a
+ endif
Karsten Hopp 4c462a
+ endif
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
  # Only allow XPM for a GUI build.
Karsten Hopp 4c462a
  ifeq (yes, $(GUI))
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 593,598 ****
Karsten Hopp 4c462a
--- 603,616 ----
Karsten Hopp 4c462a
  LIB += -lwsock32
Karsten Hopp 4c462a
  endif
Karsten Hopp 4c462a
  endif
Karsten Hopp 4c462a
+ ifeq ($(DIRECTX),yes)
Karsten Hopp 4c462a
+ # Only allow DIRECTX for a GUI build.
Karsten Hopp 4c462a
+ ifeq (yes, $(GUI))
Karsten Hopp 4c462a
+ OBJ += $(OUTDIR)/gui_dwrite.o
Karsten Hopp 4c462a
+ LIB += -ld2d1 -ldwrite
Karsten Hopp 4c462a
+ USE_STDCPLUS = yes
Karsten Hopp 4c462a
+ endif
Karsten Hopp 4c462a
+ endif
Karsten Hopp 4c462a
  ifdef XPM
Karsten Hopp 4c462a
  # Only allow XPM for a GUI build.
Karsten Hopp 4c462a
  ifeq (yes, $(GUI))
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 650,660 ****
Karsten Hopp 4c462a
  ifeq (yes, $(OLE))
Karsten Hopp 4c462a
  LIB += -loleaut32
Karsten Hopp 4c462a
  OBJ += $(OUTDIR)/if_ole.o
Karsten Hopp 4c462a
! ifeq (yes, $(STATIC_STDCPLUS))
Karsten Hopp 4c462a
! LIB += -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic
Karsten Hopp 4c462a
! else
Karsten Hopp 4c462a
! LIB += -lstdc++
Karsten Hopp 4c462a
! endif
Karsten Hopp 4c462a
  endif
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
  ifeq (yes, $(MBYTE))
Karsten Hopp 4c462a
--- 668,674 ----
Karsten Hopp 4c462a
  ifeq (yes, $(OLE))
Karsten Hopp 4c462a
  LIB += -loleaut32
Karsten Hopp 4c462a
  OBJ += $(OUTDIR)/if_ole.o
Karsten Hopp 4c462a
! USE_STDCPLUS = yes
Karsten Hopp 4c462a
  endif
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
  ifeq (yes, $(MBYTE))
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 678,683 ****
Karsten Hopp 4c462a
--- 692,705 ----
Karsten Hopp 4c462a
  DEFINES+=-DDYNAMIC_ICONV
Karsten Hopp 4c462a
  endif
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
+ ifeq (yes, $(USE_STDCPLUS))
Karsten Hopp 4c462a
+ ifeq (yes, $(STATIC_STDCPLUS))
Karsten Hopp 4c462a
+ LIB += -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic
Karsten Hopp 4c462a
+ else
Karsten Hopp 4c462a
+ LIB += -lstdc++
Karsten Hopp 4c462a
+ endif
Karsten Hopp 4c462a
+ endif
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
  all: $(TARGET) vimrun.exe xxd/xxd.exe install.exe uninstal.exe GvimExt/gvimext.dll
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
  vimrun.exe: vimrun.c
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 751,756 ****
Karsten Hopp 4c462a
--- 773,781 ----
Karsten Hopp 4c462a
  $(OUTDIR)/gui_w32.o:	gui_w32.c gui_w48.c $(INCL)
Karsten Hopp 4c462a
  	$(CC) -c $(CFLAGS) gui_w32.c -o $(OUTDIR)/gui_w32.o
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
+ $(OUTDIR)/gui_dwrite.o:	gui_dwrite.cpp $(INCL) gui_dwrite.h
Karsten Hopp 4c462a
+ 	$(CC) -c $(CFLAGS) gui_dwrite.cpp -o $(OUTDIR)/gui_dwrite.o
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
  $(OUTDIR)/if_cscope.o:	if_cscope.c $(INCL) if_cscope.h
Karsten Hopp 4c462a
  	$(CC) -c $(CFLAGS) if_cscope.c -o $(OUTDIR)/if_cscope.o
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
*** ../vim-7.4.392/src/Make_mvc.mak	2014-05-22 16:29:03.374353200 +0200
Karsten Hopp 4c462a
--- src/Make_mvc.mak	2014-08-06 14:21:57.455249166 +0200
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 24,29 ****
Karsten Hopp 4c462a
--- 24,32 ----
Karsten Hopp 4c462a
  #
Karsten Hopp 4c462a
  #	GUI interface: GUI=yes (default is no)
Karsten Hopp 4c462a
  #
Karsten Hopp 4c462a
+ #	GUI with DirectWrite(DirectX): DIRECTX=yes
Karsten Hopp 4c462a
+ #	  (default is no, requires GUI=yes)
Karsten Hopp 4c462a
+ #
Karsten Hopp 4c462a
  #	OLE interface: OLE=yes (usually with GUI=yes)
Karsten Hopp 4c462a
  #
Karsten Hopp 4c462a
  #	Multibyte support: MBYTE=yes (default is no)
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 168,173 ****
Karsten Hopp 4c462a
--- 171,179 ----
Karsten Hopp 4c462a
  !else
Karsten Hopp 4c462a
  OBJDIR = .\ObjC
Karsten Hopp 4c462a
  !endif
Karsten Hopp 4c462a
+ !if "$(DIRECTX)" == "yes"
Karsten Hopp 4c462a
+ OBJDIR = $(OBJDIR)X
Karsten Hopp 4c462a
+ !endif
Karsten Hopp 4c462a
  !if "$(OLE)" == "yes"
Karsten Hopp 4c462a
  OBJDIR = $(OBJDIR)O
Karsten Hopp 4c462a
  !endif
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 292,297 ****
Karsten Hopp 4c462a
--- 298,310 ----
Karsten Hopp 4c462a
  NETBEANS_LIB	= WSock32.lib
Karsten Hopp 4c462a
  !endif
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
+ # DirectWrite(DirectX)
Karsten Hopp 4c462a
+ !if "$(DIRECTX)" == "yes"
Karsten Hopp 4c462a
+ DIRECTX_DEFS	= -DFEAT_DIRECTX -DDYNAMIC_DIRECTX
Karsten Hopp 4c462a
+ DIRECTX_INCL	= gui_dwrite.h
Karsten Hopp 4c462a
+ DIRECTX_OBJ	= $(OUTDIR)\gui_dwrite.obj
Karsten Hopp 4c462a
+ !endif
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
  !ifndef XPM
Karsten Hopp 4c462a
  # XPM is not set, use the included xpm files, depending on the architecture.
Karsten Hopp 4c462a
  !if "$(CPU)" == "AMD64"
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 642,647 ****
Karsten Hopp 4c462a
--- 655,666 ----
Karsten Hopp 4c462a
  SUBSYSTEM = console
Karsten Hopp 4c462a
  !endif
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
+ !if "$(GUI)" == "yes" && "$(DIRECTX)" == "yes"
Karsten Hopp 4c462a
+ CFLAGS = $(CFLAGS) $(DIRECTX_DEFS)
Karsten Hopp 4c462a
+ GUI_INCL = $(GUI_INCL) $(DIRECTX_INCL)
Karsten Hopp 4c462a
+ GUI_OBJ = $(GUI_OBJ) $(DIRECTX_OBJ)
Karsten Hopp 4c462a
+ !endif
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
  # iconv.dll library (dynamically loaded)
Karsten Hopp 4c462a
  !ifndef ICONV
Karsten Hopp 4c462a
  ICONV = yes
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 1107,1112 ****
Karsten Hopp 4c462a
--- 1126,1133 ----
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
  $(OUTDIR)/gui_w32.obj:	$(OUTDIR) gui_w32.c gui_w48.c $(INCL) $(GUI_INCL)
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
+ $(OUTDIR)/gui_dwrite.obj:	$(OUTDIR) gui_dwrite.cpp $(INCL) $(GUI_INCL)
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
  $(OUTDIR)/if_cscope.obj: $(OUTDIR) if_cscope.c  $(INCL)
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
  $(OUTDIR)/if_lua.obj: $(OUTDIR) if_lua.c  $(INCL)
Karsten Hopp 4c462a
*** ../vim-7.4.392/src/eval.c	2014-08-06 13:36:56.091268582 +0200
Karsten Hopp 4c462a
--- src/eval.c	2014-08-06 14:21:57.459249166 +0200
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 12464,12469 ****
Karsten Hopp 4c462a
--- 12464,12472 ----
Karsten Hopp 4c462a
  #ifdef FEAT_DIGRAPHS
Karsten Hopp 4c462a
  	"digraphs",
Karsten Hopp 4c462a
  #endif
Karsten Hopp 4c462a
+ #ifdef FEAT_DIRECTX
Karsten Hopp 4c462a
+ 	"directx",
Karsten Hopp 4c462a
+ #endif
Karsten Hopp 4c462a
  #ifdef FEAT_DND
Karsten Hopp 4c462a
  	"dnd",
Karsten Hopp 4c462a
  #endif
Karsten Hopp 4c462a
*** ../vim-7.4.392/src/gui_dwrite.cpp	2014-08-06 14:49:19.663237363 +0200
Karsten Hopp 4c462a
--- src/gui_dwrite.cpp	2014-08-06 14:39:48.775241466 +0200
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 0 ****
Karsten Hopp 4c462a
--- 1,901 ----
Karsten Hopp 4c462a
+ /* vi:set ts=8 sts=4 sw=4 noet: */
Karsten Hopp 4c462a
+ /*
Karsten Hopp 4c462a
+  * Author: MURAOKA Taro <koron.kaoriya@gmail.com>
Karsten Hopp 4c462a
+  *
Karsten Hopp 4c462a
+  * Contributors:
Karsten Hopp 4c462a
+  *  - Ken Takata
Karsten Hopp 4c462a
+  *
Karsten Hopp 4c462a
+  * Copyright (C) 2013 MURAOKA Taro <koron.kaoriya@gmail.com>
Karsten Hopp 4c462a
+  * THIS FILE IS DISTRIBUTED UNDER THE VIM LICENSE.
Karsten Hopp 4c462a
+  */
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ #define WIN32_LEAN_AND_MEAN
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ #ifndef DYNAMIC_DIRECTX
Karsten Hopp 4c462a
+ # if WINVER < 0x0600
Karsten Hopp 4c462a
+ #  error WINVER must be 0x0600 or above to use DirectWrite(DirectX)
Karsten Hopp 4c462a
+ # endif
Karsten Hopp 4c462a
+ #endif
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ #include <windows.h>
Karsten Hopp 4c462a
+ #include <crtdbg.h>
Karsten Hopp 4c462a
+ #include <assert.h>
Karsten Hopp 4c462a
+ #include <math.h>
Karsten Hopp 4c462a
+ #include <d2d1.h>
Karsten Hopp 4c462a
+ #include <d2d1helper.h>
Karsten Hopp 4c462a
+ #include <dwrite.h>
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ #include "gui_dwrite.h"
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ #ifdef __MINGW32__
Karsten Hopp 4c462a
+ # define __maybenull	SAL__maybenull
Karsten Hopp 4c462a
+ # define __in		SAL__in
Karsten Hopp 4c462a
+ # define __out		SAL__out
Karsten Hopp 4c462a
+ #endif
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ #ifdef DYNAMIC_DIRECTX
Karsten Hopp 4c462a
+ extern "C" HINSTANCE vimLoadLib(char *name);
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ typedef int (WINAPI *PGETUSERDEFAULTLOCALENAME)(LPWSTR, int);
Karsten Hopp 4c462a
+ typedef HRESULT (WINAPI *PD2D1CREATEFACTORY)(D2D1_FACTORY_TYPE,
Karsten Hopp 4c462a
+ 	REFIID, const D2D1_FACTORY_OPTIONS *, void **);
Karsten Hopp 4c462a
+ typedef HRESULT (WINAPI *PDWRITECREATEFACTORY)(DWRITE_FACTORY_TYPE,
Karsten Hopp 4c462a
+ 	REFIID, IUnknown **);
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ static HINSTANCE hD2D1DLL = NULL;
Karsten Hopp 4c462a
+ static HINSTANCE hDWriteDLL = NULL;
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ static PGETUSERDEFAULTLOCALENAME pGetUserDefaultLocaleName = NULL;
Karsten Hopp 4c462a
+ static PD2D1CREATEFACTORY pD2D1CreateFactory = NULL;
Karsten Hopp 4c462a
+ static PDWRITECREATEFACTORY pDWriteCreateFactory = NULL;
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ #define GetUserDefaultLocaleName	(*pGetUserDefaultLocaleName)
Karsten Hopp 4c462a
+ #define D2D1CreateFactory		(*pD2D1CreateFactory)
Karsten Hopp 4c462a
+ #define DWriteCreateFactory		(*pDWriteCreateFactory)
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     static void
Karsten Hopp 4c462a
+ unload(HINSTANCE &hinst)
Karsten Hopp 4c462a
+ {
Karsten Hopp 4c462a
+     if (hinst != NULL)
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	FreeLibrary(hinst);
Karsten Hopp 4c462a
+ 	hinst = NULL;
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ }
Karsten Hopp 4c462a
+ #endif // DYNAMIC_DIRECTX
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ template <class T> inline void SafeRelease(T **ppT)
Karsten Hopp 4c462a
+ {
Karsten Hopp 4c462a
+     if (*ppT)
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	(*ppT)->Release();
Karsten Hopp 4c462a
+ 	*ppT = NULL;
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ struct GdiTextRendererContext
Karsten Hopp 4c462a
+ {
Karsten Hopp 4c462a
+     // const fields.
Karsten Hopp 4c462a
+     COLORREF color;
Karsten Hopp 4c462a
+     FLOAT cellWidth;
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     // working fields.
Karsten Hopp 4c462a
+     FLOAT offsetX;
Karsten Hopp 4c462a
+ };
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     static DWRITE_PIXEL_GEOMETRY
Karsten Hopp 4c462a
+ ToPixelGeometry(int value)
Karsten Hopp 4c462a
+ {
Karsten Hopp 4c462a
+     switch (value)
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	default:
Karsten Hopp 4c462a
+ 	case 0:
Karsten Hopp 4c462a
+ 	    return DWRITE_PIXEL_GEOMETRY_FLAT;
Karsten Hopp 4c462a
+ 	case 1:
Karsten Hopp 4c462a
+ 	    return DWRITE_PIXEL_GEOMETRY_RGB;
Karsten Hopp 4c462a
+ 	case 2:
Karsten Hopp 4c462a
+ 	    return DWRITE_PIXEL_GEOMETRY_BGR;
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     static int
Karsten Hopp 4c462a
+ ToInt(DWRITE_PIXEL_GEOMETRY value)
Karsten Hopp 4c462a
+ {
Karsten Hopp 4c462a
+     switch (value)
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	case DWRITE_PIXEL_GEOMETRY_FLAT:
Karsten Hopp 4c462a
+ 	    return 0;
Karsten Hopp 4c462a
+ 	case DWRITE_PIXEL_GEOMETRY_RGB:
Karsten Hopp 4c462a
+ 	    return 1;
Karsten Hopp 4c462a
+ 	case DWRITE_PIXEL_GEOMETRY_BGR:
Karsten Hopp 4c462a
+ 	    return 2;
Karsten Hopp 4c462a
+ 	default:
Karsten Hopp 4c462a
+ 	    return -1;
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     static DWRITE_RENDERING_MODE
Karsten Hopp 4c462a
+ ToRenderingMode(int value)
Karsten Hopp 4c462a
+ {
Karsten Hopp 4c462a
+     switch (value)
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	default:
Karsten Hopp 4c462a
+ 	case 0:
Karsten Hopp 4c462a
+ 	    return DWRITE_RENDERING_MODE_DEFAULT;
Karsten Hopp 4c462a
+ 	case 1:
Karsten Hopp 4c462a
+ 	    return DWRITE_RENDERING_MODE_ALIASED;
Karsten Hopp 4c462a
+ 	case 2:
Karsten Hopp 4c462a
+ 	    return DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC;
Karsten Hopp 4c462a
+ 	case 3:
Karsten Hopp 4c462a
+ 	    return DWRITE_RENDERING_MODE_CLEARTYPE_GDI_NATURAL;
Karsten Hopp 4c462a
+ 	case 4:
Karsten Hopp 4c462a
+ 	    return DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL;
Karsten Hopp 4c462a
+ 	case 5:
Karsten Hopp 4c462a
+ 	    return DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC;
Karsten Hopp 4c462a
+ 	case 6:
Karsten Hopp 4c462a
+ 	    return DWRITE_RENDERING_MODE_OUTLINE;
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     static D2D1_TEXT_ANTIALIAS_MODE
Karsten Hopp 4c462a
+ ToTextAntialiasMode(int value)
Karsten Hopp 4c462a
+ {
Karsten Hopp 4c462a
+     switch (value)
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	default:
Karsten Hopp 4c462a
+ 	case 0:
Karsten Hopp 4c462a
+ 	    return D2D1_TEXT_ANTIALIAS_MODE_DEFAULT;
Karsten Hopp 4c462a
+ 	case 1:
Karsten Hopp 4c462a
+ 	    return D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE;
Karsten Hopp 4c462a
+ 	case 2:
Karsten Hopp 4c462a
+ 	    return D2D1_TEXT_ANTIALIAS_MODE_GRAYSCALE;
Karsten Hopp 4c462a
+ 	case 3:
Karsten Hopp 4c462a
+ 	    return D2D1_TEXT_ANTIALIAS_MODE_ALIASED;
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     static int
Karsten Hopp 4c462a
+ ToInt(DWRITE_RENDERING_MODE value)
Karsten Hopp 4c462a
+ {
Karsten Hopp 4c462a
+     switch (value)
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	case DWRITE_RENDERING_MODE_DEFAULT:
Karsten Hopp 4c462a
+ 	    return 0;
Karsten Hopp 4c462a
+ 	case DWRITE_RENDERING_MODE_ALIASED:
Karsten Hopp 4c462a
+ 	    return 1;
Karsten Hopp 4c462a
+ 	case DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC:
Karsten Hopp 4c462a
+ 	    return 2;
Karsten Hopp 4c462a
+ 	case DWRITE_RENDERING_MODE_CLEARTYPE_GDI_NATURAL:
Karsten Hopp 4c462a
+ 	    return 3;
Karsten Hopp 4c462a
+ 	case DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL:
Karsten Hopp 4c462a
+ 	    return 4;
Karsten Hopp 4c462a
+ 	case DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC:
Karsten Hopp 4c462a
+ 	    return 5;
Karsten Hopp 4c462a
+ 	case DWRITE_RENDERING_MODE_OUTLINE:
Karsten Hopp 4c462a
+ 	    return 6;
Karsten Hopp 4c462a
+ 	default:
Karsten Hopp 4c462a
+ 	    return -1;
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ class AdjustedGlyphRun : public DWRITE_GLYPH_RUN
Karsten Hopp 4c462a
+ {
Karsten Hopp 4c462a
+ private:
Karsten Hopp 4c462a
+     FLOAT mDelta;
Karsten Hopp 4c462a
+     FLOAT *mAdjustedAdvances;
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ public:
Karsten Hopp 4c462a
+     AdjustedGlyphRun(
Karsten Hopp 4c462a
+ 	    const DWRITE_GLYPH_RUN *glyphRun,
Karsten Hopp 4c462a
+ 	    FLOAT cellWidth) :
Karsten Hopp 4c462a
+ 	DWRITE_GLYPH_RUN(*glyphRun),
Karsten Hopp 4c462a
+ 	mDelta(0.0f),
Karsten Hopp 4c462a
+ 	mAdjustedAdvances(new FLOAT[glyphRun->glyphCount])
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	assert(cellWidth != 0.0f);
Karsten Hopp 4c462a
+ 	for (UINT32 i = 0; i < glyphRun->glyphCount; ++i)
Karsten Hopp 4c462a
+ 	{
Karsten Hopp 4c462a
+ 	    FLOAT orig = glyphRun->glyphAdvances[i];
Karsten Hopp 4c462a
+ 	    FLOAT adjusted = adjustToCell(orig, cellWidth);
Karsten Hopp 4c462a
+ 	    mAdjustedAdvances[i] = adjusted;
Karsten Hopp 4c462a
+ 	    mDelta += adjusted - orig;
Karsten Hopp 4c462a
+ 	}
Karsten Hopp 4c462a
+ 	glyphAdvances = mAdjustedAdvances;
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     ~AdjustedGlyphRun(void)
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	delete[] mAdjustedAdvances;
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     FLOAT getDelta(void) const
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	return mDelta;
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     static FLOAT adjustToCell(FLOAT value, FLOAT cellWidth)
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	int cellCount = (int)floor(value / cellWidth + 0.5f);
Karsten Hopp 4c462a
+ 	if (cellCount < 1)
Karsten Hopp 4c462a
+ 	    cellCount = 1;
Karsten Hopp 4c462a
+ 	return cellCount * cellWidth;
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ };
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ class GdiTextRenderer : public IDWriteTextRenderer
Karsten Hopp 4c462a
+ {
Karsten Hopp 4c462a
+ public:
Karsten Hopp 4c462a
+     GdiTextRenderer(
Karsten Hopp 4c462a
+ 	    IDWriteBitmapRenderTarget* bitmapRenderTarget,
Karsten Hopp 4c462a
+ 	    IDWriteRenderingParams* renderingParams) :
Karsten Hopp 4c462a
+ 	cRefCount_(0),
Karsten Hopp 4c462a
+ 	pRenderTarget_(bitmapRenderTarget),
Karsten Hopp 4c462a
+ 	pRenderingParams_(renderingParams)
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	pRenderTarget_->AddRef();
Karsten Hopp 4c462a
+ 	pRenderingParams_->AddRef();
Karsten Hopp 4c462a
+ 	AddRef();
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     ~GdiTextRenderer()
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	SafeRelease(&pRenderTarget_);
Karsten Hopp 4c462a
+ 	SafeRelease(&pRenderingParams_);
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     IFACEMETHOD(IsPixelSnappingDisabled)(
Karsten Hopp 4c462a
+ 	__maybenull void* clientDrawingContext,
Karsten Hopp 4c462a
+ 	__out BOOL* isDisabled)
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	*isDisabled = FALSE;
Karsten Hopp 4c462a
+ 	return S_OK;
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     IFACEMETHOD(GetCurrentTransform)(
Karsten Hopp 4c462a
+ 	__maybenull void* clientDrawingContext,
Karsten Hopp 4c462a
+ 	__out DWRITE_MATRIX* transform)
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	//forward the render target's transform
Karsten Hopp 4c462a
+ 	pRenderTarget_->GetCurrentTransform(transform);
Karsten Hopp 4c462a
+ 	return S_OK;
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     IFACEMETHOD(GetPixelsPerDip)(
Karsten Hopp 4c462a
+ 	__maybenull void* clientDrawingContext,
Karsten Hopp 4c462a
+ 	__out FLOAT* pixelsPerDip)
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	*pixelsPerDip = pRenderTarget_->GetPixelsPerDip();
Karsten Hopp 4c462a
+ 	return S_OK;
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     IFACEMETHOD(DrawGlyphRun)(
Karsten Hopp 4c462a
+ 	__maybenull void* clientDrawingContext,
Karsten Hopp 4c462a
+ 	FLOAT baselineOriginX,
Karsten Hopp 4c462a
+ 	FLOAT baselineOriginY,
Karsten Hopp 4c462a
+ 	DWRITE_MEASURING_MODE measuringMode,
Karsten Hopp 4c462a
+ 	__in DWRITE_GLYPH_RUN const* glyphRun,
Karsten Hopp 4c462a
+ 	__in DWRITE_GLYPH_RUN_DESCRIPTION const* glyphRunDescription,
Karsten Hopp 4c462a
+ 	IUnknown* clientDrawingEffect)
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	HRESULT hr = S_OK;
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ 	GdiTextRendererContext *context =
Karsten Hopp 4c462a
+ 	    reinterpret_cast<GdiTextRendererContext*>(clientDrawingContext);
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ 	AdjustedGlyphRun adjustedGlyphRun(glyphRun, context->cellWidth);
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ 	// Pass on the drawing call to the render target to do the real work.
Karsten Hopp 4c462a
+ 	RECT dirtyRect = {0};
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ 	hr = pRenderTarget_->DrawGlyphRun(
Karsten Hopp 4c462a
+ 		baselineOriginX + context->offsetX,
Karsten Hopp 4c462a
+ 		baselineOriginY,
Karsten Hopp 4c462a
+ 		measuringMode,
Karsten Hopp 4c462a
+ 		&adjustedGlyphRun,
Karsten Hopp 4c462a
+ 		pRenderingParams_,
Karsten Hopp 4c462a
+ 		context->color,
Karsten Hopp 4c462a
+ 		&dirtyRect);
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ 	context->offsetX += adjustedGlyphRun.getDelta();
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ 	return hr;
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     IFACEMETHOD(DrawUnderline)(
Karsten Hopp 4c462a
+ 	__maybenull void* clientDrawingContext,
Karsten Hopp 4c462a
+ 	FLOAT baselineOriginX,
Karsten Hopp 4c462a
+ 	FLOAT baselineOriginY,
Karsten Hopp 4c462a
+ 	__in DWRITE_UNDERLINE const* underline,
Karsten Hopp 4c462a
+ 	IUnknown* clientDrawingEffect)
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	return E_NOTIMPL;
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     IFACEMETHOD(DrawStrikethrough)(
Karsten Hopp 4c462a
+ 	__maybenull void* clientDrawingContext,
Karsten Hopp 4c462a
+ 	FLOAT baselineOriginX,
Karsten Hopp 4c462a
+ 	FLOAT baselineOriginY,
Karsten Hopp 4c462a
+ 	__in DWRITE_STRIKETHROUGH const* strikethrough,
Karsten Hopp 4c462a
+ 	IUnknown* clientDrawingEffect)
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	return E_NOTIMPL;
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     IFACEMETHOD(DrawInlineObject)(
Karsten Hopp 4c462a
+ 	__maybenull void* clientDrawingContext,
Karsten Hopp 4c462a
+ 	FLOAT originX,
Karsten Hopp 4c462a
+ 	FLOAT originY,
Karsten Hopp 4c462a
+ 	IDWriteInlineObject* inlineObject,
Karsten Hopp 4c462a
+ 	BOOL isSideways,
Karsten Hopp 4c462a
+ 	BOOL isRightToLeft,
Karsten Hopp 4c462a
+ 	IUnknown* clientDrawingEffect)
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	return E_NOTIMPL;
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ public:
Karsten Hopp 4c462a
+     IFACEMETHOD_(unsigned long, AddRef) ()
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	return InterlockedIncrement(&cRefCount_);
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     IFACEMETHOD_(unsigned long, Release) ()
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	long newCount = InterlockedDecrement(&cRefCount_);
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ 	if (newCount == 0)
Karsten Hopp 4c462a
+ 	{
Karsten Hopp 4c462a
+ 	    delete this;
Karsten Hopp 4c462a
+ 	    return 0;
Karsten Hopp 4c462a
+ 	}
Karsten Hopp 4c462a
+ 	return newCount;
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     IFACEMETHOD(QueryInterface)(
Karsten Hopp 4c462a
+ 	IID const& riid,
Karsten Hopp 4c462a
+ 	void** ppvObject)
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	if (__uuidof(IDWriteTextRenderer) == riid)
Karsten Hopp 4c462a
+ 	{
Karsten Hopp 4c462a
+ 	    *ppvObject = this;
Karsten Hopp 4c462a
+ 	}
Karsten Hopp 4c462a
+ 	else if (__uuidof(IDWritePixelSnapping) == riid)
Karsten Hopp 4c462a
+ 	{
Karsten Hopp 4c462a
+ 	    *ppvObject = this;
Karsten Hopp 4c462a
+ 	}
Karsten Hopp 4c462a
+ 	else if (__uuidof(IUnknown) == riid)
Karsten Hopp 4c462a
+ 	{
Karsten Hopp 4c462a
+ 	    *ppvObject = this;
Karsten Hopp 4c462a
+ 	}
Karsten Hopp 4c462a
+ 	else
Karsten Hopp 4c462a
+ 	{
Karsten Hopp 4c462a
+ 	    *ppvObject = NULL;
Karsten Hopp 4c462a
+ 	    return E_FAIL;
Karsten Hopp 4c462a
+ 	}
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ 	return S_OK;
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ private:
Karsten Hopp 4c462a
+     unsigned long cRefCount_;
Karsten Hopp 4c462a
+     IDWriteBitmapRenderTarget* pRenderTarget_;
Karsten Hopp 4c462a
+     IDWriteRenderingParams* pRenderingParams_;
Karsten Hopp 4c462a
+ };
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ struct DWriteContext {
Karsten Hopp 4c462a
+     FLOAT mDpiScaleX;
Karsten Hopp 4c462a
+     FLOAT mDpiScaleY;
Karsten Hopp 4c462a
+     bool mDrawing;
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     ID2D1Factory *mD2D1Factory;
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     ID2D1DCRenderTarget *mRT;
Karsten Hopp 4c462a
+     ID2D1SolidColorBrush *mBrush;
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     IDWriteFactory *mDWriteFactory;
Karsten Hopp 4c462a
+     IDWriteGdiInterop *mGdiInterop;
Karsten Hopp 4c462a
+     IDWriteRenderingParams *mRenderingParams;
Karsten Hopp 4c462a
+     IDWriteTextFormat *mTextFormat;
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     HFONT mLastHFont;
Karsten Hopp 4c462a
+     DWRITE_FONT_WEIGHT mFontWeight;
Karsten Hopp 4c462a
+     DWRITE_FONT_STYLE mFontStyle;
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     D2D1_TEXT_ANTIALIAS_MODE mTextAntialiasMode;
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     // METHODS
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     DWriteContext();
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     virtual ~DWriteContext();
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     HRESULT SetLOGFONT(const LOGFONTW &logFont, float fontSize);
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     void SetFont(HFONT hFont);
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     void SetFont(const LOGFONTW &logFont);
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     void DrawText(HDC hdc, const WCHAR* text, int len,
Karsten Hopp 4c462a
+ 	int x, int y, int w, int h, int cellWidth, COLORREF color);
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     float PixelsToDipsX(int x);
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     float PixelsToDipsY(int y);
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     void SetRenderingParams(
Karsten Hopp 4c462a
+ 	    const DWriteRenderingParams *params);
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     DWriteRenderingParams *GetRenderingParams(
Karsten Hopp 4c462a
+ 	    DWriteRenderingParams *params);
Karsten Hopp 4c462a
+ };
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ DWriteContext::DWriteContext() :
Karsten Hopp 4c462a
+     mDpiScaleX(1.f),
Karsten Hopp 4c462a
+     mDpiScaleY(1.f),
Karsten Hopp 4c462a
+     mDrawing(false),
Karsten Hopp 4c462a
+     mD2D1Factory(NULL),
Karsten Hopp 4c462a
+     mRT(NULL),
Karsten Hopp 4c462a
+     mBrush(NULL),
Karsten Hopp 4c462a
+     mDWriteFactory(NULL),
Karsten Hopp 4c462a
+     mGdiInterop(NULL),
Karsten Hopp 4c462a
+     mRenderingParams(NULL),
Karsten Hopp 4c462a
+     mTextFormat(NULL),
Karsten Hopp 4c462a
+     mLastHFont(NULL),
Karsten Hopp 4c462a
+     mFontWeight(DWRITE_FONT_WEIGHT_NORMAL),
Karsten Hopp 4c462a
+     mFontStyle(DWRITE_FONT_STYLE_NORMAL),
Karsten Hopp 4c462a
+     mTextAntialiasMode(D2D1_TEXT_ANTIALIAS_MODE_DEFAULT)
Karsten Hopp 4c462a
+ {
Karsten Hopp 4c462a
+     HRESULT hr;
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     HDC screen = ::GetDC(0);
Karsten Hopp 4c462a
+     mDpiScaleX = ::GetDeviceCaps(screen, LOGPIXELSX) / 96.0f;
Karsten Hopp 4c462a
+     mDpiScaleY = ::GetDeviceCaps(screen, LOGPIXELSY) / 96.0f;
Karsten Hopp 4c462a
+     ::ReleaseDC(0, screen);
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED,
Karsten Hopp 4c462a
+ 	    __uuidof(ID2D1Factory), NULL,
Karsten Hopp 4c462a
+ 	    reinterpret_cast<void**>(&mD2D1Factory));
Karsten Hopp 4c462a
+     _RPT2(_CRT_WARN, "D2D1CreateFactory: hr=%p p=%p\n", hr, mD2D1Factory);
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     if (SUCCEEDED(hr))
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	D2D1_RENDER_TARGET_PROPERTIES props = {
Karsten Hopp 4c462a
+ 	    D2D1_RENDER_TARGET_TYPE_DEFAULT,
Karsten Hopp 4c462a
+ 	    { DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_IGNORE },
Karsten Hopp 4c462a
+ 	    0, 0,
Karsten Hopp 4c462a
+ 	    D2D1_RENDER_TARGET_USAGE_NONE,
Karsten Hopp 4c462a
+ 	    D2D1_FEATURE_LEVEL_DEFAULT
Karsten Hopp 4c462a
+ 	};
Karsten Hopp 4c462a
+ 	hr = mD2D1Factory->CreateDCRenderTarget(&props, &mRT);
Karsten Hopp 4c462a
+ 	_RPT2(_CRT_WARN, "CreateDCRenderTarget: hr=%p p=%p\n", hr, mRT);
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     if (SUCCEEDED(hr))
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	hr = mRT->CreateSolidColorBrush(
Karsten Hopp 4c462a
+ 		D2D1::ColorF(D2D1::ColorF::Black),
Karsten Hopp 4c462a
+ 		&mBrush);
Karsten Hopp 4c462a
+ 	_RPT2(_CRT_WARN, "CreateSolidColorBrush: hr=%p p=%p\n", hr, mBrush);
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     if (SUCCEEDED(hr))
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	hr = DWriteCreateFactory(
Karsten Hopp 4c462a
+ 		DWRITE_FACTORY_TYPE_SHARED,
Karsten Hopp 4c462a
+ 		__uuidof(IDWriteFactory),
Karsten Hopp 4c462a
+ 		reinterpret_cast<IUnknown**>(&mDWriteFactory));
Karsten Hopp 4c462a
+ 	_RPT2(_CRT_WARN, "DWriteCreateFactory: hr=%p p=%p\n", hr,
Karsten Hopp 4c462a
+ 		mDWriteFactory);
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     if (SUCCEEDED(hr))
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	hr = mDWriteFactory->GetGdiInterop(&mGdiInterop);
Karsten Hopp 4c462a
+ 	_RPT2(_CRT_WARN, "GetGdiInterop: hr=%p p=%p\n", hr, mGdiInterop);
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     if (SUCCEEDED(hr))
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	hr = mDWriteFactory->CreateRenderingParams(&mRenderingParams);
Karsten Hopp 4c462a
+ 	_RPT2(_CRT_WARN, "CreateRenderingParams: hr=%p p=%p\n", hr,
Karsten Hopp 4c462a
+ 		mRenderingParams);
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ DWriteContext::~DWriteContext()
Karsten Hopp 4c462a
+ {
Karsten Hopp 4c462a
+     SafeRelease(&mTextFormat);
Karsten Hopp 4c462a
+     SafeRelease(&mRenderingParams);
Karsten Hopp 4c462a
+     SafeRelease(&mGdiInterop);
Karsten Hopp 4c462a
+     SafeRelease(&mDWriteFactory);
Karsten Hopp 4c462a
+     SafeRelease(&mBrush);
Karsten Hopp 4c462a
+     SafeRelease(&mRT);
Karsten Hopp 4c462a
+     SafeRelease(&mD2D1Factory);
Karsten Hopp 4c462a
+ }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     HRESULT
Karsten Hopp 4c462a
+ DWriteContext::SetLOGFONT(const LOGFONTW &logFont, float fontSize)
Karsten Hopp 4c462a
+ {
Karsten Hopp 4c462a
+     // Most of this function is copy from: http://msdn.microsoft.com/en-us/library/windows/desktop/dd941783(v=vs.85).aspx
Karsten Hopp 4c462a
+     HRESULT hr = S_OK;
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     IDWriteFont *font = NULL;
Karsten Hopp 4c462a
+     IDWriteFontFamily *fontFamily = NULL;
Karsten Hopp 4c462a
+     IDWriteLocalizedStrings *localizedFamilyNames = NULL;
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     if (SUCCEEDED(hr))
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	hr = mGdiInterop->CreateFontFromLOGFONT(&logFont, &font);
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     // Get the font family to which this font belongs.
Karsten Hopp 4c462a
+     if (SUCCEEDED(hr))
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	hr = font->GetFontFamily(&fontFamily);
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     // Get the family names. This returns an object that encapsulates one or
Karsten Hopp 4c462a
+     // more names with the same meaning but in different languages.
Karsten Hopp 4c462a
+     if (SUCCEEDED(hr))
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	hr = fontFamily->GetFamilyNames(&localizedFamilyNames);
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     // Get the family name at index zero. If we were going to display the name
Karsten Hopp 4c462a
+     // we'd want to try to find one that matched the use locale, but for
Karsten Hopp 4c462a
+     // purposes of creating a text format object any language will do.
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     wchar_t familyName[100];
Karsten Hopp 4c462a
+     if (SUCCEEDED(hr))
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	hr = localizedFamilyNames->GetString(0, familyName,
Karsten Hopp 4c462a
+ 		ARRAYSIZE(familyName));
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     if (SUCCEEDED(hr))
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	// If no font size was passed in use the lfHeight of the LOGFONT.
Karsten Hopp 4c462a
+ 	if (fontSize == 0)
Karsten Hopp 4c462a
+ 	{
Karsten Hopp 4c462a
+ 	    // Convert from pixels to DIPs.
Karsten Hopp 4c462a
+ 	    fontSize = PixelsToDipsY(logFont.lfHeight);
Karsten Hopp 4c462a
+ 	    if (fontSize < 0)
Karsten Hopp 4c462a
+ 	    {
Karsten Hopp 4c462a
+ 		// Negative lfHeight represents the size of the em unit.
Karsten Hopp 4c462a
+ 		fontSize = -fontSize;
Karsten Hopp 4c462a
+ 	    }
Karsten Hopp 4c462a
+ 	    else
Karsten Hopp 4c462a
+ 	    {
Karsten Hopp 4c462a
+ 		// Positive lfHeight represents the cell height (ascent +
Karsten Hopp 4c462a
+ 		// descent).
Karsten Hopp 4c462a
+ 		DWRITE_FONT_METRICS fontMetrics;
Karsten Hopp 4c462a
+ 		font->GetMetrics(&fontMetrics);
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ 		// Convert the cell height (ascent + descent) from design units
Karsten Hopp 4c462a
+ 		// to ems.
Karsten Hopp 4c462a
+ 		float cellHeight = static_cast<float>(
Karsten Hopp 4c462a
+ 			fontMetrics.ascent + fontMetrics.descent)
Karsten Hopp 4c462a
+ 					       / fontMetrics.designUnitsPerEm;
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ 		// Divide the font size by the cell height to get the font em
Karsten Hopp 4c462a
+ 		// size.
Karsten Hopp 4c462a
+ 		fontSize /= cellHeight;
Karsten Hopp 4c462a
+ 	    }
Karsten Hopp 4c462a
+ 	}
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     // The text format includes a locale name. Ideally, this would be the
Karsten Hopp 4c462a
+     // language of the text, which may or may not be the same as the primary
Karsten Hopp 4c462a
+     // language of the user. However, for our purposes the user locale will do.
Karsten Hopp 4c462a
+     wchar_t localeName[LOCALE_NAME_MAX_LENGTH];
Karsten Hopp 4c462a
+     if (SUCCEEDED(hr))
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	if (GetUserDefaultLocaleName(localeName, LOCALE_NAME_MAX_LENGTH) == 0)
Karsten Hopp 4c462a
+ 	    hr = HRESULT_FROM_WIN32(GetLastError());
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     if (SUCCEEDED(hr))
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	// Create the text format object.
Karsten Hopp 4c462a
+ 	hr = mDWriteFactory->CreateTextFormat(
Karsten Hopp 4c462a
+ 		familyName,
Karsten Hopp 4c462a
+ 		NULL, // no custom font collection
Karsten Hopp 4c462a
+ 		font->GetWeight(),
Karsten Hopp 4c462a
+ 		font->GetStyle(),
Karsten Hopp 4c462a
+ 		font->GetStretch(),
Karsten Hopp 4c462a
+ 		fontSize,
Karsten Hopp 4c462a
+ 		localeName,
Karsten Hopp 4c462a
+ 		&mTextFormat);
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     if (SUCCEEDED(hr))
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	mFontWeight = static_cast<DWRITE_FONT_WEIGHT>(logFont.lfWeight);
Karsten Hopp 4c462a
+ 	mFontStyle = logFont.lfItalic ? DWRITE_FONT_STYLE_ITALIC
Karsten Hopp 4c462a
+ 	    : DWRITE_FONT_STYLE_NORMAL;
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     SafeRelease(&localizedFamilyNames);
Karsten Hopp 4c462a
+     SafeRelease(&fontFamily);
Karsten Hopp 4c462a
+     SafeRelease(&font);
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     return hr;
Karsten Hopp 4c462a
+ }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     void
Karsten Hopp 4c462a
+ DWriteContext::SetFont(HFONT hFont)
Karsten Hopp 4c462a
+ {
Karsten Hopp 4c462a
+     if (mLastHFont != hFont)
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	LOGFONTW lf;
Karsten Hopp 4c462a
+ 	if (GetObjectW(hFont, sizeof(lf), &lf))
Karsten Hopp 4c462a
+ 	{
Karsten Hopp 4c462a
+ 	    SetFont(lf);
Karsten Hopp 4c462a
+ 	    mLastHFont = hFont;
Karsten Hopp 4c462a
+ 	}
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     void
Karsten Hopp 4c462a
+ DWriteContext::SetFont(const LOGFONTW &logFont)
Karsten Hopp 4c462a
+ {
Karsten Hopp 4c462a
+     SafeRelease(&mTextFormat);
Karsten Hopp 4c462a
+     mLastHFont = NULL;
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     HRESULT hr = SetLOGFONT(logFont, 0.f);
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     if (SUCCEEDED(hr))
Karsten Hopp 4c462a
+ 	hr = mTextFormat->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_LEADING);
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     if (SUCCEEDED(hr))
Karsten Hopp 4c462a
+ 	hr = mTextFormat->SetParagraphAlignment(
Karsten Hopp 4c462a
+ 		DWRITE_PARAGRAPH_ALIGNMENT_CENTER);
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     if (SUCCEEDED(hr))
Karsten Hopp 4c462a
+ 	hr = mTextFormat->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP);
Karsten Hopp 4c462a
+ }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     void
Karsten Hopp 4c462a
+ DWriteContext::DrawText(HDC hdc, const WCHAR* text, int len,
Karsten Hopp 4c462a
+ 	int x, int y, int w, int h, int cellWidth, COLORREF color)
Karsten Hopp 4c462a
+ {
Karsten Hopp 4c462a
+     HRESULT hr = S_OK;
Karsten Hopp 4c462a
+     IDWriteBitmapRenderTarget *bmpRT = NULL;
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     // Skip when any fonts are not set.
Karsten Hopp 4c462a
+     if (mTextFormat == NULL)
Karsten Hopp 4c462a
+ 	return;
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     // Check possibility of zero divided error.
Karsten Hopp 4c462a
+     if (cellWidth == 0 || mDpiScaleX == 0.0f || mDpiScaleY == 0.0f)
Karsten Hopp 4c462a
+ 	return;
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     if (SUCCEEDED(hr))
Karsten Hopp 4c462a
+ 	hr = mGdiInterop->CreateBitmapRenderTarget(hdc, w, h, &bmpRT);
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     if (SUCCEEDED(hr))
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	IDWriteTextLayout *textLayout = NULL;
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ 	HDC memdc = bmpRT->GetMemoryDC();
Karsten Hopp 4c462a
+ 	BitBlt(memdc, 0, 0, w, h, hdc, x, y, SRCCOPY);
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ 	hr = mDWriteFactory->CreateGdiCompatibleTextLayout(
Karsten Hopp 4c462a
+ 		text, len, mTextFormat, PixelsToDipsX(w),
Karsten Hopp 4c462a
+ 		PixelsToDipsY(h), mDpiScaleX, NULL, TRUE, &textLayout);
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ 	if (SUCCEEDED(hr))
Karsten Hopp 4c462a
+ 	{
Karsten Hopp 4c462a
+ 	    DWRITE_TEXT_RANGE textRange = { 0, len };
Karsten Hopp 4c462a
+ 	    textLayout->SetFontWeight(mFontWeight, textRange);
Karsten Hopp 4c462a
+ 	    textLayout->SetFontStyle(mFontStyle, textRange);
Karsten Hopp 4c462a
+ 	}
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ 	if (SUCCEEDED(hr))
Karsten Hopp 4c462a
+ 	{
Karsten Hopp 4c462a
+ 	    GdiTextRenderer *renderer = new GdiTextRenderer(bmpRT,
Karsten Hopp 4c462a
+ 		    mRenderingParams);
Karsten Hopp 4c462a
+ 	    GdiTextRendererContext data = {
Karsten Hopp 4c462a
+ 		color,
Karsten Hopp 4c462a
+ 		PixelsToDipsX(cellWidth),
Karsten Hopp 4c462a
+ 		0.0f
Karsten Hopp 4c462a
+ 	    };
Karsten Hopp 4c462a
+ 	    textLayout->Draw(&data, renderer, 0, 0);
Karsten Hopp 4c462a
+ 	    SafeRelease(&renderer);
Karsten Hopp 4c462a
+ 	}
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ 	BitBlt(hdc, x, y, w, h, memdc, 0, 0, SRCCOPY);
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ 	SafeRelease(&textLayout);
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     SafeRelease(&bmpRT);
Karsten Hopp 4c462a
+ }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     float
Karsten Hopp 4c462a
+ DWriteContext::PixelsToDipsX(int x)
Karsten Hopp 4c462a
+ {
Karsten Hopp 4c462a
+     return x / mDpiScaleX;
Karsten Hopp 4c462a
+ }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     float
Karsten Hopp 4c462a
+ DWriteContext::PixelsToDipsY(int y)
Karsten Hopp 4c462a
+ {
Karsten Hopp 4c462a
+     return y / mDpiScaleY;
Karsten Hopp 4c462a
+ }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     void
Karsten Hopp 4c462a
+ DWriteContext::SetRenderingParams(
Karsten Hopp 4c462a
+ 	const DWriteRenderingParams *params)
Karsten Hopp 4c462a
+ {
Karsten Hopp 4c462a
+     if (mDWriteFactory == NULL)
Karsten Hopp 4c462a
+ 	return;
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     IDWriteRenderingParams *renderingParams = NULL;
Karsten Hopp 4c462a
+     D2D1_TEXT_ANTIALIAS_MODE textAntialiasMode =
Karsten Hopp 4c462a
+ 	D2D1_TEXT_ANTIALIAS_MODE_DEFAULT;
Karsten Hopp 4c462a
+     HRESULT hr;
Karsten Hopp 4c462a
+     if (params != NULL)
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	hr = mDWriteFactory->CreateCustomRenderingParams(params->gamma,
Karsten Hopp 4c462a
+ 		params->enhancedContrast, params->clearTypeLevel,
Karsten Hopp 4c462a
+ 		ToPixelGeometry(params->pixelGeometry),
Karsten Hopp 4c462a
+ 		ToRenderingMode(params->renderingMode), &renderingParams);
Karsten Hopp 4c462a
+ 	textAntialiasMode = ToTextAntialiasMode(params->textAntialiasMode);
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+     else
Karsten Hopp 4c462a
+ 	hr = mDWriteFactory->CreateRenderingParams(&renderingParams);
Karsten Hopp 4c462a
+     if (SUCCEEDED(hr) && renderingParams != NULL)
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	SafeRelease(&mRenderingParams);
Karsten Hopp 4c462a
+ 	mRenderingParams = renderingParams;
Karsten Hopp 4c462a
+ 	mTextAntialiasMode = textAntialiasMode;
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     DWriteRenderingParams *
Karsten Hopp 4c462a
+ DWriteContext::GetRenderingParams(
Karsten Hopp 4c462a
+ 	DWriteRenderingParams *params)
Karsten Hopp 4c462a
+ {
Karsten Hopp 4c462a
+     if (params != NULL && mRenderingParams != NULL)
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	params->gamma = mRenderingParams->GetGamma();
Karsten Hopp 4c462a
+ 	params->enhancedContrast = mRenderingParams->GetEnhancedContrast();
Karsten Hopp 4c462a
+ 	params->clearTypeLevel = mRenderingParams->GetClearTypeLevel();
Karsten Hopp 4c462a
+ 	params->pixelGeometry = ToInt(mRenderingParams->GetPixelGeometry());
Karsten Hopp 4c462a
+ 	params->renderingMode = ToInt(mRenderingParams->GetRenderingMode());
Karsten Hopp 4c462a
+ 	params->textAntialiasMode = mTextAntialiasMode;
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+     return params;
Karsten Hopp 4c462a
+ }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ ////////////////////////////////////////////////////////////////////////////
Karsten Hopp 4c462a
+ // PUBLIC C INTERFACES
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     void
Karsten Hopp 4c462a
+ DWrite_Init(void)
Karsten Hopp 4c462a
+ {
Karsten Hopp 4c462a
+ #ifdef DYNAMIC_DIRECTX
Karsten Hopp 4c462a
+     // Load libraries.
Karsten Hopp 4c462a
+     hD2D1DLL = vimLoadLib(const_cast<char*>("d2d1.dll"));
Karsten Hopp 4c462a
+     hDWriteDLL = vimLoadLib(const_cast<char*>("dwrite.dll"));
Karsten Hopp 4c462a
+     if (hD2D1DLL == NULL || hDWriteDLL == NULL)
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	DWrite_Final();
Karsten Hopp 4c462a
+ 	return;
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+     // Get address of procedures.
Karsten Hopp 4c462a
+     pGetUserDefaultLocaleName = (PGETUSERDEFAULTLOCALENAME)GetProcAddress(
Karsten Hopp 4c462a
+ 	    GetModuleHandle("kernel32.dll"), "GetUserDefaultLocaleName");
Karsten Hopp 4c462a
+     pD2D1CreateFactory = (PD2D1CREATEFACTORY)GetProcAddress(hD2D1DLL,
Karsten Hopp 4c462a
+ 	    "D2D1CreateFactory");
Karsten Hopp 4c462a
+     pDWriteCreateFactory = (PDWRITECREATEFACTORY)GetProcAddress(hDWriteDLL,
Karsten Hopp 4c462a
+ 	    "DWriteCreateFactory");
Karsten Hopp 4c462a
+ #endif
Karsten Hopp 4c462a
+ }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     void
Karsten Hopp 4c462a
+ DWrite_Final(void)
Karsten Hopp 4c462a
+ {
Karsten Hopp 4c462a
+ #ifdef DYNAMIC_DIRECTX
Karsten Hopp 4c462a
+     pGetUserDefaultLocaleName = NULL;
Karsten Hopp 4c462a
+     pD2D1CreateFactory = NULL;
Karsten Hopp 4c462a
+     pDWriteCreateFactory = NULL;
Karsten Hopp 4c462a
+     unload(hDWriteDLL);
Karsten Hopp 4c462a
+     unload(hD2D1DLL);
Karsten Hopp 4c462a
+ #endif
Karsten Hopp 4c462a
+ }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     DWriteContext *
Karsten Hopp 4c462a
+ DWriteContext_Open(void)
Karsten Hopp 4c462a
+ {
Karsten Hopp 4c462a
+ #ifdef DYNAMIC_DIRECTX
Karsten Hopp 4c462a
+     if (pGetUserDefaultLocaleName == NULL || pD2D1CreateFactory == NULL
Karsten Hopp 4c462a
+ 	    || pDWriteCreateFactory == NULL)
Karsten Hopp 4c462a
+ 	return NULL;
Karsten Hopp 4c462a
+ #endif
Karsten Hopp 4c462a
+     return new DWriteContext();
Karsten Hopp 4c462a
+ }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     void
Karsten Hopp 4c462a
+ DWriteContext_BeginDraw(DWriteContext *ctx)
Karsten Hopp 4c462a
+ {
Karsten Hopp 4c462a
+     if (ctx != NULL && ctx->mRT != NULL)
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	ctx->mRT->BeginDraw();
Karsten Hopp 4c462a
+ 	ctx->mRT->SetTransform(D2D1::IdentityMatrix());
Karsten Hopp 4c462a
+ 	ctx->mDrawing = true;
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     void
Karsten Hopp 4c462a
+ DWriteContext_BindDC(DWriteContext *ctx, HDC hdc, RECT *rect)
Karsten Hopp 4c462a
+ {
Karsten Hopp 4c462a
+     if (ctx != NULL && ctx->mRT != NULL)
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	ctx->mRT->BindDC(hdc, rect);
Karsten Hopp 4c462a
+ 	ctx->mRT->SetTextAntialiasMode(ctx->mTextAntialiasMode);
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     void
Karsten Hopp 4c462a
+ DWriteContext_SetFont(DWriteContext *ctx, HFONT hFont)
Karsten Hopp 4c462a
+ {
Karsten Hopp 4c462a
+     if (ctx != NULL)
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	ctx->SetFont(hFont);
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     void
Karsten Hopp 4c462a
+ DWriteContext_DrawText(
Karsten Hopp 4c462a
+ 	DWriteContext *ctx,
Karsten Hopp 4c462a
+ 	HDC hdc,
Karsten Hopp 4c462a
+ 	const WCHAR* text,
Karsten Hopp 4c462a
+ 	int len,
Karsten Hopp 4c462a
+ 	int x,
Karsten Hopp 4c462a
+ 	int y,
Karsten Hopp 4c462a
+ 	int w,
Karsten Hopp 4c462a
+ 	int h,
Karsten Hopp 4c462a
+ 	int cellWidth,
Karsten Hopp 4c462a
+ 	COLORREF color)
Karsten Hopp 4c462a
+ {
Karsten Hopp 4c462a
+     if (ctx != NULL)
Karsten Hopp 4c462a
+ 	ctx->DrawText(hdc, text, len, x, y, w, h, cellWidth, color);
Karsten Hopp 4c462a
+ }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     void
Karsten Hopp 4c462a
+ DWriteContext_EndDraw(DWriteContext *ctx)
Karsten Hopp 4c462a
+ {
Karsten Hopp 4c462a
+     if (ctx != NULL && ctx->mRT != NULL)
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	ctx->mRT->EndDraw();
Karsten Hopp 4c462a
+ 	ctx->mDrawing = false;
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     void
Karsten Hopp 4c462a
+ DWriteContext_Close(DWriteContext *ctx)
Karsten Hopp 4c462a
+ {
Karsten Hopp 4c462a
+     delete ctx;
Karsten Hopp 4c462a
+ }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     void
Karsten Hopp 4c462a
+ DWriteContext_SetRenderingParams(
Karsten Hopp 4c462a
+ 	DWriteContext *ctx,
Karsten Hopp 4c462a
+ 	const DWriteRenderingParams *params)
Karsten Hopp 4c462a
+ {
Karsten Hopp 4c462a
+     if (ctx != NULL)
Karsten Hopp 4c462a
+ 	ctx->SetRenderingParams(params);
Karsten Hopp 4c462a
+ }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     DWriteRenderingParams *
Karsten Hopp 4c462a
+ DWriteContext_GetRenderingParams(
Karsten Hopp 4c462a
+ 	DWriteContext *ctx,
Karsten Hopp 4c462a
+ 	DWriteRenderingParams *params)
Karsten Hopp 4c462a
+ {
Karsten Hopp 4c462a
+     if (ctx != NULL)
Karsten Hopp 4c462a
+ 	return ctx->GetRenderingParams(params);
Karsten Hopp 4c462a
+     else
Karsten Hopp 4c462a
+ 	return NULL;
Karsten Hopp 4c462a
+ }
Karsten Hopp 4c462a
*** ../vim-7.4.392/src/gui_dwrite.h	2014-08-06 14:49:19.667237363 +0200
Karsten Hopp 4c462a
--- src/gui_dwrite.h	2014-08-06 14:21:57.459249166 +0200
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 0 ****
Karsten Hopp 4c462a
--- 1,85 ----
Karsten Hopp 4c462a
+ /* vi:set ts=8 sts=4 sw=4 noet: */
Karsten Hopp 4c462a
+ /*
Karsten Hopp 4c462a
+  * Author: MURAOKA Taro <koron.kaoriya@gmail.com>
Karsten Hopp 4c462a
+  *
Karsten Hopp 4c462a
+  * Contributors:
Karsten Hopp 4c462a
+  *  - Ken Takata
Karsten Hopp 4c462a
+  *
Karsten Hopp 4c462a
+  * Copyright (C) 2013 MURAOKA Taro <koron.kaoriya@gmail.com>
Karsten Hopp 4c462a
+  * THIS FILE IS DISTRIBUTED UNDER THE VIM LICENSE.
Karsten Hopp 4c462a
+  */
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ #ifndef GUI_DWRITE_H
Karsten Hopp 4c462a
+ #define GUI_DWRITE_H
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ #ifdef __cplusplus
Karsten Hopp 4c462a
+ extern "C" {
Karsten Hopp 4c462a
+ #endif
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ typedef struct DWriteContext DWriteContext;
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ typedef struct DWriteRenderingParams {
Karsten Hopp 4c462a
+     float gamma;
Karsten Hopp 4c462a
+     float enhancedContrast;
Karsten Hopp 4c462a
+     float clearTypeLevel;
Karsten Hopp 4c462a
+     /*
Karsten Hopp 4c462a
+      * pixelGeometry:
Karsten Hopp 4c462a
+      *	0 - DWRITE_PIXEL_GEOMETRY_FLAT
Karsten Hopp 4c462a
+      *	1 - DWRITE_PIXEL_GEOMETRY_RGB
Karsten Hopp 4c462a
+      *	2 - DWRITE_PIXEL_GEOMETRY_BGR
Karsten Hopp 4c462a
+      */
Karsten Hopp 4c462a
+     int pixelGeometry;
Karsten Hopp 4c462a
+     /*
Karsten Hopp 4c462a
+      * renderingMode:
Karsten Hopp 4c462a
+      *	0 - DWRITE_RENDERING_MODE_DEFAULT
Karsten Hopp 4c462a
+      *	1 - DWRITE_RENDERING_MODE_ALIASED
Karsten Hopp 4c462a
+      *	2 - DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC
Karsten Hopp 4c462a
+      *	3 - DWRITE_RENDERING_MODE_CLEARTYPE_GDI_NATURAL
Karsten Hopp 4c462a
+      *	4 - DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL
Karsten Hopp 4c462a
+      *	5 - DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC
Karsten Hopp 4c462a
+      *	6 - DWRITE_RENDERING_MODE_OUTLINE
Karsten Hopp 4c462a
+      */
Karsten Hopp 4c462a
+     int renderingMode;
Karsten Hopp 4c462a
+     /*
Karsten Hopp 4c462a
+      * antialiasMode:
Karsten Hopp 4c462a
+      *	0 - D2D1_TEXT_ANTIALIAS_MODE_DEFAULT
Karsten Hopp 4c462a
+      *	1 - D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE
Karsten Hopp 4c462a
+      *	2 - D2D1_TEXT_ANTIALIAS_MODE_GRAYSCALE
Karsten Hopp 4c462a
+      *	3 - D2D1_TEXT_ANTIALIAS_MODE_ALIASED
Karsten Hopp 4c462a
+      */
Karsten Hopp 4c462a
+     int textAntialiasMode;
Karsten Hopp 4c462a
+ } DWriteRenderingParams;
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ void DWrite_Init(void);
Karsten Hopp 4c462a
+ void DWrite_Final(void);
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ DWriteContext *DWriteContext_Open(void);
Karsten Hopp 4c462a
+ void DWriteContext_BeginDraw(DWriteContext *ctx);
Karsten Hopp 4c462a
+ void DWriteContext_BindDC(DWriteContext *ctx, HDC hdc, RECT *rect);
Karsten Hopp 4c462a
+ void DWriteContext_SetFont(DWriteContext *ctx, HFONT hFont);
Karsten Hopp 4c462a
+ void DWriteContext_DrawText(
Karsten Hopp 4c462a
+ 	DWriteContext *ctx,
Karsten Hopp 4c462a
+ 	HDC hdc,
Karsten Hopp 4c462a
+ 	const WCHAR* text,
Karsten Hopp 4c462a
+ 	int len,
Karsten Hopp 4c462a
+ 	int x,
Karsten Hopp 4c462a
+ 	int y,
Karsten Hopp 4c462a
+ 	int w,
Karsten Hopp 4c462a
+ 	int h,
Karsten Hopp 4c462a
+ 	int cellWidth,
Karsten Hopp 4c462a
+ 	COLORREF color);
Karsten Hopp 4c462a
+ void DWriteContext_EndDraw(DWriteContext *ctx);
Karsten Hopp 4c462a
+ void DWriteContext_Close(DWriteContext *ctx);
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ void DWriteContext_SetRenderingParams(
Karsten Hopp 4c462a
+ 	DWriteContext *ctx,
Karsten Hopp 4c462a
+ 	const DWriteRenderingParams *params);
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ DWriteRenderingParams *DWriteContext_GetRenderingParams(
Karsten Hopp 4c462a
+ 	DWriteContext *ctx,
Karsten Hopp 4c462a
+ 	DWriteRenderingParams *params);
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ #ifdef __cplusplus
Karsten Hopp 4c462a
+ }
Karsten Hopp 4c462a
+ #endif
Karsten Hopp 4c462a
+ #endif/*GUI_DWRITE_H*/
Karsten Hopp 4c462a
*** ../vim-7.4.392/src/gui_w32.c	2013-08-04 16:15:37.000000000 +0200
Karsten Hopp 4c462a
--- src/gui_w32.c	2014-08-06 14:45:43.495238916 +0200
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 25,30 ****
Karsten Hopp 4c462a
--- 25,169 ----
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
  #include "vim.h"
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
+ #if defined(FEAT_DIRECTX)
Karsten Hopp 4c462a
+ # include "gui_dwrite.h"
Karsten Hopp 4c462a
+ #endif
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ #if defined(FEAT_DIRECTX) || defined(PROTO)
Karsten Hopp 4c462a
+ static DWriteContext *s_dwc = NULL;
Karsten Hopp 4c462a
+ static int s_directx_enabled = 0;
Karsten Hopp 4c462a
+ static int s_directx_load_attempted = 0;
Karsten Hopp 4c462a
+ # define IS_ENABLE_DIRECTX() (s_directx_enabled && s_dwc != NULL)
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     int
Karsten Hopp 4c462a
+ directx_enabled(void)
Karsten Hopp 4c462a
+ {
Karsten Hopp 4c462a
+     if (s_dwc != NULL)
Karsten Hopp 4c462a
+ 	return 1;
Karsten Hopp 4c462a
+     else if (s_directx_load_attempted)
Karsten Hopp 4c462a
+ 	return 0;
Karsten Hopp 4c462a
+     /* load DirectX */
Karsten Hopp 4c462a
+     DWrite_Init();
Karsten Hopp 4c462a
+     s_directx_load_attempted = 1;
Karsten Hopp 4c462a
+     s_dwc = DWriteContext_Open();
Karsten Hopp 4c462a
+     return s_dwc != NULL ? 1 : 0;
Karsten Hopp 4c462a
+ }
Karsten Hopp 4c462a
+ #endif
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ #if defined(FEAT_RENDER_OPTIONS) || defined(PROTO)
Karsten Hopp 4c462a
+     int
Karsten Hopp 4c462a
+ gui_mch_set_rendering_options(char_u *s)
Karsten Hopp 4c462a
+ {
Karsten Hopp 4c462a
+ #ifdef FEAT_DIRECTX
Karsten Hopp 4c462a
+     int	    retval = FAIL;
Karsten Hopp 4c462a
+     char_u  *p, *q;
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     int	    dx_enable = 0;
Karsten Hopp 4c462a
+     int	    dx_flags = 0;
Karsten Hopp 4c462a
+     float   dx_gamma = 0.0f;
Karsten Hopp 4c462a
+     float   dx_contrast = 0.0f;
Karsten Hopp 4c462a
+     float   dx_level = 0.0f;
Karsten Hopp 4c462a
+     int	    dx_geom = 0;
Karsten Hopp 4c462a
+     int	    dx_renmode = 0;
Karsten Hopp 4c462a
+     int	    dx_taamode = 0;
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     /* parse string as rendering options. */
Karsten Hopp 4c462a
+     for (p = s; p != NULL && *p != NUL; )
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	char_u  item[256];
Karsten Hopp 4c462a
+ 	char_u  name[128];
Karsten Hopp 4c462a
+ 	char_u  value[128];
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ 	copy_option_part(&p, item, sizeof(item), ","); 
Karsten Hopp 4c462a
+ 	if (p == NULL)
Karsten Hopp 4c462a
+ 	    break;
Karsten Hopp 4c462a
+ 	q = &item[0];
Karsten Hopp 4c462a
+ 	copy_option_part(&q, name, sizeof(name), ":");
Karsten Hopp 4c462a
+ 	if (q == NULL)
Karsten Hopp 4c462a
+ 	    return FAIL;
Karsten Hopp 4c462a
+ 	copy_option_part(&q, value, sizeof(value), ":");
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ 	if (STRCMP(name, "type") == 0)
Karsten Hopp 4c462a
+ 	{
Karsten Hopp 4c462a
+ 	    if (STRCMP(value, "directx") == 0)
Karsten Hopp 4c462a
+ 		dx_enable = 1;
Karsten Hopp 4c462a
+ 	    else
Karsten Hopp 4c462a
+ 		return FAIL;
Karsten Hopp 4c462a
+ 	}
Karsten Hopp 4c462a
+ 	else if (STRCMP(name, "gamma") == 0)
Karsten Hopp 4c462a
+ 	{
Karsten Hopp 4c462a
+ 	    dx_flags |= 1 << 0;
Karsten Hopp 4c462a
+ 	    dx_gamma = (float)atof(value);
Karsten Hopp 4c462a
+ 	}
Karsten Hopp 4c462a
+ 	else if (STRCMP(name, "contrast") == 0)
Karsten Hopp 4c462a
+ 	{
Karsten Hopp 4c462a
+ 	    dx_flags |= 1 << 1;
Karsten Hopp 4c462a
+ 	    dx_contrast = (float)atof(value);
Karsten Hopp 4c462a
+ 	}
Karsten Hopp 4c462a
+ 	else if (STRCMP(name, "level") == 0)
Karsten Hopp 4c462a
+ 	{
Karsten Hopp 4c462a
+ 	    dx_flags |= 1 << 2;
Karsten Hopp 4c462a
+ 	    dx_level = (float)atof(value);
Karsten Hopp 4c462a
+ 	}
Karsten Hopp 4c462a
+ 	else if (STRCMP(name, "geom") == 0)
Karsten Hopp 4c462a
+ 	{
Karsten Hopp 4c462a
+ 	    dx_flags |= 1 << 3;
Karsten Hopp 4c462a
+ 	    dx_geom = atoi(value);
Karsten Hopp 4c462a
+ 	    if (dx_geom < 0 || dx_geom > 2)
Karsten Hopp 4c462a
+ 		return FAIL;
Karsten Hopp 4c462a
+ 	}
Karsten Hopp 4c462a
+ 	else if (STRCMP(name, "renmode") == 0)
Karsten Hopp 4c462a
+ 	{
Karsten Hopp 4c462a
+ 	    dx_flags |= 1 << 4;
Karsten Hopp 4c462a
+ 	    dx_renmode = atoi(value);
Karsten Hopp 4c462a
+ 	    if (dx_renmode < 0 || dx_renmode > 6)
Karsten Hopp 4c462a
+ 		return FAIL;
Karsten Hopp 4c462a
+ 	}
Karsten Hopp 4c462a
+ 	else if (STRCMP(name, "taamode") == 0)
Karsten Hopp 4c462a
+ 	{
Karsten Hopp 4c462a
+ 	    dx_flags |= 1 << 5;
Karsten Hopp 4c462a
+ 	    dx_taamode = atoi(value);
Karsten Hopp 4c462a
+ 	    if (dx_taamode < 0 || dx_taamode > 3)
Karsten Hopp 4c462a
+ 		return FAIL;
Karsten Hopp 4c462a
+ 	}
Karsten Hopp 4c462a
+ 	else
Karsten Hopp 4c462a
+ 	    return FAIL;
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     /* Enable DirectX/DirectWrite */
Karsten Hopp 4c462a
+     if (dx_enable)
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	if (!directx_enabled())
Karsten Hopp 4c462a
+ 	    return FAIL;
Karsten Hopp 4c462a
+ 	DWriteContext_SetRenderingParams(s_dwc, NULL);
Karsten Hopp 4c462a
+ 	if (dx_flags)
Karsten Hopp 4c462a
+ 	{
Karsten Hopp 4c462a
+ 	    DWriteRenderingParams param;
Karsten Hopp 4c462a
+ 	    DWriteContext_GetRenderingParams(s_dwc, ¶m;;
Karsten Hopp 4c462a
+ 	    if (dx_flags & (1 << 0))
Karsten Hopp 4c462a
+ 		param.gamma = dx_gamma;
Karsten Hopp 4c462a
+ 	    if (dx_flags & (1 << 1))
Karsten Hopp 4c462a
+ 		param.enhancedContrast = dx_contrast;
Karsten Hopp 4c462a
+ 	    if (dx_flags & (1 << 2))
Karsten Hopp 4c462a
+ 		param.clearTypeLevel = dx_level;
Karsten Hopp 4c462a
+ 	    if (dx_flags & (1 << 3))
Karsten Hopp 4c462a
+ 		param.pixelGeometry = dx_geom;
Karsten Hopp 4c462a
+ 	    if (dx_flags & (1 << 4))
Karsten Hopp 4c462a
+ 		param.renderingMode = dx_renmode;
Karsten Hopp 4c462a
+ 	    if (dx_flags & (1 << 5))
Karsten Hopp 4c462a
+ 		param.textAntialiasMode = dx_taamode;
Karsten Hopp 4c462a
+ 	    DWriteContext_SetRenderingParams(s_dwc, ¶m;;
Karsten Hopp 4c462a
+ 	}
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+     s_directx_enabled = dx_enable;
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+     return OK;
Karsten Hopp 4c462a
+ #else
Karsten Hopp 4c462a
+     return FAIL;
Karsten Hopp 4c462a
+ #endif
Karsten Hopp 4c462a
+ }
Karsten Hopp 4c462a
+ #endif
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
  /*
Karsten Hopp 4c462a
   * These are new in Windows ME/XP, only defined in recent compilers.
Karsten Hopp 4c462a
   */
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 1624,1629 ****
Karsten Hopp 4c462a
--- 1763,1773 ----
Karsten Hopp 4c462a
      set_vim_var_nr(VV_WINDOWID, HandleToLong(s_hwnd));
Karsten Hopp 4c462a
  #endif
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
+ #ifdef FEAT_RENDER_OPTIONS
Karsten Hopp 4c462a
+     if (p_rop)
Karsten Hopp 4c462a
+ 	(void)gui_mch_set_rendering_options(p_rop);
Karsten Hopp 4c462a
+ #endif
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
  theend:
Karsten Hopp 4c462a
      /* Display any pending error messages */
Karsten Hopp 4c462a
      display_errors();
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 1695,1703 ****
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
      /* compute the size of the outside of the window */
Karsten Hopp 4c462a
      win_width = width + (GetSystemMetrics(SM_CXFRAME) +
Karsten Hopp 4c462a
!                          GetSystemMetrics(SM_CXPADDEDBORDER)) * 2;
Karsten Hopp 4c462a
      win_height = height + (GetSystemMetrics(SM_CYFRAME) +
Karsten Hopp 4c462a
!                            GetSystemMetrics(SM_CXPADDEDBORDER)) * 2
Karsten Hopp 4c462a
  			+ GetSystemMetrics(SM_CYCAPTION)
Karsten Hopp 4c462a
  #ifdef FEAT_MENU
Karsten Hopp 4c462a
  			+ gui_mswin_get_menu_height(FALSE)
Karsten Hopp 4c462a
--- 1839,1847 ----
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
      /* compute the size of the outside of the window */
Karsten Hopp 4c462a
      win_width = width + (GetSystemMetrics(SM_CXFRAME) +
Karsten Hopp 4c462a
! 			 GetSystemMetrics(SM_CXPADDEDBORDER)) * 2;
Karsten Hopp 4c462a
      win_height = height + (GetSystemMetrics(SM_CYFRAME) +
Karsten Hopp 4c462a
! 			   GetSystemMetrics(SM_CXPADDEDBORDER)) * 2
Karsten Hopp 4c462a
  			+ GetSystemMetrics(SM_CYCAPTION)
Karsten Hopp 4c462a
  #ifdef FEAT_MENU
Karsten Hopp 4c462a
  			+ gui_mswin_get_menu_height(FALSE)
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 2239,2244 ****
Karsten Hopp 4c462a
--- 2383,2391 ----
Karsten Hopp 4c462a
  #endif
Karsten Hopp 4c462a
      HPEN	hpen, old_pen;
Karsten Hopp 4c462a
      int		y;
Karsten Hopp 4c462a
+ #ifdef FEAT_DIRECTX
Karsten Hopp 4c462a
+     int		font_is_ttf_or_vector = 0;
Karsten Hopp 4c462a
+ #endif
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
  #ifndef MSWIN16_FASTTEXT
Karsten Hopp 4c462a
      /*
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 2326,2331 ****
Karsten Hopp 4c462a
--- 2473,2492 ----
Karsten Hopp 4c462a
      SetTextColor(s_hdc, gui.currFgColor);
Karsten Hopp 4c462a
      SelectFont(s_hdc, gui.currFont);
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
+ #ifdef FEAT_DIRECTX
Karsten Hopp 4c462a
+     if (IS_ENABLE_DIRECTX())
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	TEXTMETRIC tm;
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ 	GetTextMetrics(s_hdc, &tm;;
Karsten Hopp 4c462a
+ 	if (tm.tmPitchAndFamily & (TMPF_TRUETYPE | TMPF_VECTOR))
Karsten Hopp 4c462a
+ 	{
Karsten Hopp 4c462a
+ 	    font_is_ttf_or_vector = 1;
Karsten Hopp 4c462a
+ 	    DWriteContext_SetFont(s_dwc, (HFONT)gui.currFont);
Karsten Hopp 4c462a
+ 	}
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ #endif
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
      if (pad_size != Columns || padding == NULL || padding[0] != gui.char_width)
Karsten Hopp 4c462a
      {
Karsten Hopp 4c462a
  	vim_free(padding);
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 2360,2365 ****
Karsten Hopp 4c462a
--- 2521,2534 ----
Karsten Hopp 4c462a
  	    if (text[n] >= 0x80)
Karsten Hopp 4c462a
  		break;
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
+ #if defined(FEAT_DIRECTX)
Karsten Hopp 4c462a
+     /* Quick hack to enable DirectWrite.  To use DirectWrite (antialias), it is
Karsten Hopp 4c462a
+      * required that unicode drawing routine, currently.  So this forces it
Karsten Hopp 4c462a
+      * enabled. */
Karsten Hopp 4c462a
+     if (enc_utf8 && IS_ENABLE_DIRECTX())
Karsten Hopp 4c462a
+ 	n = 0; /* Keep n < len, to enter block for unicode. */
Karsten Hopp 4c462a
+ #endif
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
      /* Check if the Unicode buffer exists and is big enough.  Create it
Karsten Hopp 4c462a
       * with the same length as the multi-byte string, the number of wide
Karsten Hopp 4c462a
       * characters is always equal or smaller. */
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 2418,2425 ****
Karsten Hopp 4c462a
  	    i += utfc_ptr2len_len(text + i, len - i);
Karsten Hopp 4c462a
  	    ++clen;
Karsten Hopp 4c462a
  	}
Karsten Hopp 4c462a
! 	ExtTextOutW(s_hdc, TEXT_X(col), TEXT_Y(row),
Karsten Hopp 4c462a
! 			   foptions, pcliprect, unicodebuf, wlen, unicodepdy);
Karsten Hopp 4c462a
  	len = cells;	/* used for underlining */
Karsten Hopp 4c462a
      }
Karsten Hopp 4c462a
      else if ((enc_codepage > 0 && (int)GetACP() != enc_codepage) || enc_latin9)
Karsten Hopp 4c462a
--- 2587,2603 ----
Karsten Hopp 4c462a
  	    i += utfc_ptr2len_len(text + i, len - i);
Karsten Hopp 4c462a
  	    ++clen;
Karsten Hopp 4c462a
  	}
Karsten Hopp 4c462a
! #if defined(FEAT_DIRECTX)
Karsten Hopp 4c462a
! 	if (IS_ENABLE_DIRECTX() && font_is_ttf_or_vector)
Karsten Hopp 4c462a
! 	{
Karsten Hopp 4c462a
! 	    DWriteContext_DrawText(s_dwc, s_hdc, unicodebuf, wlen,
Karsten Hopp 4c462a
! 		    TEXT_X(col), TEXT_Y(row), FILL_X(cells), FILL_Y(1),
Karsten Hopp 4c462a
! 		    gui.char_width, gui.currFgColor);
Karsten Hopp 4c462a
! 	}
Karsten Hopp 4c462a
! 	else
Karsten Hopp 4c462a
! #endif
Karsten Hopp 4c462a
! 	    ExtTextOutW(s_hdc, TEXT_X(col), TEXT_Y(row),
Karsten Hopp 4c462a
! 		    foptions, pcliprect, unicodebuf, wlen, unicodepdy);
Karsten Hopp 4c462a
  	len = cells;	/* used for underlining */
Karsten Hopp 4c462a
      }
Karsten Hopp 4c462a
      else if ((enc_codepage > 0 && (int)GetACP() != enc_codepage) || enc_latin9)
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 2549,2562 ****
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
      *screen_w = workarea_rect.right - workarea_rect.left
Karsten Hopp 4c462a
  		- (GetSystemMetrics(SM_CXFRAME) +
Karsten Hopp 4c462a
!                    GetSystemMetrics(SM_CXPADDEDBORDER)) * 2;
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
      /* FIXME: dirty trick: Because the gui_get_base_height() doesn't include
Karsten Hopp 4c462a
       * the menubar for MSwin, we subtract it from the screen height, so that
Karsten Hopp 4c462a
       * the window size can be made to fit on the screen. */
Karsten Hopp 4c462a
      *screen_h = workarea_rect.bottom - workarea_rect.top
Karsten Hopp 4c462a
  		- (GetSystemMetrics(SM_CYFRAME) +
Karsten Hopp 4c462a
!                    GetSystemMetrics(SM_CXPADDEDBORDER)) * 2
Karsten Hopp 4c462a
  		- GetSystemMetrics(SM_CYCAPTION)
Karsten Hopp 4c462a
  #ifdef FEAT_MENU
Karsten Hopp 4c462a
  		- gui_mswin_get_menu_height(FALSE)
Karsten Hopp 4c462a
--- 2727,2740 ----
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
      *screen_w = workarea_rect.right - workarea_rect.left
Karsten Hopp 4c462a
  		- (GetSystemMetrics(SM_CXFRAME) +
Karsten Hopp 4c462a
! 		   GetSystemMetrics(SM_CXPADDEDBORDER)) * 2;
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
      /* FIXME: dirty trick: Because the gui_get_base_height() doesn't include
Karsten Hopp 4c462a
       * the menubar for MSwin, we subtract it from the screen height, so that
Karsten Hopp 4c462a
       * the window size can be made to fit on the screen. */
Karsten Hopp 4c462a
      *screen_h = workarea_rect.bottom - workarea_rect.top
Karsten Hopp 4c462a
  		- (GetSystemMetrics(SM_CYFRAME) +
Karsten Hopp 4c462a
! 		   GetSystemMetrics(SM_CXPADDEDBORDER)) * 2
Karsten Hopp 4c462a
  		- GetSystemMetrics(SM_CYCAPTION)
Karsten Hopp 4c462a
  #ifdef FEAT_MENU
Karsten Hopp 4c462a
  		- gui_mswin_get_menu_height(FALSE)
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 3188,3200 ****
Karsten Hopp 4c462a
  	GetWindowRect(s_hwnd, &rect);
Karsten Hopp 4c462a
  	maxDialogWidth = rect.right - rect.left
Karsten Hopp 4c462a
  				   - (GetSystemMetrics(SM_CXFRAME) +
Karsten Hopp 4c462a
!                                       GetSystemMetrics(SM_CXPADDEDBORDER)) * 2;
Karsten Hopp 4c462a
  	if (maxDialogWidth < DLG_MIN_MAX_WIDTH)
Karsten Hopp 4c462a
  	    maxDialogWidth = DLG_MIN_MAX_WIDTH;
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
  	maxDialogHeight = rect.bottom - rect.top
Karsten Hopp 4c462a
  				   - (GetSystemMetrics(SM_CYFRAME) +
Karsten Hopp 4c462a
!                                       GetSystemMetrics(SM_CXPADDEDBORDER)) * 4
Karsten Hopp 4c462a
  				   - GetSystemMetrics(SM_CYCAPTION);
Karsten Hopp 4c462a
  	if (maxDialogHeight < DLG_MIN_MAX_HEIGHT)
Karsten Hopp 4c462a
  	    maxDialogHeight = DLG_MIN_MAX_HEIGHT;
Karsten Hopp 4c462a
--- 3366,3378 ----
Karsten Hopp 4c462a
  	GetWindowRect(s_hwnd, &rect);
Karsten Hopp 4c462a
  	maxDialogWidth = rect.right - rect.left
Karsten Hopp 4c462a
  				   - (GetSystemMetrics(SM_CXFRAME) +
Karsten Hopp 4c462a
! 				      GetSystemMetrics(SM_CXPADDEDBORDER)) * 2;
Karsten Hopp 4c462a
  	if (maxDialogWidth < DLG_MIN_MAX_WIDTH)
Karsten Hopp 4c462a
  	    maxDialogWidth = DLG_MIN_MAX_WIDTH;
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
  	maxDialogHeight = rect.bottom - rect.top
Karsten Hopp 4c462a
  				   - (GetSystemMetrics(SM_CYFRAME) +
Karsten Hopp 4c462a
! 				      GetSystemMetrics(SM_CXPADDEDBORDER)) * 4
Karsten Hopp 4c462a
  				   - GetSystemMetrics(SM_CYCAPTION);
Karsten Hopp 4c462a
  	if (maxDialogHeight < DLG_MIN_MAX_HEIGHT)
Karsten Hopp 4c462a
  	    maxDialogHeight = DLG_MIN_MAX_HEIGHT;
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 3351,3361 ****
Karsten Hopp 4c462a
      /* Restrict the size to a maximum.  Causes a scrollbar to show up. */
Karsten Hopp 4c462a
      if (dlgheight > maxDialogHeight)
Karsten Hopp 4c462a
      {
Karsten Hopp 4c462a
!         msgheight = msgheight - (dlgheight - maxDialogHeight);
Karsten Hopp 4c462a
!         dlgheight = maxDialogHeight;
Karsten Hopp 4c462a
!         scroll_flag = WS_VSCROLL;
Karsten Hopp 4c462a
!         /* Make sure scrollbar doesn't appear in the middle of the dialog */
Karsten Hopp 4c462a
!         messageWidth = dlgwidth - DLG_ICON_WIDTH - 3 * dlgPaddingX;
Karsten Hopp 4c462a
      }
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
      add_word(PixelToDialogY(dlgheight));
Karsten Hopp 4c462a
--- 3529,3539 ----
Karsten Hopp 4c462a
      /* Restrict the size to a maximum.  Causes a scrollbar to show up. */
Karsten Hopp 4c462a
      if (dlgheight > maxDialogHeight)
Karsten Hopp 4c462a
      {
Karsten Hopp 4c462a
! 	msgheight = msgheight - (dlgheight - maxDialogHeight);
Karsten Hopp 4c462a
! 	dlgheight = maxDialogHeight;
Karsten Hopp 4c462a
! 	scroll_flag = WS_VSCROLL;
Karsten Hopp 4c462a
! 	/* Make sure scrollbar doesn't appear in the middle of the dialog */
Karsten Hopp 4c462a
! 	messageWidth = dlgwidth - DLG_ICON_WIDTH - 3 * dlgPaddingX;
Karsten Hopp 4c462a
      }
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
      add_word(PixelToDialogY(dlgheight));
Karsten Hopp 4c462a
*** ../vim-7.4.392/src/gui_w48.c	2014-03-23 15:12:29.923264336 +0100
Karsten Hopp 4c462a
--- src/gui_w48.c	2014-08-06 14:21:57.463249166 +0200
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 2785,2790 ****
Karsten Hopp 4c462a
--- 2785,2794 ----
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
  	out_flush();	    /* make sure all output has been processed */
Karsten Hopp 4c462a
  	(void)BeginPaint(hwnd, &ps);
Karsten Hopp 4c462a
+ #if defined(FEAT_DIRECTX)
Karsten Hopp 4c462a
+ 	if (IS_ENABLE_DIRECTX())
Karsten Hopp 4c462a
+ 	    DWriteContext_BeginDraw(s_dwc);
Karsten Hopp 4c462a
+ #endif
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
  #ifdef FEAT_MBYTE
Karsten Hopp 4c462a
  	/* prevent multi-byte characters from misprinting on an invalid
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 2800,2808 ****
Karsten Hopp 4c462a
--- 2804,2823 ----
Karsten Hopp 4c462a
  #endif
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
  	if (!IsRectEmpty(&ps.rcPaint))
Karsten Hopp 4c462a
+ 	{
Karsten Hopp 4c462a
+ #if defined(FEAT_DIRECTX)
Karsten Hopp 4c462a
+ 	    if (IS_ENABLE_DIRECTX())
Karsten Hopp 4c462a
+ 		DWriteContext_BindDC(s_dwc, s_hdc, &ps.rcPaint);
Karsten Hopp 4c462a
+ #endif
Karsten Hopp 4c462a
  	    gui_redraw(ps.rcPaint.left, ps.rcPaint.top,
Karsten Hopp 4c462a
  		    ps.rcPaint.right - ps.rcPaint.left + 1,
Karsten Hopp 4c462a
  		    ps.rcPaint.bottom - ps.rcPaint.top + 1);
Karsten Hopp 4c462a
+ 	}
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
+ #if defined(FEAT_DIRECTX)
Karsten Hopp 4c462a
+ 	if (IS_ENABLE_DIRECTX())
Karsten Hopp 4c462a
+ 	    DWriteContext_EndDraw(s_dwc);
Karsten Hopp 4c462a
+ #endif
Karsten Hopp 4c462a
  	EndPaint(hwnd, &ps);
Karsten Hopp 4c462a
      }
Karsten Hopp 4c462a
  }
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 3043,3048 ****
Karsten Hopp 4c462a
--- 3058,3069 ----
Karsten Hopp 4c462a
      void
Karsten Hopp 4c462a
  gui_mch_exit(int rc)
Karsten Hopp 4c462a
  {
Karsten Hopp 4c462a
+ #if defined(FEAT_DIRECTX)
Karsten Hopp 4c462a
+     DWriteContext_Close(s_dwc);
Karsten Hopp 4c462a
+     DWrite_Final();
Karsten Hopp 4c462a
+     s_dwc = NULL;
Karsten Hopp 4c462a
+ #endif
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
      ReleaseDC(s_textArea, s_hdc);
Karsten Hopp 4c462a
      DeleteObject(s_brush);
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
*** ../vim-7.4.392/src/option.c	2014-06-25 14:44:04.458358774 +0200
Karsten Hopp 4c462a
--- src/option.c	2014-08-06 14:33:24.503244228 +0200
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 2124,2129 ****
Karsten Hopp 4c462a
--- 2124,2138 ----
Karsten Hopp 4c462a
      {"remap",	    NULL,   P_BOOL|P_VI_DEF,
Karsten Hopp 4c462a
  			    (char_u *)&p_remap, PV_NONE,
Karsten Hopp 4c462a
  			    {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Karsten Hopp 4c462a
+     {"renderoptions", "rop", P_STRING|P_COMMA|P_RCLR|P_VI_DEF,
Karsten Hopp 4c462a
+ #ifdef FEAT_RENDER_OPTIONS
Karsten Hopp 4c462a
+ 			    (char_u *)&p_rop, PV_NONE,
Karsten Hopp 4c462a
+ 			    {(char_u *)"", (char_u *)0L}
Karsten Hopp 4c462a
+ #else
Karsten Hopp 4c462a
+ 			    (char_u *)NULL, PV_NONE,
Karsten Hopp 4c462a
+ 			    {(char_u *)NULL, (char_u *)0L}
Karsten Hopp 4c462a
+ #endif
Karsten Hopp 4c462a
+ 			    SCRIPTID_INIT},
Karsten Hopp 4c462a
      {"report",	    NULL,   P_NUM|P_VI_DEF,
Karsten Hopp 4c462a
  			    (char_u *)&p_report, PV_NONE,
Karsten Hopp 4c462a
  			    {(char_u *)2L, (char_u *)0L} SCRIPTID_INIT},
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 6999,7004 ****
Karsten Hopp 4c462a
--- 7008,7021 ----
Karsten Hopp 4c462a
      }
Karsten Hopp 4c462a
  #endif
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
+ #if defined(FEAT_RENDER_OPTIONS)
Karsten Hopp 4c462a
+     else if (varp == &p_rop && gui.in_use)
Karsten Hopp 4c462a
+     {
Karsten Hopp 4c462a
+ 	if (!gui_mch_set_rendering_options(p_rop))
Karsten Hopp 4c462a
+ 	    errmsg = e_invarg;
Karsten Hopp 4c462a
+     }
Karsten Hopp 4c462a
+ #endif
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
      /* Options that are a list of flags. */
Karsten Hopp 4c462a
      else
Karsten Hopp 4c462a
      {
Karsten Hopp 4c462a
*** ../vim-7.4.392/src/option.h	2014-06-25 14:39:35.110348584 +0200
Karsten Hopp 4c462a
--- src/option.h	2014-08-06 14:23:25.419248534 +0200
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 655,660 ****
Karsten Hopp 4c462a
--- 655,663 ----
Karsten Hopp 4c462a
  #endif
Karsten Hopp 4c462a
  EXTERN int	p_remap;	/* 'remap' */
Karsten Hopp 4c462a
  EXTERN long	p_re;		/* 'regexpengine' */
Karsten Hopp 4c462a
+ #ifdef FEAT_RENDER_OPTIONS
Karsten Hopp 4c462a
+ EXTERN char_u	*p_rop;		/* 'renderoptions' */
Karsten Hopp 4c462a
+ #endif
Karsten Hopp 4c462a
  EXTERN long	p_report;	/* 'report' */
Karsten Hopp 4c462a
  #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
Karsten Hopp 4c462a
  EXTERN long	p_pvh;		/* 'previewheight' */
Karsten Hopp 4c462a
*** ../vim-7.4.392/src/version.c	2014-08-06 13:36:56.091268582 +0200
Karsten Hopp 4c462a
--- src/version.c	2014-08-06 14:29:39.183245847 +0200
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 189,194 ****
Karsten Hopp 4c462a
--- 189,201 ----
Karsten Hopp 4c462a
  #else
Karsten Hopp 4c462a
  	"-digraphs",
Karsten Hopp 4c462a
  #endif
Karsten Hopp 4c462a
+ #ifdef FEAT_GUI_W32
Karsten Hopp 4c462a
+ # ifdef FEAT_DIRECTX
Karsten Hopp 4c462a
+ 	"+directx",
Karsten Hopp 4c462a
+ # else
Karsten Hopp 4c462a
+ 	"-directx",
Karsten Hopp 4c462a
+ # endif
Karsten Hopp 4c462a
+ #endif
Karsten Hopp 4c462a
  #ifdef FEAT_DND
Karsten Hopp 4c462a
  	"+dnd",
Karsten Hopp 4c462a
  #else
Karsten Hopp 4c462a
*** ../vim-7.4.392/src/vim.h	2014-04-02 19:54:58.275599459 +0200
Karsten Hopp 4c462a
--- src/vim.h	2014-08-06 14:21:57.467249166 +0200
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 134,139 ****
Karsten Hopp 4c462a
--- 134,146 ----
Karsten Hopp 4c462a
  # endif
Karsten Hopp 4c462a
  #endif
Karsten Hopp 4c462a
  
Karsten Hopp 4c462a
+ /* Check support for rendering options */
Karsten Hopp 4c462a
+ #ifdef FEAT_GUI
Karsten Hopp 4c462a
+ # if defined(FEAT_DIRECTX)
Karsten Hopp 4c462a
+ #  define FEAT_RENDER_OPTIONS
Karsten Hopp 4c462a
+ # endif
Karsten Hopp 4c462a
+ #endif
Karsten Hopp 4c462a
+ 
Karsten Hopp 4c462a
  /* Visual Studio 2005 has 'deprecated' many of the standard CRT functions */
Karsten Hopp 4c462a
  #if _MSC_VER >= 1400
Karsten Hopp 4c462a
  # define _CRT_SECURE_NO_DEPRECATE
Karsten Hopp 4c462a
*** ../vim-7.4.392/src/proto/gui_w32.pro	2013-08-10 13:37:36.000000000 +0200
Karsten Hopp 4c462a
--- src/proto/gui_w32.pro	2014-08-06 14:33:04.155244374 +0200
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 1,4 ****
Karsten Hopp 4c462a
--- 1,6 ----
Karsten Hopp 4c462a
  /* gui_w32.c */
Karsten Hopp 4c462a
+ int directx_enabled __ARGS((void));
Karsten Hopp 4c462a
+ int gui_mch_set_rendering_options __ARGS((char_u *s));
Karsten Hopp 4c462a
  void gui_mch_set_blinking __ARGS((long wait, long on, long off));
Karsten Hopp 4c462a
  void gui_mch_stop_blink __ARGS((void));
Karsten Hopp 4c462a
  void gui_mch_start_blink __ARGS((void));
Karsten Hopp 4c462a
*** ../vim-7.4.392/src/version.c	2014-08-06 13:36:56.091268582 +0200
Karsten Hopp 4c462a
--- src/version.c	2014-08-06 14:29:39.183245847 +0200
Karsten Hopp 4c462a
***************
Karsten Hopp 4c462a
*** 736,737 ****
Karsten Hopp 4c462a
--- 743,746 ----
Karsten Hopp 4c462a
  {   /* Add new patch number below this line */
Karsten Hopp 4c462a
+ /**/
Karsten Hopp 4c462a
+     393,
Karsten Hopp 4c462a
  /**/
Karsten Hopp 4c462a
Karsten Hopp 4c462a
-- 
Karsten Hopp 4c462a
A consultant is a person who takes your money and annoys your employees while
Karsten Hopp 4c462a
tirelessly searching for the best way to extend the consulting contract.
Karsten Hopp 4c462a
				(Scott Adams - The Dilbert principle)
Karsten Hopp 4c462a
Karsten Hopp 4c462a
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 4c462a
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 4c462a
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 4c462a
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///