Beispiel #1
0
func TestCalcCanvasSize_30x27(t *testing.T) {
	f, err := os.Create("test_page.svg")
	if err != nil {
		t.Errorf("failed to create test.svg : %s\n", err)
	}
	defer f.Close()

	canvas := svg.New(f)
	defer canvas.End()

	br := make([]rune, 100, 0x28FF)
	for i := 0; i < 100; i++ {
		switch {
		case i%5 == 0:
			br[i] = 0x2800
		case i%37 == 0:
			br[i] = 0xa
		default:
			br[i] = brl.Rune(1, 2, 3, 4, 5, 6)
		}
	}
	bs := string(br)
	fmt.Println(bs)
	calcLines(bs, 30)

	DrawPage30(canvas, bs)
}
Beispiel #2
0
func Encode(s string) (string, int) {
	needForeignMarker := hasHangul(s)

	var currentMarker rune
	rs := make([]rune, 0)
	for _, c := range s {
		switch {
		case han.IsJaeum(c) || han.IsMoeum(c):
			if currentMarker != markerJamo {
				rs = append(rs, markerJamo)
				currentMarker = markerJamo
			}
			rs = append(rs, Jamo(c)...)
		case han.IsHangul(c):
			// In Korean braille string there is no marker for
			// Korean string.
			if currentMarker != 0x00 {
				currentMarker = 0x00
			}
			i, m, f := han.Split(c)
			rs = append(rs, Jamo(i)...)
			rs = append(rs, Jamo(m)...)
			rs = append(rs, Jamo(f)...)
		case '0' <= c && c <= '9':
			if currentMarker != markerNumber {
				rs = append(rs, markerNumber)
				currentMarker = markerNumber
			}
			rs = append(rs, brl.Alphabet(c)...)
		case ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z'):
			if currentMarker != markerForeign {
				if needForeignMarker {
					rs = append(rs, markerForeign)
				}
				currentMarker = markerForeign
			}
			rs = append(rs, brl.Alphabet(c)...)
		case isSupportedSymbol(c):
			// No marker change in symbols... Is it right?
			rs = append(rs, symbol[c]...)
		case c == 0x20:
			rs = append(rs, brl.Rune())
			currentMarker = 0x00
		case c == 0x0a:
			rs = append(rs, c)
			currentMarker = 0x00
		default:
			log.Printf("Braille for %c(0x%x) not present... yet", c, c)
			rs = append(rs, brl.BrailleCodeBase)
		}

	}

	return string(rs), len(rs)
}
Beispiel #3
0
import (
	brl "github.com/suapapa/go_braille"
	han "github.com/suapapa/go_hangul"
	"log"
)

/*
자음은 초성과 종성의 모양이 다르지만, 유사성을 띠고 있다.
종성의 모양은 초성의 좌우를 뒤집어 만들거나, 모양을 아래쪽으로 한 칸 내려서 만든다.
자음 점자는 두 줄 이하만을 사용한다.
초성 ㅇ은 점자에서 따로 쓰지 않으며,
별도의 기호가 있는 ㅆ를 뺀 겹받침은 해당하는 낱자를 순서대로 적는다.
*/
var jamo = map[rune][]rune{
	// 초성
	han.LEAD_G: []rune{brl.Rune(4)},
	han.LEAD_N: []rune{brl.Rune(1, 4)},
	han.LEAD_D: []rune{brl.Rune(2, 4)},
	han.LEAD_R: []rune{brl.Rune(5)},
	han.LEAD_M: []rune{brl.Rune(1, 5)},
	han.LEAD_B: []rune{brl.Rune(4, 5)},
	han.LEAD_S: []rune{brl.Rune(6)},
	han.LEAD_J: []rune{brl.Rune(4, 6)},
	han.LEAD_C: []rune{brl.Rune(5, 6)},
	han.LEAD_K: []rune{brl.Rune(1, 2, 4)},
	han.LEAD_T: []rune{brl.Rune(1, 2, 5)},
	han.LEAD_P: []rune{brl.Rune(1, 4, 5)},
	han.LEAD_H: []rune{brl.Rune(2, 4, 5)},

	// 종성
	han.TAIL_G:  []rune{brl.Rune(1)},