• R/O
  • SSH
  • HTTPS

copper: Commit


Commit MetaInfo

Revision1572 (tree)
Time2018-07-11 16:22:55
Authormiyabe

Log Message

(empty log message)

Change Summary

Incremental Difference

--- copper/trunk/homare/src/main/java/jp/cssj/homare/css/lang/BreakAllHyphenation.java (nonexistent)
+++ copper/trunk/homare/src/main/java/jp/cssj/homare/css/lang/BreakAllHyphenation.java (revision 1572)
@@ -0,0 +1,14 @@
1+package jp.cssj.homare.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+}
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
--- copper/trunk/homare/src/main/java/jp/cssj/homare/css/lang/CSSJHyphenation.java (nonexistent)
+++ copper/trunk/homare/src/main/java/jp/cssj/homare/css/lang/CSSJHyphenation.java (revision 1572)
@@ -0,0 +1,36 @@
1+package jp.cssj.homare.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+}
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
--- copper/trunk/homare/src/main/java/jp/cssj/homare/css/lang/JapaneseKeepAllHyphenation.java (nonexistent)
+++ copper/trunk/homare/src/main/java/jp/cssj/homare/css/lang/JapaneseKeepAllHyphenation.java (revision 1572)
@@ -0,0 +1,14 @@
1+package jp.cssj.homare.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+}
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
--- copper/trunk/homare/src/main/java/jp/cssj/homare/impl/css/lang/LanguageProfile_ja.java (revision 1571)
+++ copper/trunk/homare/src/main/java/jp/cssj/homare/impl/css/lang/LanguageProfile_ja.java (revision 1572)
@@ -1,9 +1,9 @@
11 package jp.cssj.homare.impl.css.lang;
22
33 import jp.cssj.homare.css.CSSStyle;
4-import jp.cssj.homare.css.lang.BreakAllBindingRule;
5-import jp.cssj.homare.css.lang.CSSJBindingRule;
6-import jp.cssj.homare.css.lang.JapaneseKeepAllBindingRule;
4+import jp.cssj.homare.css.lang.BreakAllHyphenation;
5+import jp.cssj.homare.css.lang.CSSJHyphenation;
6+import jp.cssj.homare.css.lang.JapaneseKeepAllHyphenation;
77 import jp.cssj.homare.css.lang.LanguageProfile;
88 import jp.cssj.homare.css.value.QuotesValue;
99 import jp.cssj.homare.css.value.TextTransformValue;
@@ -16,8 +16,7 @@
1616 import jp.cssj.homare.impl.css.property.ext.CSSJNoBreakCharacters;
1717 import jp.cssj.homare.style.box.params.AbstractTextParams;
1818 import jp.cssj.sakae.gc.text.hyphenation.Hyphenation;
19-import jp.cssj.sakae.gc.text.hyphenation.impl.DefaultHyphenation;
20-import jp.cssj.sakae.gc.text.hyphenation.impl.JapaneseBindingRule;
19+import jp.cssj.sakae.gc.text.hyphenation.impl.JapaneseHyphenation;
2120
2221 /**
2322 * @author MIYABE Tatsuhiko
@@ -26,13 +25,13 @@
2625 public class LanguageProfile_ja implements LanguageProfile {
2726 private static final ValueListValue QUOTES = new ValueListValue(
2827 new Value[] { new QuotesValue("「", "」"), new QuotesValue("『", "』"), });
29-
30- private final Hyphenation normalHyph = new DefaultHyphenation(new JapaneseBindingRule());
31-
32- private final Hyphenation breakAllHyph = new DefaultHyphenation(new BreakAllBindingRule());
33-
34- private final Hyphenation keepAllHyph = new DefaultHyphenation(new JapaneseKeepAllBindingRule());
3528
29+ private final Hyphenation normalHyph = new JapaneseHyphenation();
30+
31+ private final Hyphenation breakAllHyph = new BreakAllHyphenation();
32+
33+ private final Hyphenation keepAllHyph = new JapaneseKeepAllHyphenation();
34+
3635 public String getLanguage() {
3736 return "ja";
3837 }
@@ -149,25 +148,24 @@
149148
150149 public Hyphenation getHyphenation(final CSSStyle style) {
151150 // 禁則処理
152- switch(WordBreak.get(style)) {
151+ switch (WordBreak.get(style)) {
153152 case WordBreakValue.NORMAL:
154153 final CSSJBreakRuleValue include = CSSJNoBreakCharacters.get(style);
155154 final CSSJBreakRuleValue exclude = CSSJBreakCharacters.get(style);
156155 if (include != CSSJBreakRuleValue.NONE_VALUE || exclude != CSSJBreakRuleValue.NONE_VALUE) {
157- final CSSJBindingRule binding = new CSSJBindingRule(include, exclude);
158- return new DefaultHyphenation(binding);
156+ return new CSSJHyphenation(include, exclude);
159157 }
160158
161159 return this.normalHyph;
162-
160+
163161 case WordBreakValue.KEEP_ALL:
164162 return this.keepAllHyph;
165-
163+
166164 case WordBreakValue.BREAK_ALL:
167165 return this.breakAllHyph;
168- default:
169- throw new IllegalStateException();
166+ default:
167+ throw new IllegalStateException();
170168 }
171-
169+
172170 }
173171 }
\ No newline at end of file
--- copper/trunk/homare/src/main/java/jp/cssj/homare/style/box/impl/TextBlockBox.java (revision 1571)
+++ copper/trunk/homare/src/main/java/jp/cssj/homare/style/box/impl/TextBlockBox.java (revision 1572)
@@ -25,6 +25,7 @@
2525 import jp.cssj.sakae.gc.paint.RGBColor;
2626 import jp.cssj.sakae.gc.text.FilterGlyphHandler;
2727 import jp.cssj.sakae.gc.text.GlyphHandler;
28+import jp.cssj.sakae.gc.text.hyphenation.impl.TextUnitizer;
2829
2930 /**
3031 * テキストだけを含むことができるボックスです。
@@ -348,7 +349,7 @@
348349 assert (!this.lines.isEmpty());
349350 builder.setTextState(this.textState);
350351 final GlyphHandler gh = new BuilderGlyphHandler(builder);
351- final FilterGlyphHandler textUnitizer = this.params.hyphenation.getTextUnitizer();
352+ final FilterGlyphHandler textUnitizer = new TextUnitizer(this.params.hyphenation);
352353 textUnitizer.setGlyphHandler(gh);
353354 // System.err.println("*** start");
354355 for (int i = 0; i < this.lines.size(); ++i) {
--- copper/trunk/homare/src/main/java/jp/cssj/homare/style/builder/impl/StyledTextUnitizer.java (revision 1571)
+++ copper/trunk/homare/src/main/java/jp/cssj/homare/style/builder/impl/StyledTextUnitizer.java (revision 1572)
@@ -19,6 +19,7 @@
1919 import jp.cssj.sakae.gc.text.FilterGlyphHandler;
2020 import jp.cssj.sakae.gc.text.Glypher;
2121 import jp.cssj.sakae.gc.text.Quad;
22+import jp.cssj.sakae.gc.text.hyphenation.impl.TextUnitizer;
2223 import jp.cssj.sakae.gc.text.layout.control.LineBreak;
2324 import jp.cssj.sakae.gc.text.layout.control.Tab;
2425 import jp.cssj.sakae.gc.text.layout.control.WhiteSpace;
@@ -67,7 +68,7 @@
6768 return;
6869 }
6970 final AbstractTextParams params = this.getTextParams();
70- final FilterGlyphHandler textUnitizer = params.hyphenation.getTextUnitizer();
71+ final FilterGlyphHandler textUnitizer = new TextUnitizer(params.hyphenation);
7172 textUnitizer.setGlyphHandler(this.gh);
7273 this.glypher = params.fontManager.getGlypher();
7374 this.glypher.setGlyphHander(textUnitizer);
--- copper/trunk/homare/src/main/java/jp/cssj/homare/style/builder/impl/TwoPassBlockBuilder.java (revision 1571)
+++ copper/trunk/homare/src/main/java/jp/cssj/homare/style/builder/impl/TwoPassBlockBuilder.java (revision 1572)
@@ -43,6 +43,7 @@
4343 import jp.cssj.sakae.gc.text.Quad;
4444 import jp.cssj.sakae.gc.text.Text;
4545 import jp.cssj.sakae.gc.text.TextImpl;
46+import jp.cssj.sakae.gc.text.hyphenation.impl.TextUnitizer;
4647 import jp.cssj.sakae.gc.text.layout.control.LineBreak;
4748
4849 public class TwoPassBlockBuilder implements Builder, LayoutStack, TwoPass {
@@ -614,7 +615,7 @@
614615 switch (this.recordTypes.get(i)) {
615616 case TYPE_ELEMENT: {
616617 if (textUnitizer == null) {
617- textUnitizer = builder.getFlowBox().getBlockParams().hyphenation.getTextUnitizer();
618+ textUnitizer = new TextUnitizer(builder.getFlowBox().getBlockParams().hyphenation);
618619 textUnitizer.setGlyphHandler(new BuilderGlyphHandler(builder));
619620 }
620621 final Element e = (Element) k.next();
@@ -745,7 +746,7 @@
745746 case Types.AUTO_POSITION_INLINE:
746747 final Quad quad = InlineQuad.createInlineAbsoluteBoxQuad(absoluteBox);
747748 if (textUnitizer == null) {
748- textUnitizer = builder.getFlowBox().getBlockParams().hyphenation.getTextUnitizer();
749+ textUnitizer = new TextUnitizer(builder.getFlowBox().getBlockParams().hyphenation);
749750 textUnitizer.setGlyphHandler(new BuilderGlyphHandler(builder));
750751 }
751752 textUnitizer.quad(quad);
--- copper/trunk/sakae/sakae-core/src/main/java/jp/cssj/sakae/gc/text/TextLayoutHandler.java (revision 1571)
+++ copper/trunk/sakae/sakae-core/src/main/java/jp/cssj/sakae/gc/text/TextLayoutHandler.java (revision 1572)
@@ -15,6 +15,7 @@
1515 import jp.cssj.sakae.gc.font.FontStyle;
1616 import jp.cssj.sakae.gc.font.FontStyleImpl;
1717 import jp.cssj.sakae.gc.text.hyphenation.Hyphenation;
18+import jp.cssj.sakae.gc.text.hyphenation.impl.TextUnitizer;
1819 import jp.cssj.sakae.gc.text.layout.FilterCharacterHandler;
1920 import jp.cssj.sakae.gc.text.layout.control.LineBreak;
2021 import jp.cssj.sakae.gc.text.layout.control.Tab;
@@ -45,7 +46,7 @@
4546
4647 public TextLayoutHandler(GC gc, Hyphenation hyphenation, GlyphHandler glyphHandler) {
4748 this.gc = gc;
48- FilterGlyphHandler textUnitizer = hyphenation.getTextUnitizer();
49+ FilterGlyphHandler textUnitizer = new TextUnitizer(hyphenation);
4950 textUnitizer.setGlyphHandler(glyphHandler);
5051 Glypher glypher = gc.getFontManager().getGlypher();
5152 glypher.setGlyphHander(textUnitizer);
--- copper/trunk/sakae/sakae-core/src/main/java/jp/cssj/sakae/gc/text/hyphenation/Hyphenation.java (revision 1571)
+++ copper/trunk/sakae/sakae-core/src/main/java/jp/cssj/sakae/gc/text/hyphenation/Hyphenation.java (revision 1572)
@@ -1,7 +1,5 @@
11 package jp.cssj.sakae.gc.text.hyphenation;
22
3-import jp.cssj.sakae.gc.text.FilterGlyphHandler;
4-
53 /**
64 * 言語ごとのハイフネーションです。
75 *
@@ -10,20 +8,19 @@
108 */
119 public interface Hyphenation {
1210 /**
13- * 禁則処理のためテキストを分割できないまとまりに分解するオブジェクトを返します。
14- *
15- * @return テキストを分解するオブジェクト。
11+ * 前後の文字が分割不可能であればtrueを返します。
12+ * @param c1
13+ * @param c2
14+ * @return
1615 */
17- public FilterGlyphHandler getTextUnitizer();
16+ public boolean atomic(char c1, char c2);
1817
1918 /**
20- * 両あわせ処理のために文字を分割可能であればtrueを返します。
19+ * 前後の文字の間を広げることが可能であればtrueを返します。
2120 *
2221 * @param c1
23- * 前の文字。
2422 * @param c2
25- * 後の文字。
26- * @return 分割可能であればtrue。
23+ * @return
2724 */
2825 public boolean canSeparate(char c1, char c2);
2926 }
--- copper/trunk/sakae/sakae-core/src/main/java/jp/cssj/sakae/gc/text/hyphenation/HyphenationBundle.java (revision 1571)
+++ copper/trunk/sakae/sakae-core/src/main/java/jp/cssj/sakae/gc/text/hyphenation/HyphenationBundle.java (revision 1572)
@@ -1,10 +1,9 @@
11 package jp.cssj.sakae.gc.text.hyphenation;
22
3-import jp.cssj.sakae.gc.text.hyphenation.impl.DefaultHyphenation;
4-import jp.cssj.sakae.gc.text.hyphenation.impl.JapaneseBindingRule;
3+import jp.cssj.sakae.gc.text.hyphenation.impl.JapaneseHyphenation;
54
65 public class HyphenationBundle {
7- private static final Hyphenation DEFAULT_HYPHENATION = new DefaultHyphenation(new JapaneseBindingRule());
6+ private static final Hyphenation DEFAULT_HYPHENATION = new JapaneseHyphenation();
87
98 public static Hyphenation getHyphenation(String lang) {
109 return DEFAULT_HYPHENATION;
--- copper/trunk/sakae/sakae-core/src/main/java/jp/cssj/sakae/gc/text/hyphenation/impl/JapaneseHyphenation.java (nonexistent)
+++ copper/trunk/sakae/sakae-core/src/main/java/jp/cssj/sakae/gc/text/hyphenation/impl/JapaneseHyphenation.java (revision 1572)
@@ -0,0 +1,156 @@
1+package jp.cssj.sakae.gc.text.hyphenation.impl;
2+
3+import java.lang.Character.UnicodeBlock;
4+
5+import jp.cssj.sakae.gc.text.hyphenation.Hyphenation;
6+
7+/**
8+ * @author MIYABE Tatsuhiko
9+ * @version $Id: JapaneseBindingRule.java 1570 2018-07-11 05:50:15Z miyabe $
10+ */
11+public class JapaneseHyphenation implements Hyphenation {
12+ private static final CharacterSet ASCII = new BitSetCharacterSet(
13+ "#$%&*+-/0123456789=@ABCDEFGHIJKLMNOPQRSTUVWXYZ\\^_abcdefghijklmnopqrstuvwxyz|~");
14+
15+ /**
16+ * 半角英数字。
17+ */
18+ private static final CharacterSet LATIN_OR_DIGIT = new CharacterSet() {
19+ public boolean contains(char c) {
20+ if (c > 0xFF) {
21+ return false;
22+ }
23+ if (c > 0x7F) {
24+ return true;
25+ }
26+ return ASCII.contains(c);
27+ }
28+ };
29+
30+ /** 行頭禁則和字(SPEC JIS-X4051 8.1.1 + 独自。 */
31+ private static final String GYOTO_KINSOKU = "~〜ヽヾゝゞ ー ァ ィ ゥ ェ ォ ッ ャ ュ ョ ヮ ヵ ヶ ぁ ぃ ぅ ぇ ぉ っ ゃ ゅ ょ ゎ ゕ ゖ ㇰ ㇱ ㇳ ㇲ ㇳ ㇴ ㇵ ㇶ ㇷ ㇸ ㇹ ㇺ ㇻ ㇼ ㇽ ㇾ ㇿ 々 〻\u3000・”";
32+ /** 間違って行頭禁則とされてしまう圏点記号を除外。 */
33+ private static final String GYOTO_KINSOKU_EX = "\uFE45\uFE46";
34+
35+ /**
36+ * 行頭禁則処理。 SPEC JIS-X4051 7.3
37+ */
38+ protected CharacterSet requiresBefore(char c) {
39+ // 行頭禁則
40+ if (GYOTO_KINSOKU.indexOf(c) != -1) {
41+ return CharacterSet.ALL;
42+ }
43+ if (GYOTO_KINSOKU_EX.indexOf(c) != -1) {
44+ return CharacterSet.NOTHING;
45+ }
46+ int type = Character.getType(c);
47+
48+ switch (type) {
49+ case Character.END_PUNCTUATION:
50+ case Character.OTHER_PUNCTUATION:
51+ case Character.MODIFIER_LETTER:
52+ case Character.MODIFIER_SYMBOL:
53+ // 終了括弧、区切り記号、修飾文字、修飾記号の前には文字が必要。
54+ return CharacterSet.ALL;
55+ }
56+ return CharacterSet.NOTHING;
57+ }
58+
59+ /**
60+ * 行末禁則処理。 SPEC JIS-X4051 7.4
61+ */
62+ protected CharacterSet requiresAfter(char c) {
63+ int type = Character.getType(c);
64+
65+ if (c <= 0xFF || LATIN_OR_DIGIT.contains(c)) {
66+ // 半角英数
67+ switch (type) {
68+ case Character.START_PUNCTUATION:
69+ // 開始括弧の後には何らかの文字が必要。
70+ return CharacterSet.ALL;
71+
72+ case Character.END_PUNCTUATION:
73+ // 終了括弧の後には文字が不要。
74+ return CharacterSet.NOTHING;
75+
76+ default:
77+ if (c == '\u0020' || c == '-' || c == '!' || c == '?') {
78+ // 区切りの後ではラップできる。
79+ return CharacterSet.NOTHING;
80+ }
81+ // 英数字の後には英数字が必要。
82+ return LATIN_OR_DIGIT;
83+ }
84+ } else {
85+ // その他の文字
86+ switch (type) {
87+ case Character.START_PUNCTUATION:
88+ // 開始括弧の後には何らかの文字が必要。
89+ return CharacterSet.ALL;
90+ }
91+ // ダッシュ等
92+ if (c == '─' || c == '“') {
93+ return CharacterSet.ALL;
94+ }
95+ }
96+ return CharacterSet.NOTHING;
97+ }
98+
99+ public boolean atomic(char c1, char c2) {
100+ return this.requiresAfter(c1).contains(c2) || this.requiresBefore(c2).contains(c1);
101+ }
102+
103+ public boolean canSeparate(char c1, char c2) {
104+ if (Character.isWhitespace(c1) || Character.isWhitespace(c2)) {
105+ return c1 != '\u3000';
106+ }
107+ if (this.isCJK(c1) || this.isCJK(c2)) {
108+ return true;
109+ }
110+ return false;
111+ }
112+
113+ protected boolean isCJK(char c) {
114+ UnicodeBlock b = UnicodeBlock.of(c);
115+ if (b == null) {
116+ return true;
117+ }
118+ if (b == UnicodeBlock.CJK_COMPATIBILITY) {
119+ return true;
120+ }
121+ if (b == UnicodeBlock.CJK_COMPATIBILITY_FORMS) {
122+ return true;
123+ }
124+ if (b == UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS) {
125+ return true;
126+ }
127+ if (b == UnicodeBlock.CJK_RADICALS_SUPPLEMENT) {
128+ return true;
129+ }
130+ if (b == UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION) {
131+ return true;
132+ }
133+ if (b == UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS) {
134+ return true;
135+ }
136+ if (b == UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A) {
137+ return true;
138+ }
139+ if (b == UnicodeBlock.HIRAGANA) {
140+ return true;
141+ }
142+ if (b == UnicodeBlock.KATAKANA) {
143+ return true;
144+ }
145+ if (b == UnicodeBlock.HANGUL_SYLLABLES) {
146+ return true;
147+ }
148+ if (b == UnicodeBlock.HANGUL_JAMO) {
149+ return true;
150+ }
151+ if (b == UnicodeBlock.HANGUL_COMPATIBILITY_JAMO) {
152+ return true;
153+ }
154+ return false;
155+ }
156+}
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
--- copper/trunk/sakae/sakae-core/src/main/java/jp/cssj/sakae/gc/text/hyphenation/impl/TextUnitizer.java (nonexistent)
+++ copper/trunk/sakae/sakae-core/src/main/java/jp/cssj/sakae/gc/text/hyphenation/impl/TextUnitizer.java (revision 1572)
@@ -0,0 +1,134 @@
1+package jp.cssj.sakae.gc.text.hyphenation.impl;
2+
3+import jp.cssj.sakae.gc.font.FontMetrics;
4+import jp.cssj.sakae.gc.font.FontStyle;
5+import jp.cssj.sakae.gc.text.FilterGlyphHandler;
6+import jp.cssj.sakae.gc.text.GlyphHandler;
7+import jp.cssj.sakae.gc.text.Quad;
8+import jp.cssj.sakae.gc.text.hyphenation.Hyphenation;
9+
10+/**
11+ * 禁則処理のためテキストを分割できないまとまりに分解すします。
12+ *
13+ * @author MIYABE Tatsuhiko
14+ * @version $Id: AbstractHyphenation.java,v 1.11 2006/09/06 04:32:46 harumanx
15+ * Exp $
16+ */
17+public class TextUnitizer implements FilterGlyphHandler {
18+ protected Hyphenation hyph;
19+
20+ private GlyphHandler glyphHandler;
21+
22+ /**
23+ * Previous character.
24+ */
25+ private char prevChar = 0;
26+
27+ private Quad beforeQuad = null;
28+
29+ public TextUnitizer(Hyphenation hyph) {
30+ this.hyph = hyph;
31+ }
32+
33+ public Hyphenation getHyphenation() {
34+ return hyph;
35+ }
36+
37+ public void setHyphenation(Hyphenation hyph) {
38+ this.hyph = hyph;
39+ }
40+
41+ public void setGlyphHandler(GlyphHandler glyphHandler) {
42+ this.glyphHandler = glyphHandler;
43+ }
44+
45+ public void startTextRun(int charOffset, FontStyle fontStyle, FontMetrics fontMetrics) {
46+ this.glyphHandler.startTextRun(charOffset, fontStyle, fontMetrics);
47+ }
48+
49+ public void endTextRun() {
50+ this.glyphHandler.endTextRun();
51+ }
52+
53+ public void glyph(int charOffset, char[] ch, int coff, byte clen, int gid) {
54+ char c1 = ch[coff];
55+ char c2 = ch[coff + clen - 1];
56+ this.nextGlyph(c1, c2, clen);
57+ if (this.beforeQuad != null) {
58+ this.glyphHandler.quad(this.beforeQuad);
59+ this.beforeQuad = null;
60+ }
61+ this.glyphHandler.glyph(charOffset, ch, coff, clen, gid);
62+ }
63+
64+ public void quad(Quad quad) {
65+ String str = quad.getString();
66+ if (str == Quad.BREAK) {
67+ // CONTINUE_BEFORE, CONTINUE_AFTERを除いて文字列を区切る
68+ if (this.prevChar != 0 && this.prevChar != '\u2060') {
69+ this.internalFlush();
70+ }
71+ this.prevChar = '\u200B';
72+ } else if (str == Quad.CONTINUE_BEFORE) {
73+ // 前の文字として扱う(後の文字列にくっつける<span>...)
74+ if (this.prevChar == '\u200B') {
75+ this.internalFlush();
76+ this.prevChar = '\u2060';
77+ } else {
78+ if (this.beforeQuad != null) {
79+ this.glyphHandler.quad(this.beforeQuad);
80+ }
81+ this.beforeQuad = quad;
82+ return;
83+ }
84+ } else if (str == Quad.CONTINUE_AFTER) {
85+ // 前の文字として扱う(前の文字列にくっつける...</span>)
86+ } else if (str.length() == 0) {
87+ // 前の文字として扱う(前後にくっつける)
88+ if (this.prevChar == '\u200B') {
89+ this.internalFlush();
90+ }
91+ this.prevChar = '\u2060';
92+ } else {
93+ // 相当する文字列を使う
94+ int strlen = str.length();
95+ char c1 = str.charAt(0);
96+ char c2 = str.charAt(strlen - 1);
97+ this.nextGlyph(c1, c2, strlen);
98+ }
99+ if (this.beforeQuad != null) {
100+ this.glyphHandler.quad(this.beforeQuad);
101+ this.beforeQuad = null;
102+ }
103+ this.glyphHandler.quad(quad);
104+ }
105+
106+ private void internalFlush() {
107+ this.glyphHandler.flush();
108+ }
109+
110+ public void flush() {
111+ if (this.beforeQuad != null) {
112+ this.glyphHandler.quad(this.beforeQuad);
113+ this.beforeQuad = null;
114+ }
115+ this.internalFlush();
116+ }
117+
118+ /**
119+ *
120+ * @param c1
121+ * グリフに対応する最初の文字。
122+ * @param c2
123+ * グリフに対応する最後の文字。
124+ * @param charCount
125+ * 文字数
126+ */
127+ private void nextGlyph(char c1, char c2, int charCount) {
128+ if (this.prevChar != 0 && this.prevChar != '\u2060'
129+ && (this.prevChar == '\u200B' || !this.hyph.atomic(this.prevChar, c1))) {
130+ this.internalFlush();
131+ }
132+ this.prevChar = c2;
133+ }
134+}
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Show on old repository browser