1 /* This file is part of Shapes.
3 * Shapes is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
8 * Shapes is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with Shapes. If not, see <http://www.gnu.org/licenses/>.
16 * Copyright 2008 Henrik Tidefelt
21 #include "fontmetrics.h"
22 #include "characterencoding.h"
24 #ifndef FLEXINT_H // Else *FlexLexer will be defined twice
26 # define yyFlexLexer afmFlexLexer
27 # include <FlexLexer.h>
30 class AfmScanner
: public afmFlexLexer
32 FontMetrics::AFM
* fontMetricsDst_
;
33 FontMetrics::SingleByte_WritingDirectionMetrics
* horizontalMetrics_typed_
; /* Same as fontMetricsDst_->horizontalMetrics_, but down-cast. */
34 FontMetrics::SingleByte_WritingDirectionMetrics
* verticalMetrics_typed_
; /* Same as fontMetricsDst_->verticaalMetrics_, but down-cast. */
35 FontMetrics::SingleByte_WritingDirectionMetrics
* currentDirectionDst_
;
36 int currentDirectionID_
; // This corresponds to currentDirectionDst_ and is initially -1, indicating not initialized
37 int activateDirectionID_
; // This is initially 0, and is changed by StartDirection and EndDirection
38 unsigned char metricsSets_
;
39 FontMetrics::CharacterMetrics
* currentCharacter_
;
40 FontMetrics::AFM::KernPairMap
* currentKernPairMapX_
;
41 FontMetrics::AFM::KernPairMap
* currentKernPairMapY_
;
42 const std::map
< RefCountPtr
< const char >, size_t, charRefPtrLess
> * currentNameMap_
;
43 bool tellQue_
; // write things we don't understand on stderr.
45 void throwError( const char * msg
);
46 void synchWritingDirection( );
48 const FontMetrics::CharacterEncoding
* encoding_
;
51 typedef int UnionType
;
53 AfmScanner( FontMetrics::AFM
* fontMetricsDst
, std::istream
* yyin
= 0 );
55 void setTellQue( bool tellQue
) { tellQue_
= tellQue
; }