2 * Copyright(c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 using System.ComponentModel;
22 /// FontClient provides access to font information and resources.
24 /// <since_tizen> 5 </since_tizen>
25 public class FontClient : BaseHandle
27 private static readonly FontClient instance = FontClient.Get();
29 internal FontClient(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
33 internal FontClient() : this(Interop.FontClient.NewFontClient(), true)
35 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
38 internal FontClient(FontClient handle) : this(Interop.FontClient.NewFontClient(FontClient.getCPtr(handle)), true)
40 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
43 internal static uint DefaultPointSize
47 uint ret = Interop.FontClient.DefaultPointSizeGet();
48 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
54 /// Gets the singleton pattern of the FontClient object.
56 /// <since_tizen> 5 </since_tizen>
57 public static FontClient Instance
66 /// Called when the user changes the system defaults.
68 /// <since_tizen> 5 </since_tizen>
69 public void ResetSystemDefaults()
71 Interop.FontClient.ResetSystemDefaults(SwigCPtr);
72 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
76 /// Retrieves the font point size of a given font id.
78 /// <param name="id">The font identifier.</param>
79 /// <returns>The point size in 26.6 fractional points.</returns>
80 /// <since_tizen> 5 </since_tizen>
81 public uint GetPointSize(uint id)
83 uint ret = Interop.FontClient.GetPointSize(SwigCPtr, id);
84 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
89 /// Whether the given character is supported by the font.
91 /// <param name="fontId">The id of the font.</param>
92 /// <param name="character">The character in a font.</param>
93 /// <returns>True if the character is supported by the font.</returns>
94 /// <since_tizen> 5 </since_tizen>
95 public bool IsCharacterSupportedByFont(uint fontId, uint character)
97 bool ret = Interop.FontClient.IsCharacterSupportedByFont(SwigCPtr, fontId, character);
98 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
103 /// Finds the default font for displaying a UTF-32 character.
105 /// <param name="charcode">The character for which a font is needed.</param>
106 /// <param name="requestedPointSize">The point size in 26.6 fractional points. The default point size is 12*64.</param>
107 /// <param name="preferColor">True if a color font is preferred.</param>
108 /// <returns>A valid font identifier. Zero if the font does not exist.</returns>
109 /// <since_tizen> 5 </since_tizen>
110 public uint FindDefaultFont(uint charcode, uint requestedPointSize, bool preferColor)
112 uint ret = Interop.FontClient.FindDefaultFont(SwigCPtr, charcode, requestedPointSize, preferColor);
113 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
118 /// Find the default font for displaying a UTF-32 character.
120 /// <param name="charcode">The character for which a font is needed.</param>
121 /// <param name="requestedPointSize">The point size in 26.6 fractional points. The default point size is 12*64.</param>
122 /// <returns>A valid font identifier. Zero if the font does not exist.</returns>
123 /// <since_tizen> 5 </since_tizen>
124 public uint FindDefaultFont(uint charcode, uint requestedPointSize)
126 uint ret = Interop.FontClient.FindDefaultFont(SwigCPtr, charcode, requestedPointSize);
127 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
132 /// Find the default font for displaying a UTF-32 character.
134 /// <param name="charcode">The character for which a font is needed.</param>
135 /// <returns>A valid font identifier. Zero if the font does not exist.</returns>
136 /// <since_tizen> 5 </since_tizen>
137 public uint FindDefaultFont(uint charcode)
139 uint ret = Interop.FontClient.FindDefaultFont(SwigCPtr, charcode);
140 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
145 /// Retrieve the unique identifier for a font.
147 /// <param name="path">The path to a font file.</param>
148 /// <param name="requestedPointSize">The point size in 26.6 fractional points. The default point size is 12*64.</param>
149 /// <param name="faceIndex">The index of the font face.</param>
150 /// <returns>A valid font identifier. Zero if the font does not exist.</returns>
151 /// <since_tizen> 5 </since_tizen>
152 public uint GetFontId(string path, uint requestedPointSize, uint faceIndex)
154 uint ret = Interop.FontClient.GetFontId(SwigCPtr, path, requestedPointSize, faceIndex);
155 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
160 /// Retrieve the unique identifier for a font.
162 /// <param name="path">The path to a font file.</param>
163 /// <param name="requestedPointSize">The point size in 26.6 fractional points. The default point size is 12*64.</param>
164 /// <returns>A valid font identifier. Zero if the font does not exist.</returns>
165 /// <since_tizen> 5 </since_tizen>
166 public uint GetFontId(string path, uint requestedPointSize)
168 uint ret = Interop.FontClient.GetFontId(SwigCPtr, path, requestedPointSize);
169 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
174 /// Retrieve the unique identifier for a font.
176 /// <param name="path">The path to a font file.</param>
177 /// <returns>A valid font identifier. Zero if the font does not exist.</returns>
178 /// <since_tizen> 5 </since_tizen>
179 public uint GetFontId(string path)
181 uint ret = Interop.FontClient.GetFontId(SwigCPtr, path);
182 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
187 /// Check to see if a font is scalable.
189 /// <param name="path">The path where the font file is located.</param>
190 /// <returns>True if scalable.</returns>
191 /// <since_tizen> 5 </since_tizen>
192 public bool IsScalable(string path)
194 bool ret = Interop.FontClient.IsScalable(SwigCPtr, path);
195 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
200 /// Adds custom fonts directory.
202 /// <param name="path">Path to the fonts directory.</param>
203 /// <returns>True if the fonts can be added.</returns>
204 /// <since_tizen> 5 </since_tizen>
205 public bool AddCustomFontDirectory(string path)
207 bool ret = Interop.FontClient.AddCustomFontDirectory(SwigCPtr, path);
208 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
212 internal static FontClient Get()
214 FontClient ret = new FontClient(Interop.FontClient.Get(), true);
215 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
219 internal FontClient Assign(FontClient handle)
221 FontClient ret = new FontClient(Interop.FontClient.Assign(SwigCPtr, FontClient.getCPtr(handle)), false);
222 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
226 internal void SetDpi(uint horizontalDpi, uint verticalDpi)
228 Interop.FontClient.SetDpi(SwigCPtr, horizontalDpi, verticalDpi);
229 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
232 internal void GetDpi(SWIGTYPE_p_unsigned_int horizontalDpi, SWIGTYPE_p_unsigned_int verticalDpi)
234 Interop.FontClient.GetDpi(SwigCPtr, SWIGTYPE_p_unsigned_int.getCPtr(horizontalDpi), SWIGTYPE_p_unsigned_int.getCPtr(verticalDpi));
235 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
238 internal int GetDefaultFontSize()
240 int ret = Interop.FontClient.GetDefaultFontSize(SwigCPtr);
241 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
245 internal void GetDefaultFonts(SWIGTYPE_p_std__vectorT_Dali__TextAbstraction__FontDescription_t defaultFonts)
247 Interop.FontClient.GetDefaultFonts(SwigCPtr, SWIGTYPE_p_std__vectorT_Dali__TextAbstraction__FontDescription_t.getCPtr(defaultFonts));
248 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
251 internal void GetDefaultPlatformFontDescription(FontDescription fontDescription)
253 Interop.FontClient.GetDefaultPlatformFontDescription(SwigCPtr, FontDescription.getCPtr(fontDescription));
254 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
257 internal void GetSystemFonts(SWIGTYPE_p_std__vectorT_Dali__TextAbstraction__FontDescription_t systemFonts)
259 Interop.FontClient.GetSystemFonts(SwigCPtr, SWIGTYPE_p_std__vectorT_Dali__TextAbstraction__FontDescription_t.getCPtr(systemFonts));
260 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
263 internal void GetDescription(uint id, FontDescription fontDescription)
265 Interop.FontClient.GetDescription(SwigCPtr, id, FontDescription.getCPtr(fontDescription));
266 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
269 internal uint FindFallbackFont(uint charcode, FontDescription preferredFontDescription, uint requestedPointSize, bool preferColor)
271 uint ret = Interop.FontClient.FindFallbackFont(SwigCPtr, charcode, FontDescription.getCPtr(preferredFontDescription), requestedPointSize, preferColor);
272 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
276 internal uint FindFallbackFont(uint charcode, FontDescription preferredFontDescription, uint requestedPointSize)
278 uint ret = Interop.FontClient.FindFallbackFont(SwigCPtr, charcode, FontDescription.getCPtr(preferredFontDescription), requestedPointSize);
279 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
283 internal uint FindFallbackFont(uint charcode, FontDescription preferredFontDescription)
285 uint ret = Interop.FontClient.FindFallbackFont(SwigCPtr, charcode, FontDescription.getCPtr(preferredFontDescription));
286 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
290 internal uint GetFontId(FontDescription preferredFontDescription, uint requestedPointSize, uint faceIndex)
292 uint ret = Interop.FontClient.GetFontId(SwigCPtr, FontDescription.getCPtr(preferredFontDescription), requestedPointSize, faceIndex);
293 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
297 internal uint GetFontId(FontDescription preferredFontDescription, uint requestedPointSize)
299 uint ret = Interop.FontClient.GetFontId(SwigCPtr, FontDescription.getCPtr(preferredFontDescription), requestedPointSize);
300 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
304 internal uint GetFontId(FontDescription preferredFontDescription)
306 uint ret = Interop.FontClient.GetFontId(SwigCPtr, FontDescription.getCPtr(preferredFontDescription));
307 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
311 internal bool IsScalable(FontDescription fontDescription)
313 bool ret = Interop.FontClient.IsScalable(SwigCPtr, FontDescription.getCPtr(fontDescription));
314 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
318 internal void GetFixedSizes(string path, SWIGTYPE_p_Dali__VectorT_uint32_t_TypeTraitsT_uint32_t_t__IS_TRIVIAL_TYPE__true_t sizes)
320 Interop.FontClient.GetFixedSizes(SwigCPtr, path, SWIGTYPE_p_Dali__VectorT_uint32_t_TypeTraitsT_uint32_t_t__IS_TRIVIAL_TYPE__true_t.getCPtr(sizes));
321 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
324 internal void GetFixedSizes(FontDescription fontDescription, SWIGTYPE_p_Dali__VectorT_uint32_t_TypeTraitsT_uint32_t_t__IS_TRIVIAL_TYPE__true_t sizes)
326 Interop.FontClient.GetFixedSizes(SwigCPtr, FontDescription.getCPtr(fontDescription), SWIGTYPE_p_Dali__VectorT_uint32_t_TypeTraitsT_uint32_t_t__IS_TRIVIAL_TYPE__true_t.getCPtr(sizes));
327 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
330 internal void GetFontMetrics(uint fontId, FontMetrics metrics)
332 Interop.FontClient.GetFontMetrics(SwigCPtr, fontId, FontMetrics.getCPtr(metrics));
333 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
336 internal uint GetGlyphIndex(uint fontId, uint charcode)
338 uint ret = Interop.FontClient.GetGlyphIndex(SwigCPtr, fontId, charcode);
339 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
343 internal bool GetGlyphMetrics(GlyphInfo array, uint size, GlyphType type, bool horizontal)
345 bool ret = Interop.FontClient.GetGlyphMetrics(SwigCPtr, GlyphInfo.getCPtr(array), size, (int)type, horizontal);
346 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
350 internal bool GetGlyphMetrics(GlyphInfo array, uint size, GlyphType type)
352 bool ret = Interop.FontClient.GetGlyphMetrics(SwigCPtr, GlyphInfo.getCPtr(array), size, (int)type);
353 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
357 internal void CreateBitmap(uint fontId, uint glyphIndex, bool softwareItalic, bool softwareBold, FontClient.GlyphBufferData data, int outlineWidth)
359 Interop.FontClient.CreateBitmap(SwigCPtr, fontId, glyphIndex, softwareItalic, softwareBold, FontClient.GlyphBufferData.getCPtr(data), outlineWidth);
360 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
363 internal PixelData CreateBitmap(uint fontId, uint glyphIndex, int outlineWidth)
365 PixelData ret = new PixelData(Interop.FontClient.CreateBitmap(SwigCPtr, fontId, glyphIndex, outlineWidth), true);
366 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
370 internal void CreateVectorBlob(uint fontId, uint glyphIndex, SWIGTYPE_p_p_Dali__TextAbstraction__VectorBlob blob, SWIGTYPE_p_unsigned_int blobLength, SWIGTYPE_p_unsigned_int nominalWidth, SWIGTYPE_p_unsigned_int nominalHeight)
372 Interop.FontClient.CreateVectorBlob(SwigCPtr, fontId, glyphIndex, SWIGTYPE_p_p_Dali__TextAbstraction__VectorBlob.getCPtr(blob), SWIGTYPE_p_unsigned_int.getCPtr(blobLength), SWIGTYPE_p_unsigned_int.getCPtr(nominalWidth), SWIGTYPE_p_unsigned_int.getCPtr(nominalHeight));
373 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
376 internal GlyphInfo GetEllipsisGlyph(uint requestedPointSize)
378 GlyphInfo ret = new GlyphInfo(Interop.FontClient.GetEllipsisGlyph(SwigCPtr, requestedPointSize), false);
379 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
383 internal bool IsColorGlyph(uint fontId, uint glyphIndex)
385 bool ret = Interop.FontClient.IsColorGlyph(SwigCPtr, fontId, glyphIndex);
386 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
390 internal class GlyphBufferData : Disposable
392 public GlyphBufferData() : this(Interop.FontClient.NewFontClientGlyphBufferData(), true)
394 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
397 internal GlyphBufferData(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
401 /*public byte[] Buffer
405 Interop.FontClient.GlyphBufferDataBufferSet(swigCPtr, value);
406 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
410 global::System.IntPtr cPtr = Interop.FontClient.GlyphBufferDataBufferGet(swigCPtr);
411 SWIGTYPE_p_unsigned_char ret = (cPtr == global::System.IntPtr.Zero) ? null : new SWIGTYPE_p_unsigned_char(cPtr, false);
412 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
421 Interop.FontClient.GlyphBufferDataWidthSet(SwigCPtr, value);
422 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
426 uint ret = Interop.FontClient.GlyphBufferDataWidthGet(SwigCPtr);
427 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
436 Interop.FontClient.GlyphBufferDataHeightSet(SwigCPtr, value);
437 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
441 uint ret = Interop.FontClient.GlyphBufferDataHeightGet(SwigCPtr);
442 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
447 public PixelFormat Format
451 Interop.FontClient.GlyphBufferDataFormatSet(SwigCPtr, (int)value);
452 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
456 PixelFormat ret = (PixelFormat)Interop.FontClient.GlyphBufferDataFormatGet(SwigCPtr);
457 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
462 /// This will not be public opened.
463 [EditorBrowsable(EditorBrowsableState.Never)]
464 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
466 Interop.FontClient.DeleteFontClientGlyphBufferData(swigCPtr);