Groups | Blog | Home
all groups > dotnet drawing api > july 2003 >

dotnet drawing api : Help: Alternatives to using raster fonts as graphics


John Tempest
7/9/2003 11:21:11 AM
I'm looking for some advice here. I was thinking of using a raster font
(*.fon) with a subset of dedicated block graphics characters, and then
producing an animated graphics display on a form using the DrawString method
with appropriate pen colours and background colours. Most of the screen
would be fixed display with the rest being elements that display changes of
states by repainting those elements with DrawString and changes of
foreground or background colour. This seemed to me to be a very simple way
of dealing with the graphical display which could be updated at intervals of
a second without much processing overhead.

Unfortunately, it seems, as far as I can tell, that the appropriate methods
for loading a raster font are not implemented in dotNet 1.1 in that you can
only use TrueType or OpenType fonts in font families! I only need a raster
font of fixed width and fixed point size and then I can position the
DrawString in relation to the virtual row and column of a text page.

So I'm looking for alternatives:
1. If there is a way of using an existing raster font and loading it so that
I can associate it with the form and use the DrawString method, I'd like
someone to tell me how to do that -- I can't find anything in the MSDN
library about this, nor in the WROX books on GDIplus.
2. I could, if there was an easy and inexpensive set of tools available,
modify one of the TrueType fixed width fonts and add a set of block graphics
to it. Nothing fancy is required: mostly recti-linear shapes and lines (some
diagonal) which have to fit (align) together; only two curved shapes: one a
circle (outline and filled), the other a quadrant of a circle (outline and
filled). Font editors for TrueType and OpenType font families seem to rather
expensive, and I don't need any of the complexities of ensuring that the
graphics look equally good over a range of font sizes (nor do they need to
be displayed on a web page). The kind of help that would be useful here is
where to get suitable freeware utilities and access to articles that would
help me.
3. The third alternative, which to me is the least favourable, is to
construct a set of bit maps, either as 1-bit maps which could be drawn in
one of 3 or 4 colours according to the state they are representing, or
duplicating the bit maps (ie one for each colour state).
4. Finally, write to an ANSI graphics screen from the dotNet program, if
that is still possible, and use the old ANSI graphics control characters for
setting foreground and background colours (including the flashing attribute)
and an appropriate raster graphics font. Again, it would be helpful to be
pointed to any useful articles available anywhere on the net or in book
form.

I would prefer to use the dotNet package and C# as the development system,
particularly for the benefits gaint in using classes, properties and
methods, in modelling the system that I want to represent and also for
handling the user interface: mouse-clicks, hot-spots, etc.

Any help would be greatly appreciated, thanks in advance.

John Tempest


Bob Powell [MVP]
7/9/2003 2:11:48 PM
As you correctly state, the fonts in .NET only support TrueType and OpenType
fonts. Other font programs are incompatible and cannot be used. There are no
third party tools that enable this to my knowledge.

I think that option 3 is probably your best bet even though it's not your
preferred choice. I have an article in the GDI+ FAQ that explains how to
convert colour bitmaps to 1 bit per pixel bitmaps. You could use that method
and modify the palette color for your state changes.

I don't know of any way to send ASCII control characters to the console. I
tried this some time ago and was unsuccessful.

--
Bob Powell [MVP]
C#, System.Drawing

Check out the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Buy quality Windows Forms tools
http://www.bobpowell.net/xray_tools.htm

New GDI+ articles include how to use the LinearGradientBrush and
how to draw text on a reversed Y axis for graphs and charts.

[quoted text, click to view]

Bob Powell [MVP]
7/9/2003 2:29:19 PM
I found this which may be of interest to you...

http://users.iclway.co.uk/l.emmett/

--
Bob Powell [MVP]
C#, System.Drawing

Check out the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Buy quality Windows Forms tools
http://www.bobpowell.net/xray_tools.htm

New GDI+ articles include how to use the LinearGradientBrush and
how to draw text on a reversed Y axis for graphs and charts.

[quoted text, click to view]

John Tempest
7/10/2003 1:50:01 PM
Bob, Thanks for the responses. I found your GDI+ FAQ very useful, and I am
experimenting with some of the examples. I now have some practical
alternatives to look at which I feel I can cope with.

It's a shame, none-the-less, that Microsoft has abandoned the support for
raster based fonts (and thereby, support for raster graphics solutions for
animated control systems - which are still the main means of providing
graphically oriented control systems for most industrial organisations, eg
Railway signalling, industrial chemical productions, steel mills, and
electrical generation and distribution systems, etc, etc, where the main
display devices have built-in block-character type font characters which can
have foreground and background colour, brightness, and flashing attributes,
and which can accurately and simply positioned on the display by simple
escape sequences!). Microsoft has put in tremendous resources for the
development of sophisticated, artistic, and cleanly designed fontography and
print/display layout with the TrueType and OpenType systems. But the skills
needed to alter or edit fonts are now beyond the average programmer!
Likewise, the concentration on development facilities for commerce, business
management, and finance, has left huge gaps in the development facilities
for applications outside this area.

John Tempest

[quoted text, click to view]

Bob Powell [MVP]
7/10/2003 6:26:05 PM
I suppose really that fonts used in a graphics role were simply an answer to
character based displays and a font these days needs to be a little more
sophisticated than a bitmap stored in an indexed file somewhere.

I've recently written code in .NET that decodes and extracts information
from true-type fonts, such as the character advance values and so-on.

If I could find the FON file format spec somewhere I have no doubt that I
could do a raster font reader. I've looked all over for it though and I
can't find it. Maybe I can't see the wood for the trees...

--
Bob Powell [MVP]
C#, System.Drawing

Check out the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Buy quality Windows Forms tools
http://www.bobpowell.net/xray_tools.htm

New GDI+ articles include how to use the LinearGradientBrush and
how to draw text on a reversed Y axis for graphs and charts.

[quoted text, click to view]

Niklas Gustavsson
7/10/2003 7:01:10 PM
[quoted text, click to view]

This sounds very interesting! Is the source code available for use?

/niklas
-------------------
Weblog at http://www.protocol7.com
Lead developer for SVG# (http://www.sharpvectors.org)
John Tempest
7/11/2003 11:26:21 AM
Wouldn't the structures for Fonts and something like _LoadFon be detailed
somewhere in the source code for MFC? I.e. you could trace it back through
the source codes provided for debugging in earlier versions of Visual C or
Visual C++.

John Tempest

[quoted text, click to view]

AddThis Social Bookmark Button