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 .
23 #include <i18nlangtag/languagetag.hxx>
24 #include <sallayout.hxx>
26 #include "gcach_ftyp.hxx"
27 #include "generic/glyphcache.hxx"
28 #include <graphite_features.hxx>
29 #include <graphite_serverfont.hxx>
31 float freetypeServerFontAdvance(const void* appFontHandle
, gr_uint16 glyphId
)
33 ServerFont
* pServerFont
=
34 const_cast<ServerFont
*>
35 (static_cast<const ServerFont
*>(appFontHandle
));
38 return static_cast<float>(pServerFont
->GetGlyphMetric(glyphId
).GetCharWidth());
43 // An implementation of the GraphiteLayout interface to enable Graphite enabled fonts to be used.
45 GraphiteServerFontLayout::GraphiteServerFontLayout(ServerFont
& rServerFont
) throw()
46 : ServerFontLayout(rServerFont
),
47 maImpl(rServerFont
.GetGraphiteFace()->face(), rServerFont
)
51 gr_font
* pFont
= rServerFont
.GetGraphiteFace()->font(rServerFont
.GetFontSelData().mnHeight
, rServerFont
.NeedsArtificialBold(), rServerFont
.NeedsArtificialItalic());
54 pFont
= gr_make_font_with_advance_fn(
55 // need to use mnHeight here, mfExactHeight can give wrong values
56 static_cast<float>(rServerFont
.GetFontSelData().mnHeight
),
58 freetypeServerFontAdvance
,
59 rServerFont
.GetGraphiteFace()->face());
60 rServerFont
.GetGraphiteFace()->addFont(rServerFont
.GetFontSelData().mnHeight
, pFont
, rServerFont
.NeedsArtificialBold(), rServerFont
.NeedsArtificialItalic());
62 maImpl
.SetFont(pFont
);
64 if (rServerFont
.GetFontSelData().meLanguage
!= LANGUAGE_DONTKNOW
)
66 aLang
= OUStringToOString( LanguageTag( rServerFont
.GetFontSelData().meLanguage
).getBcp47(),
67 RTL_TEXTENCODING_UTF8
);
69 OString name
= OUStringToOString(
70 rServerFont
.GetFontSelData().maTargetName
, RTL_TEXTENCODING_UTF8
);
72 printf("GraphiteServerFontLayout %lx %s size %d %f\n", (long unsigned int)this, name
.getStr(),
73 rServerFont
.GetMetricsFT().x_ppem
,
74 rServerFont
.GetFontSelData().mfExactHeight
);
76 sal_Int32 nFeat
= name
.indexOf(grutils::GrFeatureParser::FEAT_PREFIX
) + 1;
79 OString aFeat
= name
.copy(nFeat
, name
.getLength() - nFeat
);
80 mpFeatures
= new grutils::GrFeatureParser(
81 rServerFont
.GetGraphiteFace()->face(), aFeat
, aLang
);
84 printf("GraphiteServerFontLayout %s/%s/%s %x language %d features %d errors\n",
85 OUStringToOString( rServerFont
.GetFontSelData().GetFamilyName(),
86 RTL_TEXTENCODING_UTF8
).getStr(),
87 OUStringToOString( rServerFont
.GetFontSelData().maTargetName
,
88 RTL_TEXTENCODING_UTF8
).getStr(),
89 OUStringToOString( rServerFont
.GetFontSelData().maSearchName
,
90 RTL_TEXTENCODING_UTF8
).getStr(),
91 rServerFont
.GetFontSelData().meLanguage
,
92 (int)mpFeatures
->numFeatures(), mpFeatures
->parseErrors());
97 mpFeatures
= new grutils::GrFeatureParser(
98 rServerFont
.GetGraphiteFace()->face(), aLang
);
100 maImpl
.SetFeatures(mpFeatures
);
103 GraphiteServerFontLayout::~GraphiteServerFontLayout() throw()
109 bool GraphiteServerFontLayout::IsGraphiteEnabledFont(ServerFont
& rServerFont
)
111 if (rServerFont
.GetGraphiteFace())
114 printf("IsGraphiteEnabledFont\n");
121 sal_GlyphId
GraphiteLayoutImpl::getKashidaGlyph(int & width
)
123 int nKashidaIndex
= mrServerFont
.GetGlyphIndex( 0x0640 );
124 if( nKashidaIndex
!= 0 )
126 const GlyphMetric
& rGM
= mrServerFont
.GetGlyphMetric( nKashidaIndex
);
127 width
= rGM
.GetCharWidth();
133 return nKashidaIndex
;
136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */