Commit 33615643 authored by Adrian Johnson's avatar Adrian Johnson Committed by Albert Astals Cid

Expand glyph name ligatures such as "ff", "ffi" etc to normal form

Bug 7002
parent d0186c55
......@@ -26,7 +26,7 @@
// Copyright (C) 2009 Peter Kerzum <kerzum@yandex-team.ru>
// Copyright (C) 2009, 2010 David Benjamin <davidben@mit.edu>
// Copyright (C) 2011 Axel Strübing <axel.struebing@freenet.de>
// Copyright (C) 2011 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2011, 2012 Adrian Johnson <ajohnson@redneon.com>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
......@@ -55,6 +55,7 @@
#include "CharCodeToUnicode.h"
#include "FontEncodingTables.h"
#include "BuiltinFontTables.h"
#include "UnicodeTypeTable.h"
#include <fofi/FoFiIdentifier.h>
#include <fofi/FoFiType1.h>
#include <fofi/FoFiType1C.h>
......@@ -1228,6 +1229,17 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA
// construct the char code -> Unicode mapping object
ctu = CharCodeToUnicode::make8BitToUnicode(toUnicode);
// pass 1a: Expand ligatures in the Alphabetic Presentation Form
// block (eg "fi", "ffi") to normal form
for (code = 0; code < 256; ++code) {
if (unicodeIsAlphabeticPresentationForm(toUnicode[code])) {
Unicode *normalized = unicodeNormalizeNFKC(&toUnicode[code], 1, &len, NULL);
if (len > 1)
ctu->setMapping((CharCode)code, normalized, len);
gfree(normalized);
}
}
// pass 2: try to fill in the missing chars, looking for ligatures, numeric
// references and variants
if (missing) {
......
......@@ -16,6 +16,7 @@
// Copyright (C) 2006, 2007 Ed Catmur <ed@catmur.co.uk>
// Copyright (C) 2007 Jeff Muizelaar <jeff@infidigm.net>
// Copyright (C) 2008 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
......@@ -962,6 +963,14 @@ GBool unicodeTypeAlphaNum(Unicode c) {
return t == 'L' || t == 'R' || t == '#';
}
#define UNICODE_ALPHABETIC_PRESENTATION_BLOCK_BEGIN 0xFB00
#define UNICODE_ALPHABETIC_PRESENTATION_BLOCK_END 0xFB4F
GBool unicodeIsAlphabeticPresentationForm(Unicode c) {
return c >= UNICODE_ALPHABETIC_PRESENTATION_BLOCK_BEGIN
&& c <= UNICODE_ALPHABETIC_PRESENTATION_BLOCK_END;
}
Unicode unicodeToUpper(Unicode c) {
int i;
......
......@@ -14,6 +14,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2006 Ed Catmur <ed@catmur.co.uk>
// Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
......@@ -33,6 +34,8 @@ extern GBool unicodeTypeNum(Unicode c);
extern GBool unicodeTypeAlphaNum(Unicode c);
extern GBool unicodeIsAlphabeticPresentationForm(Unicode c);
extern Unicode unicodeToUpper(Unicode c);
extern Unicode *unicodeNormalizeNFKC(Unicode *in, int len,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment