aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/fontsrv
diff options
context:
space:
mode:
authorRuss Cox <rsc@swtch.com>2017-06-19 09:58:25 -0400
committerRuss Cox <rsc@swtch.com>2017-06-19 13:58:51 +0000
commit711336c348ac9b98cd22464496e6b7e9a109c3a9 (patch)
treeb9701e60d05f31ca363642a8dd73bd6d553a228a /src/cmd/fontsrv
parent1f1ab4ccbbec9c92b780f6a60ff9730126659a87 (diff)
downloadplan9port-711336c348ac9b98cd22464496e6b7e9a109c3a9.tar.gz
plan9port-711336c348ac9b98cd22464496e6b7e9a109c3a9.tar.bz2
plan9port-711336c348ac9b98cd22464496e6b7e9a109c3a9.zip
fontsrv: avoid quote mapping on fonts with indistinguishable quotes
Fixes #86. Change-Id: Id487219a0fcfdb68133fc81b11383365a1431c1c Reviewed-on: https://plan9port-review.googlesource.com/2922 Reviewed-by: Russ Cox <rsc@swtch.com>
Diffstat (limited to 'src/cmd/fontsrv')
-rw-r--r--src/cmd/fontsrv/osx.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/cmd/fontsrv/osx.c b/src/cmd/fontsrv/osx.c
index d1a31837..f48f5b49 100644
--- a/src/cmd/fontsrv/osx.c
+++ b/src/cmd/fontsrv/osx.c
@@ -17,17 +17,31 @@
extern void CGFontGetGlyphsForUnichars(CGFontRef, const UniChar[], const CGGlyph[], size_t);
+// In these fonts, it's too hard to distinguish U+2018 and U+2019,
+// so don't map the ASCII quotes there.
+// See https://github.com/9fans/plan9port/issues/86
+static char *skipquotemap[] = {
+ "Courier",
+ "Osaka",
+};
+
int
-mapUnicode(int i)
+mapUnicode(char *name, int i)
{
+ int j;
+
+ if(0xd800 <= i && i < 0xe0000) // surrogate pairs, will crash OS X libraries!
+ return 0xfffd;
+ for(j=0; j<nelem(skipquotemap); j++) {
+ if(strstr(name, skipquotemap[j]))
+ return i;
+ }
switch(i) {
case '\'':
return 0x2019;
case '`':
return 0x2018;
}
- if(0xd800 <= i && i < 0xe0000) // surrogate pairs, will crash OS X libraries!
- return 0xfffd;
return i;
}
@@ -273,7 +287,7 @@ mksubfont(XFont *f, char *name, int lo, int hi, int size, int antialias)
CFStringRef keys[] = { kCTFontAttributeName, kCTForegroundColorAttributeName };
CFTypeRef values[] = { font, white };
- sprint(buf, "%C", (Rune)mapUnicode(i));
+ sprint(buf, "%C", (Rune)mapUnicode(name, i));
str = c2mac(buf);
// See https://developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/CoreText_Programming/LayoutOperations/LayoutOperations.html#//apple_ref/doc/uid/TP40005533-CH12-SW2
@@ -298,7 +312,7 @@ mksubfont(XFont *f, char *name, int lo, int hi, int size, int antialias)
// fprint(2, "printed %#x: %g %g\n", mapUnicode(i), p1.x, p1.y);
p1 = CGContextGetTextPosition(ctxt);
- if(p1.x <= 0 || mapUnicode(i) == 0xfffd) {
+ if(p1.x <= 0 || mapUnicode(name, i) == 0xfffd) {
fc->width = 0;
fc->left = 0;
if(i == 0) {