| Seigo Nonaka | 667b69a | 2018-08-31 12:28:14 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 2018 The Android Open Source Project | 
|  | 3 | * | 
|  | 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 | 
|  | 7 | * | 
|  | 8 | *      http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 9 | * | 
|  | 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. | 
|  | 15 | */ | 
|  | 16 |  | 
|  | 17 | /** | 
|  | 18 | * @file system_fonts.h | 
|  | 19 | * @brief Provides the system font configurations. | 
|  | 20 | * | 
|  | 21 | * These APIs provides the list of system installed font files with additional metadata about the | 
|  | 22 | * font. | 
|  | 23 | * | 
|  | 24 | * The ASystemFontIterator_open method will give you an iterator which can iterate all system | 
|  | 25 | * installed font files as shown in the following example. | 
|  | 26 | * | 
| Seigo Nonaka | e9e637d | 2018-11-26 22:12:23 -0800 | [diff] [blame] | 27 | * \code{.cpp} | 
| Seigo Nonaka | 667b69a | 2018-08-31 12:28:14 -0700 | [diff] [blame] | 28 | *   ASystemFontIterator* iterator = ASystemFontIterator_open(); | 
|  | 29 | *   ASystemFont* font = NULL; | 
|  | 30 | * | 
|  | 31 | *   while ((font = ASystemFontIterator_next(iterator)) != nullptr) { | 
|  | 32 | *       // Look if the font is your desired one. | 
|  | 33 | *       if (ASystemFont_getWeight(font) == 400 && !ASystemFont_isItalic(font) | 
|  | 34 | *           && ASystemFont_getLocale(font) == NULL) { | 
|  | 35 | *           break; | 
|  | 36 | *       } | 
|  | 37 | *       ASystemFont_close(font); | 
|  | 38 | *   } | 
|  | 39 | *   ASystemFontIterator_close(iterator); | 
|  | 40 | * | 
|  | 41 | *   int fd = open(ASystemFont_getFontFilePath(font), O_RDONLY); | 
|  | 42 | *   int collectionIndex = ASystemFont_getCollectionINdex(font); | 
|  | 43 | *   std::vector<std::pair<uint32_t, float>> variationSettings; | 
|  | 44 | *   for (size_t i = 0; i < ASystemFont_getAxisCount(font); ++i) { | 
|  | 45 | *       variationSettings.push_back(std::make_pair( | 
|  | 46 | *           ASystemFont_getAxisTag(font, i), | 
|  | 47 | *           ASystemFont_getAxisValue(font, i))); | 
|  | 48 | *   } | 
|  | 49 | *   ASystemFont_close(font); | 
|  | 50 | * | 
|  | 51 | *   // Use this font for your text rendering engine. | 
|  | 52 | * | 
| Seigo Nonaka | e9e637d | 2018-11-26 22:12:23 -0800 | [diff] [blame] | 53 | * \endcode | 
| Seigo Nonaka | 667b69a | 2018-08-31 12:28:14 -0700 | [diff] [blame] | 54 | * | 
|  | 55 | * Available since API level 29. | 
|  | 56 | */ | 
|  | 57 |  | 
|  | 58 | #ifndef ANDROID_SYSTEM_FONTS_H | 
|  | 59 | #define ANDROID_SYSTEM_FONTS_H | 
|  | 60 |  | 
|  | 61 | #include <stdbool.h> | 
|  | 62 | #include <stddef.h> | 
|  | 63 | #include <sys/cdefs.h> | 
|  | 64 |  | 
|  | 65 | /****************************************************************** | 
|  | 66 | * | 
|  | 67 | * IMPORTANT NOTICE: | 
|  | 68 | * | 
|  | 69 | *   This file is part of Android's set of stable system headers | 
|  | 70 | *   exposed by the Android NDK (Native Development Kit). | 
|  | 71 | * | 
|  | 72 | *   Third-party source AND binary code relies on the definitions | 
|  | 73 | *   here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES. | 
|  | 74 | * | 
|  | 75 | *   - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES) | 
|  | 76 | *   - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS | 
|  | 77 | *   - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY | 
|  | 78 | *   - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES | 
|  | 79 | */ | 
|  | 80 |  | 
|  | 81 | __BEGIN_DECLS | 
|  | 82 |  | 
|  | 83 | #if __ANDROID_API__ >= 29 | 
|  | 84 |  | 
|  | 85 | enum { | 
|  | 86 | /** The minimum value fot the font weight value. */ | 
|  | 87 | ASYSTEM_FONT_WEIGHT_MIN = 0, | 
|  | 88 |  | 
|  | 89 | /** A font weight value for the thin weight. */ | 
|  | 90 | ASYSTEM_FONT_WEIGHT_THIN = 100, | 
|  | 91 |  | 
|  | 92 | /** A font weight value for the extra-light weight. */ | 
|  | 93 | ASYSTEM_FONT_WEIGHT_EXTRA_LIGHT = 200, | 
|  | 94 |  | 
|  | 95 | /** A font weight value for the light weight. */ | 
|  | 96 | ASYSTEM_FONT_WEIGHT_LIGHT = 300, | 
|  | 97 |  | 
|  | 98 | /** A font weight value for the normal weight. */ | 
|  | 99 | ASYSTEM_FONT_WEIGHT_NORMAL = 400, | 
|  | 100 |  | 
|  | 101 | /** A font weight value for the medium weight. */ | 
|  | 102 | ASYSTEM_FONT_WEIGHT_MEDIUM = 500, | 
|  | 103 |  | 
|  | 104 | /** A font weight value for the semi-bold weight. */ | 
|  | 105 | ASYSTEM_FONT_WEIGHT_SEMI_BOLD = 600, | 
|  | 106 |  | 
|  | 107 | /** A font weight value for the bold weight. */ | 
|  | 108 | ASYSTEM_FONT_WEIGHT_BOLD = 700, | 
|  | 109 |  | 
|  | 110 | /** A font weight value for the extra-bold weight. */ | 
|  | 111 | ASYSTEM_FONT_WEIGHT_EXTRA_BOLD = 800, | 
|  | 112 |  | 
|  | 113 | /** A font weight value for the black weight. */ | 
|  | 114 | ASYSTEM_FONT_WEIGHT_BLACK = 900, | 
|  | 115 |  | 
|  | 116 | /** The maximum value for the font weight value. */ | 
|  | 117 | ASYSTEM_FONT_WEIGHT_MAX = 1000 | 
|  | 118 | }; | 
|  | 119 |  | 
|  | 120 | /** | 
|  | 121 | * ASystemFontIterator provides access to the system font configuration. | 
|  | 122 | * | 
|  | 123 | * ASystemFontIterator is an iterator for all available system font settings. | 
|  | 124 | * This iterator is not a thread-safe object. Do not pass this iterator to other threads. | 
|  | 125 | */ | 
|  | 126 | struct ASystemFontIterator; | 
|  | 127 |  | 
|  | 128 | /** | 
|  | 129 | * ASystemFont provides information of the single system font configuration. | 
|  | 130 | */ | 
|  | 131 | struct ASystemFont; | 
|  | 132 |  | 
|  | 133 | /** | 
|  | 134 | * Create a system font iterator. | 
|  | 135 | * | 
|  | 136 | * Use ASystemFont_close() to close the iterator. | 
|  | 137 | * | 
|  | 138 | * \return a pointer for a newly allocated iterator, nullptr on failure. | 
|  | 139 | */ | 
|  | 140 | ASystemFontIterator* _Nullable ASystemFontIterator_open() __INTRODUCED_IN(29); | 
|  | 141 |  | 
|  | 142 | /** | 
|  | 143 | * Close an opened system font iterator, freeing any related resources. | 
|  | 144 | * | 
| Seigo Nonaka | e9e637d | 2018-11-26 22:12:23 -0800 | [diff] [blame] | 145 | * \param iterator a pointer of an iterator for the system fonts. Do nothing if NULL is passed. | 
| Seigo Nonaka | 667b69a | 2018-08-31 12:28:14 -0700 | [diff] [blame] | 146 | */ | 
|  | 147 | void ASystemFontIterator_close(ASystemFontIterator* _Nullable iterator) __INTRODUCED_IN(29); | 
|  | 148 |  | 
|  | 149 | /** | 
|  | 150 | * Move to the next system font. | 
|  | 151 | * | 
|  | 152 | * \param iterator an iterator for the system fonts. Passing NULL is not allowed. | 
| Seigo Nonaka | 77e562b | 2018-10-30 12:26:07 -0700 | [diff] [blame] | 153 | * \return a font. If no more font is available, returns nullptr. You need to release the returned | 
|  | 154 | *         font by ASystemFont_close when it is no longer needed. | 
| Seigo Nonaka | 667b69a | 2018-08-31 12:28:14 -0700 | [diff] [blame] | 155 | */ | 
|  | 156 | ASystemFont* _Nullable ASystemFontIterator_next(ASystemFontIterator* _Nonnull iterator) __INTRODUCED_IN(29); | 
|  | 157 |  | 
|  | 158 | /** | 
|  | 159 | * Close an ASystemFont returned by ASystemFontIterator_next. | 
|  | 160 | * | 
| Seigo Nonaka | 77e562b | 2018-10-30 12:26:07 -0700 | [diff] [blame] | 161 | * \param font a font returned by ASystemFontIterator_next or ASystemFont_matchFamilyStyleCharacter. | 
|  | 162 | *        Do nothing if NULL is passed. | 
| Seigo Nonaka | 667b69a | 2018-08-31 12:28:14 -0700 | [diff] [blame] | 163 | */ | 
|  | 164 | void ASystemFont_close(ASystemFont* _Nullable font) __INTRODUCED_IN(29); | 
|  | 165 |  | 
|  | 166 |  | 
|  | 167 | /** | 
| Seigo Nonaka | 77e562b | 2018-10-30 12:26:07 -0700 | [diff] [blame] | 168 | * Select the best font from given parameters. | 
|  | 169 | * | 
|  | 170 | * Only generic font families are supported. | 
|  | 171 | * For more information about generic font families, read [W3C spec](https://www.w3.org/TR/css-fonts-4/#generic-font-families) | 
|  | 172 | * | 
|  | 173 | * Even if no font can render the given text, this function will return a non-null result for | 
|  | 174 | * drawing Tofu character. | 
|  | 175 | * | 
|  | 176 | * Examples: | 
| Seigo Nonaka | e9e637d | 2018-11-26 22:12:23 -0800 | [diff] [blame] | 177 | * \code{.cpp} | 
| Seigo Nonaka | 77e562b | 2018-10-30 12:26:07 -0700 | [diff] [blame] | 178 | *  // Simple font query for the ASCII character. | 
|  | 179 | *  std::vector<uint16_t> text = { 'A' }; | 
|  | 180 | *  ASystemFont font = ASystemFont_matchFamilyStyleCharacter( | 
|  | 181 | *      "sans", 400, false, "en-US", text.data(), text.length(), &runLength); | 
|  | 182 | *  // runLength will be 1 and the font will points a valid font file. | 
|  | 183 | * | 
|  | 184 | *  // Querying font for CJK characters | 
|  | 185 | *  std::vector<uint16_t> text = { 0x9AA8 }; | 
|  | 186 | *  ASystemFont font = ASystemFont_matchFamilyStyleCharacter( | 
|  | 187 | *      "sans", 400, false, "zh-CN,ja-JP", text.data(), text.length(), &runLength); | 
|  | 188 | *  // runLength will be 1 and the font will points a Simplified Chinese font. | 
|  | 189 | *  ASystemFont font = ASystemFont_matchFamilyStyleCharacter( | 
|  | 190 | *      "sans", 400, false, "ja-JP,zh-CN", text.data(), text.length(), &runLength); | 
|  | 191 | *  // runLength will be 1 and the font will points a Japanese font. | 
|  | 192 | * | 
|  | 193 | *  // Querying font for text/color emoji | 
|  | 194 | *  std::vector<uint16_t> text = { 0xD83D, 0xDC68, 0x200D, 0x2764, 0xFE0F, 0x200D, 0xD83D, 0xDC68 }; | 
|  | 195 | *  ASystemFont font = ASystemFont_matchFamilyStyleCharacter( | 
|  | 196 | *      "sans", 400, false, "en-US", text.data(), text.length(), &runLength); | 
|  | 197 | *  // runLength will be 8 and the font will points a color emoji font. | 
|  | 198 | * | 
|  | 199 | *  // Mixture of multiple script of characters. | 
|  | 200 | *  // 0x05D0 is a Hebrew character and 0x0E01 is a Thai character. | 
|  | 201 | *  std::vector<uint16_t> text = { 0x05D0, 0x0E01 }; | 
|  | 202 | *  ASystemFont font = ASystemFont_matchFamilyStyleCharacter( | 
|  | 203 | *      "sans", 400, false, "en-US", text.data(), text.length(), &runLength); | 
|  | 204 | *  // runLength will be 1 and the font will points a Hebrew font. | 
| Seigo Nonaka | e9e637d | 2018-11-26 22:12:23 -0800 | [diff] [blame] | 205 | * \endcode | 
| Seigo Nonaka | 77e562b | 2018-10-30 12:26:07 -0700 | [diff] [blame] | 206 | * | 
|  | 207 | * \param familyName a null character terminated font family name | 
|  | 208 | * \param weight a font weight value. Only from 0 to 1000 value is valid | 
|  | 209 | * \param italic true if italic, otherwise false. | 
|  | 210 | * \param languageTags a null character terminated comma separated IETF BCP47 compliant language | 
|  | 211 | *                     tags. | 
| Seigo Nonaka | e9e637d | 2018-11-26 22:12:23 -0800 | [diff] [blame] | 212 | * \param text a UTF-16 encoded text buffer to be rendered. Do not pass empty string. | 
|  | 213 | * \param textLength a length of the given text buffer. This must not be zero. | 
| Seigo Nonaka | 77e562b | 2018-10-30 12:26:07 -0700 | [diff] [blame] | 214 | * \param runLengthOut if not null, the font run length will be filled. | 
|  | 215 | * \return a font to be used for given text and params. You need to release the returned font by | 
|  | 216 | *         ASystemFont_close when it is no longer needed. | 
|  | 217 | */ | 
|  | 218 | ASystemFont* _Nonnull ASystemFont_matchFamilyStyleCharacter( | 
|  | 219 | const char* _Nonnull familyName, | 
|  | 220 | uint16_t weight, | 
|  | 221 | bool italic, | 
|  | 222 | const char* _Nonnull languageTags, | 
|  | 223 | const uint16_t* _Nonnull text, | 
|  | 224 | uint32_t textLength, | 
|  | 225 | uint32_t* _Nullable runLengthOut) __INTRODUCED_IN(29); | 
|  | 226 |  | 
|  | 227 | /** | 
| Seigo Nonaka | 667b69a | 2018-08-31 12:28:14 -0700 | [diff] [blame] | 228 | * Return an absolute path to the current font file. | 
|  | 229 | * | 
|  | 230 | * Here is a list of font formats returned by this method: | 
|  | 231 | * <ul> | 
|  | 232 | *   <li>OpenType</li> | 
|  | 233 | *   <li>OpenType Font Collection</li> | 
|  | 234 | *   <li>TrueType</li> | 
|  | 235 | *   <li>TrueType Collection</li> | 
|  | 236 | * </ul> | 
|  | 237 | * The file extension could be one of *.otf, *.ttf, *.otc or *.ttc. | 
|  | 238 | * | 
|  | 239 | * The font file returned is guaranteed to be opend with O_RDONLY. | 
|  | 240 | * Note that the returned pointer is valid until ASystemFont_close() is called for the given font. | 
|  | 241 | * | 
| Seigo Nonaka | e9e637d | 2018-11-26 22:12:23 -0800 | [diff] [blame] | 242 | * \param font a font object. Passing NULL is not allowed. | 
| Seigo Nonaka | 667b69a | 2018-08-31 12:28:14 -0700 | [diff] [blame] | 243 | * \return a string of the font file path. | 
|  | 244 | */ | 
|  | 245 | const char* _Nonnull ASystemFont_getFontFilePath(const ASystemFont* _Nonnull font) __INTRODUCED_IN(29); | 
|  | 246 |  | 
|  | 247 | /** | 
|  | 248 | * Return a weight value associated with the current font. | 
|  | 249 | * | 
|  | 250 | * The weight values are positive and less than or equal to 1000. | 
|  | 251 | * Here are pairs of the common names and their values. | 
|  | 252 | * <p> | 
|  | 253 | *  <table> | 
| Seigo Nonaka | 667b69a | 2018-08-31 12:28:14 -0700 | [diff] [blame] | 254 | *  <tr> | 
|  | 255 | *  <th align="center">Value</th> | 
|  | 256 | *  <th align="center">Name</th> | 
|  | 257 | *  <th align="center">NDK Definition</th> | 
|  | 258 | *  </tr> | 
| Seigo Nonaka | 667b69a | 2018-08-31 12:28:14 -0700 | [diff] [blame] | 259 | *  <tr> | 
|  | 260 | *  <td align="center">100</td> | 
|  | 261 | *  <td align="center">Thin</td> | 
|  | 262 | *  <td align="center">{@link ASYSTEM_FONT_WEIGHT_THIN}</td> | 
|  | 263 | *  </tr> | 
|  | 264 | *  <tr> | 
|  | 265 | *  <td align="center">200</td> | 
|  | 266 | *  <td align="center">Extra Light (Ultra Light)</td> | 
|  | 267 | *  <td align="center">{@link ASYSTEM_FONT_WEIGHT_EXTRA_LIGHT}</td> | 
|  | 268 | *  </tr> | 
|  | 269 | *  <tr> | 
|  | 270 | *  <td align="center">300</td> | 
|  | 271 | *  <td align="center">Light</td> | 
|  | 272 | *  <td align="center">{@link ASYSTEM_FONT_WEIGHT_LIGHT}</td> | 
|  | 273 | *  </tr> | 
|  | 274 | *  <tr> | 
|  | 275 | *  <td align="center">400</td> | 
|  | 276 | *  <td align="center">Normal (Regular)</td> | 
|  | 277 | *  <td align="center">{@link ASYSTEM_FONT_WEIGHT_NORMAL}</td> | 
|  | 278 | *  </tr> | 
|  | 279 | *  <tr> | 
|  | 280 | *  <td align="center">500</td> | 
|  | 281 | *  <td align="center">Medium</td> | 
|  | 282 | *  <td align="center">{@link ASYSTEM_FONT_WEIGHT_MEDIUM}</td> | 
|  | 283 | *  </tr> | 
|  | 284 | *  <tr> | 
|  | 285 | *  <td align="center">600</td> | 
|  | 286 | *  <td align="center">Semi Bold (Demi Bold)</td> | 
|  | 287 | *  <td align="center">{@link ASYSTEM_FONT_WEIGHT_SEMI_BOLD}</td> | 
|  | 288 | *  </tr> | 
|  | 289 | *  <tr> | 
|  | 290 | *  <td align="center">700</td> | 
|  | 291 | *  <td align="center">Bold</td> | 
|  | 292 | *  <td align="center">{@link ASYSTEM_FONT_WEIGHT_BOLD}</td> | 
|  | 293 | *  </tr> | 
|  | 294 | *  <tr> | 
|  | 295 | *  <td align="center">800</td> | 
|  | 296 | *  <td align="center">Extra Bold (Ultra Bold)</td> | 
|  | 297 | *  <td align="center">{@link ASYSTEM_FONT_WEIGHT_EXTRA_BOLD}</td> | 
|  | 298 | *  </tr> | 
|  | 299 | *  <tr> | 
|  | 300 | *  <td align="center">900</td> | 
|  | 301 | *  <td align="center">Black (Heavy)</td> | 
|  | 302 | *  <td align="center">{@link ASYSTEM_FONT_WEIGHT_BLACK}</td> | 
|  | 303 | *  </tr> | 
| Seigo Nonaka | e9e637d | 2018-11-26 22:12:23 -0800 | [diff] [blame] | 304 | *  </table> | 
| Seigo Nonaka | 667b69a | 2018-08-31 12:28:14 -0700 | [diff] [blame] | 305 | * </p> | 
|  | 306 | * Note that the weight value may fall in between above values, e.g. 250 weight. | 
|  | 307 | * | 
|  | 308 | * For more information about font weight, read [OpenType usWeightClass](https://docs.microsoft.com/en-us/typography/opentype/spec/os2#usweightclass) | 
|  | 309 | * | 
| Seigo Nonaka | e9e637d | 2018-11-26 22:12:23 -0800 | [diff] [blame] | 310 | * \param font a font object. Passing NULL is not allowed. | 
| Seigo Nonaka | 667b69a | 2018-08-31 12:28:14 -0700 | [diff] [blame] | 311 | * \return a positive integer less than or equal to {@link ASYSTEM_FONT_MAX_WEIGHT} is returned. | 
|  | 312 | */ | 
|  | 313 | uint16_t ASystemFont_getWeight(const ASystemFont* _Nonnull font) __INTRODUCED_IN(29); | 
|  | 314 |  | 
|  | 315 | /** | 
|  | 316 | * Return true if the current font is italic, otherwise returns false. | 
|  | 317 | * | 
| Seigo Nonaka | e9e637d | 2018-11-26 22:12:23 -0800 | [diff] [blame] | 318 | * \param font a font object. Passing NULL is not allowed. | 
| Seigo Nonaka | 667b69a | 2018-08-31 12:28:14 -0700 | [diff] [blame] | 319 | * \return true if italic, otherwise false. | 
|  | 320 | */ | 
|  | 321 | bool ASystemFont_isItalic(const ASystemFont* _Nonnull font) __INTRODUCED_IN(29); | 
|  | 322 |  | 
|  | 323 | /** | 
|  | 324 | * Return a IETF BCP47 compliant language tag associated with the current font. | 
|  | 325 | * | 
|  | 326 | * For information about IETF BCP47, read [Locale.forLanguageTag(java.lang.String)](https://developer.android.com/reference/java/util/Locale.html#forLanguageTag(java.lang.String)") | 
|  | 327 | * | 
|  | 328 | * Note that the returned pointer is valid until ASystemFont_close() is called. | 
|  | 329 | * | 
| Seigo Nonaka | e9e637d | 2018-11-26 22:12:23 -0800 | [diff] [blame] | 330 | * \param font a font object. Passing NULL is not allowed. | 
| Seigo Nonaka | 667b69a | 2018-08-31 12:28:14 -0700 | [diff] [blame] | 331 | * \return a IETF BCP47 compliant langauge tag or nullptr if not available. | 
|  | 332 | */ | 
|  | 333 | const char* _Nullable ASystemFont_getLocale(const ASystemFont* _Nonnull font) __INTRODUCED_IN(29); | 
|  | 334 |  | 
|  | 335 | /** | 
|  | 336 | * Return a font collection index value associated with the current font. | 
|  | 337 | * | 
|  | 338 | * In case the target font file is a font collection (e.g. .ttc or .otc), this | 
|  | 339 | * returns a non-negative value as an font offset in the collection. This | 
|  | 340 | * always returns 0 if the target font file is a regular font. | 
|  | 341 | * | 
| Seigo Nonaka | e9e637d | 2018-11-26 22:12:23 -0800 | [diff] [blame] | 342 | * \param font a font object. Passing NULL is not allowed. | 
| Seigo Nonaka | 667b69a | 2018-08-31 12:28:14 -0700 | [diff] [blame] | 343 | * \return a font collection index. | 
|  | 344 | */ | 
|  | 345 | size_t ASystemFont_getCollectionIndex(const ASystemFont* _Nonnull font) __INTRODUCED_IN(29); | 
|  | 346 |  | 
|  | 347 | /** | 
|  | 348 | * Return a count of font variation settings associated with the current font | 
|  | 349 | * | 
|  | 350 | * The font variation settings are provided as multiple tag-values pairs. | 
|  | 351 | * | 
|  | 352 | * For example, bold italic font may have following font variation settings: | 
|  | 353 | *     'wght' 700, 'slnt' -12 | 
|  | 354 | * In this case, ASystemFont_getAxisCount returns 2 and ASystemFont_getAxisTag | 
|  | 355 | * and ASystemFont_getAxisValue will return following values. | 
| Seigo Nonaka | e9e637d | 2018-11-26 22:12:23 -0800 | [diff] [blame] | 356 | * \code{.cpp} | 
| Seigo Nonaka | 667b69a | 2018-08-31 12:28:14 -0700 | [diff] [blame] | 357 | *     ASystemFont* font = ASystemFontIterator_next(ite); | 
|  | 358 | * | 
|  | 359 | *     // Returns the number of axes | 
|  | 360 | *     ASystemFont_getAxisCount(font);  // Returns 2 | 
|  | 361 | * | 
|  | 362 | *     // Returns the tag-value pair for the first axis. | 
|  | 363 | *     ASystemFont_getAxisTag(font, 0);  // Returns 'wght'(0x77676874) | 
|  | 364 | *     ASystemFont_getAxisValue(font, 0);  // Returns 700.0 | 
|  | 365 | * | 
|  | 366 | *     // Returns the tag-value pair for the second axis. | 
|  | 367 | *     ASystemFont_getAxisTag(font, 1);  // Returns 'slnt'(0x736c6e74) | 
|  | 368 | *     ASystemFont_getAxisValue(font, 1);  // Returns -12.0 | 
| Seigo Nonaka | e9e637d | 2018-11-26 22:12:23 -0800 | [diff] [blame] | 369 | * \endcode | 
| Seigo Nonaka | 667b69a | 2018-08-31 12:28:14 -0700 | [diff] [blame] | 370 | * | 
|  | 371 | * For more information about font variation settings, read [Font Variations Table](https://docs.microsoft.com/en-us/typography/opentype/spec/fvar) | 
|  | 372 | * | 
| Seigo Nonaka | e9e637d | 2018-11-26 22:12:23 -0800 | [diff] [blame] | 373 | * \param font a font object. Passing NULL is not allowed. | 
| Seigo Nonaka | 667b69a | 2018-08-31 12:28:14 -0700 | [diff] [blame] | 374 | * \return a number of font variation settings. | 
|  | 375 | */ | 
|  | 376 | size_t ASystemFont_getAxisCount(const ASystemFont* _Nonnull font) __INTRODUCED_IN(29); | 
|  | 377 |  | 
|  | 378 |  | 
|  | 379 | /** | 
|  | 380 | * Return an OpenType axis tag associated with the current font. | 
|  | 381 | * | 
|  | 382 | * See ASystemFont_getAxisCount for more details. | 
|  | 383 | * | 
| Seigo Nonaka | e9e637d | 2018-11-26 22:12:23 -0800 | [diff] [blame] | 384 | * \param font a font object. Passing NULL is not allowed. | 
|  | 385 | * \param axisIndex an index to the font variation settings. Passing value larger than or | 
| Seigo Nonaka | 667b69a | 2018-08-31 12:28:14 -0700 | [diff] [blame] | 386 | *        equal to {@link ASystemFont_getAxisCount} is not allowed. | 
|  | 387 | * \return an OpenType axis tag value for the given font variation setting. | 
|  | 388 | */ | 
|  | 389 | uint32_t ASystemFont_getAxisTag(const ASystemFont* _Nonnull font, uint32_t axisIndex) | 
|  | 390 | __INTRODUCED_IN(29); | 
|  | 391 |  | 
|  | 392 | /** | 
|  | 393 | * Return an OpenType axis value associated with the current font. | 
|  | 394 | * | 
|  | 395 | * See ASystemFont_getAxisCount for more details. | 
|  | 396 | * | 
| Seigo Nonaka | e9e637d | 2018-11-26 22:12:23 -0800 | [diff] [blame] | 397 | * \param font a font object. Passing NULL is not allowed. | 
|  | 398 | * \param axisIndex an index to the font variation settings. Passing value larger than or | 
| Seigo Nonaka | 667b69a | 2018-08-31 12:28:14 -0700 | [diff] [blame] | 399 | *         equal to {@link ASYstemFont_getAxisCount} is not allwed. | 
|  | 400 | * \return a float value for the given font variation setting. | 
|  | 401 | */ | 
|  | 402 | float ASystemFont_getAxisValue(const ASystemFont* _Nonnull font, uint32_t axisIndex) | 
|  | 403 | __INTRODUCED_IN(29); | 
|  | 404 |  | 
|  | 405 | #endif // __ANDROID_API__ >= 29 | 
|  | 406 |  | 
|  | 407 | __END_DECLS | 
|  | 408 |  | 
|  | 409 | #endif // ANDROID_SYSTEM_FONTS_H |