Skip to content

Instantly share code, notes, and snippets.

Koze Koze

Block or report user

Report or block Koze

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Koze
Koze / JapaneseFontProblem.swift
Last active May 9, 2020
Japanese font without Japanese character causes the clip at the bottom. The final workaround with extension.
View JapaneseFontProblem.swift
//
// SmapleView.swift
// JapaneseFontCropped
//
// Created by Kazuma Koze on 2020/05/08.
// Copyright © 2020 Climb App. All rights reserved.
//
/**
Copyright 2020 Kazuma Koze
@Koze
Koze / JapaneseFontProblem.swift
Last active May 8, 2020
Japanese font without Japanese character causes the clip at the bottom. The final workaround.
View JapaneseFontProblem.swift
import SwiftUI
struct SmapleView: View {
let ctFont = CTFontCreateWithName("HiraginoSans-W3" as CFString, 50, nil)
var ctFontDescender: CGFloat {
CTFontGetDescent(ctFont)
}
let borderColor = Color(.systemBlue)
@Koze
Koze / JapaneseFontProblem.swift
Created May 8, 2020
Japanese font without Japanese character causes the clip at the bottom. A refactored quick workaround.
View JapaneseFontProblem.swift
import SwiftUI
struct SmapleView: View {
let ctFont = CTFontCreateWithName("HiraginoSans-W3" as CFString, 50, nil)
var ctFontDescender: CGFloat {
CTFontGetDescent(ctFont)
}
let borderColor = Color(.systemBlue)
@Koze
Koze / JapaneseFontProblem.swift
Created May 8, 2020
Japanese font without Japanese character causes the clip at the bottom. A quick workaround.
View JapaneseFontProblem.swift
import SwiftUI
struct SmapleView: View {
let font = Font.custom("HiraginoSans-W3", size: 50)
let uiFont = UIFont(name: "HiraginoSans-W3", size: 50)!
let borderColor = Color(.systemBlue)
var body: some View {
HStack(spacing: 10) {
@Koze
Koze / JapaneseFontProblem.swift
Created May 8, 2020
Japanese font without Japanese character causes the clip at the bottom. A workaround that doesn't work.
View JapaneseFontProblem.swift
import SwiftUI
struct SmapleView: View {
let font = Font.custom("HiraginoSans-W3", size: 50)
let borderColor = Color(.systemBlue)
var body: some View {
HStack(spacing: 10) {
Text("Copy")
@Koze
Koze / JapaneseFontProblem.swift
Last active May 8, 2020
Japanese font without Japanese character causes the clip at the bottom.
View JapaneseFontProblem.swift
import SwiftUI
struct SmapleView: View {
let font = Font.custom("HiraginoSans-W3", size: 50)
let borderColor = Color(.systemBlue)
var body: some View {
VStack(spacing: 10) {
Text("Copy")
View CKRecord+KeyPath.swift
extension CKRecord {
public subscript<Root, Value: CKRecordValueProtocol>(keyPath keyPath: WritableKeyPath<Root, Value>) -> Value? {
get {
let key = NSExpression(forKeyPath: keyPath).keyPath
return self[key]
}
set {
let key = NSExpression(forKeyPath: keyPath).keyPath
self[key] = newValue
}
@Koze
Koze / CKRecord+DynamicMemberLookup.swift
Created Mar 15, 2020
Type-safe CKRecord with dynamicMemberLookup
View CKRecord+DynamicMemberLookup.swift
extension CKRecord {
subscript<Root, Value: CKRecordValueProtocol>(dynamicMember keyPath: WritableKeyPath<Root, Value>) -> Value? {
get {
let key = NSExpression(forKeyPath: keyPath).keyPath
return self[key]
}
set {
let key = NSExpression(forKeyPath: keyPath).keyPath
// Fatal error: Could not extract a String from KeyPath Swift.ReferenceWritableKeyPath
self[key] = newValue
@Koze
Koze / CKRecord+KeyPath.swift
Created Mar 15, 2020
Type-safe CKRecord extension by Objective-C keyPath.
View CKRecord+KeyPath.swift
extension CKRecord {
public subscript<Root, Value: CKRecordValueProtocol>(keyPath keyPath: WritableKeyPath<Root, Value>) -> Value? {
get {
let key = NSExpression(forKeyPath: keyPath).keyPath
return self[key]
}
set {
let key = NSExpression(forKeyPath: keyPath).keyPath
self[key] = newValue
}
@Koze
Koze / CKRecord+RawRepresentable.swift
Last active Mar 15, 2020
A little type-safe CKRecord extension to prevent typo.
View CKRecord+RawRepresentable.swift
extension CKRecord {
subscript<T: RawRepresentable>(key: T) -> CKRecordValueProtocol? where T.RawValue == CKRecord.FieldKey {
get {
return self[key.rawValue]
}
set {
self[key.rawValue] = newValue
}
}
}
You can’t perform that action at this time.