RE: svn commit: r1590665 - /xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/AbstractFOPTextPainter.java

2014-05-02 Thread Simon Steiner
Hi,

AbstractFOPTextPainter already had a AFP class call and is only extended by a 
AFP class, a senior developer said to me maybe we should rename this class to 
AbstractAFPFOPTextPainter.

Thanks

-Original Message-
From: Vincent Hennebert [mailto:vhenneb...@gmail.com] 
Sent: 29 April 2014 09:15
To: fop-dev@xmlgraphics.apache.org
Subject: Re: svn commit: r1590665 - 
/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/AbstractFOPTextPainter.java

On 28/04/14 17:06, ssteiner wrote:
> Author: ssteiner
> Date: Mon Apr 28 15:06:33 2014
> New Revision: 1590665
>
> URL: http://svn.apache.org/r1590665
> Log:
> FOP-2345 SVG to AFP text spacing wrong
>
> Modified:
>  
> xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/AbstractFOPTextPaint
> er.java
>
> Modified: 
> xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/AbstractFOPTextPaint
> er.java
> URL: 
> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache
> /fop/svg/AbstractFOPTextPainter.java?rev=1590665&r1=1590664&r2=1590665
> &view=diff 
> ==
> 
> --- 
> xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/AbstractFOPTextPaint
> er.java (original)
> +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/AbstractFOPTextP
> +++ ainter.java Mon Apr 28 15:06:33 2014
> @@ -152,8 +152,21 @@ public abstract class AbstractFOPTextPai
>   double y = outputLocation.getY();
>   try {
>   try {
> +AFPGraphics2D afpg2d = (AFPGraphics2D)g2d;
> +int fontSize = 0;
> +if (font != null) {
> +fontSize = (int) 
> Math.round(afpg2d.convertToAbsoluteLength(font.getFontSize()));
> +}
> +if (fontSize < 6000) {
> +nativeTextHandler.drawString(g2d, txt, (float) (x + 
> tx), (float) y);
> +} else {
> +double scaleX = g2d.getTransform().getScaleX();
> +for (int i = 0; i < txt.length(); i++) {
> +double ad = 
> run.getLayout().getGlyphAdvances()[i] * scaleX;
> +nativeTextHandler.drawString(g2d, txt.charAt(i) 
> + "", (float) (x + tx + ad), (float) y);
> +}
> +}

AFP-specific code in an abstract text painter? Surely this code shouldn’t be 
there? Sounds like it should be moved into the implementation of drawString.

Vincent



Re: svn commit: r1590665 - /xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/AbstractFOPTextPainter.java

2014-05-01 Thread Luis Bernardo


This is indeed confusing but the problem comes from before. This 
abstract class is abstract only in name since it is only extended by the 
AFPTextPainter class. I think I may merge both and move the resulting 
class to one of the afp packages.


On 4/29/14, 9:15 AM, Vincent Hennebert wrote:

On 28/04/14 17:06, ssteiner wrote:

Author: ssteiner
Date: Mon Apr 28 15:06:33 2014
New Revision: 1590665

URL: http://svn.apache.org/r1590665
Log:
FOP-2345 SVG to AFP text spacing wrong

Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/AbstractFOPTextPainter.java

Modified: 
xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/AbstractFOPTextPainter.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/AbstractFOPTextPainter.java?rev=1590665&r1=1590664&r2=1590665&view=diff
== 

--- 
xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/AbstractFOPTextPainter.java 
(original)
+++ 
xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/AbstractFOPTextPainter.java 
Mon Apr 28 15:06:33 2014

@@ -152,8 +152,21 @@ public abstract class AbstractFOPTextPai
  double y = outputLocation.getY();
  try {
  try {
+AFPGraphics2D afpg2d = (AFPGraphics2D)g2d;
+int fontSize = 0;
+if (font != null) {
+fontSize = (int) 
Math.round(afpg2d.convertToAbsoluteLength(font.getFontSize()));

+}
+if (fontSize < 6000) {
+nativeTextHandler.drawString(g2d, txt, 
(float) (x + tx), (float) y);

+} else {
+double scaleX = g2d.getTransform().getScaleX();
+for (int i = 0; i < txt.length(); i++) {
+double ad = 
run.getLayout().getGlyphAdvances()[i] * scaleX;
+nativeTextHandler.drawString(g2d, 
txt.charAt(i) + "", (float) (x + tx + ad), (float) y);

+}
+}


AFP-specific code in an abstract text painter? Surely this code
shouldn’t be there? Sounds like it should be moved into the
implementation of drawString.

Vincent




Re: svn commit: r1590665 - /xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/AbstractFOPTextPainter.java

2014-04-29 Thread Vincent Hennebert

On 28/04/14 17:06, ssteiner wrote:

Author: ssteiner
Date: Mon Apr 28 15:06:33 2014
New Revision: 1590665

URL: http://svn.apache.org/r1590665
Log:
FOP-2345 SVG to AFP text spacing wrong

Modified:
 
xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/AbstractFOPTextPainter.java

Modified: 
xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/AbstractFOPTextPainter.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/AbstractFOPTextPainter.java?rev=1590665&r1=1590664&r2=1590665&view=diff
==
--- 
xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/AbstractFOPTextPainter.java 
(original)
+++ 
xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/AbstractFOPTextPainter.java 
Mon Apr 28 15:06:33 2014
@@ -152,8 +152,21 @@ public abstract class AbstractFOPTextPai
  double y = outputLocation.getY();
  try {
  try {
+AFPGraphics2D afpg2d = (AFPGraphics2D)g2d;
+int fontSize = 0;
+if (font != null) {
+fontSize = (int) 
Math.round(afpg2d.convertToAbsoluteLength(font.getFontSize()));
+}
+if (fontSize < 6000) {
+nativeTextHandler.drawString(g2d, txt, (float) (x + 
tx), (float) y);
+} else {
+double scaleX = g2d.getTransform().getScaleX();
+for (int i = 0; i < txt.length(); i++) {
+double ad = run.getLayout().getGlyphAdvances()[i] 
* scaleX;
+nativeTextHandler.drawString(g2d, txt.charAt(i) + 
"", (float) (x + tx + ad), (float) y);
+}
+}


AFP-specific code in an abstract text painter? Surely this code
shouldn’t be there? Sounds like it should be moved into the
implementation of drawString.

Vincent