On Sat, Mar 24, 2018 at 3:09 PM, Karl Garrison
wrote: > Also, I don't see this in the docs anywhere, but it took me a bit to realize > that the BMP needed to be 1 BPP. ... I suggest adding a note to the > documentation about the BMP depth requirement Ahem... "The font is a simple BMP, 32 characters wide by 8 characters tall, preferably with a palette. (BMPs without palettes still work, but in that case, no attributes will be available, nor will the cursor work.) The first entry in the palette (usually black) is treated as the background color; the last entry (usually white) is treated as the foreground. These are changed or made transparent as appropriate; any other colors in the palette are passed through unchanged. So -- although a one-bit depth is sufficient for a normal font -- you could redraw some characters as multi-colored tiles." That's from doc/sdl.md (combined into PDCurses.md, if you build that). It's been there since 2007.
As it turns out, the problem was on my end. My image editor was saving in png mode, so presumably pdcurses SDL was ignoring the file since it couldn't load it. Also, I don't see this in the docs anywhere, but it took me a bit to realize that the BMP needed to be 1 BPP. A number of image editors don't have an option to save in this mode, and my results using a higher bit depth BMP were odd (colors didn't work). I suggest adding a note to the documentation about the BMP depth requirement, and also suggest having the library give a message if it finds a font file, but can't open it, or if it is the wrong bit depth. Thanks for your help! Karl On Wed, Mar 21, 2018, 4:58 PM LM
wrote: > On Wed, Mar 21, 2018 at 4:02 PM, Karl Garrison > wrote: > > The SDL2 port also seems to add an immense speed boost, so I'm happy > about > > that. I only "upgraded", though, to stay current. > > That's good to hear. > > > > > I double-checked, and I didn't compile with WIDE defined, so that's not > my > > issue. Maybe I'll try building under a Linux VM to see if my results are > > different. For my purposes right now, developing under there would be > good > > enough, if I can't get it to work on my Macbook. > > I didn't really test a lot without the WIDE since I was trying to add > the truetype font support. If you try with wide support (using > DejaVuSansMono.ttf in the directory expected by PDC_FONT_PATH), let me > know. I'd be curious to find out why font display might not be > working on the Mac. > > I'm still using my patched version of PDCURSES. Haven't had time to > update to the latest official version, so I don't know how much the > two differ. > > Sincerely, > Laura >
On Tue, Mar 20, 2018 at 2:24 PM, Karl Garrison
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