fix wrong git ignore
This commit is contained in:
51
internal/pdf/model/textencoding/utils.go
Normal file
51
internal/pdf/model/textencoding/utils.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package textencoding
|
||||
|
||||
import "gitea.tecamino.com/paadi/pdfmerge/internal/pdf/common"
|
||||
|
||||
func glyphToRune(glyph string, glyphToRuneMap map[string]rune) (rune, bool) {
|
||||
ucode, found := glyphToRuneMap[glyph]
|
||||
if found {
|
||||
return ucode, true
|
||||
}
|
||||
|
||||
//common.Log.Debug("Glyph->Rune ERROR: Unable to find glyph %s", glyph)
|
||||
return 0, false
|
||||
}
|
||||
|
||||
func runeToGlyph(ucode rune, runeToGlyphMap map[rune]string) (string, bool) {
|
||||
glyph, found := runeToGlyphMap[ucode]
|
||||
if found {
|
||||
return glyph, true
|
||||
}
|
||||
|
||||
//common.Log.Debug("Rune->Glyph ERROR: Unable to find rune %v", ucode)
|
||||
return "", false
|
||||
}
|
||||
|
||||
func splitWords(raw string, encoder TextEncoder) []string {
|
||||
runes := []rune(raw)
|
||||
|
||||
words := []string{}
|
||||
|
||||
startsAt := 0
|
||||
for idx, code := range runes {
|
||||
glyph, found := encoder.RuneToGlyph(code)
|
||||
if !found {
|
||||
common.Log.Debug("Glyph not found for code: %s\n", string(code))
|
||||
continue
|
||||
}
|
||||
|
||||
if glyph == "space" {
|
||||
word := runes[startsAt:idx]
|
||||
words = append(words, string(word))
|
||||
startsAt = idx + 1
|
||||
}
|
||||
}
|
||||
|
||||
word := runes[startsAt:]
|
||||
if len(word) > 0 {
|
||||
words = append(words, string(word))
|
||||
}
|
||||
|
||||
return words
|
||||
}
|
||||
Reference in New Issue
Block a user