Skip to content

Instantly share code, notes, and snippets.

@IBAction func shapingToy(_: Any) {
print("shaping toy start")
//let text = "hello 😀 العالمية"
let text = "hello this is a pretty long string that's designed to see what the effect on shaping is. Probably it's not something we need to worry about"
let font = NSFont(name: "Inconsolata", size: 14)!
let attributes: [NSAttributedStringKey: AnyObject] = [
NSAttributedStringKey.font: font,
]
let attrString = NSMutableAttributedString(string: text, attributes: attributes)
// benchmark time!
@raphlinus
raphlinus / text.f.glsl
Created December 14, 2017 15:59
text compositing fragment shader
// Copyright 2017 Google LLC.
//
// 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,
@raphlinus
raphlinus / update.json
Created December 29, 2017 18:49
A typical xi-editor update notification sampled from an edit session
{"method":"update","params":{"update":{"ops":[{"n":6374,"op":"invalidate"},{"n":18,"op":"invalidate"},{"n":87,"op":"invalidate"},{"n":101,"op":"invalidate"},{"n":6580,"op":"skip"},{"n":56,"op":"copy"},{"n":63,"op":"invalidate"},{"n":63,"op":"skip"},{"n":56,"op":"copy"},{"n":61,"op":"invalidate"},{"n":61,"op":"skip"},{"n":56,"op":"copy"},{"n":59,"op":"invalidate"},{"n":59,"op":"skip"},{"n":56,"op":"copy"},{"n":57,"op":"invalidate"},{"n":57,"op":"skip"},{"n":56,"op":"copy"},{"n":55,"op":"invalidate"},{"n":55,"op":"skip"},{"n":56,"op":"copy"},{"n":53,"op":"invalidate"},{"n":53,"op":"skip"},{"n":56,"op":"copy"},{"n":52,"op":"invalidate"},{"n":52,"op":"skip"},{"n":56,"op":"copy"},{"n":49,"op":"invalidate"},{"lines":[{"styles":[0,1,3,0,5,5,0,6,3,0,1,4,0,1,3,0,7,6,0,2,3],"text":"\tinput.type = \"radio\";\n"},{"styles":[0,1,3,0,7,5,0,12,3,0,1,4,0,1,3,0,5,5,0,7,3,0,3,4,0,1,3,0,3,6,0,2,3],"text":"\tsupport.radioValue = input.value === \"t\";\n"},{"styles":[0,7,3],"text":"} )();\n"},{"styles":[0,1,3],"text":"\n"},{"styl
@raphlinus
raphlinus / OldJson.swift
Created December 29, 2017 19:08
Simple JSON task using old "idiomatic" Swift
// Copyright 2017 Google LLC
//
// 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,
@raphlinus
raphlinus / ObjCLike.swift
Created December 29, 2017 19:09
Simple JSON task using Objective-C data structures
// Copyright 2017 Google LLC
//
// 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,
@raphlinus
raphlinus / Decodable.swift
Created December 29, 2017 19:10
Simple JSON task using new Decodable protocol
// Copyright 2017 Google LLC
//
// 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,
@raphlinus
raphlinus / parse.cu
Created April 23, 2018 19:31
sketch of prefix sum to do backslash unescaping in cuda
// Copyright 2018 Google LLC
//
// 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
//
// http://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,
#![feature(test)]
extern crate test;
// Note: this dependency is nightly only
extern crate packed_simd;
#[macro_use]
extern crate cfg_if;
let menubar = NSMenu::new(nil).autorelease();
let app_menu_item = NSMenuItem::new(nil).autorelease();
menubar.addItem_(app_menu_item);
app.setMainMenu_(menubar);
let app_menu = NSMenu::new(nil).autorelease();
let quit_title = make_nsstring("Quit");
let quit_action = selector("terminate:");
let quit_key = make_nsstring("q");
let quit_item = NSMenuItem::alloc(nil)
@raphlinus
raphlinus / exclusive.rs
Created March 3, 2019 10:51
Sketch of thread-safety idea for VST
struct Key(Arc<()>);
impl Key {
pub fn new() {
Key(Arc::new(()))
}
}
// Note: Key is not Clone, there can be only one.