• Stars
    star
    133
  • Rank 272,600 (Top 6 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 9 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A simple wrapper view for UITextView that can display Furiganas.

FuriganaTextView

A simple wrapper view for UITextView that can display Furiganas.

Carthage compatible

Example

Install

Install using Carthage

FuriganaTextView has been tested to work well with Carthage. To install using Carthage:

  1. First, you need to add github "lingochamp/FuriganaTextView" to your Cartfile .
  2. When Carthage done building the frameworks, you will find a framework named LLS.framework contains the files needed for intergrating FuriganaTextView .
  3. Drag LLS.framework into your project.
  4. In the source file where you want to use FuriganaTextView, add import LLS, then you are ready to go.

Install Manually

Clone the repo then add all files inside /src into your project.

Then you are ready to go.

Usage

// Prepare furigana contents
// Note: The order of the furiganas provided to the FuriganaTextView is important.
// It must be ascending in manner of the location of the range,
// otherwise the furiganas may not be rendered at the correct position.
let furiganas = [
  Furigana(text: "", original: "", range: NSMakeRange(0, 1)),
  Furigana(text: "なか", original: "", range: NSMakeRange(1, 1)),
]
let contents = NSAttributedString(string: "田中さん、中華料理を食べたことありますか。")

// Tell FuriganaTextView about 
// the furiganas (which is an array of the Furigana struct) 
// and the contents to display (a NSAttributedString)
furiganaTextView.furiganas = furiganas
furiganaTextView.contents = contents

// To customize the text view, use the contentView
// contentView will return a valid UITextView after
// the contents has been set
furiganaTextView.contentView?.backgroundColor = UIColor.lightGray

Requirements

  • Builds with Xcode 8 and Swift 3
  • Supports iOS 7 and above

Why not CTRubyAnnotation and CoreText

FuriganaTextView is built on top of TextKit and treats furiganas as custom attributes on the contents NSAttributedString.

The custom furigana attributes can coexist with any other text attributes (e.g. NSFontAttributeName, NSForegroundColorAttributeName, etc.).

We built it this way because we want to support iOS 7, and we want to take advantage of the high level features TextKit API offeres.

Known Issues

  • The textContainerInset property of the wrapped UITextView seems not working correctly.
  • Furiganas displayed in vertical writing is not implemented yet.

More Repositories

1

FileDownloader

Multitask、MultiThread(MultiConnection)、Breakpoint-resume、High-concurrency、Simple to use、Single/NotSingle-process
Java
11,031
star
2

okdownload

A Reliable, Flexible, Fast and Powerful download engine.
Java
5,178
star
3

MagicProgressWidget

MagicProgressCircle & MagicProgressBar
Java
728
star
4

ShareLoginLib

ThirdParty login and share lib
Java
702
star
5

Diplomat

整合第三方 SDK 微信、微博、 QQ 等为统一的 Diplomat 接口。
Objective-C
661
star
6

QiniuImageLoader

在Android上结合七牛提供的API,让加载图片更有效、更节流、更简单、更可控、更酷
Java
524
star
7

okcheck

Incremental scan,integrate Lint、KtLint、UnitTest、Checkstyle、Findbugs、Pmd, powerful and easy to use
Groovy
309
star
8

LingoRecorder

LingoRecorder is a better recorder for Android, you can easily process pcm from it.
Java
184
star
9

SpanEllipsizeEnd

处理 Span 在 最大宽度文字尾省略号,无效的问题。
Java
89
star
10

Multi-Scale-BERT-AES

Demo for the paper "On the Use of BERT for Automated Essay Scoring: Joint Learning of Multi-Scale Essay Representation"
Python
56
star
11

tensorflow-dkt

Build DKT (Deep Knowledge Tracing) model with TensorFlow
Python
47
star
12

OnlineScorer-Wechat

流利说在线录音打分微信版SDK
JavaScript
37
star
13

OnlineScorer-Android

C
12
star
14

OnlineScorer-iOS

OnlineScorerRecorder for iOS
Objective-C
9
star
15

Mercury

Kotlin
9
star
16

OnlineScorer-Web

JavaScript
6
star
17

open-asr

Python
5
star
18

language-coursescript

Syntax highlighting and snippets for CourseScript.
CoffeeScript
3
star
19

open-wechat-scorer

Server-side SDK for Liulishuo Open Platform
Python
1
star
20

PTSDK-iOS

PTSDK Framework for iOS
Swift
1
star
21

cares

A forked c-ares repository to make GRPC compilation less painful
C
1
star