Re: Vector Graphics - was MFC and GDI+

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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" <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
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: How to swee youtube videos,
    ... For what it's worth, US-ASCII has always been inadequate, even for plain ... Yep, despite what many would think, English, itself, uses ... The mess of font selection in Mozilla isn't their own fault? ... the pixel as the size (it's scaled, ...
    (Fedora)
  • Re: Vector Graphics - was MFC and GDI+
    ... The solution is to use a music font; ... which can end up being either one pixel or two pixels wide depending on the layout. ... Vector GRAPHICS representations of musical symbols don't work well because the mappings to ... Nowadays printers generally gave a better resolution, ...
    (microsoft.public.vc.mfc)
  • Re: Screen vs Printer Fonts
    ... defines the output as Courier 10 pt. ... the entries in the list box are aligned just right on the display but when I print them they do not. ... The former is a TrueType or OpenType font which has a fairly wide range of available point sizes and the latter is a Screen Font which is much more restricted regarding the available point sizes, so I'm not quite sure exactly what you are doing, or whether your mention of two different font names is a simple typo in your post. ... This is because all fonts, whether they are screen fonts or TrueType fonts, are restricted to being displayed in "whole pixel" units on the output device on which they are used. ...
    (microsoft.public.vb.general.discussion)
  • Re: Find The Text :-)
    ... with the problem you have noticed, the default font point size on your ... That value is not allowed, because it is not a "whole pixel" value, and so ... the "glyphs" of most characters (the parts of the character cell ...
    (microsoft.public.vb.general.discussion)
  • Re: Find The Text :-)
    ... Actually, although what I am about to say has nothing whatsoever to do with the problem you have noticed, the default font point size on your system is not 8! ... That's because Windows requires all font sizes to be a size that equates to a "whole pixel value" on the specified output device and at the standard 96 dpi screen setting a font size of 8 points would be the equivalent of 8/72*96 = 10.67 pixels. ... There are occasions when the width and height of rectangle is dealt with differently by different pieces of code. ... However, the "glyphs" of most characters (the parts of the character cell that are black in black text) do not actually occupy the entire character cell and there is some "white space" within the cell, some at the top and some at the bottom and a little bit less at both sides, and sometimes "the black bits" even extend outside of the cell they occupy. ...
    (microsoft.public.vb.general.discussion)