Hi Victor,
Victor wrote:
I have a problem synchronizing text in Java Swing text components
(JTextPane) with the the text in SVG document.
My text component is positioned on the top of JSVCanvas and the idea is
to allow user edit text and then copy it to SVGDocument to be rendered.
The problem is that text kerning in Java components and SVG is
different. When text inserted to SVGDocument using SVG text element it
has position and height like in JTextPane (after User-space to SVG-space
transform), but distance between characters is different.
It is worth noting that a small difference in font-size or scale
factor may be unnoticeable for the height of the text but for any
length of text may become huge.
Does anyone know how add text to SVG document exactly how it appears
in Java (JTextPane or JTextField) component?
The default rendering of the SVG text comes directly from an
AWT GlyphVector. So they should match as long as it is a platform
font (i.e. not an SVG font).
I tried:
* Disable kerning in SVG and position each glyph individually using Java
GlyphVector and SVG <text x="..." y="...">. Doesn't work.
What do you mean? The text isn't positioned where you say it should
be? Are you using a list of x/y's? Sounds like your translation may
be a little off. Ask AWT what the text-length is and draw a line that
length in the document.
* Use AWTGVTFont to create GVTGlyphVector and get glyph positions Batik.
Doesn't work, all glyph info is null in AWTGVTFont, probably it can't be
used individually.
You could use the existing SVG Text API's to get the location of
each character in the string. There is a fairly complete example
in 'samples/tests/spec/scripting/text_content.svg'.
* Create text graphics node to let it render text in custom java
component. I created own SVGOMText element and when I try to convert
it to text graphics node using GVTBuilder it throws exception telling
that visibility info can't be converted. It seems to work only in
document context.
It needs CSS. The easiest way to get this is a document.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]