1 /*
2 * Distributed under the Boost Software License, Version 1.0.
3 * (See accompanying file LICENSE_1_0.txt or copy at
4 * http://www.boost.org/LICENSE_1_0.txt)
5 */6 modulepango.coverage;
7 8 importpango.utils;
9 importpango.c.coverage;
10 11 importglib;
12 13 14 /**
15 * CoverageLevel:
16 * None: The character is not representable with the font.
17 * Fallback: The character is represented in a way that may be
18 * comprehensible but is not the correct graphical form.
19 * For instance, a Hangul character represented as a
20 * a sequence of Jamos, or a Latin transliteration of a Cyrillic word.
21 * Approximate: The character is represented as basically the correct
22 * graphical form, but with a stylistic variant inappropriate for
23 * the current script.
24 * Exact: The character is represented as the correct graphical form.
25 *
26 * Used to indicate how well a font can represent a particular Unicode
27 * character point for a particular script.
28 */29 enumCoverageLevel {
30 None = PangoCoverageLevel.PANGO_COVERAGE_NONE,
31 Fallback = PangoCoverageLevel.PANGO_COVERAGE_FALLBACK,
32 Approximate = PangoCoverageLevel.PANGO_COVERAGE_APPROXIMATE,
33 Exact = PangoCoverageLevel.PANGO_COVERAGE_EXACT34 }
35 36 /**
37 * PangoCoverage:
38 *
39 * The #PangoCoverage structure represents a map from Unicode characters
40 * to #PangoCoverageLevel. It is an opaque structure with no public fields.
41 */42 structCoverage43 {
44 mixinRefCountedGObj!(PangoCoverage, "pango_coverage");
45 46 47 staticCoveragecreate() {
48 returnCoverage(pango_coverage_new(), Transfer.Full);
49 }
50 51 packagethis(PangoCoverage *ptr, Transfertransfer)
52 {
53 initialize(ptr, transfer);
54 }
55 56 this(ubyte[] bytes)
57 {
58 initialize(pango_coverage_from_bytes (bytes.ptr, cast(int)bytes.length), Transfer.Full);
59 }
60 61 Coveragecopy()
62 {
63 returnCoverage(pango_coverage_copy(nativePtr), Transfer.Full);
64 }
65 66 67 CoverageLevelget(intindex)
68 {
69 returncast(CoverageLevel)pango_coverage_get(nativePtr, index);
70 }
71 72 voidset(intindex, CoverageLevellevel)
73 {
74 pango_coverage_set(nativePtr, index, level);
75 }
76 77 voidmax (Coverageother)
78 {
79 pango_coverage_max(nativePtr, other.nativePtr);
80 }
81 82 ubyte[] toBytes()
83 {
84 ubyte *arr;
85 intn_bytes;
86 pango_coverage_to_bytes(nativePtr, &arr, &n_bytes);
87 scope(exit) g_free(arr);
88 89 if (!n_bytes) return [];
90 91 ubyte[] res = newubyte[n_bytes];
92 foreach(i; 0 .. n_bytes) {
93 res[i] = arr[i];
94 }
95 returnres;
96 }
97 }