Charpath

lenniii

Aktives Mitglied
Guten Abend,

ich bin auf der suche nach einer Methode die Außenlinien eines Textes als Pfad auf einer 2D-Fläche zu holen.

Ich habe eine Leinwand:
Java:
Graphics2D image
und ein Pfad:
Java:
GeneralPath path

Im Prinzip stelle ich mir das so vor, dass es ggf. eine Klasse gibt, die einen String als Konstruktor nimmt, und einen GeneralPath zurückliefert, der die Außenlinien beschreibt.
Java:
public GeneralPath charpath(String str){
     return charpath;
}


Hintergrund: ich baue einen PostScript Interpreter, der PostScript-Dateien als Pixelgrafiken speichert. Der Operator nennt sich 'charpath'.
Original Beschreibung Adobe PostScript Language Reference (third edition)
intersects the area inside the current clipping path with the area inside the current path to produce a new, smaller clipping path. The nonzero winding number rule (see “Nonzero Winding Number Rule” on page 195) is used to determine what points lie inside the current path, while the inside of the current clipping path is determined by whatever rule was used at the time the path was created.
In general, clip produces a new path whose inside (according to the nonzero winding number rule) consists of all areas that are inside both of the original paths. The way this new path is constructed (the order of its segments, whether it self-intersects, and so forth) is not specified. clip treats an open subpath of the current path as though it were closed; it does not actually alter the path itself. It is permissible for the current path to be empty. The result of executing clip is always a nonempty clipping path, though it may enclose zero area.
There is no way to enlarge the current clipping path (other than by initclip or initgraphics) or to set a new clipping path without reference to the current one. The recommended way of using clip is to bracket the clip operation and the sequence of graphics operations to be clipped between gsave and grestore or between clipsave and cliprestore. The grestore will restore the clipping path that was in effect before the gsave. The setgstate operator can also be used to reset the clipping path to an earlier state.
Unlike fill and stroke, clip does not implicitly perform a newpath operation after it has finished using the current path. Any subsequent path construction opera- tors will append to the current path unless newpath is invoked explicitly; this can cause unexpected behavior.

Vielen Dank für Bemühungen
Lenniii
 

Ebenius

Top Contributor
Ein Shape kannst Du so erzeugen:
Java:
  static Shape convertText(
        String text,
        Font font,
        FontRenderContext frc,
        boolean ltr) {
    final int flags =
          ltr ? Font.LAYOUT_LEFT_TO_RIGHT : Font.LAYOUT_RIGHT_TO_LEFT;
    final GlyphVector gv =
          font.layoutGlyphVector(frc, text.toCharArray(), 0, text.length(),
                flags);
    return gv.getOutline();
  }
Einen GeneralPath kannst Du Dir ja aus dem Shape machen.

Ebenius
 

Neue Themen


Oben