Commit MetaInfo
Log Message
(empty log message)
Change Summary
Incremental Difference
| | @@ -9,7 +9,7 @@ | 9 | 9 | <groupId>net.zamasoft</groupId>
| 10 | 10 | <artifactId>homare</artifactId>
| 11 | 11 | <packaging>jar</packaging>
| 12 | | - <version>3.2.1</version>
| | 12 | + <version>3.2.2</version>
| 13 | 13 | <name>Homare</name>
| 14 | 14 | <description>印刷向けのHTML/CSSレンダリングエンジンです。</description>
| 15 | 15 | <url>http://copper.osdn.jp/homare/</url>
|
| | @@ -0,0 +1,14 @@ | | 1 | +package jp.cssj.homare.impl.css.lang;
| | 2 | +
| | 3 | +import jp.cssj.sakae.gc.text.hyphenation.Hyphenation;
| | 4 | +
| | 5 | +public class BreakAllHyphenation implements Hyphenation {
| | 6 | + public boolean atomic(char c1, char c2) {
| | 7 | + return false;
| | 8 | + }
| | 9 | +
| | 10 | + public boolean canSeparate(char c1, char c2) {
| | 11 | + return true;
| | 12 | + }
| | 13 | +
| | 14 | +}
|
| | @@ -0,0 +1,36 @@ | | 1 | +package jp.cssj.homare.impl.css.lang;
| | 2 | +
| | 3 | +import jp.cssj.homare.css.value.ext.CSSJBreakRuleValue;
| | 4 | +import jp.cssj.sakae.gc.text.hyphenation.impl.CharacterSet;
| | 5 | +import jp.cssj.sakae.gc.text.hyphenation.impl.JapaneseHyphenation;
| | 6 | +
| | 7 | +public class CSSJHyphenation extends JapaneseHyphenation {
| | 8 | + final private CSSJBreakRuleValue include;
| | 9 | + final private CSSJBreakRuleValue exclude;
| | 10 | +
| | 11 | + public CSSJHyphenation(CSSJBreakRuleValue include, CSSJBreakRuleValue exclude) {
| | 12 | + this.include = include;
| | 13 | + this.exclude = exclude;
| | 14 | + }
| | 15 | +
| | 16 | + protected CharacterSet requiresBefore(char c) {
| | 17 | + if (this.include.getHead().indexOf(c) != -1) {
| | 18 | + return CharacterSet.ALL;
| | 19 | + }
| | 20 | + if (this.exclude.getHead().indexOf(c) != -1) {
| | 21 | + return CharacterSet.NOTHING;
| | 22 | + }
| | 23 | + return super.requiresBefore(c);
| | 24 | + }
| | 25 | +
| | 26 | + protected CharacterSet requiresAfter(char c) {
| | 27 | + if (this.include.getTail().indexOf(c) != -1) {
| | 28 | + return CharacterSet.ALL;
| | 29 | + }
| | 30 | + if (this.exclude.getTail().indexOf(c) != -1) {
| | 31 | + return CharacterSet.NOTHING;
| | 32 | + }
| | 33 | + return super.requiresAfter(c);
| | 34 | + }
| | 35 | +
| | 36 | +}
|
| | @@ -0,0 +1,53 @@ | | 1 | +package jp.cssj.homare.impl.css.lang; | | 2 | + | | 3 | +import java.util.ArrayList; | | 4 | +import java.util.List; | | 5 | + | | 6 | +import jp.cssj.homare.style.box.params.AbstractTextParams; | | 7 | +import jp.cssj.homare.style.builder.InlineQuad; | | 8 | +import jp.cssj.homare.style.builder.InlineQuad.InlineStartQuad; | | 9 | +import jp.cssj.sakae.gc.text.Quad; | | 10 | +import jp.cssj.sakae.gc.text.hyphenation.Hyphenation; | | 11 | +import jp.cssj.sakae.gc.text.hyphenation.impl.TextUnitizer; | | 12 | + | | 13 | +public class CSSJTextUnitizer extends TextUnitizer { | | 14 | + | | 15 | + private List<Hyphenation> hyphStack = new ArrayList<Hyphenation>();; | | 16 | + | | 17 | + public CSSJTextUnitizer(Hyphenation hyph) { | | 18 | + super(hyph); | | 19 | + this.hyphStack.add(hyph); | | 20 | + } | | 21 | + | | 22 | + public void quad(Quad quad) { | | 23 | + if (quad instanceof InlineQuad) { | | 24 | + final InlineQuad inlineQuad = (InlineQuad) quad; | | 25 | + switch (inlineQuad.getType()) { | | 26 | + case InlineQuad.INLINE_START: { | | 27 | + final InlineStartQuad inlineStartQuad = (InlineStartQuad) inlineQuad; | | 28 | + AbstractTextParams params = inlineStartQuad.box.getTextParams(); | | 29 | + this.hyphStack.add(params.hyphenation); | | 30 | + this.setHyphenation(params.hyphenation); | | 31 | + } | | 32 | + break; | | 33 | + | | 34 | + case InlineQuad.INLINE_END: { | | 35 | + this.hyphStack.remove(this.hyphStack.size() - 1); | | 36 | + final Hyphenation hyph = this.hyphStack.get(this.hyphStack.size() - 1); | | 37 | + this.setHyphenation(hyph); | | 38 | + } | | 39 | + break; | | 40 | + | | 41 | + case InlineQuad.INLINE_REPLACED: | | 42 | + case InlineQuad.INLINE_BLOCK: | | 43 | + case InlineQuad.INLINE_ABSOLUTE: | | 44 | + break; | | 45 | + | | 46 | + default: | | 47 | + throw new IllegalStateException(); | | 48 | + } | | 49 | + } | | 50 | + super.quad(quad); | | 51 | + } | | 52 | + | | 53 | +} |
| | @@ -0,0 +1,14 @@ | | 1 | +package jp.cssj.homare.impl.css.lang;
| | 2 | +
| | 3 | +import java.lang.Character.UnicodeBlock;
| | 4 | +
| | 5 | +import jp.cssj.sakae.gc.text.hyphenation.impl.JapaneseHyphenation;
| | 6 | +
| | 7 | +public class JapaneseKeepAllHyphenation extends JapaneseHyphenation {
| | 8 | + public boolean atomic(char c1, char c2) {
| | 9 | + if (this.isCJK(c1) && this.isCJK(c2) && UnicodeBlock.of(c1) != UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION) {
| | 10 | + return true;
| | 11 | + }
| | 12 | + return super.atomic(c1, c2);
| | 13 | + }
| | 14 | +}
|
| | @@ -1,9 +1,6 @@ | 1 | 1 | package jp.cssj.homare.impl.css.lang;
| 2 | 2 |
| 3 | 3 | import jp.cssj.homare.css.CSSStyle;
| 4 | | -import jp.cssj.homare.css.lang.BreakAllHyphenation;
| 5 | | -import jp.cssj.homare.css.lang.CSSJHyphenation;
| 6 | | -import jp.cssj.homare.css.lang.JapaneseKeepAllHyphenation;
| 7 | 4 | import jp.cssj.homare.css.lang.LanguageProfile;
| 8 | 5 | import jp.cssj.homare.css.value.QuotesValue;
| 9 | 6 | import jp.cssj.homare.css.value.TextTransformValue;
|
| | @@ -5,6 +5,7 @@ | 5 | 5 | import java.util.ArrayList;
| 6 | 6 | import java.util.List;
| 7 | 7 |
| | 8 | +import jp.cssj.homare.impl.css.lang.CSSJTextUnitizer;
| 8 | 9 | import jp.cssj.homare.style.box.AbstractBox;
| 9 | 10 | import jp.cssj.homare.style.box.AbstractLineBox;
| 10 | 11 | import jp.cssj.homare.style.box.IFlowBox;
|
| | @@ -25,7 +26,6 @@ | 25 | 26 | import jp.cssj.sakae.gc.paint.RGBColor;
| 26 | 27 | import jp.cssj.sakae.gc.text.FilterGlyphHandler;
| 27 | 28 | import jp.cssj.sakae.gc.text.GlyphHandler;
| 28 | | -import jp.cssj.sakae.gc.text.hyphenation.impl.TextUnitizer;
| 29 | 29 |
| 30 | 30 | /**
| 31 | 31 | * テキストだけを含むことができるボックスです。
|
| | @@ -349,7 +349,7 @@ | 349 | 349 | assert (!this.lines.isEmpty());
| 350 | 350 | builder.setTextState(this.textState);
| 351 | 351 | final GlyphHandler gh = new BuilderGlyphHandler(builder);
| 352 | | - final FilterGlyphHandler textUnitizer = new TextUnitizer(this.params.hyphenation);
| | 352 | + final FilterGlyphHandler textUnitizer = new CSSJTextUnitizer(this.params.hyphenation);
| 353 | 353 | textUnitizer.setGlyphHandler(gh);
| 354 | 354 | // System.err.println("*** start");
| 355 | 355 | for (int i = 0; i < this.lines.size(); ++i) {
|
| | @@ -4,6 +4,7 @@ | 4 | 4 | import java.util.ArrayList;
| 5 | 5 | import java.util.List;
| 6 | 6 |
| | 7 | +import jp.cssj.homare.impl.css.lang.CSSJTextUnitizer;
| 7 | 8 | import jp.cssj.homare.style.box.AbstractContainerBox;
| 8 | 9 | import jp.cssj.homare.style.box.AbstractReplacedBox;
| 9 | 10 | import jp.cssj.homare.style.box.IAbsoluteBox;
|
| | @@ -19,7 +20,6 @@ | 19 | 20 | import jp.cssj.sakae.gc.text.FilterGlyphHandler;
| 20 | 21 | import jp.cssj.sakae.gc.text.Glypher;
| 21 | 22 | import jp.cssj.sakae.gc.text.Quad;
| 22 | | -import jp.cssj.sakae.gc.text.hyphenation.impl.TextUnitizer;
| 23 | 23 | import jp.cssj.sakae.gc.text.layout.control.LineBreak;
| 24 | 24 | import jp.cssj.sakae.gc.text.layout.control.Tab;
| 25 | 25 | import jp.cssj.sakae.gc.text.layout.control.WhiteSpace;
|
| | @@ -68,7 +68,7 @@ | 68 | 68 | return;
| 69 | 69 | }
| 70 | 70 | final AbstractTextParams params = this.getTextParams();
| 71 | | - final FilterGlyphHandler textUnitizer = new TextUnitizer(params.hyphenation);
| | 71 | + final FilterGlyphHandler textUnitizer = new CSSJTextUnitizer(params.hyphenation);
| 72 | 72 | textUnitizer.setGlyphHandler(this.gh);
| 73 | 73 | this.glypher = params.fontManager.getGlypher();
| 74 | 74 | this.glypher.setGlyphHander(textUnitizer);
|
| | @@ -4,6 +4,7 @@ | 4 | 4 | import java.util.Iterator;
| 5 | 5 | import java.util.List;
| 6 | 6 |
| | 7 | +import jp.cssj.homare.impl.css.lang.CSSJTextUnitizer;
| 7 | 8 | import jp.cssj.homare.style.box.AbstractBlockBox;
| 8 | 9 | import jp.cssj.homare.style.box.AbstractContainerBox;
| 9 | 10 | import jp.cssj.homare.style.box.AbstractReplacedBox;
|
| | @@ -43,7 +44,6 @@ | 43 | 44 | import jp.cssj.sakae.gc.text.Quad;
| 44 | 45 | import jp.cssj.sakae.gc.text.Text;
| 45 | 46 | import jp.cssj.sakae.gc.text.TextImpl;
| 46 | | -import jp.cssj.sakae.gc.text.hyphenation.impl.TextUnitizer;
| 47 | 47 | import jp.cssj.sakae.gc.text.layout.control.LineBreak;
| 48 | 48 |
| 49 | 49 | public class TwoPassBlockBuilder implements Builder, LayoutStack, TwoPass {
|
| | @@ -615,7 +615,7 @@ | 615 | 615 | switch (this.recordTypes.get(i)) {
| 616 | 616 | case TYPE_ELEMENT: {
| 617 | 617 | if (textUnitizer == null) {
| 618 | | - textUnitizer = new TextUnitizer(builder.getFlowBox().getBlockParams().hyphenation);
| | 618 | + textUnitizer = new CSSJTextUnitizer(builder.getFlowBox().getBlockParams().hyphenation);
| 619 | 619 | textUnitizer.setGlyphHandler(new BuilderGlyphHandler(builder));
| 620 | 620 | }
| 621 | 621 | final Element e = (Element) k.next();
|
| | @@ -746,7 +746,7 @@ | 746 | 746 | case Types.AUTO_POSITION_INLINE:
| 747 | 747 | final Quad quad = InlineQuad.createInlineAbsoluteBoxQuad(absoluteBox);
| 748 | 748 | if (textUnitizer == null) {
| 749 | | - textUnitizer = new TextUnitizer(builder.getFlowBox().getBlockParams().hyphenation);
| | 749 | + textUnitizer = new CSSJTextUnitizer(builder.getFlowBox().getBlockParams().hyphenation);
| 750 | 750 | textUnitizer.setGlyphHandler(new BuilderGlyphHandler(builder));
| 751 | 751 | }
| 752 | 752 | textUnitizer.quad(quad);
|
| | @@ -26,6 +26,7 @@ | 26 | 26 | import jp.cssj.homare.ua.props.UAProps;
| 27 | 27 | import jp.cssj.sakae.gc.GC;
| 28 | 28 | import jp.cssj.sakae.gc.GraphicsException;
| | 29 | +import jp.cssj.sakae.gc.font.FontFamilyList;
| 29 | 30 | import jp.cssj.sakae.gc.font.FontPolicyList;
| 30 | 31 | import jp.cssj.sakae.gc.text.TextLayoutHandler;
| 31 | 32 | import jp.cssj.sakae.gc.text.hyphenation.HyphenationBundle;
|
| | @@ -148,6 +149,7 @@ | 148 | 149 | lineHandler.setLineAdvance(width);
| 149 | 150 |
| 150 | 151 | TextLayoutHandler tlf = new TextLayoutHandler(gc, HyphenationBundle.getHyphenation(null), lineHandler);
| | 152 | + tlf.setFontFamilies(FontFamilyList.SERIF);
| 151 | 153 | tlf.setFontPolicy(fontPolicy);
| 152 | 154 | tlf.setFontSize(fontSize);
| 153 | 155 | tlf.characters(text);
|
| | @@ -118,6 +118,9 @@ | 118 | 118 | if (cmap == null) {
| 119 | 119 | cmap = ((CmapTable) ttFont.getTable(Table.cmap)).getCmapFormat(Table.platformMicrosoft, Table.encodingUCS2);
| 120 | 120 | }
| | 121 | + if (cmap == null) {
| | 122 | + cmap = ((CmapTable) ttFont.getTable(Table.cmap)).getCmapFormat(Table.platformAppleUnicode,(short)-1);
| | 123 | + }
| 121 | 124 | this.cmap = cmap;
| 122 | 125 | {
| 123 | 126 | int gid = this.cmap.mapCharCode(' ');
|
| | @@ -6,6 +6,7 @@ | 6 | 6 | | 7 | 7 | public class FontFace { | 8 | 8 | public Source src = null; | | 9 | + public int index = 0; | 9 | 10 | public Font local = null; | 10 | 11 | public FontFamilyList fontFamily = null; | 11 | 12 | public short fontWeight = FontStyle.FONT_WEIGHT_400; |
| | @@ -15,8 +16,8 @@ | 15 | 16 | public String cmap = null, vcmap = null; | 16 | 17 | | 17 | 18 | public String toString() { | 18 | | - return "src=" + this.src + "/local=" + this.local + "/fontFamily=" + this.fontFamily + "/fontWeight=" | 19 | | - + this.fontWeight + "/fontStyle=" + this.fontStyle + "/unicodeRange=" + this.unicodeRange + "/panose=" | 20 | | - + this.panose + "/cmap=" + this.cmap + "/vcmap=" + this.vcmap; | | 19 | + return "src=" + this.src + "/local=" + this.local + "/index=" + this.index + "/fontFamily=" + this.fontFamily | | 20 | + + "/fontWeight=" + this.fontWeight + "/fontStyle=" + this.fontStyle + "/unicodeRange=" | | 21 | + + this.unicodeRange + "/panose=" + this.panose + "/cmap=" + this.cmap + "/vcmap=" + this.vcmap; | 21 | 22 | } | 22 | 23 | } |
| | @@ -81,6 +81,9 @@ | 81 | 81 | case FONT_POLICY_EMBEDDED:
| 82 | 82 | buff.append("embedded ");
| 83 | 83 | break;
| | 84 | + case FONT_POLICY_OUTLINES:
| | 85 | + buff.append("outlines ");
| | 86 | + break;
| 84 | 87 | default:
| 85 | 88 | throw new IllegalStateException();
| 86 | 89 | }
|
| | @@ -0,0 +1,18 @@ | | 1 | +package jp.cssj.sakae.example;
| | 2 | +
| | 3 | +import java.awt.Font;
| | 4 | +import java.io.File;
| | 5 | +
| | 6 | +import jp.cssj.sakae.font.otf.OpenTypeFontSource;
| | 7 | +import jp.cssj.sakae.gc.font.FontStyle;
| | 8 | +
| | 9 | +/**
| | 10 | + * @author MIYABE Tatsuhiko
| | 11 | + * @version $Id: AlphaDemo.java 1565 2018-07-04 11:51:25Z miyabe $
| | 12 | + */
| | 13 | +public class FontTest {
| | 14 | + public static void main(String[] args) throws Exception {
| | 15 | + File file = new File("Apple Symbols.ttf");
| | 16 | + OpenTypeFontSource otf = new OpenTypeFontSource(file, 0, FontStyle.DIRECTION_TB);
| | 17 | + }
| | 18 | +}
|
| | @@ -87,8 +87,8 @@ | 87 | 87 | this.uriToFile.put(face.src.getURI(), file);
| 88 | 88 | }
| 89 | 89 | }
| 90 | | - FontLoader.readTTF(list, face, FontLoader.TYPE_EMBEDDED, file, 0, null);
| 91 | | - FontLoader.readTTF(list, face, FontLoader.TYPE_CID_IDENTITY, file, 0, null);
| | 90 | + FontLoader.readTTF(list, face, FontLoader.TYPE_EMBEDDED, file, face.index, null);
| | 91 | + FontLoader.readTTF(list, face, FontLoader.TYPE_CID_IDENTITY, file, face.index, null);
| 92 | 92 | }
| 93 | 93 |
| 94 | 94 | if (face.unicodeRange != null && !face.unicodeRange.isEmpty()) {
|
| | @@ -60,7 +60,8 @@ | 60 | 60 | public CmapFormat getCmapFormat(short platformId, short encodingId) {
| 61 | 61 | // Find the requested format
| 62 | 62 | for (int i = 0; i < this.numTables; i++) {
| 63 | | - if (this.entries[i].getPlatformId() == platformId && this.entries[i].getEncodingId() == encodingId) {
| | 63 | + if (this.entries[i].getPlatformId() == platformId
| | 64 | + && (encodingId == -1 || this.entries[i].getEncodingId() == encodingId)) {
| 64 | 65 | return this.formats[i];
| 65 | 66 | }
| 66 | 67 | }
|
| | @@ -67,6 +68,14 @@ | 67 | 68 | return null;
| 68 | 69 | }
| 69 | 70 |
| | 71 | + public CmapFormat getCmapFormat(int ix) {
| | 72 | + return this.formats[ix];
| | 73 | + }
| | 74 | +
| | 75 | + public int getTableCount() {
| | 76 | + return this.numTables;
| | 77 | + }
| | 78 | +
| 70 | 79 | public int getType() {
| 71 | 80 | return cmap;
| 72 | 81 | }
|
Show on old repository browser
|