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;
18 using System.Collections.Generic;
19 using Tizen.NUI.BaseComponents;
25 /// FontClient provides access to font information and resources.
27 /// <since_tizen> 5 </since_tizen>
28 public class FontClient : BaseHandle
30 private static readonly FontClient instance = FontClient.Get();
32 internal FontClient(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
36 internal FontClient() : this(Interop.FontClient.NewFontClient(), true)
38 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
41 internal FontClient(FontClient handle) : this(Interop.FontClient.NewFontClient(FontClient.getCPtr(handle)), true)
43 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
46 internal static uint DefaultPointSize
50 uint ret = Interop.FontClient.DefaultPointSizeGet();
51 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
57 /// Gets the singleton pattern of the FontClient object.
59 /// <since_tizen> 5 </since_tizen>
60 public static FontClient Instance
69 /// Called when the user changes the system defaults.
71 /// <since_tizen> 5 </since_tizen>
72 public void ResetSystemDefaults()
74 Interop.FontClient.ResetSystemDefaults(SwigCPtr);
75 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
79 /// Retrieves the font point size of a given font id.
81 /// <param name="id">The font identifier.</param>
82 /// <returns>The point size in 26.6 fractional points.</returns>
83 /// <since_tizen> 5 </since_tizen>
84 public uint GetPointSize(uint id)
86 uint ret = Interop.FontClient.GetPointSize(SwigCPtr, id);
87 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
92 /// Whether the given character is supported by the font.
94 /// <param name="fontId">The id of the font.</param>
95 /// <param name="character">The character in a font.</param>
96 /// <returns>True if the character is supported by the font.</returns>
97 /// <since_tizen> 5 </since_tizen>
98 public bool IsCharacterSupportedByFont(uint fontId, uint character)
100 bool ret = Interop.FontClient.IsCharacterSupportedByFont(SwigCPtr, fontId, character);
101 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
106 /// Finds the default font for displaying a UTF-32 character.
108 /// <param name="charcode">The character for which a font is needed.</param>
109 /// <param name="requestedPointSize">The point size in 26.6 fractional points. The default point size is 12*64.</param>
110 /// <param name="preferColor">True if a color font is preferred.</param>
111 /// <returns>A valid font identifier. Zero if the font does not exist.</returns>
112 /// <since_tizen> 5 </since_tizen>
113 public uint FindDefaultFont(uint charcode, uint requestedPointSize, bool preferColor)
115 uint ret = Interop.FontClient.FindDefaultFont(SwigCPtr, charcode, requestedPointSize, preferColor);
116 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
121 /// Find the default font for displaying a UTF-32 character.
123 /// <param name="charcode">The character for which a font is needed.</param>
124 /// <param name="requestedPointSize">The point size in 26.6 fractional points. The default point size is 12*64.</param>
125 /// <returns>A valid font identifier. Zero if the font does not exist.</returns>
126 /// <since_tizen> 5 </since_tizen>
127 public uint FindDefaultFont(uint charcode, uint requestedPointSize)
129 uint ret = Interop.FontClient.FindDefaultFont(SwigCPtr, charcode, requestedPointSize);
130 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
135 /// Find the default font for displaying a UTF-32 character.
137 /// <param name="charcode">The character for which a font is needed.</param>
138 /// <returns>A valid font identifier. Zero if the font does not exist.</returns>
139 /// <since_tizen> 5 </since_tizen>
140 public uint FindDefaultFont(uint charcode)
142 uint ret = Interop.FontClient.FindDefaultFont(SwigCPtr, charcode);
143 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
148 /// Retrieve the unique identifier for a font.
150 /// <param name="path">The path to a font file.</param>
151 /// <param name="requestedPointSize">The point size in 26.6 fractional points. The default point size is 12*64.</param>
152 /// <param name="faceIndex">The index of the font face.</param>
153 /// <returns>A valid font identifier. Zero if the font does not exist.</returns>
154 /// <since_tizen> 5 </since_tizen>
155 public uint GetFontId(string path, uint requestedPointSize, uint faceIndex)
157 uint ret = Interop.FontClient.GetFontId(SwigCPtr, path, requestedPointSize, faceIndex);
158 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
163 /// Retrieve the unique identifier for a font.
165 /// <param name="path">The path to a font file.</param>
166 /// <param name="requestedPointSize">The point size in 26.6 fractional points. The default point size is 12*64.</param>
167 /// <returns>A valid font identifier. Zero if the font does not exist.</returns>
168 /// <since_tizen> 5 </since_tizen>
169 public uint GetFontId(string path, uint requestedPointSize)
171 uint ret = Interop.FontClient.GetFontId(SwigCPtr, path, requestedPointSize);
172 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
177 /// Retrieve the unique identifier for a font.
179 /// <param name="path">The path to a font file.</param>
180 /// <returns>A valid font identifier. Zero if the font does not exist.</returns>
181 /// <since_tizen> 5 </since_tizen>
182 public uint GetFontId(string path)
184 uint ret = Interop.FontClient.GetFontId(SwigCPtr, path);
185 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
190 /// Check to see if a font is scalable.
192 /// <param name="path">The path where the font file is located.</param>
193 /// <returns>True if scalable.</returns>
194 /// <since_tizen> 5 </since_tizen>
195 public bool IsScalable(string path)
197 bool ret = Interop.FontClient.IsScalable(SwigCPtr, path);
198 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
203 /// Adds custom fonts directory.
205 /// <param name="path">Path to the fonts directory.</param>
206 /// <returns>True if the fonts can be added.</returns>
207 /// <since_tizen> 5 </since_tizen>
208 public bool AddCustomFontDirectory(string path)
210 bool ret = Interop.FontClient.AddCustomFontDirectory(SwigCPtr, path);
211 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
216 /// Retrieve the list of font info supported by the system.
218 /// <returns>The list of FontInfo</returns>
220 /// <see cref="Tizen.NUI.Text.FontInfo"/>
223 /// The following example demonstrates how to use the GetSystemFonts method.
225 /// var fontList = FontClient.Instance.GetSystemFonts();
226 /// foreach(Tizen.NUI.Text.FontInfo fontInfo in fontList)
228 /// string fontFamily = fontInfo.Family;
229 /// string fontPath = fontInfo.Path;
230 /// FontWidthType fontWidth = fontInfo.Style.Width;
231 /// FontWeightType fontWeight = fontInfo.Style.Weight;
232 /// FontSlantType fontSlant = fontInfo.Style.Slant;
236 [EditorBrowsable(EditorBrowsableState.Never)]
237 public List<FontInfo> GetSystemFonts()
239 using PropertyArray fontArray = new PropertyArray(Interop.FontClient.GetSystemFonts(SwigCPtr), true);
240 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
242 List<FontInfo> fontInfoList;
243 fontInfoList = TextUtils.GetFontInfoList(fontArray);
247 internal static FontClient Get()
249 FontClient ret = new FontClient(Interop.FontClient.Get(), true);
250 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
254 internal FontClient Assign(FontClient handle)
256 FontClient ret = new FontClient(Interop.FontClient.Assign(SwigCPtr, FontClient.getCPtr(handle)), false);
257 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
261 internal void SetDpi(uint horizontalDpi, uint verticalDpi)
263 Interop.FontClient.SetDpi(SwigCPtr, horizontalDpi, verticalDpi);
264 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
267 internal void GetDpi(SWIGTYPE_p_unsigned_int horizontalDpi, SWIGTYPE_p_unsigned_int verticalDpi)
269 Interop.FontClient.GetDpi(SwigCPtr, SWIGTYPE_p_unsigned_int.getCPtr(horizontalDpi), SWIGTYPE_p_unsigned_int.getCPtr(verticalDpi));
270 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
273 internal int GetDefaultFontSize()
275 int ret = Interop.FontClient.GetDefaultFontSize(SwigCPtr);
276 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
280 internal void GetDefaultFonts(SWIGTYPE_p_std__vectorT_Dali__TextAbstraction__FontDescription_t defaultFonts)
282 Interop.FontClient.GetDefaultFonts(SwigCPtr, SWIGTYPE_p_std__vectorT_Dali__TextAbstraction__FontDescription_t.getCPtr(defaultFonts));
283 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
286 internal void GetDefaultPlatformFontDescription(FontDescription fontDescription)
288 Interop.FontClient.GetDefaultPlatformFontDescription(SwigCPtr, FontDescription.getCPtr(fontDescription));
289 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
292 internal void GetDescription(uint id, FontDescription fontDescription)
294 Interop.FontClient.GetDescription(SwigCPtr, id, FontDescription.getCPtr(fontDescription));
295 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
298 internal uint FindFallbackFont(uint charcode, FontDescription preferredFontDescription, uint requestedPointSize, bool preferColor)
300 uint ret = Interop.FontClient.FindFallbackFont(SwigCPtr, charcode, FontDescription.getCPtr(preferredFontDescription), requestedPointSize, preferColor);
301 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
305 internal uint FindFallbackFont(uint charcode, FontDescription preferredFontDescription, uint requestedPointSize)
307 uint ret = Interop.FontClient.FindFallbackFont(SwigCPtr, charcode, FontDescription.getCPtr(preferredFontDescription), requestedPointSize);
308 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
312 internal uint FindFallbackFont(uint charcode, FontDescription preferredFontDescription)
314 uint ret = Interop.FontClient.FindFallbackFont(SwigCPtr, charcode, FontDescription.getCPtr(preferredFontDescription));
315 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
319 internal uint GetFontId(FontDescription preferredFontDescription, uint requestedPointSize, uint faceIndex)
321 uint ret = Interop.FontClient.GetFontId(SwigCPtr, FontDescription.getCPtr(preferredFontDescription), requestedPointSize, faceIndex);
322 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
326 internal uint GetFontId(FontDescription preferredFontDescription, uint requestedPointSize)
328 uint ret = Interop.FontClient.GetFontId(SwigCPtr, FontDescription.getCPtr(preferredFontDescription), requestedPointSize);
329 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
333 internal uint GetFontId(FontDescription preferredFontDescription)
335 uint ret = Interop.FontClient.GetFontId(SwigCPtr, FontDescription.getCPtr(preferredFontDescription));
336 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
340 internal bool IsScalable(FontDescription fontDescription)
342 bool ret = Interop.FontClient.IsScalable(SwigCPtr, FontDescription.getCPtr(fontDescription));
343 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
347 internal void GetFixedSizes(string path, SWIGTYPE_p_Dali__VectorT_uint32_t_TypeTraitsT_uint32_t_t__IS_TRIVIAL_TYPE__true_t sizes)
349 Interop.FontClient.GetFixedSizes(SwigCPtr, path, SWIGTYPE_p_Dali__VectorT_uint32_t_TypeTraitsT_uint32_t_t__IS_TRIVIAL_TYPE__true_t.getCPtr(sizes));
350 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
353 internal void GetFixedSizes(FontDescription fontDescription, SWIGTYPE_p_Dali__VectorT_uint32_t_TypeTraitsT_uint32_t_t__IS_TRIVIAL_TYPE__true_t sizes)
355 Interop.FontClient.GetFixedSizes(SwigCPtr, FontDescription.getCPtr(fontDescription), SWIGTYPE_p_Dali__VectorT_uint32_t_TypeTraitsT_uint32_t_t__IS_TRIVIAL_TYPE__true_t.getCPtr(sizes));
356 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
359 internal void GetFontMetrics(uint fontId, FontMetrics metrics)
361 Interop.FontClient.GetFontMetrics(SwigCPtr, fontId, FontMetrics.getCPtr(metrics));
362 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
365 internal uint GetGlyphIndex(uint fontId, uint charcode)
367 uint ret = Interop.FontClient.GetGlyphIndex(SwigCPtr, fontId, charcode);
368 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
372 internal bool GetGlyphMetrics(GlyphInfo array, uint size, GlyphType type, bool horizontal)
374 bool ret = Interop.FontClient.GetGlyphMetrics(SwigCPtr, GlyphInfo.getCPtr(array), size, (int)type, horizontal);
375 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
379 internal bool GetGlyphMetrics(GlyphInfo array, uint size, GlyphType type)
381 bool ret = Interop.FontClient.GetGlyphMetrics(SwigCPtr, GlyphInfo.getCPtr(array), size, (int)type);
382 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
386 internal void CreateBitmap(uint fontId, uint glyphIndex, bool softwareItalic, bool softwareBold, FontClient.GlyphBufferData data, int outlineWidth)
388 Interop.FontClient.CreateBitmap(SwigCPtr, fontId, glyphIndex, softwareItalic, softwareBold, FontClient.GlyphBufferData.getCPtr(data), outlineWidth);
389 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
392 internal PixelData CreateBitmap(uint fontId, uint glyphIndex, int outlineWidth)
394 PixelData ret = new PixelData(Interop.FontClient.CreateBitmap(SwigCPtr, fontId, glyphIndex, outlineWidth), true);
395 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
399 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)
401 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));
402 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
405 internal GlyphInfo GetEllipsisGlyph(uint requestedPointSize)
407 GlyphInfo ret = new GlyphInfo(Interop.FontClient.GetEllipsisGlyph(SwigCPtr, requestedPointSize), false);
408 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
412 internal bool IsColorGlyph(uint fontId, uint glyphIndex)
414 bool ret = Interop.FontClient.IsColorGlyph(SwigCPtr, fontId, glyphIndex);
415 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
419 internal class GlyphBufferData : Disposable
421 public GlyphBufferData() : this(Interop.FontClient.NewFontClientGlyphBufferData(), true)
423 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
426 internal GlyphBufferData(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
430 /*public byte[] Buffer
434 Interop.FontClient.GlyphBufferDataBufferSet(swigCPtr, value);
435 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
439 global::System.IntPtr cPtr = Interop.FontClient.GlyphBufferDataBufferGet(swigCPtr);
440 SWIGTYPE_p_unsigned_char ret = (cPtr == global::System.IntPtr.Zero) ? null : new SWIGTYPE_p_unsigned_char(cPtr, false);
441 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
450 Interop.FontClient.GlyphBufferDataWidthSet(SwigCPtr, value);
451 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
455 uint ret = Interop.FontClient.GlyphBufferDataWidthGet(SwigCPtr);
456 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
465 Interop.FontClient.GlyphBufferDataHeightSet(SwigCPtr, value);
466 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
470 uint ret = Interop.FontClient.GlyphBufferDataHeightGet(SwigCPtr);
471 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
476 public PixelFormat Format
480 Interop.FontClient.GlyphBufferDataFormatSet(SwigCPtr, (int)value);
481 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
485 PixelFormat ret = (PixelFormat)Interop.FontClient.GlyphBufferDataFormatGet(SwigCPtr);
486 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
491 /// This will not be public opened.
492 [EditorBrowsable(EditorBrowsableState.Never)]
493 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
495 Interop.FontClient.DeleteFontClientGlyphBufferData(swigCPtr);