2013-04-06 08:32:31 +00:00
|
|
|
/*
|
|
|
|
* Header file for HTMLState
|
|
|
|
* Copyright (C) 2013 Lu Wang <coolwanglu@gmail.com>
|
|
|
|
*/
|
|
|
|
#ifndef HTMLSTATE_H__
|
|
|
|
#define HTMLSTATE_H__
|
|
|
|
|
2013-04-06 08:45:01 +00:00
|
|
|
#include "Color.h"
|
2013-04-06 08:32:31 +00:00
|
|
|
|
|
|
|
namespace pdf2htmlEX {
|
|
|
|
|
|
|
|
struct FontInfo
|
|
|
|
{
|
|
|
|
long long id;
|
|
|
|
bool use_tounicode;
|
|
|
|
int em_size;
|
|
|
|
double space_width;
|
|
|
|
double ascent, descent;
|
|
|
|
bool is_type3;
|
2013-09-19 14:02:12 +00:00
|
|
|
/*
|
|
|
|
* As Type 3 fonts have a font matrix
|
|
|
|
* a glyph of 1pt can be very large or very small
|
|
|
|
* however it might not be true for other font formats such as ttf
|
|
|
|
*
|
|
|
|
* Therefore when we save a Type 3 font into ttf,
|
|
|
|
* we have to scale the font to about 1,
|
|
|
|
* then apply the scaling when using the font
|
|
|
|
*
|
2013-09-20 08:35:19 +00:00
|
|
|
* The scaling factor is stored as font_size_scale
|
|
|
|
*
|
|
|
|
* The value is 1 for other fonts
|
2013-09-19 14:02:12 +00:00
|
|
|
*/
|
2013-09-20 08:35:19 +00:00
|
|
|
double font_size_scale;
|
2013-04-06 08:32:31 +00:00
|
|
|
};
|
|
|
|
|
2013-04-07 15:50:23 +00:00
|
|
|
struct HTMLTextState
|
2013-04-06 08:32:31 +00:00
|
|
|
{
|
|
|
|
const FontInfo * font_info;
|
|
|
|
double font_size;
|
|
|
|
Color fill_color;
|
|
|
|
Color stroke_color;
|
|
|
|
double letter_space;
|
|
|
|
double word_space;
|
|
|
|
|
|
|
|
// relative to the previous state
|
|
|
|
double vertical_align;
|
|
|
|
|
2013-04-06 09:10:18 +00:00
|
|
|
// the offset cause by a single ' ' char
|
|
|
|
double single_space_offset(void) const {
|
2013-07-01 04:01:29 +00:00
|
|
|
double offset = word_space + letter_space;
|
|
|
|
if(font_info->em_size != 0)
|
2013-07-06 02:10:41 +00:00
|
|
|
offset += font_info->space_width * font_size;
|
2013-07-01 04:01:29 +00:00
|
|
|
return offset;
|
2013-04-06 09:10:18 +00:00
|
|
|
}
|
|
|
|
// calculate em_size of this state
|
|
|
|
double em_size(void) const {
|
|
|
|
return font_size * (font_info->ascent - font_info->descent);
|
|
|
|
}
|
2013-04-06 08:32:31 +00:00
|
|
|
};
|
|
|
|
|
2013-04-07 15:50:23 +00:00
|
|
|
struct HTMLLineState
|
|
|
|
{
|
|
|
|
double x,y;
|
|
|
|
double transform_matrix[4];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct HTMLClipState
|
|
|
|
{
|
|
|
|
double xmin, xmax, ymin, ymax;
|
|
|
|
};
|
|
|
|
|
2013-04-06 08:32:31 +00:00
|
|
|
} // namespace pdf2htmlEX
|
|
|
|
|
|
|
|
#endif //HTMLSTATE_H__
|