(empty log message)
@@ -5,7 +5,7 @@ | ||
5 | 5 | /** |
6 | 6 | * 文字列からグリフに変換するために文字列を処理します。 |
7 | 7 | * |
8 | - * @author <a href="mailto:tatsuhiko at miya dot be">MIYABE Tatsuhiko</a> | |
8 | + * @author MIYABE Tatsuhiko | |
9 | 9 | * @version $Id$ |
10 | 10 | */ |
11 | 11 | public interface CharacterHandler { |
@@ -33,9 +33,16 @@ | ||
33 | 33 | public void quad(Quad quad); |
34 | 34 | |
35 | 35 | /** |
36 | + * テキストを区切ります。 | |
37 | + * | |
38 | + * <b>このメソッドはwordBreak()を呼びます。</b> | |
39 | + */ | |
40 | + public void flush(); | |
41 | + | |
42 | + /** | |
36 | 43 | * 段落を終わります。 |
37 | 44 | * |
38 | - * <b>このメソッドはwordBrak()を呼びます。</b> | |
45 | + * <b>このメソッドはwordBreak()を呼びます。</b> | |
39 | 46 | */ |
40 | - public void flush(); | |
47 | + public void finish(); | |
41 | 48 | } |
@@ -38,4 +38,9 @@ | ||
38 | 38 | public void quad(Quad quad); |
39 | 39 | |
40 | 40 | public void flush(); |
41 | + | |
42 | + /** | |
43 | + * テキストの書き出しを終了します。 | |
44 | + */ | |
45 | + public void finish(); | |
41 | 46 | } |
@@ -12,7 +12,7 @@ | ||
12 | 12 | * Exp $ |
13 | 13 | */ |
14 | 14 | class DefaultTextUnitizer implements FilterGlyphHandler { |
15 | - private final BindingRule bindingRule; | |
15 | + protected BindingRule hyph; | |
16 | 16 | |
17 | 17 | private GlyphHandler glyphHandler; |
18 | 18 |
@@ -23,8 +23,8 @@ | ||
23 | 23 | |
24 | 24 | private Quad beforeQuad = null; |
25 | 25 | |
26 | - public DefaultTextUnitizer(BindingRule bindingRule) { | |
27 | - this.bindingRule = bindingRule; | |
26 | + public DefaultTextUnitizer(BindingRule hyph) { | |
27 | + this.hyph = hyph; | |
28 | 28 | } |
29 | 29 | |
30 | 30 | public void setGlyphHandler(GlyphHandler glyphHandler) { |
@@ -52,6 +52,7 @@ | ||
52 | 52 | |
53 | 53 | public void quad(Quad quad) { |
54 | 54 | String str = quad.getString(); |
55 | + // System.err.println("TU QUAD: " + quad + "/" + Integer.toHexString(this.prevChar)); | |
55 | 56 | if (str == Quad.BREAK) { |
56 | 57 | // CONTINUE_BEFORE, CONTINUE_AFTERを除いて文字列を区切る |
57 | 58 | if (this.prevChar != 0 && this.prevChar != '\u2060') { |
@@ -72,6 +73,10 @@ | ||
72 | 73 | } |
73 | 74 | } else if (str == Quad.CONTINUE_AFTER) { |
74 | 75 | // 前の文字として扱う(前の文字列にくっつける...</span>) |
76 | + if (this.prevChar == '\u200B') { | |
77 | + this.internalFlush(); | |
78 | + this.prevChar = '\u2060'; | |
79 | + } | |
75 | 80 | } else if (str.length() == 0) { |
76 | 81 | // 前の文字として扱う(前後にくっつける) |
77 | 82 | if (this.prevChar == '\u200B') { |
@@ -104,6 +109,14 @@ | ||
104 | 109 | this.internalFlush(); |
105 | 110 | } |
106 | 111 | |
112 | + public void finish() { | |
113 | + if (this.beforeQuad != null) { | |
114 | + this.glyphHandler.quad(this.beforeQuad); | |
115 | + this.beforeQuad = null; | |
116 | + } | |
117 | + this.glyphHandler.finish(); | |
118 | + } | |
119 | + | |
107 | 120 | /** |
108 | 121 | * |
109 | 122 | * @param c1 |
@@ -114,10 +127,8 @@ | ||
114 | 127 | * 文字数 |
115 | 128 | */ |
116 | 129 | private void nextGlyph(char c1, char c2, int charCount) { |
117 | - if (this.prevChar != 0 | |
118 | - && this.prevChar != '\u2060' | |
119 | - && (this.prevChar == '\u200B' || !this.bindingRule.atomic( | |
120 | - this.prevChar, c1))) { | |
130 | + if (this.prevChar != 0 && this.prevChar != '\u2060' | |
131 | + && (this.prevChar == '\u200B' || !this.hyph.atomic(this.prevChar, c1))) { | |
121 | 132 | this.internalFlush(); |
122 | 133 | } |
123 | 134 | this.prevChar = c2; |
@@ -31,6 +31,10 @@ | ||
31 | 31 | this.characterHandler.flush(); |
32 | 32 | } |
33 | 33 | |
34 | + public void finish() { | |
35 | + this.characterHandler.flush(); | |
36 | + } | |
37 | + | |
34 | 38 | public void quad(Quad quad) { |
35 | 39 | this.characterHandler.quad(quad); |
36 | 40 | } |
@@ -98,4 +98,8 @@ | ||
98 | 98 | public void flush() { |
99 | 99 | // ignore |
100 | 100 | } |
101 | + | |
102 | + public void finish() { | |
103 | + // ignore | |
104 | + } | |
101 | 105 | } |
@@ -250,5 +250,10 @@ | ||
250 | 250 | this.glyphBreak(); |
251 | 251 | this.glyphHandler.flush(); |
252 | 252 | } |
253 | + | |
254 | + public void finish() { | |
255 | + this.glyphBreak(); | |
256 | + this.glyphHandler.finish(); | |
257 | + } | |
253 | 258 | } |
254 | 259 | } |
\ No newline at end of file |