mirror of
https://github.com/coteditor/CotEditor.git
synced 2024-09-11 11:25:57 +03:00
Add an option for ligatures (#209)
This commit is contained in:
parent
578b189f08
commit
af8dff0dc6
@ -5,6 +5,11 @@ Change Log
|
||||
3.7.7 (unreleased)
|
||||
--------------------------
|
||||
|
||||
### New Features
|
||||
|
||||
- Add a new option to the Appearance pane to disable ligatures.
|
||||
|
||||
|
||||
### Improvements
|
||||
|
||||
- Keep last opacity state of restored document windows.
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="WBM-EY-ENr">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="WBM-EY-ENr">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14460.31"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.70"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
@ -543,6 +543,16 @@
|
||||
<action selector="updateCursorTypeSetting:" target="WBM-EY-ENr" id="Ai3-zA-evF"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="4cD-mR-vJc">
|
||||
<rect key="frame" x="215" y="542" width="79" height="18"/>
|
||||
<buttonCell key="cell" type="check" title="Ligatures" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="g3S-3v-6ZA">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<binding destination="IE5-39-jAY" name="value" keyPath="values.ligature" id="BcZ-Pb-BN1"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="112-i3-na3" firstAttribute="baseline" secondItem="uyp-Xk-mRF" secondAttribute="baseline" id="0ZB-56-kAu"/>
|
||||
@ -550,6 +560,7 @@
|
||||
<constraint firstItem="iqn-kw-8py" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="4bD-zo-hEC" secondAttribute="trailing" constant="8" symbolic="YES" id="1pA-ty-2Q0"/>
|
||||
<constraint firstItem="icl-ar-8yG" firstAttribute="centerY" secondItem="wT1-jD-6aC" secondAttribute="centerY" id="2Da-qS-ndH"/>
|
||||
<constraint firstItem="nqX-jr-n2L" firstAttribute="baseline" secondItem="REw-fm-8pq" secondAttribute="baseline" id="2nt-4v-dcz"/>
|
||||
<constraint firstItem="4cD-mR-vJc" firstAttribute="leading" secondItem="I9r-vj-2gy" secondAttribute="trailing" constant="20" id="3ap-7B-c2c"/>
|
||||
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="I9r-vj-2gy" secondAttribute="trailing" constant="20" symbolic="YES" id="3jM-oH-o1R"/>
|
||||
<constraint firstItem="nMR-L3-OOw" firstAttribute="top" secondItem="QiH-I6-BXd" secondAttribute="top" id="560-FH-NJM"/>
|
||||
<constraint firstItem="Yzg-b2-Ep1" firstAttribute="leading" secondItem="Cq3-kO-Ned" secondAttribute="trailing" constant="6" symbolic="YES" id="58C-V5-ZWQ"/>
|
||||
@ -576,6 +587,7 @@
|
||||
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="I05-Ks-5uR" secondAttribute="trailing" constant="20" symbolic="YES" id="Jgr-0Z-HNG"/>
|
||||
<constraint firstItem="ywA-ws-Ayf" firstAttribute="top" secondItem="nqX-jr-n2L" secondAttribute="bottom" constant="9" id="JsK-EY-lgT"/>
|
||||
<constraint firstItem="uyp-Xk-mRF" firstAttribute="leading" secondItem="iqn-kw-8py" secondAttribute="leading" id="KFw-Bk-2DM"/>
|
||||
<constraint firstItem="4cD-mR-vJc" firstAttribute="firstBaseline" secondItem="I9r-vj-2gy" secondAttribute="firstBaseline" id="O95-SU-su2"/>
|
||||
<constraint firstItem="4bD-zo-hEC" firstAttribute="width" secondItem="REw-fm-8pq" secondAttribute="width" id="P3r-wJ-JCa"/>
|
||||
<constraint firstItem="c80-NU-o7Z" firstAttribute="leading" secondItem="izZ-9S-QaW" secondAttribute="trailing" constant="8" symbolic="YES" id="PaT-Me-qZB"/>
|
||||
<constraint firstItem="x9R-2Y-F6b" firstAttribute="baseline" secondItem="xAb-JZ-6Pr" secondAttribute="baseline" id="Rgk-EV-cbB"/>
|
||||
|
@ -27,6 +27,8 @@
|
||||
<dd><dl>
|
||||
<dt>Anti-aliasing</dt>
|
||||
<dd>With this option selected, CotEditor displays text anti-aliased.</dd>
|
||||
<dt>Ligatures</dt>
|
||||
<dd>With this option selected, the standard ligature rules are applied. Otherwise, all ligatures are disabled. Ligature is a typography feature joining specific characters as a single glyph.</dd>
|
||||
</dl></dd>
|
||||
|
||||
<dt>Line height</dt>
|
||||
|
@ -25,8 +25,10 @@
|
||||
<dt>フォント</dt>
|
||||
<dd>テキストの表示に使うフォントと文字サイズを設定します。</dd>
|
||||
<dd><dl>
|
||||
<dt>アンチエイリアス適用</dt>
|
||||
<dt>アンチエイリアス</dt>
|
||||
<dd>オンの場合、フォントのアンチエイリアス表示が有効になります。</dd>
|
||||
<dt>リガチャ</dt>
|
||||
<dd>オンの場合、デフォルトのリガチャが適用されます。オフの場合は無効になります。リガチャは合字とも呼ばれ、特定の文字の並びにおいて複数の文字を合成して一文字として表示するタイポグラフィの機能です。</dd>
|
||||
</dl></dd>
|
||||
|
||||
<dt>行の高さ</dt>
|
||||
|
@ -201,6 +201,8 @@
|
||||
2A4714EA209717C90093E27F /* DispatchQueue+Throttle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A4714E8209717C90093E27F /* DispatchQueue+Throttle.swift */; };
|
||||
2A476CAE1D09C8C80088E37A /* URLExtensionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A476CAD1D09C8C80088E37A /* URLExtensionsTests.swift */; };
|
||||
2A476CB11D09D0500088E37A /* FontExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A476CB01D09D0500088E37A /* FontExtensionTests.swift */; };
|
||||
2A478F3F22BE743200AEA45E /* NSTextView+Ligature.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A478F3E22BE743200AEA45E /* NSTextView+Ligature.swift */; };
|
||||
2A478F4022BE743200AEA45E /* NSTextView+Ligature.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A478F3E22BE743200AEA45E /* NSTextView+Ligature.swift */; };
|
||||
2A479C821D8C15A600EEEFC2 /* CenteringTextFieldCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A479C811D8C15A600EEEFC2 /* CenteringTextFieldCell.swift */; };
|
||||
2A479C831D8C15A600EEEFC2 /* CenteringTextFieldCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A479C811D8C15A600EEEFC2 /* CenteringTextFieldCell.swift */; };
|
||||
2A47CD3521D20E6F0094F62F /* DefaultKey+Observation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A47CD3421D20E6F0094F62F /* DefaultKey+Observation.swift */; };
|
||||
@ -1026,6 +1028,7 @@
|
||||
2A4714E8209717C90093E27F /* DispatchQueue+Throttle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DispatchQueue+Throttle.swift"; sourceTree = "<group>"; };
|
||||
2A476CAD1D09C8C80088E37A /* URLExtensionsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = URLExtensionsTests.swift; sourceTree = "<group>"; };
|
||||
2A476CB01D09D0500088E37A /* FontExtensionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FontExtensionTests.swift; sourceTree = "<group>"; };
|
||||
2A478F3E22BE743200AEA45E /* NSTextView+Ligature.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSTextView+Ligature.swift"; sourceTree = "<group>"; };
|
||||
2A479C811D8C15A600EEEFC2 /* CenteringTextFieldCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CenteringTextFieldCell.swift; sourceTree = "<group>"; };
|
||||
2A47CD3421D20E6F0094F62F /* DefaultKey+Observation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DefaultKey+Observation.swift"; sourceTree = "<group>"; };
|
||||
2A47CD3721D340030094F62F /* NSValidatedUserInterfaceItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSValidatedUserInterfaceItem.swift; sourceTree = "<group>"; };
|
||||
@ -1966,6 +1969,7 @@
|
||||
2AA4F69F20A1C190003FD515 /* NSTextView+RoundedBackground.swift */,
|
||||
2ADD0AD7217A967200F78732 /* NSTextView+LineNumber.swift */,
|
||||
2A72DA0F209B778B005242B9 /* NSTextView+MultiCursor.swift */,
|
||||
2A478F3E22BE743200AEA45E /* NSTextView+Ligature.swift */,
|
||||
2AFE848522AE71130001C4ED /* TextContainer.swift */,
|
||||
2A6FD9E61D394F5900A59784 /* LayoutManager.swift */,
|
||||
2A6FD9DC1D392EFF00A59784 /* ATSTypesetter.swift */,
|
||||
@ -2843,6 +2847,7 @@
|
||||
2A5DCE501D185F1B00D5D74C /* CharacterField.swift in Sources */,
|
||||
2A231A371E7C30F000C2A909 /* MultipleReplacementSplitViewController.swift in Sources */,
|
||||
2AA749C41D3C263300850802 /* DocumentWindowController.swift in Sources */,
|
||||
2A478F4022BE743200AEA45E /* NSTextView+Ligature.swift in Sources */,
|
||||
2A5D13261D1F9D4100D38E6A /* StatableToolbarItem.swift in Sources */,
|
||||
2A88E7721E81A2C7000019C6 /* OrderedSet.swift in Sources */,
|
||||
2AC3845420C929950003F213 /* OpacitySampleView.swift in Sources */,
|
||||
@ -3295,6 +3300,7 @@
|
||||
2A6FD9E71D394F5900A59784 /* LayoutManager.swift in Sources */,
|
||||
2AD551EA20D8206C007279B1 /* StatableMenuToolbarItem.swift in Sources */,
|
||||
2A885E331D5C3A1B00288723 /* Comparable.swift in Sources */,
|
||||
2A478F3F22BE743200AEA45E /* NSTextView+Ligature.swift in Sources */,
|
||||
2A78BFA71D1B05FB00A583D2 /* GeneralPaneController.swift in Sources */,
|
||||
2AAD61FC1D2BD102008FE772 /* String+Additions.swift in Sources */,
|
||||
2A8C338C1D3E16B00005B0B7 /* IncompatibleCharacterScanner.swift in Sources */,
|
||||
|
@ -67,6 +67,7 @@ extension DefaultKeys {
|
||||
static let fontName = DefaultKey<String>("fontName")
|
||||
static let fontSize = DefaultKey<CGFloat>("fontSize")
|
||||
static let shouldAntialias = DefaultKey<Bool>("shouldAntialias")
|
||||
static let ligature = DefaultKey<Bool>("ligature")
|
||||
static let lineHeight = DefaultKey<CGFloat>("lineHeight")
|
||||
static let highlightCurrentLine = DefaultKey<Bool>("highlightCurrentLine")
|
||||
static let cursorType = DefaultKey<CursorType>("cursorType")
|
||||
|
@ -66,6 +66,7 @@ struct DefaultSettings {
|
||||
.fontName: (NSFont.userFont(ofSize: 0) ?? NSFont.systemFont(ofSize: 0)).fontName,
|
||||
.fontSize: NSFont.systemFontSize,
|
||||
.shouldAntialias: true,
|
||||
.ligature: true,
|
||||
.lineHeight: 1.2,
|
||||
.highlightCurrentLine: false,
|
||||
.cursorType: CursorType.bar.rawValue,
|
||||
|
@ -610,6 +610,7 @@ final class Document: NSDocument, AdditionalDocumentPreparing, EncodingHolder {
|
||||
printView.documentShowsInvisibles = viewController.showsInvisibles
|
||||
printView.documentShowsLineNumber = viewController.showsLineNumber
|
||||
printView.baseWritingDirection = viewController.writingDirection
|
||||
printView.ligature = UserDefaults.standard[.ligature] ? .standard : .none
|
||||
|
||||
// set font for printing
|
||||
printView.font = UserDefaults.standard[.setPrintFont]
|
||||
|
@ -166,6 +166,7 @@ final class EditorTextView: NSTextView, Themable, CurrentLineHighlighting, Multi
|
||||
layoutManager.textFont = font
|
||||
layoutManager.usesAntialias = defaults[.shouldAntialias]
|
||||
|
||||
self.ligature = defaults[.ligature] ? .standard : .none
|
||||
self.invalidateDefaultParagraphStyle()
|
||||
|
||||
// observe change in defaults
|
||||
@ -1537,6 +1538,7 @@ final class EditorTextView: NSTextView, Themable, CurrentLineHighlighting, Multi
|
||||
.enableSmartIndent,
|
||||
.balancesBrackets,
|
||||
.shouldAntialias,
|
||||
.ligature,
|
||||
.smartInsertAndDelete,
|
||||
.enableSmartQuotes,
|
||||
.enableSmartDashes,
|
||||
@ -1577,6 +1579,9 @@ final class EditorTextView: NSTextView, Themable, CurrentLineHighlighting, Multi
|
||||
case .shouldAntialias:
|
||||
self.usesAntialias = new as! Bool
|
||||
|
||||
case .ligature:
|
||||
self.ligature = (new as! Bool) ? .standard : .none
|
||||
|
||||
case .smartInsertAndDelete:
|
||||
self.smartInsertDeleteEnabled = new as! Bool
|
||||
|
||||
|
66
CotEditor/Sources/NSTextView+Ligature.swift
Normal file
66
CotEditor/Sources/NSTextView+Ligature.swift
Normal file
@ -0,0 +1,66 @@
|
||||
//
|
||||
// NSTextView+Ligature.swift
|
||||
//
|
||||
// CotEditor
|
||||
// https://coteditor.com
|
||||
//
|
||||
// Created by 1024jp on 2019-06-22.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// © 2019 1024jp
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import AppKit
|
||||
|
||||
extension NSTextView {
|
||||
|
||||
enum LigatureMode: Int {
|
||||
|
||||
case none
|
||||
case standard
|
||||
case all
|
||||
}
|
||||
|
||||
|
||||
/// ligature mode
|
||||
var ligature: LigatureMode {
|
||||
|
||||
get {
|
||||
guard
|
||||
let rawValue = self.typingAttributes[.ligature] as? Int,
|
||||
let mode = LigatureMode(rawValue: rawValue)
|
||||
else { return .standard }
|
||||
|
||||
return mode
|
||||
}
|
||||
|
||||
set {
|
||||
switch newValue {
|
||||
case .standard: // NSTextView uses the standard ligatures by default.
|
||||
self.typingAttributes[.ligature] = nil
|
||||
if let textStorage = self.textStorage {
|
||||
textStorage.removeAttribute(.ligature, range: textStorage.range)
|
||||
}
|
||||
case .none, .all:
|
||||
self.typingAttributes[.ligature] = newValue.rawValue
|
||||
if let textStorage = self.textStorage {
|
||||
textStorage.addAttribute(.ligature, value: newValue.rawValue, range: textStorage.range)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -31,6 +31,8 @@
|
||||
"3289.title" = "Auswählen …";
|
||||
/* Class = "NSButtonCell"; title = "Anti-aliasing"; ObjectID = "3290"; */
|
||||
"3290.title" = "Schrift glätten";
|
||||
/* Class = "NSButtonCell"; title = "Ligatures"; ObjectID = "g3S-3v-6ZA"; */
|
||||
"g3S-3v-6ZA.title" = "Ligaturen";
|
||||
|
||||
/* Class = "NSTextFieldCell"; title = "Line height:"; ObjectID = "r1c-v3-qW1"; */
|
||||
"r1c-v3-qW1.title" = "Zeilenhöhe:";
|
||||
|
@ -31,6 +31,8 @@
|
||||
"3289.title" = "Choisir…";
|
||||
/* Class = "NSButtonCell"; title = "Anti-aliasing"; ObjectID = "3290"; */
|
||||
"3290.title" = "Anticrénelage";
|
||||
/* Class = "NSButtonCell"; title = "Ligatures"; ObjectID = "g3S-3v-6ZA"; */
|
||||
"g3S-3v-6ZA.title" = "Ligatures";
|
||||
|
||||
/* Class = "NSTextFieldCell"; title = "Line height:"; ObjectID = "r1c-v3-qW1"; */
|
||||
"r1c-v3-qW1.title" = "Hauteur de ligne :";
|
||||
|
@ -32,6 +32,8 @@
|
||||
"3289.title" = "Select…";
|
||||
/* Class = "NSButtonCell"; title = "Anti-aliasing"; ObjectID = "3290"; */
|
||||
"3290.title" = "Anti-aliasing";
|
||||
/* Class = "NSButtonCell"; title = "Ligatures"; ObjectID = "g3S-3v-6ZA"; */
|
||||
"g3S-3v-6ZA.title" = "Ligature";
|
||||
|
||||
/* Class = "NSTextFieldCell"; title = "Line height:"; ObjectID = "r1c-v3-qW1"; */
|
||||
"r1c-v3-qW1.title" = "Altezza riga:";
|
||||
|
@ -31,6 +31,8 @@
|
||||
"3289.title" = "選択...";
|
||||
/* Class = "NSButtonCell"; title = "Anti-aliasing"; ObjectID = "3290"; */
|
||||
"3290.title" = "アンチエイリアス適用";
|
||||
/* Class = "NSButtonCell"; title = "Ligatures"; ObjectID = "g3S-3v-6ZA"; */
|
||||
"g3S-3v-6ZA.title" = "リガチャ";
|
||||
|
||||
/* Class = "NSTextFieldCell"; title = "Line height:"; ObjectID = "r1c-v3-qW1"; */
|
||||
"r1c-v3-qW1.title" = "行の高さ:";
|
||||
|
@ -30,6 +30,8 @@
|
||||
"3289.title" = "Selecionar…";
|
||||
/* Class = "NSButtonCell"; title = "Anti-aliasing"; ObjectID = "3290"; */
|
||||
"3290.title" = "Antisserrilhado";
|
||||
/* Class = "NSButtonCell"; title = "Ligatures"; ObjectID = "g3S-3v-6ZA"; */
|
||||
"g3S-3v-6ZA.title" = "Ligadures";
|
||||
|
||||
/* Class = "NSTextFieldCell"; title = "Line height:"; ObjectID = "r1c-v3-qW1"; */
|
||||
"r1c-v3-qW1.title" = "Altura da linha:";
|
||||
|
@ -32,6 +32,8 @@
|
||||
"3289.title" = "选择…";
|
||||
/* Class = "NSButtonCell"; title = "Anti-aliasing"; ObjectID = "3290"; */
|
||||
"3290.title" = "抗锯齿";
|
||||
/* Class = "NSButtonCell"; title = "Ligatures"; ObjectID = "g3S-3v-6ZA"; */
|
||||
"g3S-3v-6ZA.title" = "连字";
|
||||
|
||||
/* Class = "NSTextFieldCell"; title = "Line height:"; ObjectID = "r1c-v3-qW1"; */
|
||||
"r1c-v3-qW1.title" = "行高:";
|
||||
|
Loading…
Reference in New Issue
Block a user