Re: Vector Graphics - was MFC and GDI+
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Tue, 24 Apr 2007 21:20:28 -0400
The problem with MoveTo/LineTo is the rasterizing of the logical coordinates; sometimes
you get thick lines, sometimes you get thin lines, depending on where the logical/physical
boundaries are. So, for example, to draw vertical lines, I used a symbol in the font,
which had the guarantee that no matter what scale I was at, or where the line was drawn
along the x-axis, it was always the same width in every case. I made the mistake of doing
LineTo calls and we got really ugly results. In one case, where I had to draw a 3-line
percussion staff, I created a clipping region, drew a standard 5-line staff, but the
clipping region lopped off the lower two lines, but the lines were always the same
thickness, no matter where they landed.
For the braces, we had an upper-half-brace character and a lower-half-brace character, and
got the font renderer to deal with the edge conditions where the lines got small at the
edges. I tried Beziers, but ultimately the only place we used them were for the slurs.
The screen resolution was bad enough that we could substitute a simple Bezier line, good
enough for layout, but a fancy Bezier-delimited area (filled with black) made a convincing
slur on the printer. Since we had two different graphics engines [argh! don't ask! It
was Not A Pretty Sight], getting that to fit perfectly in a WYSIWYG fashion was one of the
interesting challenges.
joe
On Mon, 23 Apr 2007 09:38:16 +0100, "David Webber" <dave@xxxxxxxxxxxxxxxxxxx> wrote:
Joseph M. Newcomer [MVP]
"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> wrote in message
news:mmgn231ks80mebd1mpk90mi8tom3gikqbn@xxxxxxxxxx
The solution is to use a music font; there are several available....
I know all about music fonts - I wrote mine first as soon as Windows 3.1
came out with the wonders of TrueType, and have updated it at intervals
since.
By writing my own I have complete control over the positions of the origin
of every symbol, and indeed what "components of music symbols" are
considered as part of the font. I can also distribute it with my program
(which relies on it) free of any royalties.
But music images are not just a series of symbols: there are lots of lines
too - all at different angles. There's an illuatration with lots of them
at:
http://www.mozart.co.uk/information/illustrations/exsolc.htm
Anything which looks like a symbol - note heads, clefs, key signatures,
curly tails (eg the lowest note at the end of the first line) etc are drawn
with the font.
All straight lines are drawn with MoveTo adn LineTo (and antialiasing is a
result of my having reduced the image for presentation as a web page).
All curved lines are drawn with bezier splines. I am particularly proud of
the braces { at the left of the stave, which again, because they can be of
arbitrary height and thickness are not necessarily best drawn as font
characters - these are drawn as a series of "almost parallel beziers".
(Not necessarily fast but there are rarely more than three on the screen at
a time.)
I would never tackle a music typesetting problem in terms of using my own
bitmaps
for the musical symbols. It just won't work.
Actually it can, but only for some purposes. For a particular small size
on the screen I have a collection of bitmaps which can be used as a sort of
custom raster font. It is clearer than the truetype font at the smae
hight, because I have taken liberties with the scaling (and WYSIWYGness) to
make it so. It gives a particular combination of seeing a lot of music on
the screen, and being able to edit it clearly. It *was* incredibly
useful. Less so now if you have 1280x1024 pixels or more, but nevertheless
a lot of people use it routinely.
(I should point out that I spent several
years writing music software using PostScript fonts. I developed the
in-printer
PostScript library and sent down commands that laid out the pages, so I'm
not without
substantial experience in this area). The fonts also can handle things
like the staff
lines, which can end up being either one pixel or two pixels wide
depending on the layout.
I draw them at a thickness which depends on the stave height. One two, or
more pixels thick (on really high res printers).
You either have to swtich back and forth between logical space and device
space,...
I do this in one or two places - not often I think. [Or it may be buried so
transparently in my drawing classes that I have forgotten.] But in fact I
have a classes which represent the page (and everything else) in pixel
units and do everything in MM_TEXT mode.
or use
the musical staff character from the font, qhich in the case of the Adobe
font, guarantees
that all staff lines will be the same width on any output device
whatsoever (I drew the
font by anisotropic mapping of the font and therefore wrote exactly one
character for each
mjusical line. Then I changed coordinate systems and laid the notes down
on top of that).
The anisotropic mapping idea is one I have occasionally thought about, but
never explored. (I thought about it for the beziers I mentioned above.)
But in general I think there are too many variables: consider a diagonal
line with a certain thickness. You can put the ends of the line where you
want (vertically and horizontally) but then the thickness ends up at
whatever it ends up at.
Vector GRAPHICS representations of musical symbols don't work well because
the mappings to
pixel space do not properly handle scaling, roundoff, etc.; on the other
hand, font
rendering engines are EXTREMELY GOOD at handling device-specific
transformations of vector
graphics to pixel graphics,
I agree entirely. [It was the advent of TrueType in Windows 3.1 (ca
1991?) that made me realise that I could get good quality results.]
and the Adobe Sonata font is particularly pleasant to work in.
I'd have to take it apart in my font editor(s) to locate the origins of the
symbols....
We didn't use it for the screen font because the app was done in MS-DOS,
but I've also
used it for some Windows work and the results were nice. We ended up
using a
public-domain music font for product distribution because the licensing
issues with Adobe
were too hard to deal with for a small (1-person) company,
.. but no surprises there then :-( That's why I bought Fontographer in
the very early 90s and spent some tharepeutic time designing symbols :-)
It does have the disadvantage the MOZART requires the symbols to have their
origins and relative sizes specified very precisely. But one 3rd party font
has been produced for MOZART, and I'm happy to give the spec to anyone else
who wants to produce one.
Dave
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- Follow-Ups:
- Re: Vector Graphics - was MFC and GDI+
- From: David Webber
- Re: Vector Graphics - was MFC and GDI+
- References:
- MFC and GDI+
- From: David Webber
- Re: MFC and GDI+
- From: Michael Phillips, Jr.
- Re: MFC and GDI+
- From: David Webber
- Re: MFC and GDI+
- From: Michael Phillips, Jr.
- Re: MFC and GDI+
- From: Michael Phillips, Jr.
- Re: MFC and GDI+
- From: David Webber
- Re: MFC and GDI+
- From: Michael Phillips, Jr.
- Vector Graphics - was MFC and GDI+
- From: David Webber
- Re: Vector Graphics - was MFC and GDI+
- From: Joseph M . Newcomer
- Re: Vector Graphics - was MFC and GDI+
- From: David Webber
- MFC and GDI+
- Prev by Date: Re: Variable of Timer ?
- Next by Date: Re: How to increase the CComboBox drop-down size ?
- Previous by thread: Re: Vector Graphics - was MFC and GDI+
- Next by thread: Re: Vector Graphics - was MFC and GDI+
- Index(es):
Relevant Pages
|