1 #ifndef __DALI_INTERNAL_FONT_FACTORY_H__
2 #define __DALI_INTERNAL_FONT_FACTORY_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/internal/event/text/atlas/glyph-atlas-manager-interface.h>
23 #include <dali/internal/event/text/font-metrics.h>
24 #include <dali/internal/event/text/resource/font-lookup-interface.h>
33 class GlyphAtlasManager;
36 * FontFactory is used to do the following:
37 * - create FontMetric objects
38 * - Allocate Atlas Manager
39 * - provide a FontLookupInterface
41 * @todo class needs renaming, possibly splitting as it's
42 * doing more than one thing.
44 class FontFactory : public FontLookupInterface
50 * @param resource client
52 FontFactory( ResourceClient& resourceClient );
57 virtual ~FontFactory();
60 * Gets a pre-existing font metrics object, or creates a new one if not found.
61 * @param[in] fontFamily The name of the font's family used to generate a hash for fast lookup
62 * @param[in] fontStyle The font's style used to generate a hash for fast lookup
63 * @return a pointer to a ref counted object
65 FontMetricsIntrusivePtr GetFontMetrics( const std::string& fontFamily, const std::string& fontStyle );
68 * Removes the font metrics associated with a font, from the font factory cache.
70 * @param[in] fontFamily The name of the font's family used to generate a hash for fast lookup
71 * @param[in] fontStyle The font's style used to generate a hash for fast lookup
73 void RemoveFontMetrics(const std::string& fontFamily,
74 const std::string& fontStyle);
77 * Send a single resource request for any text which is required, but is not loaded.
78 * Should be called at the end of each event cycle.
80 void SendTextRequests();
83 * Get the glyph atlas manager interface
84 * @return atlas manager interface
86 GlyphAtlasManagerInterface& GetAtlasManagerInterface();
90 * @param[in] horizontalDpi horizontal dpi
91 * @param[in] verticalDpi vertical dpi
93 void SetDpi( float horizontalDpi, float verticalDpi );
96 * Called when context has been regained after a loss. The text subsystem will
97 * reload the glyphs into a new atlas and inform their observers.
99 void RecoverFromContextLoss();
101 public: // FontLookupInterface
104 * @copydoc FontLookupInterface::GetFontInformation()
106 virtual void GetFontInformation( FontId fontId,
109 float& maxGlyphWidth,
110 float& maxGlyphHeight ) const;
115 FontFactory( const FontFactory& );
118 FontFactory& operator=( const FontFactory& rhs );
122 GlyphAtlasManager* mAtlasManager; ///< Font atlas manager
123 ResourceClient& mResourceClient; ///< resource client
124 FontMetricsMap mMetricsCache; ///< Cache of font metrics
125 unsigned int mFontCount; ///< font count
126 float mHorizontalDpi; ///< horizontal dpi
127 float mVerticalDpi; ///< vertical dpi
131 } // namespace Internal
135 #endif // __DALI_INTERNAL_FONT_FACTORY_H__