On Tue, Mar 20, 2018 at 2:24 PM, Karl Garrison <kgarri...@pobox.com> wrote:
> Does the SDL2 version of PDCurses still support using a custom font?  If so,
> are there any special considerations for this version?  Having pdcfont.bmp
> in the current directory does not work for me, nor does explicitly setting
> PDC_FONT environment work.

Don't know if the code has changed in the current version of PDCURSES
from what I added when I patched it to create the SDL2 port, but I
have the following documentation on how I modified fonts when working
with the SDL2_TTF:

Default font for SDL_TTF is assumed to be DejaVuSansMono.ttf from the Open
Source DejaVu fonts.  The code looks for this font to already be installed in
a standard directory (based on the Filesystem Hierarchy Standard)
/usr/local/share/fonts/truetype/dejavu/.  This can be modified by setting a
define during compile time
( -DPDC_FONT_PATH=/usr/share/fonts/truetype/dejavu/ ) This can be overridden
by initializing pdc_ttffont in your own code.  Similar to the
PDC_FONT environment variable for SDL bitmap fonts, one can also override TTF
fonts using the PDC_FONT and PDC_FONT_POINT_SIZE environment variables.

The SDL2 port adds:
  SDL_Window *pdc_window;
  SDL_Renderer *pdc_render;
  SDL_Texture *pdc_texture;
Using SDL_ttf (with SDL2 or SDL) adds:
  TTF_Font *pdc_ttffont;
  SDL_Color *pdc_ttffont_foregroundcolor;
  SDL_Color *pdc_ttffont_backgroundcolor;
  int pdc_ttffont_spointsz;
  int pdc_ttffont_hint;
These can be used or modified in your own code.  Like the pdc_screen variable
used by the SDL port, you can initialize pdc_window, pdc_render,
pdc_texture in your own code.  If it's not initialized, PDCurses will do
it for you.  See the sdltest demo for an example.  If PDCurses is built with
the PDC_WIDE flag, it will clean up/deallocate these variables on exit when
needed.

As mentioned, use the WIDE=Y flag with the makefile if you want
SDL2_TTF support.

I use the SDL2_TTF library with both SDL 1.x and SDL 2.x.  SDL2_TTF
supports the UCS-2 character set (16 bits).  If you want to work with
the UTF-32 character set (32 bits), I have a patched version I
modified to handle it.  You can find a link to the code at:
 http://www.distasis.com/cpp/lmports.htm

Last I checked, PDCURSES only supported the UCS-2 character set as
well.  (On Windows systems wchar_t is only 16 bits.)  Was going to
investigate support for 32 bits with PDCURSES at some point in the
future.

Sincerely,
Laura

Reply via email to