1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <osl/diagnose.h>
22 #include <sal/log.hxx>
24 #include <fontsubset.hxx>
27 FontSubsetInfo::FontSubsetInfo()
31 , m_nFontType( FontType::NO_FONT
)
33 , mpInFontBytes( nullptr)
35 , meInFontType( FontType::NO_FONT
)
36 , mnReqFontTypeMask( FontType::NO_FONT
)
38 , mpReqGlyphIds(nullptr)
39 , mpReqEncodedIds(nullptr)
44 FontSubsetInfo::~FontSubsetInfo()
48 // prepare subsetting for fonts where the input font file is mapped
49 void FontSubsetInfo::LoadFont(
51 const unsigned char* pInFontBytes
, int nInByteLength
)
53 meInFontType
= eInFontType
;
54 mpInFontBytes
= pInFontBytes
;
55 mnInByteLength
= nInByteLength
;
58 bool FontSubsetInfo::CreateFontSubset(
59 FontType nReqFontTypeMask
,
61 const sal_GlyphId
* pReqGlyphIds
, const sal_uInt8
* pReqEncodedIds
, int nReqGlyphCount
)
63 // prepare request details needed by all underlying subsetters
64 mnReqFontTypeMask
= nReqFontTypeMask
;
66 mpReqGlyphIds
= pReqGlyphIds
;
67 mpReqEncodedIds
= pReqEncodedIds
;
68 mnReqGlyphCount
= nReqGlyphCount
;
69 maReqFontName
= m_aPSName
.toUtf8();
71 // TODO: move the glyphid/encid/notdef reshuffling from the callers to here
73 // dispatch to underlying subsetters
76 // TODO: better match available input-type to possible subset-types
77 switch( meInFontType
) {
78 case FontType::CFF_FONT
:
79 bOK
= CreateFontSubsetFromCff();
82 OSL_FAIL( "unhandled type in CreateFontSubset()");
89 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */