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 global::System.Runtime.InteropServices.HandleRef getCPtr(FontClient obj)
214 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
217 internal static FontClient Get()
219 FontClient ret = new FontClient(Interop.FontClient.Get(), true);
220 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
224 internal FontClient Assign(FontClient handle)
226 FontClient ret = new FontClient(Interop.FontClient.Assign(SwigCPtr, FontClient.getCPtr(handle)), false);
227 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
231 internal void SetDpi(uint horizontalDpi, uint verticalDpi)
233 Interop.FontClient.SetDpi(SwigCPtr, horizontalDpi, verticalDpi);
234 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
237 internal void GetDpi(SWIGTYPE_p_unsigned_int horizontalDpi, SWIGTYPE_p_unsigned_int verticalDpi)
239 Interop.FontClient.GetDpi(SwigCPtr, SWIGTYPE_p_unsigned_int.getCPtr(horizontalDpi), SWIGTYPE_p_unsigned_int.getCPtr(verticalDpi));
240 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
243 internal int GetDefaultFontSize()
245 int ret = Interop.FontClient.GetDefaultFontSize(SwigCPtr);
246 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
250 internal void GetDefaultFonts(SWIGTYPE_p_std__vectorT_Dali__TextAbstraction__FontDescription_t defaultFonts)
252 Interop.FontClient.GetDefaultFonts(SwigCPtr, SWIGTYPE_p_std__vectorT_Dali__TextAbstraction__FontDescription_t.getCPtr(defaultFonts));
253 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
256 internal void GetDefaultPlatformFontDescription(FontDescription fontDescription)
258 Interop.FontClient.GetDefaultPlatformFontDescription(SwigCPtr, FontDescription.getCPtr(fontDescription));
259 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
262 internal void GetSystemFonts(SWIGTYPE_p_std__vectorT_Dali__TextAbstraction__FontDescription_t systemFonts)
264 Interop.FontClient.GetSystemFonts(SwigCPtr, SWIGTYPE_p_std__vectorT_Dali__TextAbstraction__FontDescription_t.getCPtr(systemFonts));
265 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
268 internal void GetDescription(uint id, FontDescription fontDescription)
270 Interop.FontClient.GetDescription(SwigCPtr, id, FontDescription.getCPtr(fontDescription));
271 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
274 internal uint FindFallbackFont(uint charcode, FontDescription preferredFontDescription, uint requestedPointSize, bool preferColor)
276 uint ret = Interop.FontClient.FindFallbackFont(SwigCPtr, charcode, FontDescription.getCPtr(preferredFontDescription), requestedPointSize, preferColor);
277 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
281 internal uint FindFallbackFont(uint charcode, FontDescription preferredFontDescription, uint requestedPointSize)
283 uint ret = Interop.FontClient.FindFallbackFont(SwigCPtr, charcode, FontDescription.getCPtr(preferredFontDescription), requestedPointSize);
284 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
288 internal uint FindFallbackFont(uint charcode, FontDescription preferredFontDescription)
290 uint ret = Interop.FontClient.FindFallbackFont(SwigCPtr, charcode, FontDescription.getCPtr(preferredFontDescription));
291 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
295 internal uint GetFontId(FontDescription preferredFontDescription, uint requestedPointSize, uint faceIndex)
297 uint ret = Interop.FontClient.GetFontId(SwigCPtr, FontDescription.getCPtr(preferredFontDescription), requestedPointSize, faceIndex);
298 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
302 internal uint GetFontId(FontDescription preferredFontDescription, uint requestedPointSize)
304 uint ret = Interop.FontClient.GetFontId(SwigCPtr, FontDescription.getCPtr(preferredFontDescription), requestedPointSize);
305 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
309 internal uint GetFontId(FontDescription preferredFontDescription)
311 uint ret = Interop.FontClient.GetFontId(SwigCPtr, FontDescription.getCPtr(preferredFontDescription));
312 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
316 internal bool IsScalable(FontDescription fontDescription)
318 bool ret = Interop.FontClient.IsScalable(SwigCPtr, FontDescription.getCPtr(fontDescription));
319 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
323 internal void GetFixedSizes(string path, SWIGTYPE_p_Dali__VectorT_uint32_t_TypeTraitsT_uint32_t_t__IS_TRIVIAL_TYPE__true_t sizes)
325 Interop.FontClient.GetFixedSizes(SwigCPtr, path, SWIGTYPE_p_Dali__VectorT_uint32_t_TypeTraitsT_uint32_t_t__IS_TRIVIAL_TYPE__true_t.getCPtr(sizes));
326 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
329 internal void GetFixedSizes(FontDescription fontDescription, SWIGTYPE_p_Dali__VectorT_uint32_t_TypeTraitsT_uint32_t_t__IS_TRIVIAL_TYPE__true_t sizes)
331 Interop.FontClient.GetFixedSizes(SwigCPtr, FontDescription.getCPtr(fontDescription), SWIGTYPE_p_Dali__VectorT_uint32_t_TypeTraitsT_uint32_t_t__IS_TRIVIAL_TYPE__true_t.getCPtr(sizes));
332 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
335 internal void GetFontMetrics(uint fontId, FontMetrics metrics)
337 Interop.FontClient.GetFontMetrics(SwigCPtr, fontId, FontMetrics.getCPtr(metrics));
338 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
341 internal uint GetGlyphIndex(uint fontId, uint charcode)
343 uint ret = Interop.FontClient.GetGlyphIndex(SwigCPtr, fontId, charcode);
344 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
348 internal bool GetGlyphMetrics(GlyphInfo array, uint size, GlyphType type, bool horizontal)
350 bool ret = Interop.FontClient.GetGlyphMetrics(SwigCPtr, GlyphInfo.getCPtr(array), size, (int)type, horizontal);
351 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
355 internal bool GetGlyphMetrics(GlyphInfo array, uint size, GlyphType type)
357 bool ret = Interop.FontClient.GetGlyphMetrics(SwigCPtr, GlyphInfo.getCPtr(array), size, (int)type);
358 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
362 internal void CreateBitmap(uint fontId, uint glyphIndex, bool softwareItalic, bool softwareBold, FontClient.GlyphBufferData data, int outlineWidth)
364 Interop.FontClient.CreateBitmap(SwigCPtr, fontId, glyphIndex, softwareItalic, softwareBold, FontClient.GlyphBufferData.getCPtr(data), outlineWidth);
365 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
368 internal PixelData CreateBitmap(uint fontId, uint glyphIndex, int outlineWidth)
370 PixelData ret = new PixelData(Interop.FontClient.CreateBitmap(SwigCPtr, fontId, glyphIndex, outlineWidth), true);
371 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
375 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)
377 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));
378 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
381 internal GlyphInfo GetEllipsisGlyph(uint requestedPointSize)
383 GlyphInfo ret = new GlyphInfo(Interop.FontClient.GetEllipsisGlyph(SwigCPtr, requestedPointSize), false);
384 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
388 internal bool IsColorGlyph(uint fontId, uint glyphIndex)
390 bool ret = Interop.FontClient.IsColorGlyph(SwigCPtr, fontId, glyphIndex);
391 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
395 internal class GlyphBufferData : Disposable
397 public GlyphBufferData() : this(Interop.FontClient.NewFontClientGlyphBufferData(), true)
399 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
402 internal GlyphBufferData(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
406 /*public byte[] Buffer
410 Interop.FontClient.GlyphBufferDataBufferSet(swigCPtr, value);
411 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
415 global::System.IntPtr cPtr = Interop.FontClient.GlyphBufferDataBufferGet(swigCPtr);
416 SWIGTYPE_p_unsigned_char ret = (cPtr == global::System.IntPtr.Zero) ? null : new SWIGTYPE_p_unsigned_char(cPtr, false);
417 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
426 Interop.FontClient.GlyphBufferDataWidthSet(SwigCPtr, value);
427 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
431 uint ret = Interop.FontClient.GlyphBufferDataWidthGet(SwigCPtr);
432 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
441 Interop.FontClient.GlyphBufferDataHeightSet(SwigCPtr, value);
442 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
446 uint ret = Interop.FontClient.GlyphBufferDataHeightGet(SwigCPtr);
447 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
452 public PixelFormat Format
456 Interop.FontClient.GlyphBufferDataFormatSet(SwigCPtr, (int)value);
457 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
461 PixelFormat ret = (PixelFormat)Interop.FontClient.GlyphBufferDataFormatGet(SwigCPtr);
462 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
467 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(GlyphBufferData obj)
469 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
472 /// This will not be public opened.
473 [EditorBrowsable(EditorBrowsableState.Never)]
474 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
476 Interop.FontClient.DeleteFontClientGlyphBufferData(swigCPtr);