[aXSL-commit] SF.net SVN: axsl:[2688] trunk/axsl
An API for XSL-FO.
Status: Alpha
Brought to you by:
victormote
From: <vic...@us...> - 2023-01-18 19:02:03
|
Revision: 2688 http://sourceforge.net/p/axsl/code/2688 Author: victormote Date: 2023-01-18 19:02:02 +0000 (Wed, 18 Jan 2023) Log Message: ----------- 1. Add ipd to creation methods for word content. 2. Add method returning a horizontal stretch value for text items. 3. Add doc regarding meaning and completeness of various items related to text state. Modified Paths: -------------- trunk/axsl/axsl-areatree/src/main/java/org/axsl/area/factory/LineContentFactory.java trunk/axsl/axsl-galley/src/main/java/org/axsl/galley/GlyphAreaSequenceG5.java trunk/axsl/axsl-galley/src/main/java/org/axsl/galley/trait/CharacterTraitsTa.java Modified: trunk/axsl/axsl-areatree/src/main/java/org/axsl/area/factory/LineContentFactory.java =================================================================== --- trunk/axsl/axsl-areatree/src/main/java/org/axsl/area/factory/LineContentFactory.java 2023-01-14 15:46:15 UTC (rev 2687) +++ trunk/axsl/axsl-areatree/src/main/java/org/axsl/area/factory/LineContentFactory.java 2023-01-18 19:02:02 UTC (rev 2688) @@ -86,12 +86,14 @@ * @param paragraph The text words for which the glyph areas should be created. * @param startLocation The starting location in {@code paragraph} for the text in the new area, inclusive. * @param endLocation The ending location in {@code paragraph} for the text in the new area, exclusive. + * @param ipd The inline-progression-dimension, in millipoints, which the new {@link GlyphAreaSequenceG5} consumes + * on the line. * @param hasFauxSmallCaps True if and only if the new {@link GlyphAreaSequenceG5} item content should be handled as * faux small caps. * @return The new {@link GlyphAreaSequenceG5} instance, or null if there is no content. */ GlyphAreaSequenceG5 createGlyphAreaSequence(FoTextWords paragraph, TextTokenFlowLocation startLocation, - TextTokenFlowLocation endLocation, boolean hasFauxSmallCaps); + TextTokenFlowLocation endLocation, int ipd, boolean hasFauxSmallCaps); /** * Creates a new Area for external-graphic content. Modified: trunk/axsl/axsl-galley/src/main/java/org/axsl/galley/GlyphAreaSequenceG5.java =================================================================== --- trunk/axsl/axsl-galley/src/main/java/org/axsl/galley/GlyphAreaSequenceG5.java 2023-01-14 15:46:15 UTC (rev 2687) +++ trunk/axsl/axsl-galley/src/main/java/org/axsl/galley/GlyphAreaSequenceG5.java 2023-01-18 19:02:02 UTC (rev 2688) @@ -29,7 +29,46 @@ import org.axsl.galley.trait.NominalFontTa; /** - * An Area containing text. + * <p>An Area containing text. + * This class does not map directly to a concept in the XSL-FO Area Tree. + * XSL-FO has a notion of a "glyph-area" which is useful for the abstract description of the laid-out document. + * As a practical matter, it is much more convenient to treat contiguous glyph-areas that have identical text-related + * traits as a sequence of such glyph-areas, which is what this class represents.</p> + * + * <p>Implementations of this interface are primarily concerned with providing information about the + * inline-progression-dimension. + * We will use PDF as a baseline format to which we might render documents. + * The PDF "Text State Parameters and Operators" lists nine parameters that can be set when writing text.</p> + * <ul> + * <li>"Character spacing" is handled by {@link CharacterTraitsTa#traitLetterSpacing()}.</li> + * <li>"Word spacing" is handled by {@link CharacterTraitsTa#traitWordSpacing()}.</li> + * <li>"Horizontal scaling" is handled by {@link CharacterTraitsTa#getIpdScaling()}.</li> + * <li>"Leading" is specifically handled by other areas, specifically those that stack the line areas of which this + * glyph-area sequence might be a part.</li> + * <li>"Text font" is handled by {@link NominalFontTa#traitNominalFont()}.</li> + * <li>"Text font size" is handled by {@link FontSizeTa#traitFontSize()}.</li> + * <li>"Text rendering mode" handles how glyphs are stroked and filled and clipped. + * XSL-FO only considers that text will be filled, so we do not consider this parameter.</li> + * <li>"Text rise" has to do with temporary positioning for items like subscripts and superscripts. + * This is handled by the method {@link GeneralInlineAreaG5#baselineY()}.</li> + * <li>"Text knockout" is a relatively esoteric concept that doesn't map to anything in XSL-FO and is therefore not + * supported.</li> + * </ul> + * + * <p>The order in which these parameters is applied is significant. + * Again, we will follow the PDF model:</p> + * <ol> + * <li>Conceptually, font-size is applied to everything for purposes of scaling both block-progression-dimension and + * inline-progression-dimension. + * Then any "horizontal scaling" is applied, but only to the inline-progression-dimension.</li> + * <li>Character spacing and word spacing are provided in text-space units. + * In other words, when computing their actual size, the font-size must first be applied, then any ipd stretching. + * For example, word spacing of 20 at 12 points and 100% stretch would result in 240 millipoints. + * If a stretch of 105% were applied, the result would be 240 * 1.05 = 252 millipoints. + * Stated another way, character spacing and word spacing are both affected by the horizontal scaling.</li> + * </ol> + * + * @see "PDF Reference, Sixth Edition (PDF Format Version 1.7), Section 5.2, Text State Parameters and Operators." */ public interface GlyphAreaSequenceG5 extends GeneralInlineAreaG5, NominalFontTa, Modified: trunk/axsl/axsl-galley/src/main/java/org/axsl/galley/trait/CharacterTraitsTa.java =================================================================== --- trunk/axsl/axsl-galley/src/main/java/org/axsl/galley/trait/CharacterTraitsTa.java 2023-01-14 15:46:15 UTC (rev 2687) +++ trunk/axsl/axsl-galley/src/main/java/org/axsl/galley/trait/CharacterTraitsTa.java 2023-01-18 19:02:02 UTC (rev 2688) @@ -23,22 +23,46 @@ package org.axsl.galley.trait; +import java.math.BigDecimal; + /** * Accessor for the character traits. */ public interface CharacterTraitsTa { + /** The default inline-progression-dimension scaling factor. */ + BigDecimal DEFAULT_IPD_SCALING = new BigDecimal("100"); + /** - * The "letter-spacing" trait for this area. - * @return The letter-spacing, in millipoints. + * The "letter-spacing" trait for this area, i.e. the extra space between glyphs in a word. + * @return The letter-spacing, in thousandths of a text-space unit. + * To convert the returned value to millipoints, multiply by the font-size. + * For example, letter-spacing of 20 at 13 points would be 260 millipoints. */ - int traitLetterSpacing(); + default int traitLetterSpacing() { + return 0; + } /** - * The "word-spacing" trait for this area, i.e. the extra size that should be added to the width of the space - * character. - * @return Returns the amount of word-spacing, in millipoints. + * The "word-spacing" trait for this area, i.e. the extra space to be added between words, or added to the width of + * the space character. + * @return Returns the amount of word-spacing, in thousandths of a text-space unit. + * To convert the returned value to millipoints, multiply by the font-size. + * For example, word-spacing of -3 at 12 points would -36 millipoints. */ - int traitWordSpacing(); + default int traitWordSpacing() { + return 0; + } + /** + * Returns the scaling percentage to be applied to the inline-progression-dimension for this area. + * A factor of 100% indicates that no scaling should be done. + * This does not map directly to an XSL-FO trait, but is used for cases where font-stretch is simulated, or where + * the ipd of the font characters themselves has been adjusted as part of the line-breaking logic. + * @return The scaling percentage to be applied to the inline-progression-dimension for this area. + */ + default BigDecimal getIpdScaling() { + return DEFAULT_IPD_SCALING; + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |