-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathuHarfBuzz.pas
3152 lines (2713 loc) · 136 KB
/
uHarfBuzz.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Translation of the HarfBuzz interface into Delphi Language/Object Pascal
// Based on version 2.9.0
// This header file is Copyright (C) 2021 by Benjamin Desef
// You may use it under the same conditions as HarfBuzz itself, i.e., the "Old MIT"
// license.
// The original HarfBuzz copyright header is
// Copyright © 2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020 Google, Inc.
// Copyright © 2018,2019,2020 Ebrahim Byagowi
// Copyright © 2019,2020 Facebook, Inc.
// Copyright © 2012 Mozilla Foundation
// Copyright © 2011 Codethink Limited
// Copyright © 2008,2010 Nokia Corporation and/or its subsidiary(-ies)
// Copyright © 2009 Keith Stribley
// Copyright © 2009 Martin Hosken and SIL International
// Copyright © 2007 Chris Wilson
// Copyright © 2006 Behdad Esfahbod
// Copyright © 2005 David Turner
// Copyright © 2004,2007,2008,2009,2010 Red Hat, Inc.
// Copyright © 1998-2004 David Turner and Werner Lemberg
//
// Permission is hereby granted, without written agreement and without
// license or royalty fees, to use, copy, modify, and distribute this
// software and its documentation for any purpose, provided that the
// above copyright notice and the following two paragraphs appear in
// all copies of this software.
//
// IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
// DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
// IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
// THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
// BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
// ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
// PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
{$Z4}
Unit uHarfBuzz;
Interface
{$IFDEF FPC}
{$MODE Delphi}
{$MESSAGE FATAL 'Replace every instance of "[Ref] Const" in this file by "Constref", then disable this error.'}
{$ENDIF}
Uses SysUtils{$IFNDEF VER230}, AnsiStrings{$ENDIF}, uFreeType;
Const
HarfbuzzDLL = 'harfbuzz.dll';
Type
EHarfBuzz = Class(Exception)
End;
{$REGION 'hb-common.h'}
THBBool = Type LongBool;
PHBCodepoint = ^THBCodepoint;
THBCodepoint = Type Cardinal;
PHBPosition = ^THBPosition;
THBPosition = Type Integer;
THBMask = Type Cardinal;
THBVarInt = Packed Record
Case Byte Of
0:
(u32: Cardinal);
1:
(i32: Integer);
2:
(u16: Packed Array [0 .. 1] Of Word);
3:
(i16: Packed Array [0 .. 1] Of SmallInt);
4:
(u8: Packed Array [0 .. 3] Of Byte);
5:
(i8: Packed Array [0 .. 3] Of ShortInt);
End;
PHBTag = ^THBTag;
THBTag = Type Cardinal;
THBTagHelper = Record Helper For THBTag
Public Type
THBTagString = String[4];
Public Const
None = THBTag($00000000);
Max = THBTag($FFFFFFFF);
MaxSigned = THBTag($7FFFFFFF);
Public
Class Function FromString(Const AStr: AnsiString): THBTag; Static; Inline;
Function ToString: THBTagString; Inline;
End;
Type
THBDirection = (hbdInvalid = 0, hbdLTR = 4, hbdRTL, hbdTTB, hbdBTT);
THBDirectionHelper = Record Helper For THBDirection
Public Type
THBDirectionString = String[7]; // at most "invalid"
Public
Class Function FromString(Const AStr: AnsiString): THBDirection; Static; Inline;
Function ToString: THBDirectionString; Inline;
Function IsValid: Boolean; Inline;
Function IsHorizontal: Boolean; Inline;
Function IsVertical: Boolean; Inline;
Function IsForward: Boolean; Inline;
Function IsBackward: Boolean; Inline;
Function Reverse: THBDirection; Inline;
End;
THBLanguage = Record
Strict Private
FValue: Pointer;
// internal type
Public
Class Function FromString(Const AStr: AnsiString): THBLanguage; Static; Inline;
Function ToString: AnsiString; Inline;
Class Function Default: THBLanguage; Static; Inline;
Class Operator Implicit(Const AValue: AnsiString): THBLanguage; Inline;
Class Operator Implicit(Const AValue: THBLanguage): AnsiString; Inline;
End;
THBLanguageHelper = Record Helper For THBLanguage
Public Const
Invalid: THBLanguage = (FValue: NIL);
End;
THBScript = (hbsCommon = $5A797979 { Zyyy } , // 1.1
hbsInherited = $5A696E68 { Zinh } , // 1.1
hbsUnknown = $5A7A7A7A { Zzzz } , // 5.0
hbsArabic = $41726162 { Arab } , // 1.1
hbsArmenian = $41726D6E { Armn } , // 1.1
hbsBengali = $42656E67 { Beng } , // 1.1
hbsCyrillic = $4379726C { Cyrl } , // 1.1
hbsDevanagari = $44657661 { Deva } , // 1.1
hbsGeorgian = $47656F72 { Geor } , // 1.1
hbsGreek = $4772656B { Grek } , // 1.1
hbsGujarati = $47756A72 { Gujr } , // 1.1
hbsGurmukhi = $47757275 { Guru } , // 1.1
hbsHangul = $48616E67 { Hang } , // 1.1
hbsHan = $48616E69 { Hani } , // 1.1
hbsHebrew = $48656272 { Hebr } , // 1.1
hbsHiragana = $48697261 { Hira } , // 1.1
hbsKannada = $4B6E6461 { Knda } , // 1.1
hbsKatakana = $4B616E61 { Kana } , // 1.1
hbsLao = $4C616F6F { Laoo } , // 1.1
hbsLatin = $4C61746E { Latn } , // 1.1
hbsMalayalam = $4D6C796D { Mlym } , // 1.1
hbsOriya = $4F727961 { Orya } , // 1.1
hbsTamil = $54616D6C { Taml } , // 1.1
hbsTelugu = $54656C75 { Telu } , // 1.1
hbsThai = $54686169 { Thai } , // 1.1
hbsTibetan = $54696274 { Tibt } , // 2.0
hbsBopomofo = $426F706F { Bopo } , // 3.0
hbsBraille = $42726169 { Brai } , // 3.0
hbsCanadianSyllabics = $43616E73 { Cans } , // 3.0
hbsCherokee = $43686572 { Cher } , // 3.0
hbsEthiopic = $45746869 { Ethi } , // 3.0
hbsKhmer = $4B686D72 { Khmr } , // 3.0
hbsMongolian = $4D6F6E67 { Mong } , // 3.0
hbsMyanmar = $4D796D72 { Mymr } , // 3.0
hbsOgham = $4F67616D { Ogam } , // 3.0
hbsRunic = $52756E72 { Runr } , // 3.0
hbsSinhala = $53696E68 { Sinh } , // 3.0
hbsSyriac = $53797263 { Syrc } , // 3.0
hbsThaana = $54686161 { Thaa } , // 3.0
hbsYi = $59696969 { Yiii } , // 3.0
hbsDeseret = $44737274 { Dsrt } , // 3.1
hbsGothic = $476F7468 { Goth } , // 3.1
hbsOldItalic = $4974616C { Ital } , // 3.1
hbsBuhid = $42756864 { Buhd } , // 3.2
hbsHanunoo = $48616E6F { Hano } , // 3.2
hbsTagalog = $54676C67 { Tglg } , // 3.2
hbsTagbanwa = $54616762 { Tagb } , // 3.2
hbsCypriot = $43707274 { Cprt } , // 4.0
hbsLimbu = $4C696D62 { Limb } , // 4.0
hbsLinearB = $4C696E62 { Linb } , // 4.0
hbsOsmanya = $4F736D61 { Osma } , // 4.0
hbsShavian = $53686177 { Shaw } , // 4.0
hbsTaiLe = $54616C65 { Tale } , // 4.0
hbsUgaritic = $55676172 { Ugar } , // 4.0
hbsBuginese = $42756769 { Bugi } , // 4.1
hbsCoptic = $436F7074 { Copt } , // 4.1
hbsGlagolitic = $476C6167 { Glag } , // 4.1
hbsKharoshthi = $4B686172 { Khar } , // 4.1
hbsNewTaiLue = $54616C75 { Talu } , // 4.1
hbsOldPersian = $5870656F { Xpeo } , // 4.1
hbsSylotiNagri = $53796C6F { Sylo } , // 4.1
hbsTifinagh = $54666E67 { Tfng } , // 4.1
hbsBalinese = $42616C69 { Bali } , // 5.0
hbsCuneiform = $58737578 { Xsux } , // 5.0
hbsNko = $4E6B6F6F { Nkoo } , // 5.0
hbsPhagsPa = $50686167 { Phag } , // 5.0
hbsPhoenician = $50686E78 { Phnx } , // 5.0
hbsCarian = $43617269 { Cari } , // 5.1
hbsCham = $4368616D { Cham } , // 5.1
hbsKayahLi = $4B616C69 { Kali } , // 5.1
hbsLepcha = $4C657063 { Lepc } , // 5.1
hbsLycian = $4C796369 { Lyci } , // 5.1
hbsLydian = $4C796469 { Lydi } , // 5.1
hbsOlChiki = $4F6C636B { Olck } , // 5.1
hbsRejang = $526A6E67 { Rjng } , // 5.1
hbsSaurashtra = $53617572 { Saur } , // 5.1
hbsSundanese = $53756E64 { Sund } , // 5.1
hbsVai = $56616969 { Vaii } , // 5.1
hbsAvestan = $41767374 { Avst } , // 5.2
hbsBamum = $42616D75 { Bamu } , // 5.2
hbsEgyptianHieroglyphs = $45677970 { Egyp } , // 5.2
hbsImperialAramaic = $41726D69 { Armi } , // 5.2
hbsInscriptionalPahlavi = $50686C69 { Phli } , // 5.2
hbsInscriptionalParthian = $50727469 { Prti } , // 5.2
hbsJavanese = $4A617661 { Java } , // 5.2
hbsKaithi = $4B746869 { Kthi } , // 5.2
hbsLisu = $4C697375 { Lisu } , // 5.2
hbsMeeteiMayek = $4D746569 { Mtei } , // 5.2
hbsOldSouthArabian = $53617262 { Sarb } , // 5.2
hbsOldTurkic = $4F726B68 { Orkh } , // 5.2
hbsSamaritan = $53616D72 { Samr } , // 5.2
hbsTaiTham = $4C616E61 { Lana } , // 5.2
hbsTaiViet = $54617674 { Tavt } , // 5.2
hbsBatak = $4261746B { Batk } , // 6.0
hbsBrahmi = $42726168 { Brah } , // 6.0
hbsMandaic = $4D616E64 { Mand } , // 6.0
hbsChakma = $43616B6D { Cakm } , // 6.1
hbsMeroiticCursive = $4D657263 { Merc } , // 6.1
hbsMeroiticHieroglyphs = $4D65726F { Mero } , // 6.1
hbsMiao = $506C7264 { Plrd } , // 6.1
hbsSharada = $53687264 { Shrd } , // 6.1
hbsSoraSompeng = $536F7261 { Sora } , // 6.1
hbsTakri = $54616B72 { Takr } , // 6.1
// Since: 0.9.30
hbsBassaVah = $42617373 { Bass } , // 7.0
hbsCaucasianAlbanian = $41676862 { Aghb } , // 7.0
hbsDuployan = $4475706C { Dupl } , // 7.0
hbsElbasan = $456C6261 { Elba } , // 7.0
hbsGrantha = $4772616E { Gran } , // 7.0
hbsKhojki = $4B686F6A { Khoj } , // 7.0
hbsKhudawadi = $53696E64 { Sind } , // 7.0
hbsLinearA = $4C696E61 { Lina } , // 7.0
hbsMahajani = $4D61686A { Mahj } , // 7.0
hbsManichaean = $4D616E69 { Mani } , // 7.0
hbsMendeKikakui = $4D656E64 { Mend } , // 7.0
hbsModi = $4D6F6469 { Modi } , // 7.0
hbsMro = $4D726F6F { Mroo } , // 7.0
hbsNabataean = $4E626174 { Nbat } , // 7.0
hbsOldNorthArabian = $4E617262 { Narb } , // 7.0
hbsOldPermic = $5065726D { Perm } , // 7.0
hbsPahawhHmong = $486D6E67 { Hmng } , // 7.0
hbsPalmyrene = $50616C6D { Palm } , // 7.0
hbsPauCinHau = $50617563 { Pauc } , // 7.0
hbsPsalterPahlavi = $50686C70 { Phlp } , // 7.0
hbsSiddham = $53696464 { Sidd } , // 7.0
hbsTirhuta = $54697268 { Tirh } , // 7.0
hbsWarangCiti = $57617261 { Wara } , // 7.0
hbsAhom = $41686F6D { Ahom } , // 8.0
hbsAnatolianHieroglyphs = $486C7577 { Hluw } , // 8.0
hbsHatran = $48617472 { Hatr } , // 8.0
hbsMultani = $4D756C74 { Mult } , // 8.0
hbsOldHungarian = $48756E67 { Hung } , // 8.0
hbsSignwriting = $53676E77 { Sgnw } , // 8.0
// Since 1.3.0
hbsAdlam = $41646C6D { Adlm } , // 9.0
hbsBhaiksuki = $42686B73 { Bhks } , // 9.0
hbsMarchen = $4D617263 { Marc } , // 9.0
hbsOsage = $4F736765 { Osge } , // 9.0
hbsTangut = $54616E67 { Tang } , // 9.0
hbsNewa = $4E657761 { Newa } , // 9.0
// Since 1.6.0
hbsMasaramGondi = $476F6E6D { Gonm } , // 10.0
hbsNushu = $4E736875 { Nshu } , // 10.0
hbsSoyombo = $536F796F { Soyo } , // 10.0
hbsZanabazarSquare = $5A616E62 { Zanb } , // 10.0
// Since 1.8.0
hbsDogra = $446F6772 { Dogr } , // 11.0
hbsGunjalaGondi = $476F6E67 { Gong } , // 11.0
hbsHanifiRohingya = $526F6867 { Rohg } , // 11.0
hbsMakasar = $4D616B61 { Maka } , // 11.0
hbsMedefaidrin = $4D656466 { Medf } , // 11.0
hbsOldSogdian = $536F676F { Sogo } , // 11.0
hbsSogdian = $536F6764 { Sogd } , // 11.0
// Since 2.4.0
hbsElymaic = $456C796D { Elym } , // 12.0
hbsNandinagari = $4E616E64 { Nand } , // 12.0
hbsNyiakengPuachueHmong = $486D6E70 { Hmnp } , // 12.0
hbsWancho = $5763686F { Wcho } , // 12.0
// Since 2.6.7
hbsChorasmian = $43687273 { Chrs } , // 13.0
hbsDivesAkuru = $4469616B { Diak } , // 13.0
hbsKhitanSmallScript = $4B697473 { Kits } , // 13.0
hbsYezidi = $59657A69 { Yezi } , // 13.0
// No script set.
hbsInvalid = THBTag.None);
THBScriptHelper = Record Helper For THBScript
Public
Class Function FromISO15924(Const ATag: THBTag): THBScript; Static; Inline;
Class Function FromString(Const AStr: AnsiString): THBScript; Static; Inline;
Function ToISO15924: THBTag; Inline;
Function GetHorizontalDirection: THBDirection; Inline;
End;
THBDestroyFunc = Procedure(UserData: Pointer); Cdecl;
PHBFeature = ^THBFeature;
THBFeature = Record
Strict Private
Const
sInvalidFeatureString = 'Invalid feature string: %s';
Public
Tag: THBTag;
Value, Start, &End: Cardinal;
Public Const
cGlobalStart = 0;
cGlobalEnd = Cardinal( -1);
Public
Class Function FromString(Const AStr: AnsiString): THBFeature; Static; Inline;
Function ToString: AnsiString; Inline;
End;
PHBVariation = ^THBVariation;
THBVariation = Record
Strict Private
Const
sInvalidVariationString = 'Invalid variation string: %s';
Public
Tag: THBTag;
Value: Single;
Class Function FromString(Const AStr: AnsiString): THBVariation; Static; Inline;
Function ToString: AnsiString; Inline;
End;
THBColor = Record
Strict Private
FValue: Packed Array [0 .. 3] Of Byte;
Public
Constructor Mix(Const B, G, R, A: Byte);
Property Alpha: Byte Read FValue[0] Write FValue[0];
Property Red: Byte Read FValue[1] Write FValue[1];
Property Green: Byte Read FValue[2] Write FValue[2];
Property Blue: Byte Read FValue[3] Write FValue[3];
End;
{$ENDREGION}
{$REGION 'hb-blob.h'}
THBMemoryMode = (hbmmDuplicate, hbmmReadonly, hbmmWritable, hbmmReadonlyMayMakeWritable);
THBBlob = Record
Strict Private
{$HINTS OFF}
FValue: Pointer;
{$HINTS ON}
// internal type
Strict Private
Const
sErrorUserData = 'Error setting blob user data';
sCreationFailed = 'Blob creation failed';
Public
Class Function Create(Const AData: TBytes; Const AMode: THBMemoryMode; Const AUserData: Pointer; Const ADestroy: THBDestroyFunc; Const AFailOnError: Boolean = False): THBBlob; Overload;
Static; Inline;
Class Function Create(Const AFileName: AnsiString; Const AFailOnError: Boolean = False): THBBlob; Overload; Static; Inline;
Function CreateSubBlob(Const AOffset, ALength: Integer): THBBlob; Inline;
Function CopyWritable: THBBlob; Inline;
Class Function GetEmpty: THBBlob; Static; Inline;
Function Reference: THBBlob; Inline;
Procedure Destroy; Inline;
Procedure SetUserData(Const AKey; Const AData: Pointer; Const ADestroy: THBDestroyFunc; Const AReplace: Boolean); Inline;
Function GetUserData(Const AKey): Pointer; Inline;
Procedure MakeImmutable; Inline;
Function IsImmutable: Boolean; Inline;
Function GetLength: Cardinal; Inline;
Function GetData(Out OLength: Cardinal): PByte; Inline;
Function GetDataWritable(Out OLength: Cardinal): PByte; Inline;
Function GetFaceCount: Cardinal; Inline;
End;
{$ENDREGION}
{$REGION 'hb-unicode.h'}
Const
cHBUnicodeMax = Cardinal($10FFFF);
Type
THBUnicodeGeneralCategory = ( //
hbugcControl, // Cc
hbugcFormat, // Cf
hbugcUnassigned, // Cn
hbugcPrivateUse, // Co
hbugcSurrogate, // Cs
hbugcLowercaseLetter, // Ll
hbugcModifierLetter, // Lm
hbugcOtherLetter, // Lo
hbugcTitlecaseLetter, // Lt
hbugcUppercaseLetter, // Lu
hbugcSpacingMark, // Mc
hbugcEnclosingMark, // Me
hbugcNonSpacingMark, // Mn
hbugcDecimalNumber, // Nd
hbugcLetterNumber, // Nl
hbugcOtherNumber, // No
hbugcConnectPunctuation, // Pc
hbugcDashPunctuation, // Pd
hbugcClosePunctuation, // Pe
hbugcFinalPunctuation, // Pf
hbugcInitialPunctuation, // Pi
hbugcOtherPunctuation, // Po
hbugcOpenPunctuation, // Ps
hbugcCurrencySymbol, // Sc
hbugcModifierSymbol, // Sk
hbugcMathSymbol, // Sm
hbugcOtherSymbol, // So
hbugcLineSeparator, // Zl
hbugcParagraphSeparator, // Zp
hbugcSpaceSeparator // Zs
);
THBUnicodeCombiningClass = ( //
hbuccNotReordered = 0, hbuccOverlay = 1, hbuccNukta = 7, hbuccKanaVoicing = 8, hbuccVirama = 9,
// Hebrew
hbuccCcc10 = 10, hbuccCcc11 = 11, hbuccCcc12 = 12, hbuccCcc13 = 13, hbuccCcc14 = 14, hbuccCcc15 = 15, hbuccCcc16 = 16, hbuccCcc17 = 17, hbuccCcc18 = 18, hbuccCcc19 = 19, hbuccCcc20 = 20,
hbuccCcc21 = 21, hbuccCcc22 = 22, hbuccCcc23 = 23, hbuccCcc24 = 24, hbuccCcc25 = 25, hbuccCcc26 = 26,
// Arabic
hbuccCcc27 = 27, hbuccCcc28 = 28, hbuccCcc29 = 29, hbuccCcc30 = 30, hbuccCcc31 = 31, hbuccCcc32 = 32, hbuccCcc33 = 33, hbuccCcc34 = 34, hbuccCcc35 = 35,
// Syriac
hbuccCcc36 = 36,
// Telugu
hbuccCcc84 = 84, hbuccCcc91 = 91,
// Thai
hbuccCcc103 = 103, hbuccCcc107 = 107,
// Lao
hbuccCcc118 = 118, hbuccCcc122 = 122,
// Tibetan
hbuccCcc129 = 129, hbuccCcc130 = 130, hbuccCcc133 = 132,
hbuccAttachedBelowLeft = 200, hbuccAttachedBelow = 202, hbuccAttachedAbove = 214, hbuccAttachedAboveRight = 216, hbuccBelowLeft = 218, hbuccBelow = 220, hbuccBelowRight = 222, hbuccLeft = 224,
hbuccRight = 226, hbuccAboveLeft = 228, hbuccAbove = 230, hbuccAboveRight = 232, hbuccDoubleBelow = 233, hbuccDoubleAbove = 234,
hbuccIotaSubscript = 240,
hbuccInvalid = 255);
THBUnicodeFuncs = Record
Strict Private
FValue: Pointer;
// internal type
Public Type
THBUnicodeCombiningClassFunc = Function(Const uFuncs: THBUnicodeFuncs; Const AUnicode: THBCodepoint; Const AUserData: Pointer): THBUnicodeCombiningClass; Cdecl;
THBUnicodeGeneralCategoryFunc = Function(Const uFuncs: THBUnicodeFuncs; Const AUnicode: THBCodepoint; Const AUserData: Pointer): THBUnicodeGeneralCategory; Cdecl;
THBUnicodeMirroringFunc = Function(Const uFuncs: THBUnicodeFuncs; Const AUnicode: THBCodepoint; Const AUserData: Pointer): THBCodepoint; Cdecl;
THBUnicodeScriptFunc = Function(Const uFuncs: THBUnicodeFuncs; Const AUnicode: THBCodepoint; Const AUserData: Pointer): THBScript; Cdecl;
THBUnicodeComposeFunc = Function(Const uFuncs: THBUnicodeFuncs; Const A, B: THBCodepoint; Out AB: THBCodepoint; Const AUserData: Pointer): THBBool; Cdecl;
THBUnicodeDecomposeFunc = Function(Const uFuncs: THBUnicodeFuncs; Const AB: THBCodepoint; Out A, B: THBCodepoint; Const AUserData: Pointer): THBBool; Cdecl;
Public
Class Function GetDefault: THBUnicodeFuncs; Static; Inline;
Class Function Create(Parent: THBUnicodeFuncs): THBUnicodeFuncs; Overload; Static; Inline;
Class Function Create: THBUnicodeFuncs; Overload; Static; Inline;
Class Function GetEmpty: THBUnicodeFuncs; Static; Inline;
Function Reference: THBUnicodeFuncs; Inline;
Procedure Destroy; Inline;
Procedure SetUserData(Const AKey; Const AData: Pointer; Const ADestroy: THBDestroyFunc; Const AReplace: Boolean); Inline;
Function GetUserData(Const AKey): Pointer; Inline;
Procedure MakeImmutable; Inline;
Function IsImmutable: Boolean; Inline;
Function GetParent: THBUnicodeFuncs; Inline;
Procedure SetCombiningClassFunc(Const AFunc: THBUnicodeCombiningClassFunc; Const AUserData: Pointer; Const ADestroy: THBDestroyFunc); Inline;
Procedure SetGeneralCategoryFunc(Const AFunc: THBUnicodeGeneralCategoryFunc; Const AUserData: Pointer; Const ADestroy: THBDestroyFunc); Inline;
Procedure SetMirroringFunc(Const AFunc: THBUnicodeMirroringFunc; Const AUserData: Pointer; Const ADestroy: THBDestroyFunc); Inline;
Procedure SetScriptFunc(Const AFunc: THBUnicodeScriptFunc; Const AUserData: Pointer; Const ADestroy: THBDestroyFunc); Inline;
Procedure SetComposeFunc(Const AFunc: THBUnicodeComposeFunc; Const AUserData: Pointer; Const ADestroy: THBDestroyFunc); Inline;
Procedure SetDecomposeFunc(Const AFunc: THBUnicodeDecomposeFunc; Const AUserData: Pointer; Const ADestroy: THBDestroyFunc); Inline;
Function CombiningClass(Const AUnicode: THBCodepoint): THBUnicodeCombiningClass; Inline;
Function GeneralCategory(Const AUnicode: THBCodepoint): THBUnicodeGeneralCategory; Inline;
Function Mirroring(Const AUnicode: THBCodepoint): THBCodepoint; Inline;
Function Script(Const AUnicode: THBCodepoint): THBCodepoint; Inline;
Function Compose(Const A, B: THBCodepoint; Out AB: THBCodepoint): Boolean; Inline;
Function Decompose(Const AB: THBCodepoint; Out A, B: THBCodepoint): Boolean; Inline;
End;
THBUnicodeFuncsHelper = Record Helper For THBUnicodeFuncs
Public Const
cNIL: THBUnicodeFuncs = (FValue: NIL);
End;
{$ENDREGION}
{$REGION 'hb-set.h'}
THBSet = Record
Strict Private
{$HINTS OFF}
FValue: Pointer;
{$HINTS ON}
// internal type
Strict Private
Const
sErrorUserData = 'Error setting set user data';
Public Const
SetValueInvalid = THBCodepoint( -1);
Public
Class Function Create: THBSet; Static; Inline;
Class Function GetEmpty: THBSet; Static; Inline;
Function Reference: THBSet; Inline;
Procedure Destroy; Inline;
Procedure SetUserData(Const AKey; Const AData: Pointer; Const ADestroy: THBDestroyFunc; Const AReplace: Boolean); Inline;
Function GetUserData(Const AKey): Pointer; Inline;
Function AllocationSuccessful: Boolean; Inline;
Function Copy: THBSet; Inline;
Procedure Clear; Inline;
Function IsEmpty: Boolean; Inline;
Function Has(Const ACodepoint: THBCodepoint): Boolean; Inline;
Procedure Add(Const ACodepoint: THBCodepoint); Inline;
Procedure AddRange(Const AFirst, ALast: THBCodepoint); Inline;
Procedure Delete(Const ACodepoint: THBCodepoint); Inline;
Procedure DeleteRange(Const AFirst, ALast: THBCodepoint); Inline;
Function IsEqual(Const AOther: THBSet): Boolean; Inline;
Class Operator Equal(Const ASet, AOther: THBSet): Boolean; Inline;
Function IsSubset(Const ALargerSet: THBSet): Boolean; Inline;
Class Operator GreaterThanOrEqual(Const ASuperset, ASubset: THBSet): Boolean; Inline;
Class Operator LessThanOrEqual(Const ASubset, ASuperset: THBSet): Boolean; Inline;
Procedure Assign(Const AOther: THBSet); Inline;
Procedure Union(Const AOther: THBSet); Inline;
Procedure Intersect(Const AOther: THBSet); Inline;
Procedure Subtract(Const AOther: THBSet); Inline;
Procedure SymmetricDifference(Const AOther: THBSet); Inline;
Function Count: Cardinal; Inline;
Function Min: THBCodepoint; Inline;
Function Max: THBCodepoint; Inline;
Function Next(Var Codepoint: THBCodepoint): Boolean; Inline;
Function GetNext(Const ACodepoint: THBCodepoint): THBCodepoint; Inline;
Function Previous(Var Codepoint: THBCodepoint): Boolean; Inline;
Function GetPrevious(Const ACodepoint: THBCodepoint): THBCodepoint; Inline;
Function NextRange(Var First, Last: THBCodepoint): Boolean; Inline;
Function PreviousRange(Var First, Last: THBCodepoint): Boolean; Inline;
End;
{$ENDREGION}
{$REGION 'hb-face.h'}
THBFace = Record
Strict Private
{$HINTS OFF}
FValue: Pointer;
{$HINTS ON}
// internal type
Strict Private
Const
sErrorAddBuilder = 'Error adding fact builder table';
Strict Private
Procedure SetIndex(Const AIndex: Cardinal); Inline;
Function GetIndex: Cardinal; Inline;
Procedure SetUpEM(Const AUpEM: Cardinal); Inline;
Function GetUpEM: Cardinal; Inline;
Procedure SetGlyphCount(Const AGlyphCount: Cardinal); Inline;
Function GetGlyphCount: Cardinal; Inline;
Public Type
THBReferenceTableFunc = Function(Const AFace: THBFace; Const ATag: THBTag; Const AUserData: Pointer): THBBlob; Cdecl;
Public
Class Function Create(Blob: THBBlob; Const AIndex: Cardinal): THBFace; Overload; Static; Inline;
Class Function Create(Const AReferenceTableFunc: THBReferenceTableFunc; Const AUserData: Pointer; Const ADestroy: THBDestroyFunc): THBFace; Overload; Static; Inline;
Class Function Create(Const AFTFace: TFTFace; Const ADestroy: THBDestroyFunc): THBFace; Overload; Static; Inline;
Class Function CreateCached(Const AFTFace: TFTFace): THBFace; Static; Inline;
Class Function CreateReferenced(FTFace: TFTFace): THBFace; Static; Inline;
Class Function GetEmpty: THBFace; Static; Inline;
Function Reference: THBFace; Inline;
Procedure Destroy; Inline;
Procedure SetUserData(Const AKey; Const AData: Pointer; Const ADestroy: THBDestroyFunc; Const AReplace: Boolean); Inline;
Function GetUserData(Const AKey): Pointer; Inline;
Procedure MakeImmutable; Inline;
Function IsImmutable: Boolean; Inline;
Function ReferenceTable(Const ATag: THBTag): THBBlob; Inline;
Function GetTableTags: TArray<THBTag>; Inline;
Procedure CollectUnicodes(Into: THBSet); Inline;
Procedure CollectVariationSelectors(Into: THBSet); Inline;
Procedure CollectVariationUnicodes(Const AVariationSelector: THBCodepoint; Into: THBSet); Inline;
Class Function BuilderCreate: THBFace; Static; Inline;
Procedure BuilderAddTable(Const ATag: THBTag; Blob: THBBlob); Inline;
Property Index: Cardinal Read GetIndex Write SetIndex;
Property UpEM: Cardinal Read GetUpEM Write SetUpEM;
Property GlyphCount: Cardinal Read GetGlyphCount Write SetGlyphCount;
End;
{$ENDREGION}
{$REGION 'hb-font.h'}
THBFontExtents = Record
Public
Ascender: THBPosition;
Descender, LineGap: THBPosition;
Strict Private
{$HINTS OFF}
FReserved9, FReserved8, FReserved7, FReserved6, FReserved5, FReserved4, FReserved3, FReserved2, FReserved1: THBPosition;
{$HINTS ON}
End;
THBGlyphExtents = Record
XBearing, YBearing, Width, Height: THBPosition;
End;
THBFont = Record
Strict Private
{$HINTS OFF}
FValue: Pointer;
{$HINTS ON}
// internal type
Strict Private
Const
sErrorUserData = 'Error setting font user data';
Public Type
THBFontScale = Record
Private
FParent: Pointer;
Function GetXScale: Integer; Inline;
Function GetYScale: Integer; Inline;
Procedure SetXScale(Const AValue: Integer); Inline;
Procedure SetYScale(Const AValue: Integer); Inline;
Public
Property XScale: Integer Read GetXScale Write SetXScale;
Property YScale: Integer Read GetYScale Write SetYScale;
End;
THBFontPpEM = Record
Private
FParent: Pointer;
Function GetXPpEM: Cardinal; Inline;
Function GetYPpEM: Cardinal; Inline;
Procedure SetXPpEM(Const AValue: Cardinal); Inline;
Procedure SetYPpEM(Const AValue: Cardinal); Inline;
Public
Property XPpEM: Cardinal Read GetXPpEM Write SetXPpEM;
Property YPpEM: Cardinal Read GetYPpEM Write SetYPpEM;
End;
Strict Private
Procedure SetParent(Const AParent: THBFont); Inline;
Function GetParent: THBFont; Inline;
Procedure SetFace(Const AFace: THBFace); Inline;
Function GetFace: THBFace; Inline;
Procedure SetScale(Const AValue: THBFontScale); Inline;
Function GetScale: THBFontScale; Inline;
Procedure SetPpEM(Const AValue: THBFontPpEM); Inline;
Function GetPpEM: THBFontPpEM; Inline;
Procedure SetPTEM(Const APtEM: Single); Inline;
Function GetPTEM: Single; Inline;
Procedure SetVarCoordsNormalized(Const ACoords2F14: TArray<Integer>); Inline;
Function GetVarCoordsNormalized: TArray<Integer>; Inline;
Procedure FTSetLoadFlags(Const ALoadFlags: TFTLoadFlags); Inline;
Function FTGetLoadFlags: TFTLoadFlags; Inline;
Public
Function GetHExtents(Out OExtents: THBFontExtents): Boolean; Inline;
Function GetVExtents(Out OExtents: THBFontExtents): Boolean; Inline;
Function GetNominalGlyph(Const AUnicode: THBCodepoint; Out OGlyph: THBCodepoint): Boolean; Inline;
Function GetVariationGlyph(Const AUnicode, AVariationSelector: THBCodepoint; Out OGlyph: THBCodepoint): Boolean; Inline;
Function GetNominalGlyphs(Const ACount: Cardinal; Const AFirstUnicode: PHBCodepoint; Const AUnicodeStride: Cardinal; OFirstGlyph: PHBCodepoint; Const AGlyphStride: Cardinal): Integer; Inline;
Function GetGlyphHAdvance(Const AGlyph: THBCodepoint): THBPosition; Inline;
Function GetGlyphVAdvance(Const AGlyph: THBCodepoint): THBPosition; Inline;
Procedure GetGlyphHAdvances(Const ACount: Cardinal; Const AFirstGlyph: PHBCodepoint; Const AGlyphStride: Cardinal; OFirstAdvance: PHBPosition; Const AAdvanceStride: Cardinal); Inline;
Procedure GetGlyphVAdvances(Const ACount: Cardinal; Const AFirstGlyph: PHBCodepoint; Const AGlyphStride: Cardinal; OFirstAdvance: PHBPosition; Const AAdvanceStride: Cardinal); Inline;
Function GetGlyphHOrigin(Const AGlyph: THBCodepoint; Out X, Y: THBPosition): Boolean; Inline;
Function GetGlyphVOrigin(Const AGlyph: THBCodepoint; Out X, Y: THBPosition): Boolean; Inline;
Function GetGlyphHKerning(Const ALeftGlyph, ARightGlyph: THBCodepoint): THBPosition; Inline;
Function GetGlyphExtents(Const AGlyph: THBCodepoint; Out OExtents: THBGlyphExtents): Boolean; Inline;
Function GetGlyphContourPoint(Const AGlyph: THBCodepoint; Const APointIndex: Cardinal; Out X, Y: THBPosition): Boolean; Inline;
Function GetGlyphName(Const AGlyph: THBCodepoint): AnsiString; Inline;
Function GetGlyphFromName(Const AName: AnsiString; Out OGlyph: THBCodepoint): Boolean; Inline;
Function GetGlyph(Const AUnicode, AVariationSelector: THBCodepoint; Out OGlyph: THBCodepoint): Boolean; Inline;
Procedure GetExtentsForDirection(Const ADirection: THBDirection; Out OExtents: THBFontExtents); Inline;
Procedure GetGlyphAdvanceForDirection(Const AGlyph: THBCodepoint; Const ADirection: THBDirection; Out X, Y: THBPosition); Inline;
Procedure GetGlyphAdvancesForDirection(Const ADirection: THBDirection; Const ACount: Cardinal; Const AFirstGlyph: PHBCodepoint; Const AGlyphStride: Cardinal; OFirstAdvance: PHBPosition;
Const AAdvanceStride: Cardinal); Inline;
Procedure GetGlyphOriginForDirection(Const AGlyph: THBCodepoint; Const ADirection: THBDirection; Out X, Y: THBPosition); Inline;
Procedure AddGlyphOriginForDirection(Const AGlyph: THBCodepoint; Const ADirection: THBDirection; Out X, Y: THBPosition); Inline;
Procedure SubtractGlyphOriginForDirection(Const AGlyph: THBCodepoint; Const ADirection: THBDirection; Out X, Y: THBPosition); Inline;
Procedure GetGlyphKerningForDirection(Const AFirstGlyph, ASecondGlyph: THBCodepoint; Const ADirection: THBDirection; Out X, Y: THBPosition); Inline;
Function GetGlyphExtentsForOrigin(Const AGlyph: THBCodepoint; Const ADirection: THBDirection; Out OExtents: THBGlyphExtents): Boolean; Inline;
Function GetGlyphContourPointForOrigin(Const AGlyph: THBCodepoint; Const APointIndex: Cardinal; Const ADirection: THBDirection; Out X, Y: THBPosition): Boolean; Inline;
Function GlyphToString(Const AGlyph: THBCodepoint): AnsiString; Inline;
Function GlyphFromString(Const AString: AnsiString; Out OGlyph: THBCodepoint): Boolean; Inline;
Class Function Create(Const AFace: THBFace): THBFont; Overload; Static; Inline;
Class Function Create(Const AParent: THBFont): THBFont; Overload; Static; Inline;
Class Function Create(Const AFTFace: TFTFace; Const ADestroy: THBDestroyFunc): THBFont; Overload; Static; Inline;
Class Function CreateReferenced(FTFace: TFTFace): THBFont; Static; Inline;
Class Function GetEmpty: THBFont; Static; Inline;
Function Reference: THBFont; Inline;
Procedure Destroy; Inline;
Procedure SetUserData(Const AKey; Const AData: Pointer; Const ADestroy: THBDestroyFunc; Const AReplace: Boolean); Inline;
Function GetUserData(Const AKey): Pointer; Inline;
Procedure MakeImmutable; Inline;
Function IsImmutable: Boolean; Inline;
Procedure SetFuncsData(Const AFontData: Pointer; Const ADestroy: THBDestroyFunc); Inline;
Procedure SetVariations(Const AVariations: TArray<THBVariation>); Inline;
Procedure SetVarCoordsDesign(Const ACoords: TArray<Single>); Inline;
Procedure SetVarNamedInstance(Const AInstanceIndex: Cardinal); Inline;
Function FTGetFace: TFTFace; Inline;
Function FTLockFace: TFTFace; Inline;
Procedure FTUnlockFace; Inline;
Procedure FTFontChanged; Inline;
Procedure FTFontSetFuncs; Inline;
Property Parent: THBFont Read GetParent Write SetParent;
Property Face: THBFace Read GetFace Write SetFace;
Property Scale: THBFontScale Read GetScale Write SetScale;
Property PpEM: THBFontPpEM Read GetPpEM Write SetPpEM;
Property PTEM: Single Read GetPTEM Write SetPTEM;
Property VarCoordsNormalized: TArray<Integer> Read GetVarCoordsNormalized Write SetVarCoordsNormalized;
Property FTLoadFlags: TFTLoadFlags Read FTGetLoadFlags Write FTSetLoadFlags;
End;
THBFaceHelper = Record Helper For THBFace
Public
Function CreateFont: THBFont; Inline;
End;
THBFontFuncs = Record
Strict Private
{$HINTS OFF}
FValue: Pointer;
{$HINTS ON}
// internal type
Strict Private
Const
sErrorUserData = 'Error setting font funcs user data';
Public Type
THBFontGetFontExtentsFunc = Function(Const AFont: THBFont; Const AFontData: Pointer; Out OExtents: THBFontExtents; Const AUserData: Pointer): THBBool; Cdecl;
THBFontGetFontHExtentsFunc = THBFontGetFontExtentsFunc;
THBFontGetFontVExtentsFunc = THBFontGetFontExtentsFunc;
THBFontGetNominalGlyphFunc = Function(Const AFont: THBFont; Const AFontData: Pointer; Const AUnicode: THBCodepoint; Out OGlyph: THBCodepoint; Const AUserData: Pointer): THBBool; Cdecl;
THBFontGetVariationGlyphFunc = Function(Const AFont: THBFont; Const AFontData: Pointer; Const AUnicode, AVariationSelector: THBCodepoint; Out OGlyph: THBCodepoint; Const AUserData: Pointer)
: THBBool; Cdecl;
THBFontGetNominalGlyphsFunc = Function(Const AFont: THBFont; Const AFontData: Pointer; Const ACount: Cardinal; Const AFirstUnicode: PHBCodepoint; Const AUnicodeStride: Cardinal;
OFirstGlyph: PHBCodepoint; Const AGlyphStride: Cardinal; Const AUserData: Pointer): Cardinal; Cdecl;
THBFontGetGlyphAdvanceFunc = Function(Const AFont: THBFont; Const AFontData: Pointer; Const AGlyph: THBCodepoint; Const AUserData: Pointer): THBPosition; Cdecl;
THBFontGetGlyphHAdvanceFunc = THBFontGetGlyphAdvanceFunc;
THBFontGetGlyphVAdvanceFunc = THBFontGetGlyphAdvanceFunc;
THBFontGetGlyphAdvancesFunc = Procedure(Const AFont: THBFont; Const AFontData: Pointer; Const ACount: Cardinal; Const AFirstGlyph: PHBCodepoint; Const AGlyphStride: Cardinal;
OFirstAdvance: PHBPosition; Const AAdvanceStride: Cardinal; Const AUserData: Pointer); Cdecl;
THBFontGetGlyphHAdvancesFunc = THBFontGetGlyphAdvancesFunc;
THBFontGetGlyphVAdvancesFunc = THBFontGetGlyphAdvancesFunc;
THBFontGetGlyphOriginFunc = Function(Const AFont: THBFont; Const AFontData: Pointer; Const AGlyph: THBCodepoint; Out X, Y: THBPosition; Const AUserData: Pointer): THBBool; Cdecl;
THBFontGetGlyphHOriginFunc = THBFontGetGlyphOriginFunc;
THBFontGetGlyphVOriginFunc = THBFontGetGlyphOriginFunc;
THBFontGetGlyphKerningFunc = Function(Const AFont: THBFont; Const AFontData: Pointer; Const AFirstGlyph, ASecondGlyph: THBCodepoint; Const AUserData: Pointer): THBPosition; Cdecl;
THBFontGetGlyphHKerningFunc = THBFontGetGlyphKerningFunc;
THBFontGetGlyphExtentsFunc = Function(Const AFont: THBFont; Const AFontData: Pointer; Const AGlyph: THBCodepoint; Out OExtents: THBGlyphExtents; Const AUserData: Pointer): THBBool; Cdecl;
THBFontGetGlyphContourPointFunc = Function(Const AFont: THBFont; Const AFontData: Pointer; Const AGlyph: THBCodepoint; Const APointIndex: Cardinal; Out X, Y: THBPosition;
Const AUserData: Pointer): THBBool; Cdecl;
THBFontGetGlyphNameFunc = Function(Const AFont: THBFont; Const AFontData: Pointer; Const AGlyph: THBCodepoint; Name: PAnsiChar; Const ASize: Cardinal; Const AUserData: Pointer): THBBool; Cdecl;
THBFontGetGlyphFromNameFunc = Function(Const AFont: THBFont; Const AFontData: Pointer; Const AName: PAnsiChar; Const ALen: Integer; Out OGlyph: THBCodepoint; Const AUserData: Pointer)
: THBBool; Cdecl;
Public
Class Function Create: THBFontFuncs; Static; Inline;
Class Function GetEmpty: THBFontFuncs; Static; Inline;
Function Reference: THBFontFuncs; Inline;
Procedure Destroy; Inline;
Procedure SetUserData(Const AKey; Const AData: Pointer; Const ADestroy: THBDestroyFunc; Const AReplace: Boolean); Inline;
Function GetUserData(Const AKey): Pointer; Inline;
Procedure MakeImmutable; Inline;
Function IsImmutable: Boolean; Inline;
Procedure SetFontHExtentsFunc(Const AFunc: THBFontGetFontHExtentsFunc; Const AUserData: Pointer; Const ADestroy: THBDestroyFunc); Inline;
Procedure SetFontVExtentsFunc(Const AFunc: THBFontGetFontVExtentsFunc; Const AUserData: Pointer; Const ADestroy: THBDestroyFunc); Inline;
Procedure SetNominalGlyphFunc(Const AFunc: THBFontGetNominalGlyphFunc; Const AUserData: Pointer; Const ADestroy: THBDestroyFunc); Inline;
Procedure SetNorminalGlyphsFunc(Const AFunc: THBFontGetNominalGlyphsFunc; Const AUserData: Pointer; Const ADestroy: THBDestroyFunc); Inline;
Procedure SetVariationGlyphFunc(Const AFunc: THBFontGetVariationGlyphFunc; Const AUserData: Pointer; Const ADestroy: THBDestroyFunc); Inline;
Procedure SetGlyphHAdvanceFunc(Const AFunc: THBFontGetGlyphHAdvanceFunc; Const AUserData: Pointer; Const ADestroy: THBDestroyFunc); Inline;
Procedure SetGlyphVAdvanceFunc(Const AFunc: THBFontGetGlyphVAdvanceFunc; Const AUserData: Pointer; Const ADestroy: THBDestroyFunc); Inline;
Procedure SetGlyphHAdvancesFunc(Const AFunc: THBFontGetGlyphHAdvancesFunc; Const AUserData: Pointer; Const ADestroy: THBDestroyFunc); Inline;
Procedure SetGlyphVAdvancesFunc(Const AFunc: THBFontGetGlyphVAdvancesFunc; Const AUserData: Pointer; Const ADestroy: THBDestroyFunc); Inline;
Procedure SetGlyphHOriginFunc(Const AFunc: THBFontGetGlyphHOriginFunc; Const AUserData: Pointer; Const ADestroy: THBDestroyFunc); Inline;
Procedure SetGlyphVOriginFunc(Const AFunc: THBFontGetGlyphVOriginFunc; Const AUserData: Pointer; Const ADestroy: THBDestroyFunc); Inline;
Procedure SetGlyphHKerningFunc(Const AFunc: THBFontGetGlyphHKerningFunc; Const AUserData: Pointer; Const ADestroy: THBDestroyFunc); Inline;
Procedure SetGlyphExtentsFunc(Const AFunc: THBFontGetGlyphExtentsFunc; Const AUserData: Pointer; Const ADestroy: THBDestroyFunc); Inline;
Procedure SetGlyphContourPointFunc(Const AFunc: THBFontGetGlyphContourPointFunc; Const AUserData: Pointer; Const ADestroy: THBDestroyFunc); Inline;
Procedure SetGlyphNameFunc(Const AFunc: THBFontGetGlyphNameFunc; Const AUserData: Pointer; Const ADestroy: THBDestroyFunc); Inline;
Procedure SetGlyphFromNameFunc(Const AFunc: THBFontGetGlyphFromNameFunc; Const AUserData: Pointer; Const ADestroy: THBDestroyFunc); Inline;
End;
THBFontHelper = Record Helper For THBFont
Public
Procedure SetFuncs(Const AClass: THBFontFuncs; Const AFontData: Pointer; Const ADestroy: THBDestroyFunc); Inline;
End;
{$ENDREGION}
{$REGION 'hb-buffer.h'}
THBGlyphFlag = (hbgfUnsafeToBreak);
THBGlyphFlags = Set Of THBGlyphFlag;
PHBGlyphInfo = ^THBGlyphInfo;
THBGlyphInfo = Record
Public
Codepoint: THBCodepoint;
Strict Private
FMask: THBMask;
Function GetGlyphFlags: THBGlyphFlags; Inline;
Public
Property GlyphFlags: THBGlyphFlags Read GetGlyphFlags;
Public
Cluster: Cardinal;
Strict Private
{$HINTS OFF}
Var1, Var2: THBVarInt;
{$HINTS ON}
End;
PHBGlyphPosition = ^THBGlyphPosition;
THBGlyphPosition = Record
Public
XAdvance, YAdvance, XOffset, YOffset: THBPosition;
Strict Private
{$HINTS OFF}
FVar: THBVarInt;
{$HINTS ON}
End;
PHBSegmentProperties = ^THBSegmentProperties;
THBSegmentProperties = Record
Public
Direction: THBDirection;
Script: THBScript;
Language: THBLanguage;
Strict Private
FReserved1, FReserved2: Pointer;
Public
Class Operator Equal(Const A, B: THBSegmentProperties): Boolean; Inline;
Function Hash: Cardinal; Inline;
End;
THBSegmentPropertiesHelper = Record Helper For THBSegmentProperties
Public Const
// issue with typed constants: we cannot refer to THBLanguage.Invalid here - this is not recognized as a constant
Default: THBSegmentProperties = (Direction: hbdInvalid; Script: hbsInvalid; Language: (); FReserved1: NIL; FReserved2: NIL);
End;
THBBufferContentType = (hbbctInvalid, hbbctUnicode, hbbctGlyphs);
THBBufferFlag = (hbbfBot, hbbfEot, hbbfPreserveDefaultIgnorables, hbbfRemoveDefaultIgnorables, hbbfDoNotInsertDottedCircle);
THBBufferFlags = Set Of THBBufferFlag;
THBBufferClusterLevel = (hbbclMonotoneGraphemes, hbbclMonotoneCharacters, hbbclCharacters, hbbclDefault = hbbclMonotoneGraphemes);
THBBufferSerializeFlag = (hbbsfNoClusters, hbbsfNoPositions, hbbsfNoGlyphNames, hbbsfGlyphExtents, hbbsfGlyphFlags, hbbsfNoAdvances);
THBBufferSerializeFlags = Set Of THBBufferSerializeFlag;
THBBufferSerializeFormat = (hbbsfText = $54455854 { TEXT } , hbbsfJson = $4A534F4E { JSON } , hbbsfInvalid = THBTag.None);
THBBufferSerializeFormatHelper = Record Helper For THBBufferSerializeFormat
Public
Class Function SerializeFormatFromString(Const AStr: AnsiString): THBBufferSerializeFormat; Static; Inline;
Function SerializeFormatToString: AnsiString; Inline;
Class Function SerializeListFormats: TArray<AnsiString>; Static;
End;
THBBufferDiffFlag = (hbbdfContentTypeMismatch, hbbdfLengthMismatch, hbbdfNotdefPresent, hbbdfDottedCirclePresent, hbbdfCodepointMismatch, hbbdfClusterMismatch, hbbdfGlyphFlagsMismatch,
hbbdfPositionMismatch);
THBBufferDiffFlags = Set Of THBBufferDiffFlag;
THBBufferDiffFlagsHelper = Record Helper For THBBufferDiffFlags
Public Const
Equal: THBBufferDiffFlags = [];
End;
THBBuffer = Record
Strict Private
{$HINTS OFF}
FValue: Pointer;
{$HINTS ON}
// internal type
Strict Private
Const
sErrorDeserializeGlyphs = 'Error deserializing glyphs';
sErrorDeserializeUnicode = 'Error deserializing unicode';
sErrorPreAllocate = 'Error preallocating buffer';
sErrorSetLength = 'Error setting buffer length';
sErrorUserData = 'Error setting buffer user data';
sErrorShape = 'Error while shaping';
Strict Private
Procedure SetContentType(Const AContentType: THBBufferContentType); Inline;
Function GetContentType: THBBufferContentType; Inline;
Procedure SetUnicodeFuncs(Const AUnicodeFuncs: THBUnicodeFuncs); Inline;
Function GetUnicodeFuncs: THBUnicodeFuncs; Inline;
Procedure SetDirection(Const ADirection: THBDirection); Inline;
Function GetDirection: THBDirection; Inline;
Procedure SetScript(Const AScript: THBScript); Inline;
Function GetScript: THBScript; Inline;
Procedure SetLanguage(Const ALanguage: THBLanguage); Inline;
Function GetLanguage: THBLanguage; Inline;
Procedure SetSegmentProperties(Const AProps: THBSegmentProperties); Inline;
Function GetSegmentProperties: THBSegmentProperties; Inline;
Procedure SetClusterLevel(Const AClusterLevel: THBBufferClusterLevel); Inline;
Function GetClusterLevel: THBBufferClusterLevel; Inline;
Procedure SetFlags(Const AFlags: THBBufferFlags); Inline;
Function GetFlags: THBBufferFlags; Inline;
Procedure SetReplacementCodepoint(Const AReplacement: THBCodepoint); Inline;
Function GetReplacementCodepoint: THBCodepoint; Inline;
Procedure SetInvisibleGlyph(Const AInvisible: THBCodepoint); Inline;
Function GetInvisibleGlyph: THBCodepoint; Inline;
Procedure SetLength(Const ALength: Cardinal); Inline;
Function GetLength: Cardinal; Inline;
Public Type
THBBufferMessageFunc = Function(Const ABuffer: THBBuffer; Const AFont: THBFont; Const AMessage: PAnsiChar; Const AUserData: Pointer): THBBool; Cdecl;
Public Const
BufferReplacementCodepointDefault = $FFFD;
Public
Class Function Create: THBBuffer; Static; Inline;
Class Function GetEmpty: THBBuffer; Static; Inline;
Function Reference: THBBuffer; Inline;
Procedure Destroy; Inline;
Procedure SetUserData(Const AKey; Const AData: Pointer; Const ADestroy: THBDestroyFunc; Const AReplace: THBBool); Inline;
Function GetUserData(Const AKey): Pointer; Inline;
Procedure GuessSegmentProperties; Inline;
Procedure Reset; Inline;
Procedure ClearContents; Inline;
Procedure PreAllocate(Const ASize: Cardinal); Inline;
Function AllocationSuccessful: Boolean; Inline;
Procedure Reverse; Inline;
Procedure ReverseRange(Const AStart, AEnd: Cardinal); Inline;
Procedure ReverseClusters; Inline;
Procedure Add(Const ACodepoint: THBCodepoint; Const ACluster: Cardinal); Overload; Inline;
Procedure Add(Const AText: UTF8String; Const AItemOffset: Cardinal = 0; Const AItemLength: Integer = -1); Overload; Inline;
Procedure Add(Const AText: UnicodeString; Const AItemOffset: Cardinal = 0; Const AItemLength: Integer = -1); Overload; Inline;
Procedure Add(Const AText: UCS4String; Const AItemOffset: Cardinal = 0; Const AItemLength: Integer = -1); Overload; Inline;
Procedure Add(Const AText: AnsiString; Const AItemOffset: Cardinal = 0; Const AItemLength: Integer = -1); Overload; Inline;
Procedure Add(Const AText: TArray<THBCodepoint>; Const AItemOffset: Cardinal = 0; Const AItemLength: Integer = -1); OverloaD; Inline;
Procedure Append(Const ASource: THBBuffer; Const AStart, AEnd: Cardinal); Inline;
Function GetGlyphInfos: TArray<THBGlyphInfo>; Inline;
Function GetGlyphPositions: TArray<THBGlyphPosition>; Inline;
Function HasPositions: Boolean; Inline;
Procedure NormalizeGlyphs; Inline;
Function SerializeGlyphs(Const AStart, AEnd: Cardinal; Const AFont: THBFont; Const AFormat: THBBufferSerializeFormat; Const AFlags: THBBufferSerializeFlags): AnsiString;
Function SerializeUnicode(Const AStart, AEnd: Cardinal; Const AFormat: THBBufferSerializeFormat; Const AFlags: THBBufferSerializeFlags): AnsiString;
Function Serialize(Const AStart, AEnd: Cardinal; Const AFont: THBFont; Const AFormat: THBBufferSerializeFormat; Const AFlags: THBBufferSerializeFlags): AnsiString;
Procedure DeserializeGlyphs(Const ABuf: AnsiString; Const AFont: THBFont; Const AFormat: THBBufferSerializeFormat); Inline;
Procedure DeserializeUnicode(Const ABuf: AnsiString; Const AFormat: THBBufferSerializeFormat); Inline;
Function Diff(Const AReference: THBBuffer; Const ADottedcircleGlyph: THBCodepoint; Const APositionFuzz: Cardinal): THBBufferDiffFlags; Inline;
Procedure SetMessageFunc(Const AFunc: THBBufferMessageFunc; Const AUserData: Pointer; Const ADestroy: THBDestroyFunc); Inline;
Procedure Shape(Font: THBFont; Const AFeatures: TArray<THBFeature> = NIL); Inline;
Procedure ShapeFull(Font: THBFont; Const AFeatures: TArray<THBFeature>; Const AShaperList: TArray<AnsiString>);
Class Function ListShapers: TArray<AnsiString>; Static;
Property ContentType: THBBufferContentType Read GetContentType Write SetContentType;
Property UnicodeFuncs: THBUnicodeFuncs Read GetUnicodeFuncs Write SetUnicodeFuncs;
Property Direction: THBDirection Read GetDirection Write SetDirection;
Property Script: THBScript Read GetScript Write SetScript;
Property Language: THBLanguage Read GetLanguage Write SetLanguage;
Property SegmentProperties: THBSegmentProperties Read GetSegmentProperties Write SetSegmentProperties;
Property ClusterLevel: THBBufferClusterLevel Read GetClusterLevel Write SetClusterLevel;
Property Flags: THBBufferFlags Read GetFlags Write SetFlags;
Property ReplacementCodepoint: THBCodepoint Read GetReplacementCodepoint Write SetReplacementCodepoint;
Property InvisibleGlyph: THBCodepoint Read GetInvisibleGlyph Write SetInvisibleGlyph;
Property Length: Cardinal Read GetLength Write SetLength;
End;
{$ENDREGION}
{$REGION 'hb-map.h'}
THBMap = Record
Strict Private
{$HINTS OFF}
FValue: Pointer;
{$HINTS ON}