[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-user: PCB: simple FreeType fonts implementation



This subject has been discussed many times on this list.

Recently, I tested ideas from
http://archives.seul.org/geda/user/Jan-2009/msg00869.html
and this resulted in a patchset 2684726 at
https://sourceforge.net/tracker/index.php?func=detail&aid=2684726&group_id=73743&atid=538813

Of course, this is of very limited use, but somebody
may be interested.

  General features

First patches introduce multiple fonts per board; every text
has a pointer to it's font; the font for a new text
is selected in the text input window; I also added a field
for the font scale.

Then different text layouts are introduced.
Texts may be vertical or horizontal; the layout also may be
`reverse': for horizontal layouts this means right-to-left;
for vertical --- donwside-up.
(http://ineiev.users.sourceforge.net/pcb/graph/layout.png)
(the figure shows an optimistic case for a horizontal font turned
vertically: in general, the letters are not adjusted horizontally).

A new font type added, based on FreeType2 library. TTF and Type1
fonts seem to work, PCF don't (most probably, I load them
incorrectly).

The glyphs are loaded and rendered in DrawTextLowLevel() function;
perhaps some caching could improve performance, but this is a _simple_
implementation.

Kerning should work for horizontal layouts
(http://ineiev.users.sourceforge.net/pcb/graph/kerning.png)

FreeType does not support kerning for vertical layouts,
and actually I have no idea if the implementation may be used
for such scripts.

  Glyphs rendering

At first I rendered them with `vertical' lines, like this:
(http://ineiev.users.sourceforge.net/pcb/graph/fill.png)

This was the most simple way, though small characters become
unreadable too soon.

Then I learnt FreeType glyphs had outline structures and
drew them with lines:
(http://ineiev.users.sourceforge.net/pcb/graph/outline.png)

The next way was to join outlines with fills:
(http://ineiev.users.sourceforge.net/pcb/graph/full.png)

The `vertical' lines don't fill the outlines very good, some
small spaces remain; probably, something should be adjusted.

At last, I tried to do it with polygons:
(http://ineiev.users.sourceforge.net/pcb/graph/poly.png)

I don't do it clearly, because some contours need to be
added, other subtracted, and it is not evident to me how
to do it in real time.

Besides that, I think lines look more realistic, because
the polygons are not restricted with design rules;
the lines are.

  Cyrillic texts

The latest example demostrated a Cyrillic font; the implementation
matches this script quite well; some fonts lacked `ж' glyph;
no other inconveniences.

  Polytonic Greek

(http://ineiev.users.sourceforge.net/pcb/graph/grdjvu.png)
There may be some problems: first, the implementation does not
support combining characters, so there may be difficulties
when entering accented letters; I entered them
via Gnome character map application.

Also, once I could not pull `μ' glyph from a font,
though it was present; probably something wrong
with that font mapping.

  Devanagari

(http://ineiev.users.sourceforge.net/pcb/graph/devanagari.png)
The consonants are not joined into ligatures (this was expected);
however, it puts viramam where it makes sence; it even adds
vowels (much better than I expected).
`i short' is put in a wrong place: I actually wrote
an incorrect sequence to force it hang where it should,
e.g. "-ko(i)va-" instead of "-kovi-".

  Afro-Asiatic scripts

(http://ineiev.users.sourceforge.net/pcb/graph/ar.png)
I really can't tell how usable it is for tfel-ot-thgir scripts;
I reproduced a word, I don't know how correctly.
I checked "reverse" checkbox in the text input window and
dragged the letters from Gnome character map.
Some letters take several places in the map; my font accepted
one of them and rejected the rest.

  Some notes on usage

To load a font, use LoadFreetype action,
like this: LoadFreetype(some_font.pfb); it will be added to
the font list of the current board. Every font in the list
has use counter, it will be embedded when saving the board
if some texts use it.

Different rendering options (outlines, fill, polygons)
are switched with defines in src/ft2font.c

  Final remarks

Once I thought whether it would be better to use pango instead
of freetype; it would solve problems with combining character,
but it has the next disadvantages:
first, it is a stronger dependence;
second, it renders to bitmaps only, whereas having
vectored outlines is important when the characters grow small.

As I mentioned, these patches can hardly be used in practice,
because I had to change PCB file format, so mainstream PCB won't
read the files saved by the patched program.

Regards,
   Ineiev


_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user