Skip to content

Instantly share code, notes, and snippets.

#import <Foundation/Foundation.h>
#import <CoreText/CoreText.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
CTFontRef font = CTFontCreateUIFontForLanguage(kCTFontUIFontSystem, 12, NULL);
{
CTFontRef fallback = CTFontCreateForStringWithLanguage(font, CFSTR("\u4E2D"), CFRangeMake(0, 1), CFSTR("zh-Hans"));
CFCharacterSetRef covered = CTFontCopyCharacterSet(fallback);
bool isMember = CFCharacterSetIsCharacterMember(covered, 0x61);

Keybase proof

I hereby claim:

  • I am jjgod on github.
  • I am jjgod (https://keybase.io/jjgod) on keybase.
  • I have a public key whose fingerprint is 5FD9 C8A0 2F01 70B9 872A A8C4 E982 2F2B 1778 9415

To claim this, I am signing this object:

@jjgod
jjgod / trace
Created November 10, 2016 23:29
trace git-lfs: run_command: git rev-list --objects 254f152b1f29e5662e41537bcbd862e57d1f9e81 --not --remotes=beta --
trace git-lfs: run_command: git cat-file --batch-check
trace git-lfs: run_command: git cat-file --batch
trace git-lfs: tq: running as batched queue, batch size of 100
trace git-lfs: tq: sending batch of size 0
trace git-lfs: tq: sending batch of size 0
trace git-lfs: tq: sending batch of size 0
trace git-lfs: run_command: git rev-list --objects 5821074cbe43093285cda6dc7e290c723849531e --not --remotes=beta --
trace git-lfs: run_command: git cat-file --batch-check
trace git-lfs: run_command: git cat-file --batch
@jjgod
jjgod / gist:0e65b96ab698e87a1261e563e9b4aeab
Created September 16, 2016 03:02
spin dump with build test
Date/Time: 2016-09-15 19:57:18 -0700
OS Version: Mac OS X 10.12.1 (Build 16B2327)
Architecture: x86_64h
Report Version: 25
Data Source: Stackshots
Command: Sublime Text
Path: /Volumes/Sublime Text/Sublime Text.app/Contents/MacOS/Sublime Text
Version: Build 3110 (3110)
@jjgod
jjgod / spindump.txt
Last active September 16, 2016 01:07
spindump
Date/Time: 2016-09-15 18:04:43 -0700
OS Version: Mac OS X 10.12.1 (Build 16B2327)
Architecture: x86_64h
Report Version: 25
Data Source: Stackshots
Command: Sublime Text
Path: /Volumes/NMOS/Applications/Sublime Text.app/Contents/MacOS/Sublime Text
Version: Build 3122 (3122)
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match target="pattern">
<test name="family" compare="eq">
<string>STHeiti</string>
</test>
<edit name="family" mode="prepend" binding="strong">
<string>PingFang SC</string>
</edit>
//
// Network.swift
// ACArticle
//
// Created by Zhida Cheng on 7/6/16.
// Copyright © 2016 Zhida Cheng. All rights reserved.
//
import Foundation
- (void)drawRect:(NSRect)dirtyRect {
CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort];
CGContextSetTextMatrix(context, CGAffineTransformIdentity);
CTFontRef font = CTFontCreateUIFontForLanguage(kCTFontUIFontSystem, 12.0, NULL);
// Use this to find out the feature identifiers we use below.
CFTypeRef features = CTFontCopyAttribute(font, kCTFontFeaturesAttribute);
NSLog(@"%@", features);
CFRelease(features);
~/C/t/t/d/tests (master) xdvipdfmx -v -z0 -o ttc2.pdf ttc
<FONTMAP:/usr/local/texlive/2015/texmf-var/fonts/map/pdftex/updmap/pdftex.map><FONTMAP:/usr/local/texlive/2015/texmf-var/fonts/map/dvipdfmx/updmap/kanjix.map><FONTMAP:/usr/local/texlive/2015/texmf-dist/fonts/map/dvipdfmx/ckx.map>ttc -> ttc2.pdf
DVI Comment: XeTeX output 2015.02.21:1509
<AGL:texglyphlist.txt><AGL:pdfglyphlist.txt><AGL:glyphlist.txt>[1<test.ttc@9.96pt<NATIVE-FONTMAP:./test.ttc/0/H/65536/0/0>
pdf_font>> Input encoding "Identity-H" requires at least 2 bytes.
pdf_font>> The -m <00> option will be assumed for "./test.ttc".
xdvipdfmx:warning: File name="./test.ttc" format="opentype fonts" might be found in different location than I expected:
xdvipdfmx:warning: >> ./test.ttc
xdvipdfmx:warning: >> Please adjust your TEXMF as conformant with:
From 3b4b66c04a2567c72754a55e53db41394249b223 Mon Sep 17 00:00:00 2001
From: bungeman <bungeman@google.com>
Date: Thu, 8 Jan 2015 08:33:44 -0800
Subject: [PATCH] Work around changes in OSX 10.10.
In 10.10.1 CTFontGetAdvancesForGlyphs applies the font
transform to the width of the advance but always sets the
height of the advance to 0. Work around this by measuring the
advance with an unrotated font and apply the transform
manually.