LibreOffice Module vcl (master) 1
ttcr.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
25#pragma once
26
27#include <sft.hxx>
28#include <vector>
29
30namespace vcl
31{
32class TrueTypeTable;
33struct tdata_loca;
34struct table_cmap;
35struct TableEntry;
36
37
38/* TrueType data types */
39 typedef struct {
40 sal_uInt16 aw;
41 sal_Int16 lsb;
43
52 };
53
55 public:
60 TrueTypeCreator(sal_uInt32 tag);
65 void AddTable(std::unique_ptr<TrueTypeTable> table);
73 void RemoveTable(sal_uInt32 tag);
80 SFErrCodes StreamToMemory(std::vector<sal_uInt8>& rOutBuffer);
81
82 private:
83 TrueTypeTable *FindTable(sal_uInt32 tag);
84 void ProcessTables();
85
86 sal_uInt32 m_tag;
87 std::vector<std::unique_ptr<TrueTypeTable>> m_tables;
88 };
89
90 /* A generic base class for all TrueType tables */
92 protected:
93 TrueTypeTable(sal_uInt32 tag_) : m_tag(tag_) {}
94
95 public:
96 virtual ~TrueTypeTable();
97
106 virtual int GetRawData(TableEntry*) = 0;
107
108 sal_uInt32 m_tag = 0; /* table tag */
109 std::unique_ptr<sal_uInt8[]> m_rawdata; /* raw data allocated by GetRawData_*() */
110 };
111
113 {
114 public:
123 TrueTypeTableGeneric(sal_uInt32 tag,
124 sal_uInt32 nbytes,
125 const sal_uInt8* ptr);
126 TrueTypeTableGeneric(sal_uInt32 tag,
127 sal_uInt32 nbytes,
128 std::unique_ptr<sal_uInt8[]> ptr);
129 virtual ~TrueTypeTableGeneric() override;
130 virtual int GetRawData(TableEntry*) override;
131 private:
132 sal_uInt32 m_nbytes;
133 std::unique_ptr<sal_uInt8[]> m_ptr;
134 };
135
143 {
144 public:
145 TrueTypeTableHead(sal_uInt32 fontRevision,
146 sal_uInt16 flags,
147 sal_uInt16 unitsPerEm,
148 const sal_uInt8 *created,
149 sal_uInt16 macStyle,
150 sal_uInt16 lowestRecPPEM,
151 sal_Int16 fontDirectionHint);
152 virtual ~TrueTypeTableHead() override;
153 virtual int GetRawData(TableEntry*) override;
154
155 std::unique_ptr<sal_uInt8[]> m_head;
156 };
157
163 {
164 public:
165 TrueTypeTableHhea(sal_Int16 ascender,
166 sal_Int16 descender,
167 sal_Int16 linegap,
168 sal_Int16 caretSlopeRise,
169 sal_Int16 caretSlopeRun);
170 virtual ~TrueTypeTableHhea() override;
171 virtual int GetRawData(TableEntry*) override;
172
173 std::unique_ptr<sal_uInt8[]> m_hhea;
174 };
175
182 {
183 public:
185 virtual ~TrueTypeTableLoca() override;
186 virtual int GetRawData(TableEntry*) override;
187
188 std::unique_ptr<tdata_loca> m_loca;
189 };
190
198 {
199 public:
200 TrueTypeTableMaxp(const sal_uInt8* maxp, int size);
201 virtual ~TrueTypeTableMaxp() override;
202 virtual int GetRawData(TableEntry*) override;
203
204 std::unique_ptr<sal_uInt8[]> m_maxp;
205 };
206
211 {
212 public:
214 virtual ~TrueTypeTableGlyf() override;
215 virtual int GetRawData(TableEntry*) override;
216
225 sal_uInt32 glyfAdd(std::unique_ptr<GlyphData> glyphdata, AbstractTrueTypeFont *fnt);
226
231 sal_uInt32 glyfCount() { return m_list.size(); }
232
233 std::vector<std::unique_ptr<GlyphData>> m_list;
234 };
235
240 {
241 public:
243 virtual ~TrueTypeTableCmap() override;
244 virtual int GetRawData(TableEntry*) override;
245
249 void cmapAdd(sal_uInt32 id, sal_uInt32 c, sal_uInt32 g);
250
251 private:
252 std::unique_ptr<table_cmap> m_cmap;
253 };
254
262 {
263 public:
264 TrueTypeTableName(std::vector<NameRecord> nr);
265 virtual ~TrueTypeTableName() override;
266 virtual int GetRawData(TableEntry*) override;
267 private:
268 std::vector<NameRecord> m_list;
269 };
270
275 {
276 public:
277 TrueTypeTablePost(sal_Int32 format,
278 sal_Int32 italicAngle,
279 sal_Int16 underlinePosition,
280 sal_Int16 underlineThickness,
281 sal_uInt32 isFixedPitch);
282 virtual ~TrueTypeTablePost() override;
283 virtual int GetRawData(TableEntry*) override;
284 private:
285 sal_uInt32 m_format;
286 sal_uInt32 m_italicAngle;
289 sal_uInt32 m_isFixedPitch;
290 };
291
292} // namespace
293
294/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt32 m_tag
TrueType file tag.
Definition: ttcr.hxx:86
TrueTypeTable * FindTable(sal_uInt32 tag)
Definition: ttcr.cxx:846
TrueTypeCreator(sal_uInt32 tag)
TrueTypeCreator constructor.
Definition: ttcr.cxx:126
void ProcessTables()
Definition: ttcr.cxx:871
void RemoveTable(sal_uInt32 tag)
Removes a TrueType table from the TrueType creator if it is stored there.
Definition: ttcr.cxx:138
~TrueTypeCreator()
TrueTypeCreator destructor.
Definition: ttcr.cxx:1090
SFErrCodes StreamToMemory(std::vector< sal_uInt8 > &rOutBuffer)
Writes a TrueType font generated by the TrueTypeCreator to a segment of memory that this method alloc...
Definition: ttcr.cxx:151
void AddTable(std::unique_ptr< TrueTypeTable > table)
Adds a TrueType table to the TrueType creator.
Definition: ttcr.cxx:131
std::vector< std::unique_ptr< TrueTypeTable > > m_tables
List of table tags and pointers.
Definition: ttcr.hxx:87
Creates a new empty 'cmap' table.
Definition: ttcr.hxx:240
void cmapAdd(sal_uInt32 id, sal_uInt32 c, sal_uInt32 g)
Add a character/glyph pair to a cmap table.
Definition: ttcr.cxx:752
virtual int GetRawData(TableEntry *) override
This function converts the data of a TrueType table to a raw array of bytes.
Definition: ttcr.cxx:466
virtual ~TrueTypeTableCmap() override
Definition: ttcr.cxx:302
std::unique_ptr< table_cmap > m_cmap
Definition: ttcr.hxx:252
virtual int GetRawData(TableEntry *) override
This function converts the data of a TrueType table to a raw array of bytes.
Definition: ttcr.cxx:325
std::unique_ptr< sal_uInt8[]> m_ptr
Definition: ttcr.hxx:133
TrueTypeTableGeneric(sal_uInt32 tag, sal_uInt32 nbytes, const sal_uInt8 *ptr)
Creates a new raw TrueType table.
Definition: ttcr.cxx:624
virtual ~TrueTypeTableGeneric() override
Definition: ttcr.cxx:278
Creates a new empty 'glyf' table.
Definition: ttcr.hxx:211
sal_uInt32 glyfAdd(std::unique_ptr< GlyphData > glyphdata, AbstractTrueTypeFont *fnt)
Add a glyph to a glyf table.
Definition: ttcr.cxx:798
std::vector< std::unique_ptr< GlyphData > > m_list
Definition: ttcr.hxx:233
virtual int GetRawData(TableEntry *) override
This function converts the data of a TrueType table to a raw array of bytes.
Definition: ttcr.cxx:374
virtual ~TrueTypeTableGlyf() override
Definition: ttcr.cxx:298
sal_uInt32 glyfCount()
Query the number of glyphs currently stored in the 'glyf' table.
Definition: ttcr.hxx:231
Creates a new 'head' table for a TrueType font.
Definition: ttcr.hxx:143
std::unique_ptr< sal_uInt8[]> m_head
Definition: ttcr.hxx:155
TrueTypeTableHead(sal_uInt32 fontRevision, sal_uInt16 flags, sal_uInt16 unitsPerEm, const sal_uInt8 *created, sal_uInt16 macStyle, sal_uInt16 lowestRecPPEM, sal_Int16 fontDirectionHint)
Definition: ttcr.cxx:647
virtual ~TrueTypeTableHead() override
Definition: ttcr.cxx:282
virtual int GetRawData(TableEntry *) override
This function converts the data of a TrueType table to a raw array of bytes.
Definition: ttcr.cxx:334
Creates a new 'hhea' table for a TrueType font.
Definition: ttcr.hxx:163
TrueTypeTableHhea(sal_Int16 ascender, sal_Int16 descender, sal_Int16 linegap, sal_Int16 caretSlopeRise, sal_Int16 caretSlopeRun)
Definition: ttcr.cxx:674
virtual ~TrueTypeTableHhea() override
Definition: ttcr.cxx:286
std::unique_ptr< sal_uInt8[]> m_hhea
Definition: ttcr.hxx:173
virtual int GetRawData(TableEntry *) override
This function converts the data of a TrueType table to a raw array of bytes.
Definition: ttcr.cxx:343
Creates a new empty 'loca' table for a TrueType font.
Definition: ttcr.hxx:182
virtual ~TrueTypeTableLoca() override
Definition: ttcr.cxx:290
std::unique_ptr< tdata_loca > m_loca
Definition: ttcr.hxx:188
virtual int GetRawData(TableEntry *) override
This function converts the data of a TrueType table to a raw array of bytes.
Definition: ttcr.cxx:352
Creates a new 'maxp' table based on an existing maxp table.
Definition: ttcr.hxx:198
virtual int GetRawData(TableEntry *) override
This function converts the data of a TrueType table to a raw array of bytes.
Definition: ttcr.cxx:365
virtual ~TrueTypeTableMaxp() override
Definition: ttcr.cxx:294
TrueTypeTableMaxp(const sal_uInt8 *maxp, int size)
Definition: ttcr.cxx:706
std::unique_ptr< sal_uInt8[]> m_maxp
Definition: ttcr.hxx:204
Creates a new 'name' table.
Definition: ttcr.hxx:262
TrueTypeTableName(std::vector< NameRecord > nr)
Definition: ttcr.cxx:730
virtual ~TrueTypeTableName() override
Definition: ttcr.cxx:306
std::vector< NameRecord > m_list
Definition: ttcr.hxx:268
virtual int GetRawData(TableEntry *) override
This function converts the data of a TrueType table to a raw array of bytes.
Definition: ttcr.cxx:514
Creates a new 'post' table of one of the supported formats.
Definition: ttcr.hxx:275
sal_Int16 m_underlineThickness
Definition: ttcr.hxx:288
sal_uInt32 m_italicAngle
Definition: ttcr.hxx:286
virtual int GetRawData(TableEntry *) override
This function converts the data of a TrueType table to a raw array of bytes.
Definition: ttcr.cxx:574
TrueTypeTablePost(sal_Int32 format, sal_Int32 italicAngle, sal_Int16 underlinePosition, sal_Int16 underlineThickness, sal_uInt32 isFixedPitch)
Definition: ttcr.cxx:736
sal_uInt32 m_isFixedPitch
Definition: ttcr.hxx:289
virtual ~TrueTypeTablePost() override
Definition: ttcr.cxx:310
sal_uInt32 m_format
Definition: ttcr.hxx:285
sal_Int16 m_underlinePosition
Definition: ttcr.hxx:287
virtual int GetRawData(TableEntry *)=0
This function converts the data of a TrueType table to a raw array of bytes.
std::unique_ptr< sal_uInt8[]> m_rawdata
Definition: ttcr.hxx:109
TrueTypeTable(sal_uInt32 tag_)
Definition: ttcr.hxx:93
virtual ~TrueTypeTable()
Definition: ttcr.cxx:276
sal_uInt32 m_tag
Definition: ttcr.hxx:108
@ table
size
SFErrCodes
Return value of OpenTTFont() and CreateT3FromTTGlyphs()
Definition: sft.hxx:65
TTCRErrCodes
Error codes for most functions.
Definition: ttcr.hxx:45
@ TTCR_OK
no error
Definition: ttcr.hxx:46
@ TTCR_UNKNOWN
Unknown TrueType table
Definition: ttcr.hxx:48
@ TTCR_POSTFORMAT
unsupported format of a 'post' table
Definition: ttcr.hxx:51
@ TTCR_ZEROGLYPHS
At least one glyph should be defined
Definition: ttcr.hxx:47
@ TTCR_NONAMES
'name' table does not contain any names
Definition: ttcr.hxx:49
@ TTCR_NAMETOOLONG
'name' table is too long (string data > 64K)
Definition: ttcr.hxx:50
Sun Font Tools.
sal_uInt16 aw
Definition: ttcr.hxx:40
sal_Int16 lsb
Definition: ttcr.hxx:41
unsigned char sal_uInt8