1. ------------------------------------------------------------------------------ 
  2. --                                                                          -- 
  3. --      Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet       -- 
  4. --                     Copyright (C) 2000-2014, AdaCore                     -- 
  5. --                                                                          -- 
  6. -- This library is free software;  you can redistribute it and/or modify it -- 
  7. -- under terms of the  GNU General Public License  as published by the Free -- 
  8. -- Software  Foundation;  either version 3,  or (at your  option) any later -- 
  9. -- version. This library is distributed in the hope that it will be useful, -- 
  10. -- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- -- 
  11. -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.                            -- 
  12. --                                                                          -- 
  13. -- As a special exception under Section 7 of GPL version 3, you are granted -- 
  14. -- additional permissions described in the GCC Runtime Library Exception,   -- 
  15. -- version 3.1, as published by the Free Software Foundation.               -- 
  16. --                                                                          -- 
  17. -- You should have received a copy of the GNU General Public License and    -- 
  18. -- a copy of the GCC Runtime Library Exception along with this program;     -- 
  19. -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    -- 
  20. -- <http://www.gnu.org/licenses/>.                                          -- 
  21. --                                                                          -- 
  22. ------------------------------------------------------------------------------ 
  23.  
  24. pragma Ada_2005; 
  25.  
  26. pragma Warnings (Off, "*is already use-visible*"); 
  27. with Glib;                    use Glib; 
  28. with Glib.Generic_Properties; use Glib.Generic_Properties; 
  29.  
  30. package Pango.Language is 
  31.  
  32.    type Pango_Language is new Glib.C_Boxed with null record; 
  33.    Null_Pango_Language : constant Pango_Language; 
  34.  
  35.    function From_Object (Object : System.Address) return Pango_Language; 
  36.    function From_Object_Free (B : access Pango_Language'Class) return Pango_Language; 
  37.    pragma Inline (From_Object_Free, From_Object); 
  38.  
  39.    type Pango_Script is ( 
  40.       Pango_Script_Invalid_Code, 
  41.       Pango_Script_Common, 
  42.       Pango_Script_Inherited, 
  43.       Pango_Script_Arabic, 
  44.       Pango_Script_Armenian, 
  45.       Pango_Script_Bengali, 
  46.       Pango_Script_Bopomofo, 
  47.       Pango_Script_Cherokee, 
  48.       Pango_Script_Coptic, 
  49.       Pango_Script_Cyrillic, 
  50.       Pango_Script_Deseret, 
  51.       Pango_Script_Devanagari, 
  52.       Pango_Script_Ethiopic, 
  53.       Pango_Script_Georgian, 
  54.       Pango_Script_Gothic, 
  55.       Pango_Script_Greek, 
  56.       Pango_Script_Gujarati, 
  57.       Pango_Script_Gurmukhi, 
  58.       Pango_Script_Han, 
  59.       Pango_Script_Hangul, 
  60.       Pango_Script_Hebrew, 
  61.       Pango_Script_Hiragana, 
  62.       Pango_Script_Kannada, 
  63.       Pango_Script_Katakana, 
  64.       Pango_Script_Khmer, 
  65.       Pango_Script_Lao, 
  66.       Pango_Script_Latin, 
  67.       Pango_Script_Malayalam, 
  68.       Pango_Script_Mongolian, 
  69.       Pango_Script_Myanmar, 
  70.       Pango_Script_Ogham, 
  71.       Pango_Script_Old_Italic, 
  72.       Pango_Script_Oriya, 
  73.       Pango_Script_Runic, 
  74.       Pango_Script_Sinhala, 
  75.       Pango_Script_Syriac, 
  76.       Pango_Script_Tamil, 
  77.       Pango_Script_Telugu, 
  78.       Pango_Script_Thaana, 
  79.       Pango_Script_Thai, 
  80.       Pango_Script_Tibetan, 
  81.       Pango_Script_Canadian_Aboriginal, 
  82.       Pango_Script_Yi, 
  83.       Pango_Script_Tagalog, 
  84.       Pango_Script_Hanunoo, 
  85.       Pango_Script_Buhid, 
  86.       Pango_Script_Tagbanwa, 
  87.       Pango_Script_Braille, 
  88.       Pango_Script_Cypriot, 
  89.       Pango_Script_Limbu, 
  90.       Pango_Script_Osmanya, 
  91.       Pango_Script_Shavian, 
  92.       Pango_Script_Linear_B, 
  93.       Pango_Script_Tai_Le, 
  94.       Pango_Script_Ugaritic, 
  95.       Pango_Script_New_Tai_Lue, 
  96.       Pango_Script_Buginese, 
  97.       Pango_Script_Glagolitic, 
  98.       Pango_Script_Tifinagh, 
  99.       Pango_Script_Syloti_Nagri, 
  100.       Pango_Script_Old_Persian, 
  101.       Pango_Script_Kharoshthi, 
  102.       Pango_Script_Unknown, 
  103.       Pango_Script_Balinese, 
  104.       Pango_Script_Cuneiform, 
  105.       Pango_Script_Phoenician, 
  106.       Pango_Script_Phags_Pa, 
  107.       Pango_Script_Nko, 
  108.       Pango_Script_Kayah_Li, 
  109.       Pango_Script_Lepcha, 
  110.       Pango_Script_Rejang, 
  111.       Pango_Script_Sundanese, 
  112.       Pango_Script_Saurashtra, 
  113.       Pango_Script_Cham, 
  114.       Pango_Script_Ol_Chiki, 
  115.       Pango_Script_Vai, 
  116.       Pango_Script_Carian, 
  117.       Pango_Script_Lycian, 
  118.       Pango_Script_Lydian, 
  119.       Pango_Script_Batak, 
  120.       Pango_Script_Brahmi, 
  121.       Pango_Script_Mandaic, 
  122.       Pango_Script_Chakma, 
  123.       Pango_Script_Meroitic_Cursive, 
  124.       Pango_Script_Meroitic_Hieroglyphs, 
  125.       Pango_Script_Miao, 
  126.       Pango_Script_Sharada, 
  127.       Pango_Script_Sora_Sompeng, 
  128.       Pango_Script_Takri); 
  129.    pragma Convention (C, Pango_Script); 
  130.  
  131.  
  132.    for Pango_Script use ( 
  133.       Pango_Script_Invalid_Code => -1, 
  134.       Pango_Script_Common => 0, 
  135.       Pango_Script_Inherited => 1, 
  136.       Pango_Script_Arabic => 2, 
  137.       Pango_Script_Armenian => 3, 
  138.       Pango_Script_Bengali => 4, 
  139.       Pango_Script_Bopomofo => 5, 
  140.       Pango_Script_Cherokee => 6, 
  141.       Pango_Script_Coptic => 7, 
  142.       Pango_Script_Cyrillic => 8, 
  143.       Pango_Script_Deseret => 9, 
  144.       Pango_Script_Devanagari => 10, 
  145.       Pango_Script_Ethiopic => 11, 
  146.       Pango_Script_Georgian => 12, 
  147.       Pango_Script_Gothic => 13, 
  148.       Pango_Script_Greek => 14, 
  149.       Pango_Script_Gujarati => 15, 
  150.       Pango_Script_Gurmukhi => 16, 
  151.       Pango_Script_Han => 17, 
  152.       Pango_Script_Hangul => 18, 
  153.       Pango_Script_Hebrew => 19, 
  154.       Pango_Script_Hiragana => 20, 
  155.       Pango_Script_Kannada => 21, 
  156.       Pango_Script_Katakana => 22, 
  157.       Pango_Script_Khmer => 23, 
  158.       Pango_Script_Lao => 24, 
  159.       Pango_Script_Latin => 25, 
  160.       Pango_Script_Malayalam => 26, 
  161.       Pango_Script_Mongolian => 27, 
  162.       Pango_Script_Myanmar => 28, 
  163.       Pango_Script_Ogham => 29, 
  164.       Pango_Script_Old_Italic => 30, 
  165.       Pango_Script_Oriya => 31, 
  166.       Pango_Script_Runic => 32, 
  167.       Pango_Script_Sinhala => 33, 
  168.       Pango_Script_Syriac => 34, 
  169.       Pango_Script_Tamil => 35, 
  170.       Pango_Script_Telugu => 36, 
  171.       Pango_Script_Thaana => 37, 
  172.       Pango_Script_Thai => 38, 
  173.       Pango_Script_Tibetan => 39, 
  174.       Pango_Script_Canadian_Aboriginal => 40, 
  175.       Pango_Script_Yi => 41, 
  176.       Pango_Script_Tagalog => 42, 
  177.       Pango_Script_Hanunoo => 43, 
  178.       Pango_Script_Buhid => 44, 
  179.       Pango_Script_Tagbanwa => 45, 
  180.       Pango_Script_Braille => 46, 
  181.       Pango_Script_Cypriot => 47, 
  182.       Pango_Script_Limbu => 48, 
  183.       Pango_Script_Osmanya => 49, 
  184.       Pango_Script_Shavian => 50, 
  185.       Pango_Script_Linear_B => 51, 
  186.       Pango_Script_Tai_Le => 52, 
  187.       Pango_Script_Ugaritic => 53, 
  188.       Pango_Script_New_Tai_Lue => 54, 
  189.       Pango_Script_Buginese => 55, 
  190.       Pango_Script_Glagolitic => 56, 
  191.       Pango_Script_Tifinagh => 57, 
  192.       Pango_Script_Syloti_Nagri => 58, 
  193.       Pango_Script_Old_Persian => 59, 
  194.       Pango_Script_Kharoshthi => 60, 
  195.       Pango_Script_Unknown => 61, 
  196.       Pango_Script_Balinese => 62, 
  197.       Pango_Script_Cuneiform => 63, 
  198.       Pango_Script_Phoenician => 64, 
  199.       Pango_Script_Phags_Pa => 65, 
  200.       Pango_Script_Nko => 66, 
  201.       Pango_Script_Kayah_Li => 67, 
  202.       Pango_Script_Lepcha => 68, 
  203.       Pango_Script_Rejang => 69, 
  204.       Pango_Script_Sundanese => 70, 
  205.       Pango_Script_Saurashtra => 71, 
  206.       Pango_Script_Cham => 72, 
  207.       Pango_Script_Ol_Chiki => 73, 
  208.       Pango_Script_Vai => 74, 
  209.       Pango_Script_Carian => 75, 
  210.       Pango_Script_Lycian => 76, 
  211.       Pango_Script_Lydian => 77, 
  212.       Pango_Script_Batak => 78, 
  213.       Pango_Script_Brahmi => 79, 
  214.       Pango_Script_Mandaic => 80, 
  215.       Pango_Script_Chakma => 81, 
  216.       Pango_Script_Meroitic_Cursive => 82, 
  217.       Pango_Script_Meroitic_Hieroglyphs => 83, 
  218.       Pango_Script_Miao => 84, 
  219.       Pango_Script_Sharada => 85, 
  220.       Pango_Script_Sora_Sompeng => 86, 
  221.       Pango_Script_Takri => 87); 
  222.  
  223.    type Pango_Script_Array is array (Natural range <>) of Pango_Script; 
  224.  
  225.    ---------------------------- 
  226.    -- Enumeration Properties -- 
  227.    ---------------------------- 
  228.  
  229.    package Pango_Script_Properties is 
  230.       new Generic_Internal_Discrete_Property (Pango_Script); 
  231.    type Property_Pango_Script is new Pango_Script_Properties.Property; 
  232.  
  233.    ------------------ 
  234.    -- Constructors -- 
  235.    ------------------ 
  236.  
  237.    function Get_Type return Glib.GType; 
  238.    pragma Import (C, Get_Type, "pango_language_get_type"); 
  239.  
  240.    ------------- 
  241.    -- Methods -- 
  242.    ------------- 
  243.  
  244.    function Get_Sample_String (Self : Pango_Language) return UTF8_String; 
  245.    --  Get a string that is representative of the characters needed to render 
  246.    --  a particular language. 
  247.    --  The sample text may be a pangram, but is not necessarily. It is chosen 
  248.    --  to be demonstrative of normal text in the language, as well as exposing 
  249.    --  font feature requirements unique to the language. It is suitable for use 
  250.    --  as sample text in a font selection dialog. 
  251.    --  If Language is null, the default language as found by 
  252.    --  Pango.Language.Get_Default is used. 
  253.    --  If Pango does not have a sample string for Language, the classic "The 
  254.    --  quick brown fox..." is returned. This can be detected by comparing the 
  255.    --  returned pointer value to that returned for (non-existent) language code 
  256.    --  "xx". That is, compare to: 
  257.    --    pango_language_get_sample_string (pango_language_from_string ("xx")) 
  258.  
  259.    function Get_Scripts (Self : Pango_Language) return Pango_Script_Array; 
  260.    --  Determines the scripts used to to write Language. If nothing is known 
  261.    --  about the language tag Language, or if Language is null, then null is 
  262.    --  returned. The list of scripts returned starts with the script that the 
  263.    --  language uses most and continues to the one it uses least. 
  264.    --  The value Num_Script points at will be set to the number of scripts in 
  265.    --  the returned array (or zero if null is returned). 
  266.    --  Most languages use only one script for writing, but there are some that 
  267.    --  use two (Latin and Cyrillic for example), and a few use three (Japanese 
  268.    --  for example). Applications should not make any assumptions on the 
  269.    --  maximum number of scripts returned though, except that it is positive if 
  270.    --  the return value is not null, and it is a small number. 
  271.    --  The Pango.Language.Includes_Script function uses this function 
  272.    --  internally. 
  273.    --  Since: gtk+ 1.22 
  274.  
  275.    function Includes_Script 
  276.       (Self   : Pango_Language; 
  277.        Script : Pango_Script) return Boolean; 
  278.    --  Determines if Script is one of the scripts used to write Language. The 
  279.    --  returned value is conservative; if nothing is known about the language 
  280.    --  tag Language, True will be returned, since, as far as Pango knows, 
  281.    --  Script might be used to write Language. 
  282.    --  This routine is used in Pango's itemization process when determining if 
  283.    --  a supplied language tag is relevant to a particular section of text. It 
  284.    --  probably is not useful for applications in most circumstances. 
  285.    --  This function uses Pango.Language.Get_Scripts internally. 
  286.    --  Since: gtk+ 1.4 
  287.    --  "script": a Pango.Language.Pango_Script 
  288.  
  289.    function Matches 
  290.       (Self       : Pango_Language; 
  291.        Range_List : UTF8_String) return Boolean; 
  292.    --  Checks if a language tag matches one of the elements in a list of 
  293.    --  language ranges. A language tag is considered to match a range in the 
  294.    --  list if the range is '*', the range is exactly the tag, or the range is 
  295.    --  a prefix of the tag, and the character after it in the tag is '-'. 
  296.    --  "range_list": a list of language ranges, separated by ';', ':', ',', or 
  297.    --  space characters. Each element must either be '*', or a RFC 3066 
  298.    --  language range canonicalized as by Pango.Language.From_String 
  299.  
  300.    function To_String (Self : Pango_Language) return UTF8_String; 
  301.    --  Gets the RFC-3066 format string representing the given language tag. 
  302.  
  303.    --------------- 
  304.    -- Functions -- 
  305.    --------------- 
  306.  
  307.    function From_String (Language : UTF8_String := "") return Pango_Language; 
  308.    --  Take a RFC-3066 format language tag as a string and convert it to a 
  309.    --  Pango.Language.Pango_Language pointer that can be efficiently copied 
  310.    --  (copy the pointer) and compared with other language tags (compare the 
  311.    --  pointer.) 
  312.    --  This function first canonicalizes the string by converting it to 
  313.    --  lowercase, mapping '_' to '-', and stripping all characters other than 
  314.    --  letters and '-'. 
  315.    --  Use Pango.Language.Get_Default if you want to get the 
  316.    --  Pango.Language.Pango_Language for the current locale of the process. 
  317.    --  "language": a string representing a language tag, or null 
  318.  
  319.    function Get_Default return Pango_Language; 
  320.    --  Returns the Pango.Language.Pango_Language for the current locale of the 
  321.    --  process. Note that this can change over the life of an application. 
  322.    --  On Unix systems, this is the return value is derived from 
  323.    --  'setlocale(LC_CTYPE, NULL)', and the user can affect this through the 
  324.    --  environment variables LC_ALL, LC_CTYPE or LANG (checked in that order). 
  325.    --  The locale string typically is in the form lang_COUNTRY, where lang is 
  326.    --  an ISO-639 language code, and COUNTRY is an ISO-3166 country code. For 
  327.    --  instance, sv_FI for Swedish as written in Finland or pt_BR for 
  328.    --  Portuguese as written in Brazil. 
  329.    --  On Windows, the C library does not use any such environment variables, 
  330.    --  and setting them won't affect the behavior of functions like ctime. The 
  331.    --  user sets the locale through the Regional Options in the Control Panel. 
  332.    --  The C library (in the setlocale function) does not use country and 
  333.    --  language codes, but country and language names spelled out in English. 
  334.    --  However, this function does check the above environment variables, and 
  335.    --  does return a Unix-style locale string based on either said environment 
  336.    --  variables or the thread's current locale. 
  337.    --  Your application should call 'setlocale(LC_ALL, "");' for the user 
  338.    --  settings to take effect. Gtk+ does this in its initialization functions 
  339.    --  automatically (by calling gtk_set_locale). See 'man setlocale' for more 
  340.    --  details. 
  341.    --  Since: gtk+ 1.16 
  342.  
  343. private 
  344.  
  345.    Null_Pango_Language : constant Pango_Language := (Glib.C_Boxed with null record); 
  346.  
  347. end Pango.Language;