[Lazarus] How can I improve my bitmap font drawing unit (attached) ?

Pavel Řezníček cigydd at gmail.com
Thu Aug 28 18:11:10 CEST 2008


Peter Williams wrote:
>
> Hi All,
>
> I'd like some advice about the attached unit, named 
> "uFixedWidthFonts.pas". It is designed to read 2-colour bitmaps of 
> font character sets of different sizes, from files which are Windowz 
> BMP format. For example, "Chars_Lower_8x8.bmp" -- this is a 320 x 56 
> pixels, 1 layer BMP file, file size 2.25 KB. E.g. the BMP file is a 2 
> colour image of a 256 character bitmap, where each character in the 
> BMP file (in this case) is 8x8 pixels.
>
> There are 8 BMP files:
>
> Chars_Lower_8x8.bmp
> Chars_Lower_16x16.bmp
> Chars_Lower_24x24.bmp
> Chars_Lower_32x32.bmp
> Chars_Upper_8x8.bmp
> Chars_Upper_16x16.bmp
> Chars_Upper_24x24.bmp
> Chars_Upper_32x32.bmp
>
> The *Lower* files define the Commodore PET 4032 upper/lower case 
> character set & the *Upper* files define the Graphics/Uppercase 
> character set.
>
> My main question is: would I be better off using a TImageList?!? Can 
> someone please post sample code. Note: I tried to run the TImageList 
> example program for Lazarus... it compiles okay... but when run it 
> does not find some of its files (BMPs) in the Image sub-folder of the 
> example program. e.g. it gets a runtime error.
>
> Note that this unit is based strongly on a unit from the Jedi SDL 
> component, sample unit for drawing bitmap fonts onto a graphic canvas.
>
> At the moment I use statements like this to define the bitmap font 
> (some of the code is pasted below):
>
> Best Regards & Happy Programming ;-)))
> PEW
> ...

G'day Peter,

what are you currently coding reminds me on my effort to rewrite an
Atari ST game. I had many single bitmaps for that reason but it was in
the times when I knew only Visual Basic and nothing more and was a
beginner. As I got experience, I created three regular MS Windows bitmap
fonts:

The 1st to simulate the real ST character set,
the 2nd to display the lowest character codes from 0 to 31 - I shifted
them by 32 in codes
the 3rd to resemble the Atari font style but displaying the Windows code
page (actually, it was in Eastern European CP1250).

I then managed to create a half-way text/binary editor that used the
RichTextBox to edit binary files from Atari in their original look.

I used a font creation program called Softy to achieve this and also the
resource editor shipped with Delphi 5.

In Visual Basic, there was a control called PictureClip. It would serve
well for your purpose (if you wrote it in VB, of course). I think it was
actually an OCX (ActiveX) control from Windows that you could employ but
if you are going to be multi-platform friendly, you cannot rely on a
Windows-only technology.

Picture clip's principle is that you can define rows and columns over a
loaded image and then easily get parts of it by accessing the cells or
get the part by directly specifying the coordinates and size of the
wanted region.

Does somebody know if there's such a control for Lazarus too?

BTW, you did this yourself. Every needed function is already contained
in the graphic controls containing TCanvas ;-)

I now try to start a Motorola 68000 code disassembler and perhaps a
partial Atari ST emulator.

However I have no special advise for you that you requested how to speed
the drawing up. I suppose you won't go the way of real system fonts
because your approach is more dynamic. It's easier to draw a bitmap of
the whole font than to use special software and install the font to the
system. Not mentioning that I found no direct way to convert those
system fonts to Linux.

Pavel



More information about the Lazarus mailing list