2 * Copyright(c) 2019 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
28 private static readonly FontClient instance = FontClient.Get();
30 internal FontClient(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.FontClient.Upcast(cPtr), cMemoryOwn)
34 internal FontClient() : this(Interop.FontClient.NewFontClient(), true)
36 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
39 internal FontClient(FontClient handle) : this(Interop.FontClient.NewFontClient(FontClient.getCPtr(handle)), true)
41 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
44 internal static uint DefaultPointSize
48 uint ret = Interop.FontClient.DefaultPointSizeGet();
49 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
55 /// Gets the singleton pattern of the FontClient object.
57 /// <since_tizen> 5 </since_tizen>
58 public static FontClient Instance
67 /// Called when the user changes the system defaults.
69 /// <since_tizen> 5 </since_tizen>
70 public void ResetSystemDefaults()
72 Interop.FontClient.ResetSystemDefaults(swigCPtr);
73 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
77 /// Retrieves the font point size of a given font id.
79 /// <param name="id">The font identifier.</param>
80 /// <returns>The point size in 26.6 fractional points.</returns>
81 /// <since_tizen> 5 </since_tizen>
82 public uint GetPointSize(uint id)
84 uint ret = Interop.FontClient.GetPointSize(swigCPtr, id);
85 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
90 /// Whether the given character is supported by the font.
92 /// <param name="fontId">The id of the font.</param>
93 /// <param name="character">The character in a font.</param>
94 /// <returns>True if the character is supported by the font.</returns>
95 /// <since_tizen> 5 </since_tizen>
96 public bool IsCharacterSupportedByFont(uint fontId, uint character)
98 bool ret = Interop.FontClient.IsCharacterSupportedByFont(swigCPtr, fontId, character);
99 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
104 /// Finds the default font for displaying a UTF-32 character.
106 /// <param name="charcode">The character for which a font is needed.</param>
107 /// <param name="requestedPointSize">The point size in 26.6 fractional points. The default point size is 12*64.</param>
108 /// <param name="preferColor">True if a color font is preferred.</param>
109 /// <returns>A valid font identifier. Zero if the font does not exist.</returns>
110 /// <since_tizen> 5 </since_tizen>
111 public uint FindDefaultFont(uint charcode, uint requestedPointSize, bool preferColor)
113 uint ret = Interop.FontClient.FindDefaultFont(swigCPtr, charcode, requestedPointSize, preferColor);
114 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
119 /// Find the default font for displaying a UTF-32 character.
121 /// <param name="charcode">The character for which a font is needed.</param>
122 /// <param name="requestedPointSize">The point size in 26.6 fractional points. The default point size is 12*64.</param>
123 /// <returns>A valid font identifier. Zero if the font does not exist.</returns>
124 /// <since_tizen> 5 </since_tizen>
125 public uint FindDefaultFont(uint charcode, uint requestedPointSize)
127 uint ret = Interop.FontClient.FindDefaultFont(swigCPtr, charcode, requestedPointSize);
128 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
133 /// Find the default font for displaying a UTF-32 character.
135 /// <param name="charcode">The character for which a font is needed.</param>
136 /// <returns>A valid font identifier. Zero if the font does not exist.</returns>
137 /// <since_tizen> 5 </since_tizen>
138 public uint FindDefaultFont(uint charcode)
140 uint ret = Interop.FontClient.FindDefaultFont(swigCPtr, charcode);
141 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
146 /// Retrieve the unique identifier for a font.
148 /// <param name="path">The path to a font file.</param>
149 /// <param name="requestedPointSize">The point size in 26.6 fractional points. The default point size is 12*64.</param>
150 /// <param name="faceIndex">The index of the font face.</param>
151 /// <returns>A valid font identifier. Zero if the font does not exist.</returns>
152 /// <since_tizen> 5 </since_tizen>
153 public uint GetFontId(string path, uint requestedPointSize, uint faceIndex)
155 uint ret = Interop.FontClient.GetFontId(swigCPtr, path, requestedPointSize, faceIndex);
156 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
161 /// Retrieve the unique identifier for a font.
163 /// <param name="path">The path to a font file.</param>
164 /// <param name="requestedPointSize">The point size in 26.6 fractional points. The default point size is 12*64.</param>
165 /// <returns>A valid font identifier. Zero if the font does not exist.</returns>
166 /// <since_tizen> 5 </since_tizen>
167 public uint GetFontId(string path, uint requestedPointSize)
169 uint ret = Interop.FontClient.GetFontId(swigCPtr, path, requestedPointSize);
170 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
175 /// Retrieve the unique identifier for a font.
177 /// <param name="path">The path to a font file.</param>
178 /// <returns>A valid font identifier. Zero if the font does not exist.</returns>
179 /// <since_tizen> 5 </since_tizen>
180 public uint GetFontId(string path)
182 uint ret = Interop.FontClient.GetFontId(swigCPtr, path);
183 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
188 /// Check to see if a font is scalable.
190 /// <param name="path">The path where the font file is located.</param>
191 /// <returns>True if scalable.</returns>
192 /// <since_tizen> 5 </since_tizen>
193 public bool IsScalable(string path)
195 bool ret = Interop.FontClient.IsScalable(swigCPtr, path);
196 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
201 /// Adds custom fonts directory.
203 /// <param name="path">Path to the fonts directory.</param>
204 /// <returns>True if the fonts can be added.</returns>
205 /// <since_tizen> 5 </since_tizen>
206 public bool AddCustomFontDirectory(string path)
208 bool ret = Interop.FontClient.AddCustomFontDirectory(swigCPtr, path);
209 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
213 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FontClient obj)
215 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
218 internal static FontClient Get()
220 FontClient ret = new FontClient(Interop.FontClient.Get(), true);
221 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
225 internal FontClient Assign(FontClient handle)
227 FontClient ret = new FontClient(Interop.FontClient.Assign(swigCPtr, FontClient.getCPtr(handle)), false);
228 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
232 internal void SetDpi(uint horizontalDpi, uint verticalDpi)
234 Interop.FontClient.SetDpi(swigCPtr, horizontalDpi, verticalDpi);
235 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
238 internal void GetDpi(SWIGTYPE_p_unsigned_int horizontalDpi, SWIGTYPE_p_unsigned_int verticalDpi)
240 Interop.FontClient.GetDpi(swigCPtr, SWIGTYPE_p_unsigned_int.getCPtr(horizontalDpi), SWIGTYPE_p_unsigned_int.getCPtr(verticalDpi));
241 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
244 internal int GetDefaultFontSize()
246 int ret = Interop.FontClient.GetDefaultFontSize(swigCPtr);
247 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
251 internal void GetDefaultFonts(SWIGTYPE_p_std__vectorT_Dali__TextAbstraction__FontDescription_t defaultFonts)
253 Interop.FontClient.GetDefaultFonts(swigCPtr, SWIGTYPE_p_std__vectorT_Dali__TextAbstraction__FontDescription_t.getCPtr(defaultFonts));
254 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
257 internal void GetDefaultPlatformFontDescription(FontDescription fontDescription)
259 Interop.FontClient.GetDefaultPlatformFontDescription(swigCPtr, FontDescription.getCPtr(fontDescription));
260 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
263 internal void GetSystemFonts(SWIGTYPE_p_std__vectorT_Dali__TextAbstraction__FontDescription_t systemFonts)
265 Interop.FontClient.GetSystemFonts(swigCPtr, SWIGTYPE_p_std__vectorT_Dali__TextAbstraction__FontDescription_t.getCPtr(systemFonts));
266 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
269 internal void GetDescription(uint id, FontDescription fontDescription)
271 Interop.FontClient.GetDescription(swigCPtr, id, FontDescription.getCPtr(fontDescription));
272 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
275 internal uint FindFallbackFont(uint charcode, FontDescription preferredFontDescription, uint requestedPointSize, bool preferColor)
277 uint ret = Interop.FontClient.FindFallbackFont(swigCPtr, charcode, FontDescription.getCPtr(preferredFontDescription), requestedPointSize, preferColor);
278 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
282 internal uint FindFallbackFont(uint charcode, FontDescription preferredFontDescription, uint requestedPointSize)
284 uint ret = Interop.FontClient.FindFallbackFont(swigCPtr, charcode, FontDescription.getCPtr(preferredFontDescription), requestedPointSize);
285 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
289 internal uint FindFallbackFont(uint charcode, FontDescription preferredFontDescription)
291 uint ret = Interop.FontClient.FindFallbackFont(swigCPtr, charcode, FontDescription.getCPtr(preferredFontDescription));
292 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
296 internal uint GetFontId(FontDescription preferredFontDescription, uint requestedPointSize, uint faceIndex)
298 uint ret = Interop.FontClient.GetFontId(swigCPtr, FontDescription.getCPtr(preferredFontDescription), requestedPointSize, faceIndex);
299 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
303 internal uint GetFontId(FontDescription preferredFontDescription, uint requestedPointSize)
305 uint ret = Interop.FontClient.GetFontId(swigCPtr, FontDescription.getCPtr(preferredFontDescription), requestedPointSize);
306 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
310 internal uint GetFontId(FontDescription preferredFontDescription)
312 uint ret = Interop.FontClient.GetFontId(swigCPtr, FontDescription.getCPtr(preferredFontDescription));
313 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
317 internal bool IsScalable(FontDescription fontDescription)
319 bool ret = Interop.FontClient.IsScalable(swigCPtr, FontDescription.getCPtr(fontDescription));
320 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
324 internal void GetFixedSizes(string path, SWIGTYPE_p_Dali__VectorT_uint32_t_TypeTraitsT_uint32_t_t__IS_TRIVIAL_TYPE__true_t sizes)
326 Interop.FontClient.GetFixedSizes(swigCPtr, path, 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 GetFixedSizes(FontDescription fontDescription, SWIGTYPE_p_Dali__VectorT_uint32_t_TypeTraitsT_uint32_t_t__IS_TRIVIAL_TYPE__true_t sizes)
332 Interop.FontClient.GetFixedSizes(swigCPtr, FontDescription.getCPtr(fontDescription), SWIGTYPE_p_Dali__VectorT_uint32_t_TypeTraitsT_uint32_t_t__IS_TRIVIAL_TYPE__true_t.getCPtr(sizes));
333 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
336 internal void GetFontMetrics(uint fontId, FontMetrics metrics)
338 Interop.FontClient.GetFontMetrics(swigCPtr, fontId, FontMetrics.getCPtr(metrics));
339 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
342 internal uint GetGlyphIndex(uint fontId, uint charcode)
344 uint ret = Interop.FontClient.GetGlyphIndex(swigCPtr, fontId, charcode);
345 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
349 internal bool GetGlyphMetrics(GlyphInfo array, uint size, GlyphType type, bool horizontal)
351 bool ret = Interop.FontClient.GetGlyphMetrics(swigCPtr, GlyphInfo.getCPtr(array), size, (int)type, horizontal);
352 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
356 internal bool GetGlyphMetrics(GlyphInfo array, uint size, GlyphType type)
358 bool ret = Interop.FontClient.GetGlyphMetrics(swigCPtr, GlyphInfo.getCPtr(array), size, (int)type);
359 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
363 internal void CreateBitmap(uint fontId, uint glyphIndex, bool softwareItalic, bool softwareBold, FontClient.GlyphBufferData data, int outlineWidth)
365 Interop.FontClient.CreateBitmap(swigCPtr, fontId, glyphIndex, softwareItalic, softwareBold, FontClient.GlyphBufferData.getCPtr(data), outlineWidth);
366 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
369 internal PixelData CreateBitmap(uint fontId, uint glyphIndex, int outlineWidth)
371 PixelData ret = new PixelData(Interop.FontClient.CreateBitmap(swigCPtr, fontId, glyphIndex, outlineWidth), true);
372 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
376 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)
378 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));
379 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
382 internal GlyphInfo GetEllipsisGlyph(uint requestedPointSize)
384 GlyphInfo ret = new GlyphInfo(Interop.FontClient.GetEllipsisGlyph(swigCPtr, requestedPointSize), false);
385 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
389 internal bool IsColorGlyph(uint fontId, uint glyphIndex)
391 bool ret = Interop.FontClient.IsColorGlyph(swigCPtr, fontId, glyphIndex);
392 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
396 internal class GlyphBufferData : Disposable
399 public GlyphBufferData() : this(Interop.FontClient.NewFontClientGlyphBufferData(), true)
401 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
404 internal GlyphBufferData(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
408 /*public byte[] Buffer
412 Interop.FontClient.GlyphBufferDataBufferSet(swigCPtr, value);
413 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
417 global::System.IntPtr cPtr = Interop.FontClient.GlyphBufferDataBufferGet(swigCPtr);
418 SWIGTYPE_p_unsigned_char ret = (cPtr == global::System.IntPtr.Zero) ? null : new SWIGTYPE_p_unsigned_char(cPtr, false);
419 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
428 Interop.FontClient.GlyphBufferDataWidthSet(swigCPtr, value);
429 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
433 uint ret = Interop.FontClient.GlyphBufferDataWidthGet(swigCPtr);
434 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
443 Interop.FontClient.GlyphBufferDataHeightSet(swigCPtr, value);
444 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
448 uint ret = Interop.FontClient.GlyphBufferDataHeightGet(swigCPtr);
449 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
454 public PixelFormat Format
458 Interop.FontClient.GlyphBufferDataFormatSet(swigCPtr, (int)value);
459 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
463 PixelFormat ret = (PixelFormat)Interop.FontClient.GlyphBufferDataFormatGet(swigCPtr);
464 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
469 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(GlyphBufferData obj)
471 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
474 /// This will not be public opened.
475 [EditorBrowsable(EditorBrowsableState.Never)]
476 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
478 Interop.FontClient.DeleteFontClientGlyphBufferData(swigCPtr);