Propchange: 
xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/svg/font/FontInfoBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/svg/font/FontInfoBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Revision Id

Added: 
xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/svg/font/GlyphLayoutTestCase.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/svg/font/GlyphLayoutTestCase.java?rev=1508208&view=auto
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/svg/font/GlyphLayoutTestCase.java
 (added)
+++ 
xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/svg/font/GlyphLayoutTestCase.java
 Mon Jul 29 21:45:20 2013
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.svg.font;
+
+import java.util.Collections;
+
+import org.junit.Test;
+
+import org.apache.fop.fonts.FontInfo;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Specifically tests glyph positioning from a real font.
+ */
+public class GlyphLayoutTestCase extends FOPGVTGlyphVectorTest {
+
+    /**
+     * Glyph positioning using the legacy kern table.
+     */
+    @Test
+    public void testBasicGlyphPositioning() throws Exception {
+        testGlyphLayout(false);
+    }
+
+    /**
+     * Glyph positioning using GPOS sub-tables.
+     */
+    @Test
+    public void testAdvancedGlyphPositioning() throws Exception {
+        testGlyphLayout(true);
+    }
+
+    private void testGlyphLayout(boolean useAdvanced) {
+        FOPGVTFont font = loadFont(useAdvanced);
+        glyphVector = (FOPGVTGlyphVector) font.createGlyphVector(null, 
"L\u201DP,V.F,A\u2019LT.");
+        glyphVector.performDefaultLayout();
+        // Values in font units (unitsPerEm = 2048), glyph width - kern
+        int[] widths = {
+                /* L */ 1360 - 491,
+                /* " */ 1047,
+                /* P */ 1378 - 415,
+                /* , */ 651,
+                /* V */ 1479 - 358,
+                /* . */ 651,
+                /* F */ 1421 - 319,
+                /* , */ 651,
+                /* A */ 1479 - 301,
+                /* ' */ 651,
+                /* L */ 1360 - 167,
+                /* T */ 1366 - 301,
+                /* . */ 651};
+        checkGlyphPositions(13, widths);
+    }
+
+    private FOPGVTFont loadFont(boolean useAdvanced) {
+        FontInfo fontInfo = new 
FontInfoBuilder().useDejaVuLGCSerif(useAdvanced).build();
+        FOPFontFamilyResolver resolver = new 
FOPFontFamilyResolverImpl(fontInfo);
+        FOPGVTFontFamily family = 
resolver.resolve(FontInfoBuilder.DEJAVU_LGC_SERIF);
+        return family.deriveFont(1000, Collections.emptyMap());
+    }
+
+    private void checkGlyphPositions(int expectedGlyphCount, int[] widths) {
+        assertEquals(expectedGlyphCount, glyphVector.getNumGlyphs());
+        float[] positions = new float[2 * (widths.length + 1)];
+        for (int i = 0, n = 2; i < widths.length; i++, n += 2) {
+            positions[n] = positions[n - 2] + widths[i] / 2.048f;
+        }
+        for (int i = 0; i <= widths.length; i++) {
+            assertEquals(positions[2 * i], 
glyphVector.getGlyphPosition(i).getX(), 3);
+        }
+    }
+
+}

Propchange: 
xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/svg/font/GlyphLayoutTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/svg/font/GlyphLayoutTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Revision Id

Added: 
xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/svg/glyph-orientation.svg
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/svg/glyph-orientation.svg?rev=1508208&view=auto
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/svg/glyph-orientation.svg
 (added)
+++ 
xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/svg/glyph-orientation.svg
 Mon Jul 29 21:45:20 2013
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<svg width="100" height="140" xmlns="http://www.w3.org/2000/svg";>
+<rect x="0" y="0" width="100%" height="100%" fill="none" stroke="black" 
stroke-width="2"/>
+<g transform="translate(10) scale(20) scale(0.001) translate(0, 1000)"
+  font-family="sans-serif" font-size="1000">
+  <text x="1000" writing-mode="tb">ABCD</text>
+  <text x="2500" writing-mode="tb" glyph-orientation-vertical="0">EFGH</text>
+  <text x="0" y="5000" glyph-orientation-horizontal="270">IJKL</text>
+</g>
+</svg>

Added: 
xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/svg/rotated-glyph.svg
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/svg/rotated-glyph.svg?rev=1508208&view=auto
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/svg/rotated-glyph.svg
 (added)
+++ 
xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/svg/rotated-glyph.svg
 Mon Jul 29 21:45:20 2013
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+<svg width="300" height="150" xmlns="http://www.w3.org/2000/svg";>
+<rect x="0" y="0" width="100%" height="100%" fill="none" stroke="black" 
stroke-width="2"/>
+<text font-family="Helvetica" font-size="100" x="40" y="110" rotate="0 45 
0">ABC</text>
+</svg>

Added: 
xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/svg/spacing.svg
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/svg/spacing.svg?rev=1508208&view=auto
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/svg/spacing.svg
 (added)
+++ 
xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/svg/spacing.svg
 Mon Jul 29 21:45:20 2013
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<svg width="150" height="200" xmlns="http://www.w3.org/2000/svg";>
+<rect x="0" y="0" width="100%" height="100%" stroke="black" stroke-width="2" 
fill="none"/>
+<g transform="translate(10) scale(40) scale(0.001) translate(0, 1000)"
+  font-family="sans-serif" font-size="1000">
+  <g transform="">
+    <text>VAV</text>
+    <line x1="667" y1="-818" x2="667" y2="100" stroke-width="10" 
stroke="blue"/>
+  </g>
+  <g transform="translate(0, 1000)">
+    <text kerning="0">VAV</text>
+    <line x1="667" y1="-818" x2="667" y2="100" stroke-width="10" 
stroke="blue"/>
+  </g>
+  <g transform="translate(0, 2000)">
+    <text letter-spacing="100">VAV</text>
+  </g>
+  <g transform="translate(0, 3000)">
+    <text word-spacing="500">ab cd</text>
+  </g>
+</g>
+</svg>



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to