forked from yvt/xtbook
-
Notifications
You must be signed in to change notification settings - Fork 1
/
XTBFont.h
66 lines (51 loc) · 1.63 KB
/
XTBFont.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
* XTBFont.h
* XTBook
*
* Created by Nexhawks on 2/11/11.
* Copyright 2011 Nexhawks. All rights reserved.
*
*/
#pragma once
#include <stdint.h>
#include <tcw/twFont.h>
class twSDLDC;
class XTBFont : public twFont{
protected:
unsigned char *fontData;
unsigned int *indexMap;
unsigned char *widthMap;
int topMargin;
int actualLineHeight;
virtual void drawGlyph(twSDLDC *, uint16_t color, twPoint pt, uint16_t chr) const=0;
virtual void bitmapForGlyph(uint8_t *, uint16_t)const=0;
void drawGlyphScaled(twSDLDC *, uint16_t, twRect, uint16_t, int baseWidth, int alpha) const;
int widthForScaledGlyph(int baseWidth, int height) const;
void drawGlyphScaledSpan(uint16_t *destSpan,
const uint8_t *srcLine1,
const uint8_t *srcLine2,
int pixels,
int startSrcX,
int deltaSrcX,
int fSrcY, // [0-0xffff]
uint16_t nativeColor,
int alpha,
int lastSrcX) const;
void drawGlyphScaledSpan(uint16_t *destSpan,
const uint8_t *srcLine,
int pixels,
int startSrcX,
int deltaSrcX,
uint16_t nativeColor,
int alpha,
int lastSrcX) const;
public:
XTBFont(unsigned char *fontData, unsigned int *indexMap, unsigned char *widthMap);
virtual void render(twDC *, twColor, const twPoint&, const std::wstring&) const;
virtual twSize measure(const std::wstring&) const;
/** advanced rendering.
* @param alpha alpha value in range [0-255].
* @size height of character. */
void render(twDC *, twColor, const twPoint&, const std::wstring&, int size, int alpha) const;
twSize measure(const std::wstring&, int size) const;
};