filters

transform.h
1/*
2 * Copyright (c) 2003 Nicolas HADACEK (hadacek@kde.org)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20#ifndef TRANSFORM_H
21#define TRANSFORM_H
22
23#include <tqpair.h>
24#include "CharTypes.h"
25
26namespace PDFImport
27{
28 // check for special char (numerical values should be < 256)
29 enum CharType {
30 Unknown = 0,
31 Punctuation = 1,
32 SymbolChar = 2,
33 Digit = 3,
34 Letter = 4,
35
36 Hyphen = 5, // symbol that can be an hyphen or a bullet
37 Bullet = 6, // symbol that can be a bullet
38 SuperScript = 7,
39 SpecialSymbol = 8, // symbol that appears in Times font (0x22??)
40 Ligature = 13,
41
42 // latex
43 Punctuation_Accent = 9, // punctuation that can be an accent
44 Accent = 10, // other accent
45 Letter_CanHaveAccent = 11, // letter that can have an accent
46
47 LatexSpecial = 12 // special case of needed Symbol->Times mapping
48 // only '\' (0x005C)
49 };
50
51 inline bool isPunctuation(CharType type) {
52 return ( type==Punctuation || type==Hyphen
53 || type==Punctuation_Accent );
54 }
55 inline bool isSymbol(CharType type) {
56 return ( type==SymbolChar || type==Hyphen || type==Bullet
57 || type==SpecialSymbol || type==Accent
58 || type==LatexSpecial );
59 }
60 inline bool isLetter(CharType type) {
61 return ( type==Letter || type==Letter_CanHaveAccent );
62 }
63 inline bool isAlphaNumeric(CharType type) {
64 return ( type==Digit || isLetter(type) );
65 }
66 inline bool isAccent(CharType type) {
67 return ( type==Punctuation_Accent || type==Accent );
68 }
69
70 CharType type(Unicode);
71
72 enum { MaxLigatureLength = 3 };
73 uint checkLigature(Unicode, Unicode res[MaxLigatureLength]);
74
75 CharType checkSpecial(Unicode, Unicode &res);
76
77 // detect some letter/accent combinations
78 // (latex layouts them separately)
79 Unicode checkCombi(Unicode letter, Unicode accent);
80}
81
82#endif