LibreOffice Module vcl (master) 1
pdffontcache.cxx
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
20#include <sal/config.h>
21
22#include <sal/types.h>
23
25#include <pdf/pdffontcache.hxx>
26#include <salgdi.hxx>
27
28#include <typeinfo>
29
30using namespace vcl;
31
32PDFFontCache::FontIdentifier::FontIdentifier( const vcl::font::PhysicalFontFace* pFont, bool bVertical ) :
33 m_nFontId( pFont->GetFontId() ),
34 m_bVertical( bVertical ),
35 m_typeFontFace( const_cast<std::type_info*>(&typeid(pFont)) )
36{
37}
38
40{
41 FontIdentifier aId( pFont, bVertical );
42 FontToIndexMap::iterator it = m_aFontToIndex.find( aId );
43 if( it != m_aFontToIndex.end() )
44 return m_aFonts[ it->second ];
45 m_aFontToIndex[ aId ] = sal_uInt32(m_aFonts.size());
46 m_aFonts.emplace_back( );
47 return m_aFonts.back();
48}
49
50sal_Int32 PDFFontCache::getGlyphWidth( const vcl::font::PhysicalFontFace* pFont, sal_GlyphId nGlyph, bool bVertical, SalGraphics* pGraphics )
51{
52 sal_Int32 nWidth = 0;
53 FontData& rFontData( getFont( pFont, bVertical ) );
54 if( rFontData.m_nWidths.empty() )
55 {
56 pGraphics->GetGlyphWidths( pFont, bVertical, rFontData.m_nWidths, rFontData.m_aGlyphIdToIndex );
57 }
58 if( ! rFontData.m_nWidths.empty() )
59 {
60 if (nGlyph < rFontData.m_nWidths.size())
61 nWidth = rFontData.m_nWidths[nGlyph];
62 }
63 return nWidth;
64}
65
66/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void GetGlyphWidths(const vcl::font::PhysicalFontFace *pFont, bool bVertical, std::vector< sal_Int32 > &rWidths, Ucs2UIntMap &rUnicodeEnc)=0
sal_Int32 getGlyphWidth(const vcl::font::PhysicalFontFace *, sal_GlyphId, bool bVertical, SalGraphics *)
std::vector< FontData > m_aFonts
FontToIndexMap m_aFontToIndex
FontData & getFont(const vcl::font::PhysicalFontFace *, bool bVertical)
abstract base class for physical font faces
sal_uInt16 sal_GlyphId
Definition: glyphid.hxx:24
OUString aId
std::vector< sal_Int32 > m_nWidths